Advertisement

Can I make objects shine less when close to a light in Unity?

Started by September 23, 2022 11:24 PM
3 comments, last by Aressera 2 years, 2 months ago

So I'm making this game that's dark, where I turned off all the lights and I'm lighting the players view using a spot light. I've tweaked the lights to a place where I like them but when I get close to the walls or ground, they shine too bright. I'll attach Images to show what I mean, I was wondering if there was a solution to this. Maybe some sort of limit to how much a material can react to light, or something.

This is when I'm too close:

This is when I'm far enough, and it looks good

Looks like you want to tweak the attenuation properties of the light. Reduce it's brightness, but make sure it's not faded out at a too short distance.

Another related option is to use area lights instead point lights. But for now it seems mainly the above settings which are bad.

Advertisement

@JoeJ Yeah that's the problem, I basically tweaked the attenuation values in the URP to get better distance, but this was the result. So I was hoping there was something in materials or shaders were you can tell a material to stop being affected by light after a certain amount.

You probably want to use a different formulation of distance attenuation on the lighting in the shaders. By adjusting the “constant attenuation" you can avoid the intensity blowing up at short distances.

Change from something like this:

attenuation = 1/(distance*distance);

To something like this, where epsilon controls how bright it is at short distances. I'd recommend epsilon = 1, which will ensure the light intensity will never go above 1.

attenuation = 1/(epsilon + distance*distance);

This topic is closed to new replies.

Advertisement