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

Fix use of discard in shaders #79865

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions drivers/gles3/shaders/scene.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -1039,17 +1039,16 @@ void main() {
if (alpha < alpha_scissor_threshold) {
discard;
}
#endif // ALPHA_SCISSOR_USED

#else
#ifdef MODE_RENDER_DEPTH
#ifdef USE_OPAQUE_PREPASS
#if !defined(ALPHA_SCISSOR_USED)

if (alpha < opaque_prepass_threshold) {
discard;
}

#endif // not ALPHA_SCISSOR_USED
#endif // USE_OPAQUE_PREPASS
#endif // MODE_RENDER_DEPTH
#endif // !ALPHA_SCISSOR_USED

#endif // !USE_SHADOW_TO_OPACITY

Expand Down Expand Up @@ -1270,17 +1269,16 @@ void main() {
if (alpha < alpha_scissor) {
discard;
}
#endif // ALPHA_SCISSOR_USED

#else
#ifdef MODE_RENDER_DEPTH
#ifdef USE_OPAQUE_PREPASS
#if !defined(ALPHA_SCISSOR_USED)

if (alpha < opaque_prepass_threshold) {
discard;
}

#endif // not ALPHA_SCISSOR_USED
#endif // USE_OPAQUE_PREPASS
#endif // MODE_RENDER_DEPTH
#endif // !ALPHA_SCISSOR_USED

#endif // USE_SHADOW_TO_OPACITY

Expand Down
2 changes: 1 addition & 1 deletion drivers/gles3/storage/material_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ MaterialStorage::MaterialStorage() {
actions.render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["particle_trails"] = "#define USE_PARTICLE_TRAILS\n";
actions.render_mode_defines["depth_draw_opaque"] = "#define USE_OPAQUE_PREPASS\n";
actions.render_mode_defines["depth_prepass_alpha"] = "#define USE_OPAQUE_PREPASS\n";

bool force_lambert = GLOBAL_GET("rendering/shading/overrides/force_lambert_over_burley");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ void SceneShaderForwardClustered::init(const String p_defines) {
actions.render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["particle_trails"] = "#define USE_PARTICLE_TRAILS\n";
actions.render_mode_defines["depth_draw_opaque"] = "#define USE_OPAQUE_PREPASS\n";
actions.render_mode_defines["depth_prepass_alpha"] = "#define USE_OPAQUE_PREPASS\n";

bool force_lambert = GLOBAL_GET("rendering/shading/overrides/force_lambert_over_burley");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void SceneShaderForwardMobile::init(const String p_defines) {
actions.render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n";
actions.render_mode_defines["particle_trails"] = "#define USE_PARTICLE_TRAILS\n";
actions.render_mode_defines["depth_draw_opaque"] = "#define USE_OPAQUE_PREPASS\n";
actions.render_mode_defines["depth_prepass_alpha"] = "#define USE_OPAQUE_PREPASS\n";

bool force_lambert = GLOBAL_GET("rendering/shading/overrides/force_lambert_over_burley");
if (!force_lambert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,11 +875,15 @@ void fragment_shader(in SceneData scene_data) {
alpha = compute_alpha_antialiasing_edge(alpha, alpha_texture_coordinate, alpha_antialiasing_edge);
#endif // ALPHA_ANTIALIASING_EDGE_USED

#ifdef MODE_RENDER_DEPTH
#ifdef USE_OPAQUE_PREPASS
#ifndef ALPHA_SCISSOR_USED
if (alpha < scene_data.opaque_prepass_threshold) {
discard;
}
#endif // !ALPHA_SCISSOR_USED
#endif // USE_OPAQUE_PREPASS
#endif // MODE_RENDER_DEPTH

#endif // !USE_SHADOW_TO_OPACITY

Expand Down Expand Up @@ -2038,15 +2042,17 @@ void fragment_shader(in SceneData scene_data) {
if (alpha < alpha_scissor) {
discard;
}
#endif // ALPHA_SCISSOR_USED

#else
#ifdef MODE_RENDER_DEPTH
#ifdef USE_OPAQUE_PREPASS

if (alpha < scene_data.opaque_prepass_threshold) {
discard;
}

#endif // USE_OPAQUE_PREPASS
#endif // MODE_RENDER_DEPTH
#endif // ALPHA_SCISSOR_USED

#endif // USE_SHADOW_TO_OPACITY

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,15 @@ void main() {
alpha = compute_alpha_antialiasing_edge(alpha, alpha_texture_coordinate, alpha_antialiasing_edge);
#endif // ALPHA_ANTIALIASING_EDGE_USED

#ifdef MODE_RENDER_DEPTH
#ifdef USE_OPAQUE_PREPASS
#ifndef ALPHA_SCISSOR_USED
if (alpha < scene_data.opaque_prepass_threshold) {
discard;
}
#endif // !ALPHA_SCISSOR_USED
#endif // USE_OPAQUE_PREPASS
#endif // MODE_RENDER_DEPTH

#endif // !USE_SHADOW_TO_OPACITY

Expand Down Expand Up @@ -1685,15 +1689,17 @@ void main() {
if (alpha < alpha_scissor) {
discard;
}
#endif // ALPHA_SCISSOR_USED

#else
#ifdef MODE_RENDER_DEPTH
#ifdef USE_OPAQUE_PREPASS

if (alpha < scene_data.opaque_prepass_threshold) {
discard;
}

#endif // USE_OPAQUE_PREPASS
#endif // MODE_RENDER_DEPTH
#endif // !ALPHA_SCISSOR_USED

#endif // USE_SHADOW_TO_OPACITY

Expand Down