[Moved to Github] Can't override Fog Shader Chunk (fogExp2PS)

I’m trying to override the fog shader chunk, but the method addFog is not replaced. The scene fog is set to exponential squared, so I tried replacing the chunk fogExp2PS with the following shader code:

// Custom Shader Chunk for fogLinearPS / fogExpPS / fogExp2PS 

uniform vec3 fog_color;
uniform float fog_density;
vec3 addFog(vec3 color) {
    // overwrite with green color
    return vec3(0.0, 1.0, 0.0);
}

The box in the middle should get green, but it has the default fog applied:

You can find a minimal scene setup that shows the problem here:
https://playcanvas.com/editor/scene/688152

What am I missing?

No ideas so far? Should I write an issue on Github, or what is the best angle to continue? I’m quite sure it is unexpected behavior.

GitHub will probably get more eyes on it and does help them track the issue better.

Ah. This seems to be the problem:

The code to insert the correct fog chunk is ignoring the specified custom chunks and just looking at the built-in chunks. I’ve submitted an issue report for you on the engine repo:

Feel free to subscribe to that to get updates on a fix. :slight_smile:

1 Like

Hi @will, thanks a lot for the answer and reasearch! I found a PR that already handles the problem, might be the interesting to pull out the changes from there into a new PR. I’ll follow the conversation on Github, thanks for opening an issue there :slight_smile:

1 Like