File: rect_instanced.vert

package info (click to toggle)
warzone2100 4.6.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 660,332 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 (29 lines) | stat: -rw-r--r-- 808 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
#version 450

layout(std140, set = 0, binding = 0) uniform cbuffer {
	mat4 ProjectionMatrix;
};

layout(location = 0) in vec4 vertex;
layout(location = 5) in mat4 instanceModelMatrix;
layout(location = 9) in vec4 instancePackedValues; // vec2 (offset), vec2 (scale)
layout(location = 10) in vec4 instanceColour;

layout(location = 0) out vec2 uv;
layout(location = 1) out vec4 colour;

void main()
{
	// unpack inputs
	#define transformationMatrix instanceModelMatrix
	vec2 tuv_offset = instancePackedValues.xy;
	vec2 tuv_scale = instancePackedValues.zw;

	gl_Position = ProjectionMatrix * transformationMatrix * vertex;
	uv = tuv_scale * vertex.xy + tuv_offset;
	gl_Position.y *= -1.;
	gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;

	// pack outputs for fragment shader
	colour = instanceColour;
}