x


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!

more ▼

asked Feb 13 '11 at 11:48 PM

UltimateWalrus 1 gravatar image

UltimateWalrus 1
20 2 2 7

(comments are locked)
10|3000 characters needed characters left

3 answers: sort voted first

Use a shader for the monster that adds some extra color value, similar to the built-in VertexLit shader's Emissive Color property.

more ▼

answered Feb 14 '11 at 12:45 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

Thanks for your help! I managed to do it using a shader which calculates the color based on (_Ambient + primary)*texture .

Feb 14 '11 at 03:15 AM UltimateWalrus 1
(comments are locked)
10|3000 characters needed characters left

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)

more ▼

answered Feb 14 '11 at 01:28 AM

Myth gravatar image

Myth
404 21 27 42

This is a good idea as well, I'll keep this in mind as I'll probably need to use this later in my game. Thanks!

Feb 14 '11 at 03:16 AM UltimateWalrus 1

In fact I may very well use this technique, as increasing ambient isn't giving me the exact effect I wanted.

Feb 14 '11 at 03:18 AM UltimateWalrus 1
(comments are locked)
10|3000 characters needed characters left

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. ;-)

more ▼

answered Feb 14 '11 at 01:52 AM

Jessy gravatar image

Jessy
15.6k 72 95 196

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x491
x39
x19
x5
x3

asked: Feb 13 '11 at 11:48 PM

Seen: 2030 times

Last Updated: Jul 18 '11 at 11:49 PM