1
0
Fork 0
wgpu-tutorial/src/terrain.vert

29 lines
837 B
GLSL

#version 450
layout(location=0) in vec3 a_position;
layout(location=1) in vec3 a_normal;
layout(location=1) out vec3 v_position;
layout(location=2) out vec3 v_normal;
layout(location=3) out vec3 v_light_position;
layout(location=4) out vec3 v_view_position;
layout(set=1, binding=0) uniform Uniforms {
vec3 u_view_position;
mat4 u_view_proj; // TODO: pass in view and projection matrix seperately
};
layout(set=2, binding=0) uniform Light {
vec3 light_position;
vec3 light_color;
};
void main() {
v_normal = a_normal;
vec4 pos = u_view_proj * vec4(a_position + u_view_position, 1.0);
v_position = pos.xyz;
v_light_position = (u_view_proj * vec4(light_position, 1.0)).xyz;
v_view_position = (u_view_proj * vec4(u_view_position, 1.0)).xyz;
gl_Position = u_view_proj * vec4(a_position, 1.0);
}