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
Cleanup and improve sky render #70253
Conversation
bdd1521
to
92dd9e5
Compare
ERR_FAIL_COND(p_render_buffers.is_null()); | ||
|
||
// make sure we support our view count | ||
ERR_FAIL_COND(p_view_count == 0); |
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 wonder if we should actually return a true/false from setup_sky
, then we can do our checks in one place and prevent the rest from running on failure. Right now it is possibly we run other stages of sky rendering if setup fails.
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.
Thats a good idea, we could likely set draw_sky
to false if setup_sky
fails which would avoid the other operations. Thats something for another PR though as we would need to think about what kind of fallback information we would need to provide in that case (clear color etc.).
92dd9e5
to
6db3c67
Compare
0c28686
to
a17a91f
Compare
This turns out not to be needed, updating radiance buffers for Sky is the exception where we do not pre-apply the sky orientation, instead the sky-orientation is applied when the radiance is read in the scene shader. This prevents the need for costly updating of the radiance map just because the sky orientation changes. |
The big change in this new commit is using render buffers for reflection probes. This way there is no need for duplicating logic in Sky to handle buffers differently between scene rendering and reflection probe rendering. There is a good argument for embedding the full reflection probe atlas logic into render buffers as a lot of code is duplicated for this in Sky to make I'm putting this ready for review, I still need to check if the Z-buffer in stereoscopic is working as expected but that is not critical to what this PR is about and if it is broken, it was already broken. |
a17a91f
to
6b41d7b
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.
Some initial comments
} | ||
} | ||
uniforms.push_back(u); | ||
} | ||
|
||
texture_uniform_sets[p_version] = RD::get_singleton()->uniform_set_create(uniforms, p_default_shader_rd, SKY_SET_TEXTURES); | ||
return texture_uniform_sets[p_version]; | ||
return RD::get_singleton()->uniform_set_create(uniforms, p_default_shader_rd, SKY_SET_TEXTURES); |
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.
Why are we no longer caching the uniform sets? Since we aren't using the uniform set cache here we will end up producing a new uniform set each time this is called
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.
How did I end up with that, it's supposed to be calling the framebuffer cache, I'll fix it up
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.
Ok should be correct now.
servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp
Outdated
Show resolved
Hide resolved
servers/rendering/renderer_rd/forward_mobile/render_forward_mobile.cpp
Outdated
Show resolved
Hide resolved
6b41d7b
to
b772488
Compare
Hmm, that makes sense though I don't think they are freed at the end, I could be missing the code somewhere but it looks like they are only freed if the atlas size changes? |
At the end the atlas size is set to 0 to free it |
Mixed up sky and reflection probe, shows even more than it makes sense to move this into our buffers object. |
b772488
to
e886a7a
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.
Looks good! I think your remaining ideas would be good to do in future PRs. This already is getting quite large
Thanks! |
This PR fixes a number of issues with the sky rendering and moves to some of the newer abilities we added:
draw
(nowdraw_sky
) so we only have one implementation to manage.RenderSceneBuffersRD
to handle helper buffers. This can be further improved by moving the logic for creating all buffers used here. This would further clean up code currently duplicated between our reflection probe logic andSkyRD::update_radiance_buffers
Still todo:
Bugsquad edit: