-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
Backport new 3D point light attenuation as an option (3.x) #52918
Backport new 3D point light attenuation as an option (3.x) #52918
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have looked through the code and tested it in GLES2 and GLES3. It looks a shedload better than the old attenuation imo (or at least more realistic). 👍
I don't know whether @clayjohn wants to give it a once over too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I'm sure many users will find this very useful.
3830e97
to
4c94ad8
Compare
4c94ad8
to
31b9d08
Compare
The CPU lightmapper now takes the new light attenuation option into account. Fully baked light (with bounces disabled) on the left, real-time light on the right: GLES3Note: The lightmap's colors appear washed out unless Hdr As Srgb is manually enabled on the texture's import settings. Enabling this import setting makes the colors correct, but the resulting lightmap becomes too dark compared to the real-time rendering. This doesn't happen in GLES2. We should look into this in a separate issue.
GLES2
|
66085d7
to
78d47a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are a couple of leftover debug prints, other than that it looks good :)
This provides more realistic lighting with a very small performance cost. The option is available in both GLES3 and GLES2, and can be enabled in the Project Settings. This goes well with the ACES Fitted tonemapping mode that was recently added. When enabled, this also makes upgrading Godot 3.x projects to Godot 4.0 easier, since lighting in 3.x will better match how it'll look in Godot 4.0.
78d47a4
to
85e080f
Compare
Thanks! |
Unreal 4 allows both physically based and legacy light attenuation to be used in the same scene, because it is recognized that some lights may require an artistic approach even if most are physically based. Can you make it a setting per-light instead of a project-wide setting? |
@Giwayume this still allows tweaking the falloff curve for artistic purposes just like it used to! The difference is now the default curve uses proper inverse squared law. |
I'm aware, https://docs.unrealengine.com/4.27/en-US/Resources/ContentExamples/Lighting/4_1/
https://docs.unrealengine.com/4.27/en-US/Resources/ContentExamples/Lighting/4_2/
Unreal intentionally keeps both falloff implementations because they recognize some games need it. Indeed I have seen Unreal 4 games that liberally use a combination of both. It's just a check box on the individual light to switch between the two types. |
Adding a per-light toggle will inevitably increase the performance demands (and configuration complexity), so I'd prefer not to do it. You can use a zero or slightly negative attenuation curve for fill lights (right-click the easing curve to show presets). This will prevent them from reaching high levels of brightness 🙂 |
I think if Unreal 4 can manage it, it's not a big performance it. |
This provides more realistic lighting with a very small performance cost. The option is available in both GLES3 and GLES2, and can be enabled in the Project Settings. This goes well with the ACES Fitted tonemapping mode that was recently added.
When enabled, this also makes upgrading Godot 3.x projects to Godot 4.0 easier, since lighting in 3.x will better match how it'll look in Godot 4.0.
Testing project: test_light_attenuation_3.x.zip
Testing project 2 (use for testing CPU lightmapper attenuation backport): test_light_attenuation_lightmap_3.x.zip
Preview
Note: The difference in brightness between the GLES3 and GLES2 images is expected, as GLES2 does not use HDR internally.
Lights in the middle have their attenuation set to 1.0 (the default). Lights on the right have their attenuation set to 0.5 ("Out" preset). The red light in the distance has its attenuation set to 2 ("In" preset).
GLES3 fragment shading
GLES2 fragment shading
GLES3 vertex shading
Note: Vertex shading looks broken here due to the floor's low vertex count.
GLES2 vertex shading
Note: Vertex shading looks broken here due to the floor's low vertex count.
TODO