- Home /
Changing ambient light for just one object?
Hello,
I have sort of a survival-horror style game where the lighting is very dark. I have a monster who I would like to be visible through the darkness.
In DirectX or OpenGL, this would be trivial --- I'd just set the ambient light higher before the object is rendered, and set it back to where it was after it's been rendered.
Is there a way to do this in Unity? Are there some kind of prerender/postrender callback functions for a given object that I don't know about?
Thanks!
Answer by Eric5h5 · Feb 14, 2011 at 12:45 AM
Use a shader for the monster that adds some extra color value, similar to the built-in VertexLit shader's Emissive Color property.
Thanks for your help! I managed to do it using a shader which calculates the color based on (_Ambient + primary)*texture .
Answer by Myth · Feb 14, 2011 at 01:28 AM
Put the monster on a different layer and have a separate light for the monster
(I think it is cull you change on the light)
This is a good idea as well, I'll keep this in $$anonymous$$d as I'll probably need to use this later in my game. Thanks!
In fact I may very well use this technique, as increasing ambient isn't giving me the exact effect I wanted.
Answer by Jessy · Feb 14, 2011 at 01:52 AM
All the built-in shaders shaders that use lighting multiply the ambient light color by some other color. Despite what is said in the documentation, you're not restricted to 0-1; a Color is just four run-of-the-mill floats. If you need the ambient setting boosted, you can pick something that looks good using the color picker, in the Editor, and multiply all the channels of it by a constant greater than 1.
Unfortunately, as far as I know, the color for ambient and diffuse lighting is tied together in all of the built-in shaders, so I don't know that you can achieve this effect without deep modification. I had a look at some surface shader examples, and it didn't look easy, but I didn't look for very long. ;-)
Your answer
Follow this Question
Related Questions
Illumination at runtime being weird. 1 Answer
Raytracing: Callback when Raytracing finished 0 Answers
Order of OnPostRender callbacks? 1 Answer
Android build not displaying correctly? (answered) 1 Answer
Blank screen on Android 0 Answers