Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #version 300
- //modified from https://gamedev.stackexchange.com/q/159657/99481
- uniform sampler2D u_texture;
- uniform float u_smoothing;
- in vec4 v_color;
- in vec2 v_texCoords;
- out vec4 fragColor;
- void main() {
- // SDF
- vec4 tex_color = texture(u_texture, v_texCoords);
- float tex_distance = tex_color.a;
- float min_bound = 0.5f - u_smoothing;
- float max_bound = 0.5f + u_smoothing;
- float alpha = smoothstep(min_bound, max_bound, tex_distance);
- float v_alpha = v_color.a
- float sdfAlpha = alpha * v_alpha;
- vec3 sdfRGB = v_color.rgb;
- vec4 sdfColor = vec4(sdfRGB, sdfAlpha);
- // Regular
- vec4 regularColor = v_color * tex_color;
- float v_x = v_texCoords.x;
- float sdf_step = step(1.0f, v_x);
- // Making a choice
- fragColor = mix(regularColor, sdfColor, sdf_step);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement