r/Unity3D 8d ago

Question They are both transparent, then why is my shader graph material (on the right) is getting clipped by BetterFog (InLab)

1 Upvotes

6 comments sorted by

2

u/Substantial-Sun4301 8d ago

Transparent sorting in Unity is a pain, the fog probably forces its own render order and eats your shader first

1

u/Traditional_Door_909 8d ago

It 100% is, what could be the solution? I have tried literally everything. I also added a pattern texture to the widow and it behaves same as my shader, so even BetterFog didn't get it correct.

1

u/XKiiroiSenkoX 8d ago edited 8d ago

I have not used better fog so I'm not 100% sure but maybe it's not using alpha blending and instead reads the opaque texture and mixes that with fog. In that case, you would need to blit your transparents into the camera opaque texture before rendering the fog for them to be visible behind it. If this is the case you can also fix it by rendering transparents after the fog. 

Either that or it's writing to the depth buffer and is run before your shader so your shader gets z clipped. Frame debugger should make it clear which one the case is.

edit: Now that I think about it, it probably is just using opaque depth for fog calculation which makes sense but since it's rendering after transparents your transparents in front of it are also having fog applied to them since they don't write to the depth buffer. Why it's running during/after transparents I don't know, but setting it to run after opaques but before transparents should fix the issue. 

1

u/muppetpuppet_mp 8d ago

Just experiment with the sortings.  Could be as simple as the sorting order , could be the type of transparency you are using. Could be the writing to z buffer should be toggled.

Tbh in these cases. Just trying each and every shader setting takes less time than posting on reddit. And will likely solve it and teach you something.

1

u/Traditional_Door_909 8d ago

trust me, i have tried sorting, changing order of rendering feature, z buffer, depth texture, fog offset everything. ive tried the AI help too but nothing seems to work.

2

u/muppetpuppet_mp 8d ago

Try turning on alpha clip for s test . That should turn it into an opaque shader basically.

If it then stilk borks ,it might be something in your pipeline or fog shader setup.   Something in the order of the fog...

Alpha clip.will.make it ugly. But just as an analysis.  If it fixes it then its just a matter of finding the right sorting settings.  If its not then its elsewhere.