diff options
author | clayjohn <claynjohn@gmail.com> | 2023-01-20 15:41:20 -0800 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2023-01-20 15:41:20 -0800 |
commit | 6d0af4fcd8dbe9720e9b8601b1c138506fe51003 (patch) | |
tree | 31e95464171140b0bca0f5eb59f9d2b2fc1a9bd3 | |
parent | 9f74f0f6c5e5c98b18f4f0ad95092a88d064f616 (diff) |
Assign light indices after sorting in OpenGL renderer
This ensures that the light indices sent to the shader actually match where the light is saved
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index e4bcc424b3..c14aa8791c 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1535,8 +1535,6 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b } } - li->gl_id = r_omni_light_count; - scene_state.omni_light_sort[r_omni_light_count].instance = li; scene_state.omni_light_sort[r_omni_light_count].depth = distance; r_omni_light_count++; @@ -1560,8 +1558,6 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b } } - li->gl_id = r_spot_light_count; - scene_state.spot_light_sort[r_spot_light_count].instance = li; scene_state.spot_light_sort[r_spot_light_count].depth = distance; r_spot_light_count++; @@ -1586,6 +1582,8 @@ void RasterizerSceneGLES3::_setup_lights(const RenderDataGLES3 *p_render_data, b GLES3::LightInstance *li = (i < r_omni_light_count) ? scene_state.omni_light_sort[index].instance : scene_state.spot_light_sort[index].instance; RID base = li->light; + li->gl_id = index; + Transform3D light_transform = li->transform; Vector3 pos = inverse_transform.xform(light_transform.origin); |