Navigation Menu

Skip to content

Commit

Permalink
Renderer|FX: Monochrome shaders for frame post-processing
Browse files Browse the repository at this point in the history
“fx.post.monochrome.inverted” replicates the original Doom
invulnerability effect.
  • Loading branch information
skyjake committed Nov 15, 2013
1 parent 5fd6348 commit d0f6f71
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions doomsday/client/data/shaders.dei
Expand Up @@ -155,6 +155,69 @@ group fx {
}"
}
}

# Post-processing shaders need to have uFadeInOut (0..1) for
# fading the effect in/out.
group post {
shader monochrome {
vertex = "
uniform highp mat4 uMvpMatrix;
attribute highp vec4 aVertex;
attribute highp vec2 aUV;
varying highp vec2 vUV;

void main(void) {
gl_Position = uMvpMatrix * aVertex;
vUV = aUV;
}"
fragment = "
uniform sampler2D uTex;
uniform highp float uFadeInOut;
varying highp vec2 vUV;

void main(void) {
highp vec4 original = texture2D(uTex, vUV);
highp float intens =
(0.2125 * original.r) +
(0.7154 * original.g) +
(0.0721 * original.b);
gl_FragColor = vec4(vec3(intens), 1.0);
if(uFadeInOut < 1.0) {
gl_FragColor = mix(original, gl_FragColor, uFadeInOut);
}
}"
}

shader monochrome.inverted {
vertex = "
uniform highp mat4 uMvpMatrix;
attribute highp vec4 aVertex;
attribute highp vec2 aUV;
varying highp vec2 vUV;

void main(void) {
gl_Position = uMvpMatrix * aVertex;
vUV = aUV;
}"
fragment = "
uniform sampler2D uTex;
uniform highp float uFadeInOut;
varying highp vec2 vUV;

void main(void) {
highp vec4 original = texture2D(uTex, vUV);
highp float intens =
(0.2125 * original.r) +
(0.7154 * original.g) +
(0.0721 * original.b);

gl_FragColor = vec4(vec3(1.0 - intens), 1.0);
if(uFadeInOut < 1.0) {
gl_FragColor = mix(original, gl_FragColor, uFadeInOut);
}
}"
}
}
}

group vr {
Expand Down

0 comments on commit d0f6f71

Please sign in to comment.