Hey, I used an outline filter in a game once
uniform sampler2D bgl_RenderedTexture;
uniform sampler2D bgl_DepthTexture;
uniform vec2 bgl_TextureCoordinateOffset[9];
const float near = 0.1;
const float far = 100.0;
float depth(in vec2 coo)
{
vec4 depth = texture2D(bgl_DepthTexture, coo);
return -near / (-1.0+float(depth) * ((far-near)/far));
}
void main(void)
{
vec4 sample[9];
vec4 border;
vec4 texcol = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
for (int i = 0; i < 9; i++)
{
sample[i] = vec4(depth(gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]));
}
vec4 horizEdge = sample[2] + sample[5] + sample[8] -
(sample[0] + sample[3] + sample[6]);
vec4 vertEdge = sample[0] + sample[1] + sample[2] -
(sample[6] + sample[7] + sample[8]);
border.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
(vertEdge.rgb * vertEdge.rgb));
if (border.r > 0.8||border.g > 0.8||border.b > 0.8){
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);
}else{
gl_FragColor.rgb = texcol.rgb;
gl_FragColor.a = 1.0;
}
}
This is the code. Using it should give you the same effect as before!
Nice project btw! Keep going