aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/shaders/chunk.frag
blob: 1066dc592166dd7758a792da81d01f5cf36cd015 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#version 330 core
out vec4 FragColor;

in vec2 TexCoord;
in vec2 BTexCoord;
in vec4 Color;
in vec4 MQPos;
in vec4 Viewport;
in mat4 ProjInv;
in vec4 FogColor;
in vec2 FogStartEnd;
in float FogFactor;
flat in vec2 ProvokingTexCoord;

uniform sampler2D atlas;
uniform sampler2D lightTex;

void main()
{
	vec2 goodTexCoord = TexCoord;

#ifdef SIMPLIFY_MESHES
	if(MQPos.x <= 254){
		float wrappedU = mod(MQPos.x, 1.0);
		float wrappedV = mod(MQPos.y, 1.0);
		
		goodTexCoord = ProvokingTexCoord.xy + (((TexCoord.xy - ProvokingTexCoord.xy) / MQPos.zw) * vec2(wrappedU, wrappedV));
	}
#endif
	
	vec4 texColor = texture(atlas, goodTexCoord
#ifdef SHORT_UV
	/ 32768.0
#endif
	);
	
	vec4 colorMult = Color/256.0;
	
	vec4 lightyColor = texture(lightTex, (BTexCoord + 8.0) / 256.0);

	vec4 rasterColor = 
#ifdef PASS_0
		vec4((texColor.xyz * colorMult.xyz) * lightyColor.xyz, texColor.w);
#else
		(texColor * colorMult) * lightyColor;
#endif
	
#ifdef RENDER_FOG
		FragColor = vec4(mix(FogColor.xyz, rasterColor.xyz, FogFactor), rasterColor.w);
#else
		FragColor = rasterColor;
#endif
}