44 lines
1.0 KiB
GLSL
44 lines
1.0 KiB
GLSL
#version 400
|
|
uniform mat4 camera;
|
|
uniform mat4 modelViewMatrix;
|
|
uniform mat4 projectionMatrix;
|
|
|
|
uniform mat4 normalMatrix;
|
|
uniform mat4 modelMatrix;
|
|
uniform mat4 worldMatrix;
|
|
|
|
layout(location = 0) in vec3 position;
|
|
layout(location = 1) in vec2 inCoord;
|
|
|
|
layout (location = 2) in float zPos;
|
|
layout (location = 3) in vec3 inNormal;
|
|
|
|
out vec2 fragTexCoord;
|
|
out vec2 tilePos;
|
|
out vec3 fragVert;
|
|
smooth out vec3 vWorldPos;
|
|
uniform mat4 MVP;
|
|
smooth out vec3 vNormal;
|
|
out float z_pos;
|
|
|
|
void main()
|
|
{
|
|
gl_Position = MVP * vec4(position.x, position.y, zPos, 1.0);
|
|
|
|
// World position: anchored to terrain ground
|
|
vec4 wPos = worldMatrix * vec4(position.x, position.y, zPos, 1.0);
|
|
vWorldPos = wPos.xyz;
|
|
|
|
// Texture coordinates based on world coordinates (stays fixed when camera moves)
|
|
fragTexCoord = vec2(wPos.x * 0.5, wPos.y * 0.5);
|
|
|
|
// Tile-local position for the hexagon border outline
|
|
vec4 tpos = modelMatrix * vec4(position.x, position.y, 0.0, 1.0);
|
|
tilePos = vec2(tpos.x, tpos.y);
|
|
|
|
vNormal = inNormal.xyz;
|
|
fragVert = position;
|
|
z_pos = zPos;
|
|
}
|
|
|