X-Git-Url: http://git.mutantstargoat.com?p=demo;a=blobdiff_plain;f=gl_shaders%2Fmorphing.v.glsl;h=6f72aa78d57d91ada32d9d080d14f79a950aa89c;hp=cbb3d9e8c5e9f77adcc53d756392a9efbdf5687b;hb=978140660bed8a4bbe782dc5ca0516a80e1ba233;hpb=f4ba93a902613f2b2c4a397d5a526fb4a4161e86 diff --git a/gl_shaders/morphing.v.glsl b/gl_shaders/morphing.v.glsl index cbb3d9e..6f72aa7 100644 --- a/gl_shaders/morphing.v.glsl +++ b/gl_shaders/morphing.v.glsl @@ -3,12 +3,15 @@ uniform mat4 mview; uniform mat4 mmviewproj; +uniform float t; +const float half_height = 0.855; + varying vec3 pos; varying vec3 normal; varying vec3 ldir; varying vec2 tex_coord; -const vec3 lpos = vec3(-10.0, 100.0, 10.0); +const vec3 lpos = vec3(0.0, 100.0, -10.0); /* attributes */ layout(location = 1) in vec3 attr_pos; @@ -17,12 +20,21 @@ layout(location = 3) in vec2 attr_tex; void main() { - gl_Position = mmviewproj * vec4(attr_pos, 1.0); + vec3 sph_pos = normalize(vec3(attr_pos.x, attr_pos.y - half_height, attr_pos.z)); + + 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); - pos = (mview * vec4(attr_pos, 1.0)).xyz; + gl_Position = mmviewproj * vec4(p, 1.0); + + pos = (mview * vec4(p, 1.0)).xyz; ldir = (mview * vec4(lpos, 1.0)).xyz; mat3 normal_matrix = mat3(mview); - normal = normal_matrix * attr_normal; + normal = normal_matrix * n; + tex_coord = attr_tex; } \ No newline at end of file