renderergl2: reimplement greyscale as backend post after all 2D+3D draws
Fixes #654 - HUD/UI previously bypassed greyscale. r_greyscale now supports partial desaturation [0-1]. Removed unused legacy logic from tr_shade.c
This commit is contained in:
1 parent
7bd2c17f9d
commit
453705553b
9 files changed
+166
-111
No files matched your search
@@ -0,0 +1,15 @@
|
||||
uniform sampler2D u_TextureMap;
|
||||
uniform float u_Greyscale;
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
// From Rec. 709-1 4.2 "Derivation of luminance signal"
|
||||
const vec3 LUMA = vec3(0.2125, 0.7154, 0.0721);
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(u_TextureMap, var_TexCoords);
|
||||
if (u_Greyscale > 0.0) {
|
||||
float y = dot(color.rgb, LUMA);
|
||||
color.rgb = mix(color.rgb, vec3(y), clamp(u_Greyscale, 0.0, 1.0));
|
||||
}
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
attribute vec4 attr_Position;
|
||||
attribute vec2 attr_TexCoord0;
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
void main() {
|
||||
vec2 clipXY = (attr_Position.xy * r_FBufScale) * 2.0 - 1.0;
|
||||
clipXY.y = -clipXY.y;
|
||||
|
||||
gl_Position = vec4(clipXY, 0.0, 1.0);
|
||||
var_TexCoords = attr_TexCoord0;
|
||||
}
|
||||
Reference in new issue
Block a user