X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=gl_shaders%2Fdefault.v.glsl;h=b550308275342f22ec91130a38e2fc2591de6f1b;hb=05d269a194496bcef85da78652b947f5bf1c9bcf;hp=455759db70961995eaf8dd3c90a280e1119c4caf;hpb=978140660bed8a4bbe782dc5ca0516a80e1ba233;p=demo diff --git a/gl_shaders/default.v.glsl b/gl_shaders/default.v.glsl index 455759d..b550308 100644 --- a/gl_shaders/default.v.glsl +++ b/gl_shaders/default.v.glsl @@ -1,13 +1,12 @@ #version 450 -//#extension GL_ARB_separate_shader_objects : enable -uniform mat4 mview; -uniform mat4 mmviewproj; +#define MATRIX_UNIFORMS 0 -varying vec3 pos; -varying vec3 normal; -varying vec3 ldir; -varying vec2 tex_coord; +layout(std140, binding = MATRIX_UNIFORMS) uniform vu { + mat4 mview; + uniform mat4 mmviewproj; + uniform mat4 mmod; +} m; const vec3 lpos = vec3(-10.0, 100.0, 10.0); @@ -16,14 +15,17 @@ layout(location = 1) in vec3 attr_pos; layout(location = 2) in vec3 attr_normal; layout(location = 3) in vec2 attr_tex; +/* varyings */ +layout(location = 4) out vec3 pos; +layout(location = 5) out vec2 tex_coord; +layout(location = 6) out vec3 world_normal; + void main() { - gl_Position = mmviewproj * vec4(attr_pos, 1.0); - - pos = (mview * vec4(attr_pos, 1.0)).xyz; - ldir = (mview * vec4(lpos, 1.0)).xyz; + gl_Position = m.mmviewproj * vec4(attr_pos, 1.0); - mat3 normal_matrix = mat3(mview); - normal = normal_matrix * attr_normal; + pos = (m.mview * vec4(attr_pos, 1.0)).xyz; tex_coord = attr_tex; -} \ No newline at end of file + + world_normal = (m.mmod * vec4(attr_normal, 1.0)).xyz; +}