-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add support for double-sided materials #491
Conversation
It's working well in URP and the built-in pipeline, but HDRP is more difficult.
I had hoped to get this PR ready for final review so it can be included in next week's release, but HDRP and I still are not getting along. Will probably need to push it until next release. |
Ok I think this is working well now. Double-sided rendering is working in all pipelines. The way it works is that the Shader and Material now have double-sided mode enabled. At runtime, we disable it if the glTF does not require it by setting some material parameters. This seems to work a lot better than the opposite. I'm not 100% sure why, but my theory is that double-sided rendering is a "feature" (at least in some RPs). If the shaders are compiled with support for that feature, then dynamically disabling it at runtime is fine. However, if the shaders are compiled without support for the feature at all, then enabling it dynamically is not possible. I also fixed cartographic polygons in HDRP by enabling "alpha clipping". |
I'm moving this into next week's release, but time is short so we'll move it back out if there are any concerns at all. |
Thanks @kring ! I verified that this was working (at least in URP) using the TextureSettingsTest sample model. Just to sanity check, I noticed some seemingly unrelated edits to the material? Some of them seemed like autogenerated additions, but I wasn't sure about this one. Was this done by Unity too? |
@j9liu I didn't purposely change that, so I can only imagine Unity change it itself for some reason. I reverted it back to "Auto" though, and everything still seems to be working well, so I've pushed up that change. |
Merging this one for tomorrow's release, too. |
As reported here:
https://community.cesium.com/t/3d-tiles-model-appeared-with-face-orientation-flipped-backface-culling/34155
We previously weren't supporting glTF's doubleSided property. Now we are.
This was tricky because Unity controls this with a render-pipeline-dependent material property. I also had to add some nodes to our CesiumDefaultTilesetShader to flip the direction of the normal for back faces, as required by the glTF spec.
This is a draft because it's not quite working well in HDRP yet. For reasons I don't understand, HDRP defies all attempts to dynamically turn on double-sided rendering dynamically. I have some local changes where I turn it on via the UI, and then I'm able to turn it off dynamically. But I haven't committed that yet because it seems dodgy. Also, unlike the othe render pipelines, HDRP seems to automatically invert normals for back faces, which means my nodes that do that manually are now making the normals wrong again. I'm not sure yet the best way to deal with that.
Fixes #370
Fixes #486