feat: added phong and basic shaders, updated mesh format
This commit is contained in:
26
assets/shaders/phong-solid.vertex.glsl
Normal file
26
assets/shaders/phong-solid.vertex.glsl
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 a_xyz;
|
||||
layout (location = 1) in vec2 a_uv;
|
||||
layout (location = 2) in vec3 a_normal;
|
||||
|
||||
uniform mat4 model;
|
||||
uniform mat4 view;
|
||||
uniform mat4 projection;
|
||||
uniform vec3 light_pos;
|
||||
|
||||
out vec3 normal_cameraspace;
|
||||
out vec3 light_direction_cameraspace;
|
||||
out vec3 eye_direction_cameraspace;
|
||||
out vec3 position_worldspace;
|
||||
|
||||
void main() {
|
||||
vec3 vertex_cameraspace = (view * model * vec4(a_xyz, 1)).xyz;
|
||||
vec3 light_pos_cameraspace = (view * vec4(light_pos, 1)).xyz;
|
||||
|
||||
normal_cameraspace = (transpose(inverse(view * model)) * vec4(a_normal, 0)).xyz;
|
||||
light_direction_cameraspace = light_pos_cameraspace + eye_direction_cameraspace;
|
||||
eye_direction_cameraspace = vec3(0, 0, 0) - vertex_cameraspace;
|
||||
position_worldspace = (model * vec4(a_xyz, 1)).xyz;
|
||||
|
||||
gl_Position = projection * view * model * vec4(a_xyz, 1);
|
||||
}
|
||||
Reference in New Issue
Block a user