Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example shadow / contact fix #20849

Merged
merged 2 commits into from
Dec 7, 2020
Merged

Example shadow / contact fix #20849

merged 2 commits into from
Dec 7, 2020

Conversation

Fluqz
Copy link
Contributor

@Fluqz Fluqz commented Dec 7, 2020

Related issue: Fixed #20848

Description

The current example has a small z-fighting bug, because of multiple planes laying over each other.
polygonOffset will fix the issue

@gkjohnson
Copy link
Collaborator

gkjohnson commented Dec 7, 2020

Thanks! With polygonOffset the vertical offset should no longer be needed:

https://github.com/mrdoob/three.js/pull/20849/files#diff-f6e6eaefcc3ba526fa08c969dcb2456960450a4e12162ce3464e5f7f3007104fR140

And here's the updated live example link from this PR:

https://raw.githack.com/Fluqz/three.js/contact-shadows/examples/webgl_shadow_contact.html

@mrdoob mrdoob added this to the r124 milestone Dec 7, 2020
@mrdoob mrdoob merged commit 76c5f55 into mrdoob:dev Dec 7, 2020
@mrdoob
Copy link
Owner

mrdoob commented Dec 7, 2020

Thanks!

@marcofugaro
Copy link
Contributor

Guys I just noticed now the meshes go through the shadow plane, making the fillPlane useless. Not even the color input in the gui works.

Any idea how to fix this with polygonOffset?

Current Original
Screenshot 2021-01-11 at 13 45 20 Screenshot 2021-01-11 at 13 45 47

@gkjohnson
Copy link
Collaborator

Guys I just noticed now the meshes go through the shadow plane, making the fillPlane useless.

Oh good catch. Just tried it out and what's happening is the shadow plane renders first and renders to depth meaning the fill plane fails the depth test everywhere. If the fill plane weren't transparent this would have worked. I just tried a couple fixes and here's what works:

  • Keep the polygon offset and set renderOrder = 1 on the shadow plane or
  • Set depthWrite = false on both materials and set renderOrder = 1 on the shadow plane

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 11, 2021

Set depthWrite = false on both materials and set renderOrder = 1 on the shadow plane

I vote for this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Example - webgl_shadow_contact artifacts
5 participants