渲染后端加入
This commit is contained in:
8
shaders/shape.frag
Normal file
8
shaders/shape.frag
Normal file
@@ -0,0 +1,8 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
in vec4 vColor;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = vColor;
|
||||
}
|
||||
13
shaders/shape.vert
Normal file
13
shaders/shape.vert
Normal file
@@ -0,0 +1,13 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
layout(location = 0) in vec2 aPosition;
|
||||
layout(location = 1) in vec4 aColor;
|
||||
|
||||
uniform mat4 u_viewProjection;
|
||||
|
||||
out vec4 vColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_viewProjection * vec4(aPosition, 0.0, 1.0);
|
||||
vColor = aColor;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
16
shaders/sprite.vert
Normal file
16
shaders/sprite.vert
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 300 es
|
||||
precision highp float;
|
||||
layout(location = 0) in vec2 aPosition;
|
||||
layout(location = 1) in vec2 aTexCoord;
|
||||
layout(location = 2) in vec4 aColor;
|
||||
|
||||
uniform mat4 uViewProjection;
|
||||
|
||||
out vec2 vTexCoord;
|
||||
out vec4 vColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = uViewProjection * vec4(aPosition, 0.0, 1.0);
|
||||
vTexCoord = aTexCoord;
|
||||
vColor = aColor;
|
||||
}
|
||||
Reference in New Issue
Block a user