Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light attenuation is incorrect in VoxelGI (values above 1.0 are too dark) #80101

Open
Tracked by #55328
SenhorPatolino opened this issue Aug 1, 2023 · 9 comments
Open
Tracked by #55328

Comments

@SenhorPatolino
Copy link

SenhorPatolino commented Aug 1, 2023

Godot version

v4.1.stable.official [9704596]

System information

Godot v4.1.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 Ti (NVIDIA; 31.0.15.3598) - Intel(R) Xeon(R) CPU E3-1230 V2 @ 3.30GHz (8 Threads)

Issue description

Light attenuation greatly affects VoxelGI, way more than it should, depending on the value it won't even show up, neither increasing the range solves it:

Light attenuation set to 3.14
image
image

Light attenuation set to 1.0
image
image

Steps to reproduce

Add any kinds of 3D light, set the attenuation to a value bellow 1 and it will start showing up incorrectly, range and intensity will start to have no effect over the light, and it will have a hard cut

Minimal reproduction project

VoxelGIAttenuation.zip

@Calinou
Copy link
Member

Calinou commented Aug 1, 2023

Can you reproduce this with GIProbe in 3.5.2?

@SenhorPatolino
Copy link
Author

3.5.2 tested and it works fine

This is an omni light with attenuation set to 3.14, I made the light intensity low and increased indirect light contribution to showcase the actual GIprobe
image

@Calinou
Copy link
Member

Calinou commented Aug 1, 2023

Note that light attenuation in 3.x uses a different algorithm than 4.x: #44941

You can use the 4.x light attenuation formula in 3.x by enabling Use Physical Light Attenuation in the Project Settings then restarting the editor. Remember to bake GIProbe again after doing so, though I don't remember if physical light attenuation affects GIProbe.

@SenhorPatolino
Copy link
Author

I tested in Godot 4 with that option and it worked, although range and Intensity still have a "clamped" functionality, and by clamped I mean that the intensity lumens actually controls the range and intensity. So the parameters range and intensity act more like a "mix factor".

@Calinou
Copy link
Member

Calinou commented Aug 2, 2023

I tested in Godot 4 with that option and it worked, although range and Intensity still have a "clamped" functionality, and by clamped I mean that the intensity lumens actually controls the range and intensity. So the parameters range and intensity act more like a "mix factor".

I was referring to an option which does not exist in Godot 4: physical light attenuation, not physical light units 🙂

@SenhorPatolino
Copy link
Author

Oh, huh, that was my bad, I'll test that again, though it is curious how enabling physical light units actually helps.

I tested Physical Light Attenuation in Godot 3.5.2 and it does work completely fine
image

@takdew
Copy link

takdew commented Oct 26, 2024

Any updates on this? It still doesn't work in 4.4 dev3

@Calinou
Copy link
Member

Calinou commented Oct 26, 2024

Any updates on this? It still doesn't work in 4.4 dev3

I've taken a look at the code that updates VoxelGI lighting and couldn't find anything of note.

@Calinou Calinou changed the title Light attenuation incorrect in VoxelGI Light attenuation is incorrect in VoxelGI (values above 1.0 are too dark) Oct 26, 2024
@takdew
Copy link

takdew commented Oct 26, 2024

I've taken a look at the code that updates VoxelGI lighting and couldn't find anything of note.

It would seem, that removing the attenuation check in line 281 from the file you linked fixes VoxelGI completely cutting off light, that should propagate otherwise.

-       if (attenuation < 0.01 || (length(normal) > 0.2 && dot(normal, light_dir) >= 0)) {
+	if ((length(normal) > 0.2 && dot(normal, light_dir) >= 0)) {
		return false; //not facing the light, or attenuation is near zero
	}

This is the testing setup without VoxelGI and with attenuation 2.0 and indirect energy 16.0:
att_2_novoxel

This is with VoxelGI currently (note that there is no difference at all):
att_2_voxel_prechange

The same setup after removing the check:
att_2_voxel_postchange

For reference, here's the same setup with SDFGI enabled (default config):
att_2_sdfgi

Another reference - attenuation 1.0 with VoxelGI (before and after look the same in this case):
att_1_voxel_postchange

Removing the check, from my understanding, might degrade performance due to computing lighting that might actually have near zero attenuation.

On the other hand, changing it to a lower value, e.g. 0.0001, introduces unexpected colors where light is nearing zero attenuation (at least in my production scene).

When compared to SDFGI, you can clearly tell that there is a huge difference between how attenuation is computed for VoxelGI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants