Merge pull request #92070 from lawnjelly/fix_fragcolor_write

[3.x] Fix fragcolor write locations in scene shaders
This commit is contained in:
lawnjelly 2024-05-20 20:46:14 +01:00 committed by GitHub
commit 6c2870d73c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -2467,6 +2467,12 @@ FRAGMENT_SHADER_CODE
frag_color.rgb = mix(pow((frag_color.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), frag_color.rgb * (1.0 / 12.92), vec3(lessThan(frag_color.rgb, vec3(0.04045)))); frag_color.rgb = mix(pow((frag_color.rgb + vec3(0.055)) * (1.0 / (1.0 + 0.055)), vec3(2.4)), frag_color.rgb * (1.0 / 12.92), vec3(lessThan(frag_color.rgb, vec3(0.04045))));
#endif #endif
// Write to the final output once and only once.
// Use a temporary in the rest of the shader.
// This is for drivers that have a performance drop
// when the output is read during the shader.
gl_FragColor = frag_color;
#else // not RENDER_DEPTH #else // not RENDER_DEPTH
//depth render //depth render
#ifdef USE_RGBA_SHADOWS #ifdef USE_RGBA_SHADOWS
@ -2474,10 +2480,8 @@ FRAGMENT_SHADER_CODE
highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias highp float depth = ((position_interp.z / position_interp.w) + 1.0) * 0.5 + 0.0; // bias
highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0)); highp vec4 comp = fract(depth * vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0));
comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0); comp -= comp.xxyz * vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
frag_color = comp; gl_FragColor = comp;
#endif #endif
#endif #endif
gl_FragColor = frag_color;
} }

View File

@ -2453,13 +2453,13 @@ FRAGMENT_SHADER_CODE
#endif //ubershader-runtime #endif //ubershader-runtime
#endif //SHADELESS //ubershader-runtime #endif //SHADELESS //ubershader-runtime
#endif //USE_MULTIPLE_RENDER_TARGETS //ubershader-runtime
// Write to the final output once and only once. // Write to the final output once and only once.
// Use a temporary in the rest of the shader. // Use a temporary in the rest of the shader.
// This is for drivers that have a performance drop // This is for drivers that have a performance drop
// when the output is read during the shader. // when the output is read during the shader.
frag_color_final = frag_color; frag_color_final = frag_color;
#endif //USE_MULTIPLE_RENDER_TARGETS //ubershader-runtime
#endif //RENDER_DEPTH //ubershader-runtime #endif //RENDER_DEPTH //ubershader-runtime
} }