X-Git-Url: https://eleni.mutantstargoat.com/git/?p=demo;a=blobdiff_plain;f=gl_shaders%2Fmorphing.v.glsl;fp=gl_shaders%2Fmorphing.v.glsl;h=80b7e3910b19fa7f50b9d371ab483b6307199191;hp=d84336f6e08ffecdcd009107cdff9d27ea400c09;hb=05d269a194496bcef85da78652b947f5bf1c9bcf;hpb=6cecb8f16f1863496884ca86790375dbb27138ba diff --git a/gl_shaders/morphing.v.glsl b/gl_shaders/morphing.v.glsl index d84336f..80b7e39 100644 --- a/gl_shaders/morphing.v.glsl +++ b/gl_shaders/morphing.v.glsl @@ -1,25 +1,30 @@ #version 450 -uniform mat4 mview; -uniform mat4 mmviewproj; -uniform mat4 mmod; +#define MATRIX_UNIFORMS 0 +#define MORPHING_UNIFORMS 3 -uniform float t; -const float half_height = 0.855; - -varying vec3 pos; -// varying vec3 normal; -// varying vec3 ldir; -varying vec2 tex_coord; -varying vec3 world_normal; +layout(std140, binding = MATRIX_UNIFORMS) uniform vu { + mat4 mview; + uniform mat4 mmviewproj; + uniform mat4 mmod; +} m; -// const vec3 lpos = vec3(0.0, 100.0, -10.0); +layout(std140, binding = MORPHING_UNIFORMS) uniform mvu { + float t; +} time; /* attributes */ 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; + +const float half_height = 0.855; + void main() { vec3 sph_pos = normalize(vec3(attr_pos.x, attr_pos.y - half_height, attr_pos.z)); @@ -27,17 +32,13 @@ void main() vec3 sph_normal = sph_pos; sph_pos.y += half_height; - vec3 p = mix(attr_pos, sph_pos, t); - vec3 n = mix(attr_normal, sph_normal, t); - - gl_Position = mmviewproj * vec4(p, 1.0); + vec3 p = mix(attr_pos, sph_pos, time.t); + vec3 n = mix(attr_normal, sph_normal, time.t); - pos = (mview * vec4(p, 1.0)).xyz; - // ldir = (mview * vec4(lpos, 1.0)).xyz; + gl_Position = m.mmviewproj * vec4(p, 1.0); - // mat3 normal_matrix = mat3(mview); - // normal = normal_matrix * n; + pos = (m.mview * vec4(p, 1.0)).xyz; tex_coord = attr_tex; - world_normal = (mmod * vec4(attr_normal, 1.0)).xyz; -} \ No newline at end of file + world_normal = (m.mmod * vec4(attr_normal, 1.0)).xyz; +}