How to make the fog filter not render in front of a geometry?

Hi, does anyone know how I could make the fog filter not render “in front” of a geometry? Currently, the fog filter completely fogs the sky and I would rather have the sky uncovered by the fog filter.

BTW (on a side note) the fog filter seems to break the water filter at least on my system. It makes the caustics disappear and we can see everything that is under water very clearly, compared to without the fog filter.

Step 1: don’t use fog filter… it’s a post processing effect and so will be applied to the whole screen.

Step 2: add vertex fog to your shaders and then you can do it for whatever objects you want (for example, often lights will not have fog or require different fog settings)

The alternative is to render the sky as one viewport and the scene as another.

Regarding water, I suspect it depends on where you put it in the stack… but then there really won’t be any ‘good’ place to put it, I guess. If you go with vertex fog then the water filter would have to have fog also. The up side is fog would be perfect and way more controllable.

Hello Paul, weird thing, I did not receive the usual email notification that you replied to my post! I nearly missed it but my tab was open yesterday night so I just hit refresh by mistake and I saw you replied!

Yes, I was thinking of doing this, but then I did not do that, because I thought that I would have to duplicate all the .frag files like Lighting.frag, Grass.frag, Terrain.frag etc… and put the fog code in them. That’s one thing but also, I tried for 1 material and it works indeed BUT if the geometry is inside shadow, the fog cannot be white or like any saturated color. Am I doing this wrong or is this really how vertex fog should be implemented?

@.Ben. said: Hello Paul, weird thing, I did not receive the usual email notification that you replied to my post! I nearly missed it but my tab was open yesterday night so I just hit refresh by mistake and I saw you replied!

Yes, I was thinking of doing this, but then I did not do that, because I thought that I would have to duplicate all the .frag files like Lighting.frag, Grass.frag, Terrain.frag etc… and put the fog code in them. That’s one thing but also, I tried for 1 material and it works indeed BUT if the geometry is inside shadow, the fog cannot be white or like any saturated color. Am I doing this wrong or is this really how vertex fog should be implemented?

I think shadows would maybe have to take vertex fog into account also. I haven’t used the shadows in my apps that do vertex fog so I never encountered this.

1 Like

Have you tried putting the sky into the translucent bucket, adding a translucent bucket filter to the end of the stack, and setting the frag depth to 1 in the sky shader? (so it’s rendered behind everything (and after everything, if its the only geometry in the translucent bucket), but not affected by the fog filter). I don’t know if it will work, but might be worth a try

if the sky is not in the sky bucket you 'll have some weird things happening.

I though I added an option to exclude the sky but I didn’t.
@t0neg0d once posted a fog filter with that option.

The WaterFilter has an integrated fog underwater. It has a boolean method that returns true if the camera is under the water level (isUnderWater()) you could disable the fog filter whenever you get underwater.

1 Like

Thanks guys for replying… OMG… I’m really not getting emails anymore from this forum. I’ll have to keep all my tabs open in my browser and refresh every couple hours… damnit.

@pspeed I actually went and took the vertex fog route this morning and it doesn’t give quite the same effect as the FogFilter. I’m not saying I won’t end up using it, but I’m not sure this is what I’m aiming for. One example is that YES the sky is now fogless which is perfect, but the water filter is too, which breaks the illusion of fog, it’s quite contrasting and looks too rough. I’ll try to duplicate the water filter shader files and modify them to add the vertex fog on it too and post results later on. I’ll +1 the ideas for now as it’s very interesting. Vertex fog saves me a render pass, which is good.

@wezrule I’ll try this later on. Tough, would messing with the filter stack decrease fps and if so, would it do dramatically? I’m trying to save fps as much as possible, altough I know filters are greedy on fps.

@nehon OK for the underwater flag, yes I’m already using this flag for sounds and gravity toggling, good idea. I’ll keep this in mind. Thx. +1’ed as this makes very much sense concerning this issue.

@.Ben. said: @pspeed I actually went and took the vertex fog route this morning and it doesn't give quite the same effect as the FogFilter. I'm not saying I won't end up using it, but I'm not sure this is what I'm aiming for. One example is that YES the sky is now fogless which is perfect, but the water filter is too, which breaks the illusion of fog, it's quite contrasting and looks too rough. I'll try to duplicate the water filter shader files and modify them to add the vertex fog on it too and post results later on. I'll +1 the ideas for now as it's very interesting. Vertex fog saves me a render pass, which is good.

Yes, as I mentioned… the water would have to do fog also.

The nice thing about vertex fog is that you can be nice and advanced… for example, with the proper inputs you could make it foggier towards the ground, you can have objects with no fog or different fog (like lights), and so on. Lots of control that is harder to do with post-proc fog. It just comes at a complexity price.