Fix use of discard in shaders
discard was being included in all shaders set to depth pass opaque, which is the majority of shaders Instead it should only be used with alpha prepass materials
This commit is contained in:
parent
f6187014ec
commit
7c812cd7e9
6 changed files with 27 additions and 17 deletions
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -2038,8 +2042,8 @@ 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) {
|
||||
|
@ -2047,6 +2051,8 @@ void fragment_shader(in SceneData scene_data) {
|
|||
}
|
||||
|
||||
#endif // USE_OPAQUE_PREPASS
|
||||
#endif // MODE_RENDER_DEPTH
|
||||
#endif // ALPHA_SCISSOR_USED
|
||||
|
||||
#endif // USE_SHADOW_TO_OPACITY
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -1685,8 +1689,8 @@ 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) {
|
||||
|
@ -1694,6 +1698,8 @@ void main() {
|
|||
}
|
||||
|
||||
#endif // USE_OPAQUE_PREPASS
|
||||
#endif // MODE_RENDER_DEPTH
|
||||
#endif // !ALPHA_SCISSOR_USED
|
||||
|
||||
#endif // USE_SHADOW_TO_OPACITY
|
||||
|
||||
|
|
Loading…
Reference in a new issue