Have fog apply transparency as opposed to color?

I have a specific setup where instead of fog fading to a color, it would be nice if I could make it subtract to the colors alpha color the farther out it goes?

I could totally do this manually in a shader, but I’m trying to make the grid material specifically have this happen. Is my only option to do modified version of the grid material shader and spin up my own version to have this happen, or is there some magic trick Im not thinking off?

Another way would be to do it would maybe be in a post pass that has the depth passed to it and just fade it out there? Hmmm actually that might be the ticket.

You could use the node material version of the grid material:

You can more easily modify this version than the glsl shader one.

1 Like

What does the fog node need for input?

image
a red dont and “input” is not very robust of a hint XD

I tried to feed the scene depth value to it but I guess that was not it?

ahhh this helps nevermind:

actually I’m not able to get the fog node to work correct, do you know where can I find a setup with this node is working?

It actually ended up being easier just to extend the grid material and update the shader code to get the desired result.

1 Like

In case you want to make it work with the node material:

Node material: https://nme.babylonjs.com/#I4DJ9Z#96

4 Likes