#Achieve "Neutral" Lighting?

1 messages · Page 1 of 1 (latest)

sharp crest
#

Hi all, I think I might already know the answer, but is there no way to light a scene in Godot in such a way that a white light (1,1,1) will give you colors that exactly match the albedo source colors from the materials etc?

This is how I'm used to colors interacting with lighting in other engines and graphics libraries, and so far the only way I've been able to get anything neutral in Godot is to have no light source, and full ambient light. Any light source seems to add something to the color, instead of simply taking away shadow. It makes it really difficult to author textures and stuff because what I paint ends up looking totally off in Godot.

shy solstice
#

Try these. Importantly, the background contributes no lighting. The energy of the ambient light and sun sum to 1.

#

Alternately, set the ambient energy to 0, and the sun to 1. Or the ambient to .2, and the sun to .8

#

That should get you fully lit areas that are the same brightness as your albedo textures.

#

Partially lit areas may be different than you expect though, due to linear/srgb conversions somewhere along the pipeline

sharp crest
#

Ooooo!! That's so cool, I will give this a shot the next chance I get, thank you!!

sharp crest
#

@shy solstice Your math works, thank you very much! This however has the caveat that all contributing lights must have the same color and are complementary in energy. If I could figure out the exact math I could figure out a way to reverse it to work with different-colored lights. My goal is to try to specify a "desired ambient color" and then a "desired fully-lit color", and do some math to figure out what color/energy to set both lights.

shy solstice
#

But you still have more or less "boolean" needs, right? Either ambient lit or fully lit. And fully lit should be a particular color (that closely matches the input albedo color)?

#

You don't think you'll have a range of realistic lighting setups between those?

#

Actually, is there a particular lighting engine that you're trying to match the behavior of? You might be best served at some point by writing your own lighting function in a shader. Especially if you're trying to match an older lighting engine before PBR took over everything

#

Huh... even .5 and .5, white and white for the ambient and sun light brightens the final color to be a little higher than the albedo texture. That's probably from linear/srgb conversions and tonemapping somewhere.

sharp crest
# shy solstice Huh... even .5 and .5, white and white for the ambient and sun light brightens t...

You gotta change the Tonemapping and the Reflected Light sections of the World Environment. For me I was able to get complete parity when changing just energy on lights of identical color, so that's all good.

And yes I have boolean needs in the sense that I just need to specify what the "ambient" color is and what the "fully lit" color is. And they might not be the same. Like, if I want fully white in the light, but bluish ambient, I can't find the math to make that happen right now.

shy solstice
#

What are your tonemapping settings? I had linear at 1

sharp crest
#

that's what I had it to.

shy solstice
#

I can't figure out the math after a bit of trying. If it helps you at all, I set up a tool script like this to speed up testing:

@tool
class_name LightManager
extends Node3D

# Make the environment and light children of this node
@onready var we : WorldEnviron
ment = $WorldEnvironment  
@onready var dir : DirectionalLight3D = $DirectionalLight3D

@export var fully_lit_target: Color
@export var fully_lit_energy := 1.0
@export var ambient_lit_target: Color
@export var ambient_lit_energy := 0.5

func _process(delta: float) -> void:
    # Do math here
    var ambient_energy = ambient_lit_energy
    var dir_energy = fully_lit_energy
    var dir_color = fully_lit_target
    var ambient_color = ambient_lit_target
    
    # None of this math is good
    var fully_lit_mult  = fully_lit_target * fully_lit_energy
    var ambient_mult = ambient_lit_target * ambient_lit_energy
    dir_color = fully_lit_mult - ambient_mult
    ambient_color = ambient_mult
    dir_energy = 1.0
    ambient_energy = 1.0
    
    we.environment.ambient_light_color = ambient_color
    we.environment.ambient_light_energy = ambient_energy
    dir.light_color = dir_color
    dir.light_energy = dir_energy