Shadows with custom color?

Is possible in some way, maybe extending the shader chunks, to set a custom color for the shadows that an object receive?

Hi @MIC_MATRIX91 and welcome,

I think yes overriding the respective shader chunks can definitely do that. I am not sure though what would be the best place to start with that, there are several chunks depending on the selected shadow type used by the shadow renderer.

@mvaligursky may know more on this :innocent:

The part of the shader that integrates shadow intensity into the final pixel is not in the chunks and is directly generated in the code, so you would need to fork and change the engine.

Shadow color in general is controlled by the color of the ambient light … so perhaps adjusting that would be sufficient?

1 Like

Hi @Leonidas, many thanks for your answer!

I’m currently using the “Variance Shadow Map 16 bit”. Going through the code in debug, I’ve seen that the “shadowVSM_commonPS” chunk should be used.
So, maybe adding some code here can change the shadow color?

Sorry but I don’t know shaders at all so I don’t know where to put my hands!
Thanks for your help

Hi @mvaligursky, thanks for your answer!
You gave me an idea, saying that the color is controlled by the ambient light.

Indeed, overriding the “ambientConstantPS” shader chunk only for one particular object and setting by hand the “light_globalAmbient” vec3 property, kind of did the trick I wanted, so many thanks!

void addAmbient() {
    //dDiffuseLight += light_globalAmbient;
    dDiffuseLight += vec3(1.0,1.0,1.0);
}
3 Likes