渲染后端加入
This commit is contained in:
21
shaders/sprite.frag
Normal file
21
shaders/sprite.frag
Normal file
@@ -0,0 +1,21 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec2 vTexCoord;
|
||||
in vec4 vColor;
|
||||
|
||||
uniform sampler2D uTexture;
|
||||
uniform int uUseSDF;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
if (uUseSDF == 1) {
|
||||
float dist = texture(uTexture, vTexCoord).a;
|
||||
float sd = (dist - 0.502) * 3.98;
|
||||
float w = fwidth(sd);
|
||||
float alpha = smoothstep(-w, w, sd);
|
||||
fragColor = vec4(vColor.rgb, vColor.a * alpha);
|
||||
} else {
|
||||
fragColor = texture(uTexture, vTexCoord) * vColor;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user