Dairy-Drift/resources/shaders/plane/shader.vert

25 lines
663 B
GLSL
Raw Normal View History

2023-03-31 11:27:31 +02:00
#version 330 core
layout(location = 0) in vec3 position;
layout(location = 1) in vec2 texcoord;
out vec2 v_texcoord;
uniform mat4 model;
uniform mat4 view;
uniform mat4 projection;
uniform float tile_size;
uniform float scroll_speed;
uniform vec3 camera_position;
void main()
{
// Apply the model, view, and projection matrices
gl_Position = projection * view * model * vec4(position, 1.0);
// Calculate the texture coordinate offset based on the camera position
vec2 offset = (camera_position.xz - position.xz) / tile_size;
offset += scroll_speed * vec2(0, 1) * -(gl_Position.w / projection[1][1]);
v_texcoord = texcoord + offset;
2023-03-31 11:27:31 +02:00
}