Any way to set a material to not be affected by the scene's ambient colour?

Even though my emissive is set to intensity 1, when I manually modify my scene’s 'ambient color ’ in the settings menu, the material is affected and becomes lighter/darker. How would I prevent this?

the material is also set to material.useLighting=false;


here’s an issue on this, with possible workaround

Thanks but no luck. I’m actually rendering to a RenderTarget and it seems that the ambient colour is actually affecting the pixel color on that too!
Any way to stop this happening?

Not sure if there is an easy way … another way would be to override the three shader chunks starting with ambient here, to not contribute any color to the pixel:

Thanks but I have no idea what you are suggesting :slight_smile:
My issue is that I am trying to do pixel operations on a rendertarget which is nothing to do with the scene, yet the scene ambient colour is affecting it. I’m guessing this shouldn’t really happen even at the engine level?

Note: This seems to happen to only colors that are NOT full intensity (ie full Red 1,0,0 does NOT get affected by changing ambient, although a colour something like 0.5,0,0 will get affected by ambient scene colour)

If you do operations where you don’t want light, you should:

  • use emissive only on the material, as that is not affected by the lighting
  • if this is more like a data processing, you should write a custom shader for it?

It’s hard to advice without understanding what you’re trying to do.

Ah ha !! I was setting my diffuse colour value to the same colour as my emissive value!

The diffuse value needs to be set to BLACK in order to not be affected by the ambient and then just use the emissive value on its own to control color.


1 Like