fog and shader generator

It seems fog is not supported by the shader generator so my toon shaded models won’t be affected by it no matter how far from the camera.
Now what must be done to ‘fix’ this manually?

You could write a fog generator?

It should be simple post process shader just compare the depth and add a gray color.

But it also could be inside the pixel shader computing depth and giving color.

From some info I got from the forums it seems that if I write a custom shader then the shader generator (normal maps, bloom, gloss, glow, hdr, cel, shadows) won’t work. Is this correct?

A custom shader overrides the shader generated by the Shader Generator for that node, yes.

…so maybe we could get fog support for the Shader Generator?

…like using CommonFilters? Having all the cool stuff from the Shader Generator and fog from a custom shader on top?

If yes, than could you write a shader like that for cg-challenged people?

That would be a feature request: … 1&start=90

We just talked about this above. Using a custom shader would work if you didn’t need anything else which setShaderAuto() turns on. But then I could just use the fog from Panda.
The only way I see is to modify the shaderGen code, which is in C++ and I don’t know much about shaders, so…

Yep. I’ve already posed a request for fog there, back in September 2009: … 4386#44386

Sorry, I was thinking about the FilterManager class. If I get it right you can render your scene to an off-screen buffer and use that rendered image (along with the info from the depth buffer) to add a post-process fog with a custom shader. That custom shader wouldn’t override the auto shader because it’s not applied to any of the nodes visible in the original scene, just to one polygon with a image of your scene glued on as a texture.

There is one in Demomaster?

So you can have a fullscreen fog shader that doesn’t need to know the distances of the nodes or something?
Can someone comfirm this.

Well we just have to wait then.

There is one in Demomaster?

So you can have a fullscreen fog shader that doesn’t need to know the distances of the nodes or something?
Can someone comfirm this.

There’s the depth buffer I suppose that would be what’s needed.

The manual ( … ge_Filters )says:

The fog in “Demomaster” is in the tunnel demo, but it’s not a post-process fog.

Hm, could work.
Can someone confirm this?

That should work. You can base on the DOF sample in demomaster. I’ve made one and can post it later today.

Get it at:, it is an add-on to the demomaster

Will have a look.

That would be great if a fog working together with the shader generator was posted in the Code Snippets or something. Thanks and don’t rush.

EDIT: OK, just read your new post.

EDIT2: Problem?

First I have only tested on my machine with version 1.6.2

May be other people can test it also on their machine ?

How about other samples in demomaster ? Do you have any problem running them ?

Also, can you turn on the buffer view and capture a screen? ( click on Basics tab, then click on the “Toggle Buffer Viewer” item.)

This is a Panda 1.7.0 thing:


I see random images of mine in the buffer viewer.

My system still in 1.6.2 because I have some other important stuffs in my python 2.5. May be the depth buffer calls are changed in 1.7.0 ?

Anyway, you should get the idea already, right ?

It dosen’t work for me either(using 1.7.0).

For me the idea is not the problem, writing a working shader is. It’s like going on Mount Everest… I get the basic idea of walking uphill but that dosen’t help me much :smiley:

Maybe. Well the shader generator at least was modified for the automatic shadows.

Well, like wezu said the idea is not the problem. But I don’t know shader programming. Still, thanks for th help. I might just downgrade to Panda 1.6.2 for now.