0

Global Fog + Alpha Clip

bradleyoboothe 10 år siden opdateret 10 år siden 2
Hello! I'm having a problem with Alpha Clip and the depth buffer. I'm made a vegetation shader using Shader Forge, but image effects like Global Fog, Edge Detect Effect Normals, and Sun Shafts seem to ignore the trees and draw on top of them. Any ideas? 

Here's the problem graph. As you can see, it's a fairly standard alpha clip shader, with a bit of vertex animation. I have tried removing the vertex animation, but that made no difference.
Image 283

Here's a screenshot of the problem described above.
Image 284
I've had this issue before. It's because you don't have a texture property called _MainTex. Rename your "Diffuse" Texture 2D node to "MainTex" and it should fix your problem. You also need a color property called "_Color" but you've got that set up already. I don't know the exact technical details, but I believe it's because image effects use fallback shaders for depth (such as vertex lit) and if you don't use the same property names your shader won't be compatible and cause these problems. It's a weird dependency requirement that doesn't seem to be documented anywhere (like beast lightmapping).

If you're using forward rendering you might discover a new problem with vertex offset not updating in the depth buffer. I don't know how to fix this other than adding a deferred pre-pass to your shader and switching to deferred rendering. This could just be a technical limitation with forward rendering and not a Shader Forge bug.
Oh, awesome! That did the trick. My grass and leaves look nice and beautiful now :) That's so crazy it's undocumented like that. That should probably be in Shader Forge's documentation somewhere considering how easy it is to miss. Luckily my leaves and grass move only subtly, so the depth problem with vertex animation isn't noticeable.

Thanks a lot!

Kundesupport af UserEcho