File: quad_texture2darray.frag

package info (click to toggle)
warzone2100 4.6.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 660,320 kB
  • sloc: cpp: 676,209; ansic: 391,201; javascript: 78,238; python: 16,632; php: 4,294; sh: 4,094; makefile: 2,629; lisp: 1,492; cs: 489; xml: 404; perl: 224; ruby: 156; java: 89
file content (31 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (2)
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
#version 450

layout(std140, set = 0, binding = 0) uniform cbuffer {
	mat4 transformationMatrix;
	mat4 uvTransformMatrix;
	ivec4 swizzle;
	vec4 color;
	int layer;
};

layout(set = 1, binding = 0) uniform sampler2DArray tex;

layout(location = 0) in vec2 uv;
layout(location = 0) out vec4 FragColor;

float getVecComponent(vec4 v, int c)
{
	float f = (c == 0) ? v.x :
		(c == 1) ? v.y :
		(c == 2) ? v.z : v.w;
	return f;
}

void main()
{
	vec4 texColour = texture(tex, vec3(uv, layer), 0.f);

	vec4 fragColour = vec4(getVecComponent(texColour, swizzle.x), getVecComponent(texColour, swizzle.y), getVecComponent(texColour, swizzle.z), getVecComponent(texColour, swizzle.w));

	FragColor = fragColour * color;
}