-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGLShadowMap: Support material.map with alphaTest #25000
Conversation
@hybridherbst Can you please give it a try? |
Here's a transparent video being used as map: |
Hey guys! It was recommended that I post this here from the forums. https://discourse.threejs.org/t/r147-instancing-with-shadows/45423 It seems this PR has affected shadows of meshes that are created using instancing. Up through r146 for example, the below pattern worked:
Now that depth material is ignored, this pattern has broke. What is the preferred method now to apply shadows to instances? If I comment out this PR, it goes back to working, but I prefer not to modify the base THREE code. |
I assume the issue is your custom depth material is not being honored. I do not expect this PR is the cause of the problem you are facing. I think there is a more fundamental problem. Please file a new PR and provide sufficient information to replicate the issue. A simple, live example would be helpful. Also, please explain why a custom depth material is required in your use case. |
With due respect, I assure you this PR is causing customDepthMaterial to not be honored in this case. Reverting this specific PR resolves the issue and I will explain why. Here
Overwriting
This did not meet conditions of my instanced objects with alphaTest and no alphaMap. Now, with the new conditions from this PR,
I will work on an example, however setting one up with shadows and instancing will take me several hours. Thank you for taking the time to look into this. |
There is nothing inherently wrong with this PR. There is a more fundamental problem that is causing a user's three.js no longer has any examples requiring a |
I showed where the overwrite happened and it is because the change in the conditional from this PR allows the Reverting only this PR which definitely overwrites the customDepthMaterial value I will make a demo this week. If the plan is to ignore this and allow customDepthMaterial to be deprecated in these cases, PLEASE let me know so I do not waste my time. |
He didn't say this will go unnoticed, he just mentioned it's better to open a new issue and reference this PR. |
I was asking "if", since this PR knowingly overwrites the depthMaterial in a way that may show possible deprecation. I have a lot to do and wanted to make sure my time is well spent. I was not meaning to be rude if that's the cause of your reply. I am working to demonstrate this issue. It will just take some time. |
@titansoftime If you have a valid use case that requires |
Sure. In the meantime, this was another user's use case (same thing, shadows on instanced meshes). This thread points to now removed examples. I'm assuming the lambert material instance example they are referring to was the only instance example showing how to shadow instances. https://threejs.org/examples/?q=ins#webgl_buffergeometry_instancing_lambert |
A live example of 147 not working with instanced shadows with alphaTest set on the material. https://jsfiddle.net/titansoftime/q39foeLb/ You can switch between the live 147 (not working as neeeded) and 146 version of three.js. By swapping the sources at the top. You can also toggle instancing via the instancing variable. Here is it defaulted to 146: |
@titansoftime The following works for me for your test case, but I would request @Mugen87 to confirm. I think if an app sets a +++ b/src/renderers/webgl/WebGLShadowMap.js
@@ -235,6 +235,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {
if ( customMaterial !== undefined ) {
result = customMaterial;
+ return result;
} else {
|
Your code solution if I understand it correctly seems reasonable to me, but I am unsure the far reaching consequences. If a customDepthMaterial is explicitly set, use it and do not override. Preferably, shadows on meshes created via instancing would work like regular shadows in userland and do the magic behind the scenes without a weird customDepthMaterial. I don't even really know for sure what that even is, let alone updating related uniforms. For now I will patch out this PR until the council of three has decided a permanent solution. |
Fixes #24995.