The title is over simplifying what I want to achieve. Basically, I have a 2d game and I want to make a light scattering effect over the grid of tiles. The algorithm for light dispersion is simple, I just need to find a way to increase the ‘lightness’ of each tile according to the calculated value.
How to do that is the tricky part. I can get somewhere by simply setting the ambient to white or gray and mess with the main color of the materials, but there’s a problem with that approach: I can’t get it to work well with traditional lights. For example, if I want zero light dispersion on some tile its main color would be black, that means it would be pitch black even with an omni light nearby. So I really need something like the ambient light, only for individual objects.
I originally made this thread at the scripting forum first but got no responses there. Since this might have a solution in the form of a shader I’m bringing the ball over here.
Lighting should be calculated in an additive manner, so for your shader you want the point light or directional light to act as usual, and then add the ambient to it. If you can’t hack it straight into the unity rendering pipeline, then I’d just multiply your custom ambient by the diffuse texture/colour and set that as emissive. Look into the self-illumination or reflective Unity shaders for an example of using emissive.
Hey, thanks for replying I even forgot about this thread.
I solved this by tweaking the built-in shader bumped specular self illumination. I made it so that instead of a texture for self illumination it’s just the color texture multiplied by a value.