From d0f6f716e5ebd030217d7b1eac90549fb5ce7095 Mon Sep 17 00:00:00 2001 From: skyjake Date: Fri, 15 Nov 2013 09:30:48 +0200 Subject: [PATCH] Renderer|FX: Monochrome shaders for frame post-processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “fx.post.monochrome.inverted” replicates the original Doom invulnerability effect. --- doomsday/client/data/shaders.dei | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/doomsday/client/data/shaders.dei b/doomsday/client/data/shaders.dei index 97cdd69af2..9124c622be 100644 --- a/doomsday/client/data/shaders.dei +++ b/doomsday/client/data/shaders.dei @@ -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 {