Shader not affected by light nor fog

Hi,
I recently made a splatmap shader for a terrain with grass, sand and rock. Now this custom shader works but the terrain isn’t affected by any lighting nor by fog.

Is there a simple way of fixing this? I don’t really know much GLSL so I don’t know if I have to code this in the shader or there’s a Panda3D way of doing it.
Thanks for help.

In short: If you’re using a custom shader, then indeed, it’s up to you to implement whatever visual effects you want to have apply, whether light, fog, or anything else.

Now, theoretically, one could have an out-of-the-box post-process shader to handle things like light and fog–but I don’t think that Panda has those particular post-processes out of the box.

[edit]
That said, it might be worth looking around the forums: you may find shader-code for those effects that you can perhaps integrate with your current shader.

OK, thanks. I thought that maybe there was a way to “import” lighting and fog information into the shader from the running game and that I was maybe even able to change fog values at runtime…
I’ll look around :slight_smile:

1 Like

I mean, if you implement those features in your shader, then you likely can do so.

That is, the information is likely there, and you can likely change it at runtime–but you have to tell the shader what to do with it.

1 Like

This page in the manuel goes over how to get access to lights and fog in your shader.
https://docs.panda3d.org/1.10/python/programming/shaders/list-of-glsl-inputs

2 Likes

Thanks, I saw that page before but didn’t really understand, you know I don’t really know much GLSL and shader stuff. I think I’ll go learn more :slight_smile: Thanks for your suggestion and confirmation!

1 Like

Those inputs represent the data that you have access to in a shader. p3d_Fog contains the numeric values describing the fog that affects your object. gl_FragCoord.z should be the depth of a given fragment. Now you just need mix() and a bit of math to create a fog of your own.

1 Like

I see, I should be able to do it. Thanks!