Skip to content

Instantly share code, notes, and snippets.

@nikp123
Created July 16, 2021 06:43
Show Gist options
  • Save nikp123/19047776f961bd9e725a003574f3c039 to your computer and use it in GitHub Desktop.
Save nikp123/19047776f961bd9e725a003574f3c039 to your computer and use it in GitHub Desktop.
Soft-shadows XAVA post-render shader
precision mediump float;
varying vec2 v_texCoord;
uniform sampler2D s_texture;
const float pi = 3.14159265f;
const float check_steph = 0.00125;
const float check_stepv = 0.005;
void main() {
vec4 sourcecol = texture2D(s_texture, v_texCoord);
//vec2 offset = vec2(-0.002, 0.01);
if(sourcecol.rgb == vec3(0.0, 0.0, 0.0)) {
float intensity = 0.0;
for(int i=-5; i<2; i++) {
for(int j=-2; j<5; j++) {
vec2 check_pos = v_texCoord.xy+vec2(float(i)*check_steph, float(j)*check_stepv);
vec4 check_col = texture2D(s_texture, check_pos);
if(check_col.rgb != vec3(0.0, 0.0, 0.0)) {
intensity += 0.015;
}
}
}
gl_FragColor = vec4(0.0, 0.0, 0.0, intensity);
} else gl_FragColor = sourcecol;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment