-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Shader optimizations to reduce VGPR usage and increase occupancy #45023
Conversation
@@ -6288,13 +6283,14 @@ void RendererSceneRenderRD::_setup_lights(const PagedArray<RID> &p_lights, const | |||
float sign = storage->light_is_negative(base) ? -1 : 1; | |||
Color linear_col = storage->light_get_color(base).to_linear(); | |||
|
|||
light_data.attenuation_energy[0] = Math::make_half_float(storage->light_get_param(base, RS::LIGHT_PARAM_ATTENUATION)); | |||
light_data.attenuation_energy[1] = Math::make_half_float(sign * storage->light_get_param(base, RS::LIGHT_PARAM_ENERGY) * Math_PI); | |||
light_data.attenuation = storage->light_get_param(base, RS::LIGHT_PARAM_ATTENUATION); |
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.
This just cleaned up how parameters are sent to the reflection probe struct
uint8_t color_specular[4]; //rgb color, a specular (8 bit unorm) | ||
uint16_t cone_attenuation_angle[2]; // attenuation and angle, (16bit float) | ||
uint8_t shadow_color_enabled[4]; //shadow rgb color, a>0.5 enabled (8bit unorm) | ||
|
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.
Likewise cleaned up lights
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 mostly good!
} | ||
#endif //LOW_END_MODE | ||
// multiply by albedo | ||
diffuse_light *= albedo; // ambient must be multiplied by albedo at the end |
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.
comment out of date
#ifndef LOW_END_MODE | ||
if (scene_data.ssao_enabled) { | ||
float ssao = texture(sampler2D(ao_buffer, material_samplers[SAMPLER_LINEAR_CLAMP]), screen_uv).r; | ||
ao = min(ao, ssao); |
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.
We need to delete SSAO_ao_affect from environment etc.
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.
For reference, I opened an issue to track this: #54611
1131b2c
to
8b6c33c
Compare
Im getting 2 types of artifacts with shaders. One is random blocks of shadow that flicker in and out (likely entire clusters missing a light). And the second is that the derivative shadow optimization doesnt scale well with distance from a shadow. So when you get far enough away from a shadow the edges take on a very aliased look |
8b6c33c
to
dc2ec58
Compare
@akien-mga Should hopefully be ok to merge but the static checks are not passing and I already have clang-format-11. |
@reduz I would recommend avoiding nested ternary operators, it should fix the clang-format issue at the same time. |
dc2ec58
to
9683c70
Compare
9683c70
to
e71492a
Compare
@clayjohn disabled it for now |
e71492a
to
1f56612
Compare
I went over the files, it wasn't an in-depth review but I didn't spot anything wrong. Other than that, Github lists some files as edited, but they don't contain any changes, not sure what's going on. Also, static checks have failed, I think they should be restarted. |
I restarted CI jobs for static checks and Android which failed for a seemingly unrelated reason, likely a CI oops. |
Ah no it's not a CI issue, @reduz did remove executable permission on those files, so they can't run on CI: |
1f56612
to
a5fbe24
Compare
Clustering is now GPU based, uses an implementation based on the Activision algorithm.
a5fbe24
to
099dee3
Compare
Thanks! |
Reduced from 116 to 80 VGPRs in normal usage, still more work is needed.
Some not often used features are gone for the sake of this and some are disabled, will re-enable later.
-Shadow color per light is gone
-Oren Nayar is gone (implement manually if you really want it, makes little difference)
-SSAO color is gone
-SSAO ao affect is gone because this confused users, min(ao,ssao) now used, should work in most cases.
Also
-softshadows (based on angular distance) are likely going to be removed from directional light, too expensive dont look great, and dont make much of a difference
-projectors are disabled.