Graffiti Shader

GeeXLab - Graffiti shader - GLSL


How to run the demo?
Download and unzip GeeXLab and the demopack where you want, launch GeeXLab and drop the demo (main.xml) in GeeXLab. This demo requires OpenGL 2.1+.

I found this cool effect in this shadertoy demo. I put the graffiti effect in a simple GeeXLab demo. That’s all!

GeeXLab - Graffiti shader - GLSL

In the following pixel shader, tex2 is the background texture (wall) and tex0 and tex1 are the graffiti. The graffiti are textures with green screen background like this one:
GeeXLab - green screen image

Pixel shader:

#version 120
#define PI 3.14159265359
uniform vec2 u_resolution;
uniform float u_time;
varying vec4 v_uv;
uniform sampler2D tex0;
uniform sampler2D tex1;
uniform sampler2D tex2;
uniform vec4 fx_params; // x=0.01;  y=0.6
vec3 graffiti(in vec2 uv, in sampler2D chan, in vec2 lit, float dist)
    vec3 col = vec3(0.0);
    vec3 texUV = texture2D(chan,uv).rgb;
    vec2 dShad = lit*vec2(dist);
    vec3 greenRef = texture2D(chan,vec2(.999,.999)).rgb;
    float gr =  0.7 - texUV.g; // red patches -= vec2(fx_params.y)*smoothstep(.1, .4, gr);
    gr = texture2D(chan,uv - vec2(fx_params.x)).r - texUV.r;	//Black sketch
    col -= smoothstep(.0,.5,gr);
    gr = texture2D(chan,uv + vec2(fx_params.x)).r - texUV.r;
    col -= smoothstep(.0,.5,gr);
    float shad = float(any(bvec3(step(.25,abs(texture2D(chan,uv + dShad*(1.-float(any(bvec2(step(1.-dShad,uv)))))).rgb - greenRef)))));
    float mask = float(any(bvec3(step(.25,abs(texUV - greenRef)))));
    col -= shad*(1.-mask);
    return col;
void main() 
    vec2 st = v_uv.xy;
    st.y *= -1.0;
    vec3 color = texture2D(tex2, st).rgb;
    vec2 lit = vec2(0.1, 0.1);
    float dist = 0.025;
    color += graffiti(st, tex0, lit, dist);
    color += graffiti(st, tex1, lit, dist);
    gl_FragColor = vec4(color,1.0);

GeeXLab - Graffiti shader - GLSL

Leave a Comment

Your email address will not be published. Required fields are marked *