File: core.vert

package info (click to toggle)
performous 1.3.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,932 kB
  • sloc: cpp: 35,814; sh: 925; python: 626; xml: 480; makefile: 37
file content (33 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (5)
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
#version 330 core

//DEFINES

layout(location = 0) in vec3 vertPos;
layout(location = 1) in vec2 vertTexCoord;
layout(location = 2) in vec3 vertNormal;
layout(location = 3) in vec4 vertColor;

layout (std140) uniform shaderMatrices {
	mat4 projMatrix;
	mat4 mvMatrix;
	mat4 normalMatrix;
	mat4 colorMatrix;
};

out vData {
	vec3 lightDir;
	vec2 texCoord;
	vec3 normal;
	vec4 color;
} vertex;

void main() {
	const vec3 lightPos = vec3(-10.0, 2.0, 15.0);
	vec4 posEye = mvMatrix * vec4(vertPos, 1.0); // Vertex position in eye space
	gl_Position = projMatrix * posEye; // Vertex position in normalized device coordinates
	vertex.lightDir = lightPos - posEye.xyz / posEye.w; // Light position relative to vertex
	vertex.texCoord = vertTexCoord;
	vertex.normal = normalize(mat3(normalMatrix) * vertNormal);
	vertex.color = vertColor;
}