summaryrefslogtreecommitdiff
path: root/gfx/gl/shaders/commonPoint.glsl
blob: a9817fb640aa8909bceb32ee63cbd70c5616f052 (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
layout(binding = 1) uniform usampler2DRect materialData;

MaterialDetail
getMaterialDetail(uint midx)
{
	if (midx > 0u) {
		const vec4 sPosSize = texture(materialData, uvec2(0, midx - 1u));
		const uvec4 sMode = texture(materialData, uvec2(1, midx - 1u));
		const uint mapmodeU = sMode.x & 0xFu;
		const uint mapmodeV = (sMode.x & 0xF0u) >> 1;
		return MaterialDetail(sPosSize.xy, sPosSize.zw, uvec2(mapmodeU, mapmodeV));
	}
	return MaterialDetail(vec2(0, 0), vec2(0, 0), uvec2(0, 0));
}

void
main()
{
	FragPos = (model * vec4(position, 1.0)).xyz + modelPos;
	TexCoords = texCoord;
	Normal = (model * vec4(normal, 0.0)).xyz;
	Colour = colour;
	Material = getMaterialDetail(material);

	gl_Position = viewProjection * vec4(FragPos - viewPoint, 1);
}