2021-07-23 00:52:31 +08:00
|
|
|
precision mediump float;
|
|
|
|
|
2021-07-23 23:24:09 +08:00
|
|
|
uniform sampler2D u_texture;
|
2021-10-14 06:26:26 +08:00
|
|
|
uniform float u_atlasSize;
|
2021-07-23 23:24:09 +08:00
|
|
|
|
|
|
|
varying float v_lighting;
|
2021-07-23 00:52:31 +08:00
|
|
|
varying vec4 v_occlusion;
|
|
|
|
varying vec2 v_texcoord;
|
2021-07-28 00:57:44 +08:00
|
|
|
varying vec2 v_blockTexcoord;
|
2021-07-23 00:52:31 +08:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
float u = v_texcoord.x;
|
|
|
|
float v = v_texcoord.y;
|
|
|
|
|
|
|
|
float a = v_occlusion.x;
|
|
|
|
float b = v_occlusion.y;
|
|
|
|
float c = v_occlusion.z;
|
|
|
|
float d = v_occlusion.w;
|
|
|
|
float g = v*(u*b + (1.0-u)*d) + (1.0-v)*(u*a + (1.0-u)*c);
|
|
|
|
|
2021-10-14 06:26:26 +08:00
|
|
|
vec2 tex = v_blockTexcoord + (v_texcoord / (u_atlasSize * 3.0));
|
2021-07-28 00:57:44 +08:00
|
|
|
vec3 diffuse = texture2D(u_texture, tex).rgb;
|
2022-02-12 09:54:31 +08:00
|
|
|
|
2021-07-23 23:24:09 +08:00
|
|
|
gl_FragColor = vec4(diffuse * (v_lighting * g), 1.0);
|
2021-07-23 00:52:31 +08:00
|
|
|
}
|