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

SpotLight3D turns negative, and creates black boxes on small angles with volumetric fog #78500

Closed
Tracked by #69579
Jonne-G opened this issue Jun 21, 2023 · 9 comments · Fixed by #82546
Closed
Tracked by #69579

Comments

@Jonne-G
Copy link

Jonne-G commented Jun 21, 2023

Godot version

v4.0.stable.official [92bee43]

System information

Windows 10, AMD 5 5600G, RTX 3060, Forward+ Shading

Issue description

When creating a SpotLight3D in a scene with fog, the light will first invert (e.g. opposite colours) and then create black splotches as seen in the screenshots below:

Angle of 2.0 degrees, range 15.0
Godot_v4 0-stable_win64_WCqaG9lyQk

Angle of 1.0 degrees, range 15.0,
Godot_v4 0-stable_win64_1cBv1k55nQ

Steps to reproduce

Create a spotlight with the following settings:

range: 15
angle: 1.0

Colour: ff3e00
Energy, Indirect Energy, and Volumetric Fog Energy: 500

Size: 1.0 m

And a world environment with volumetric fog on set to defaults.

Note that any angle below 3 seems to act strangely.

Minimal reproduction project

Note for opening the project: The scene opens with the camera close to the center of the scene.
Make sure to toggle the volumetric fog off and on to reset the dark spots.

SpotLight3DBugRepro.zip

@clayjohn
Copy link
Member

This looks suspiciously similar to a bug we already fixed. Could you try again with 4.0.3 to see if the bug has been fixed already?

@Jonne-G
Copy link
Author

Jonne-G commented Jun 21, 2023

I tried with the latest available build, but the issue still persists.

@Calinou
Copy link
Member

Calinou commented Jun 21, 2023

I can confirm this on v4.1.beta.custom_build [f2ce0b6] (Linux, GeForce RTX 4090 with NVIDIA 530.41.03). Disabling volumetric fog resolves the issue.

image

@viksl
Copy link
Contributor

viksl commented Jul 6, 2023

This happens not just with SpotLight3D but also OmniLight3D, DirectionalLight and well any light in general I assume , in 4.1rc3 win 10, nvidia gtx 1660Ti.

EDIT:
For me this seems to be cause by Temporal Reprojection in the Volumetric Fog. Pictures below are on/off - you can keep switching it as many times as you want it doesn't go away after turning it on/off but it goes away after turning the entire Volumetric Fog on/off it seems.
In the scene below everything is white because of the glow, if I turn it off I get those black blotches as @Calinou above

obrazek
obrazek

But in my case it takes a while until it happens, it gradually cummulates over 30-60 minutes, I'm not 100% sure if it's the same as the above or not?

The simples way to reproduce this is to turn on the directional light (it's on by default), enable volumetri fog, enable temporal reprojection (it's on by default), set the length to 0, then back to anything, then rotate the 3d viewport a bit and see it grow. It happens in real projects with regular length too but it takes longer.

In the video you can see the whole thing happening, as long as you are in the light's range it can happen, it also happens when you only hover over editor's buttons and such (for some reason I have no idea why but it's there, clearly visible at the last part of the video)

Video link: https://youtu.be/v9CuizB4kU4

@Calinou @Jonne-G would you mind checking if the above is related to the temporal reprojection as I mentioned above, please?
In the last part of the video there are issues which happen by hovering over editor elements, should I report this as a separate editor bug for temporal reprojection or keep it here?

@viksl
Copy link
Contributor

viksl commented Aug 17, 2023

I can reproduce this at least partially in 4.1.1 but not in 4.2 master, @Jonne-G can you please check? Though I think there are three issues included here.

@Jonne-G
Copy link
Author

Jonne-G commented Aug 18, 2023

@viksl I tried in 4.2 with temporal reprojection turned off and on.
With it off, the black spot stays on the light, whilst with it on it will slowly cover the scene.
It seems like 4.2 still has the issue present.

I don't think the reprojection is the issue, from what I can tell it is working as intended i.e. reprojecting lighting data from previous frames to new ones. It's just that it gets garbled data.

Unless I'm misunderstanding what you are referring to.

@viksl
Copy link
Contributor

viksl commented Aug 18, 2023

@Jonne-G interesting, for me it looks way different at this point and I've been testing it to see if it spreads or not for hours and nothing on my side (win 10, nvidia gpu too), I also had it tested on linux with nvidia gpu and nothing but neither of these GPUs were rtx ones.

The light turning negative on its own without checking negative checkbox also still happens?

It happens only with spotlight not with omnilight, correct?

@viksl
Copy link
Contributor

viksl commented Aug 23, 2023

I noticed that when I change the Volume Depth to at least 256 (in the video I use 512) and then up the Detail Spread to values above 5.5 I start getting similar issue (the black areas) which spread around.

Video here: https://youtu.be/Vz-fKhp5scQ

I also noticed going through the shader code that on line 426 I get INF and -INF values:
https://github.com/godotengine/godot/blob/6758a7f8c07d1f4c8ec4f052ded6d26402967ebe/servers/rendering/renderer_rd/shaders/environment/volumetric_fog_process.glsl#L426C8-L426C8

Particularly it comes from:
normalize(view_pos)

It happens only for one frame and then I get some float values but during this one frame NaN values spread later on where the total_light is used into prev_ textures and such (for example good first texture to check is density_map) and then keep spreading in frames afterwards.

Again the black areas are only visible with temporal reprojection on, if you turn it off it's hidden, if you turn it back on it shows just like it showed previously (meaning it's still storead in the texture I assume). The only way to get rid of this is either to quickly move the camera in the opposite direction or turning the volumetric fog itself on and then on again but if the detail spread values are still set above 5.5 (in my case) then it will start again and it will spread again (though the texture seems to get reset as expected).

I can't say for sure it's related but it does seem to connect.

EDIT:
I don't think all the NaN values come from this, it seems the view_pos close to zero or zero vector3 in another place ends up with zero division and such too.

@Calinou Calinou changed the title SpotLight3D turns negative, and creates black boxes on small angles SpotLight3D turns negative, and creates black boxes on small angles with volumetric fog Sep 16, 2023
@viksl
Copy link
Contributor

viksl commented Sep 29, 2023

I was finally able to reproduce this now after I made a HW upgrade (no idea why it does this only with certainl HW?), can you please test this:
#82546

It's the same fix which was used with gles3, I don't know if this is also ok for vulkan side or not? If nothing else it does fixes this issue on my side.

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

Successfully merging a pull request may close this issue.

5 participants