render routes in mini-world
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / scene_route.h
index 8e3cc10385942f9d1d493c01e15e158e0a78ebcf..eea0c75bd0211b544ac9a43f78cebd4ed4a24046 100644 (file)
@@ -7,7 +7,7 @@ static struct vg_shader _shader_scene_route = {
    .link = shader_scene_route_link,
    .vs = 
 {
-.orig_file = "shaders/scene.vs",
+.orig_file = "shaders/scene_override.vs",
 .static_src = 
 "layout (location=0) in vec3  a_co;\n"
 "layout (location=1) in vec4  a_norm;\n"
@@ -36,6 +36,7 @@ static struct vg_shader _shader_scene_route = {
 "uniform mat4x3 uMdl;\n"
 "uniform mat4   uPv;\n"
 "uniform mat4   uPvmPrev;\n"
+"uniform mat3   uNormalMtx;\n"
 "\n"
 "out vec2 aUv;\n"
 "out vec4 aNorm;\n"
@@ -53,7 +54,7 @@ static struct vg_shader _shader_scene_route = {
 "   gl_Position = vproj0;\n"
 "\n"
 "   aUv = a_uv;\n"
-"   aNorm = vec4( mat3(uMdl) * a_norm.xyz, a_norm.w );\n"
+"   aNorm = vec4( uNormalMtx * a_norm.xyz, a_norm.w );\n"
 "   aCo = a_co;\n"
 "   aWorldCo = world_pos0;\n"
 "}\n"
@@ -508,6 +509,7 @@ static struct vg_shader _shader_scene_route = {
 static GLuint _uniform_scene_route_uMdl;
 static GLuint _uniform_scene_route_uPv;
 static GLuint _uniform_scene_route_uPvmPrev;
+static GLuint _uniform_scene_route_uNormalMtx;
 static GLuint _uniform_scene_route_uTexGarbage;
 static GLuint _uniform_scene_route_uTexGradients;
 static GLuint _uniform_scene_route_uCamera;
@@ -524,6 +526,9 @@ static void shader_scene_route_uPv(m4x4f m){
 static void shader_scene_route_uPvmPrev(m4x4f m){
    glUniformMatrix4fv(_uniform_scene_route_uPvmPrev,1,GL_FALSE,(float*)m);
 }
+static void shader_scene_route_uNormalMtx(m3x3f m){
+   glUniformMatrix3fv(_uniform_scene_route_uNormalMtx,1,GL_FALSE,(float*)m);
+}
 static void shader_scene_route_uTexGarbage(int i){
    glUniform1i(_uniform_scene_route_uTexGarbage,i);
 }
@@ -547,6 +552,7 @@ static void shader_scene_route_link(void){
    _uniform_scene_route_uMdl = glGetUniformLocation( _shader_scene_route.id, "uMdl" );
    _uniform_scene_route_uPv = glGetUniformLocation( _shader_scene_route.id, "uPv" );
    _uniform_scene_route_uPvmPrev = glGetUniformLocation( _shader_scene_route.id, "uPvmPrev" );
+   _uniform_scene_route_uNormalMtx = glGetUniformLocation( _shader_scene_route.id, "uNormalMtx" );
    _uniform_scene_route_uTexGarbage = glGetUniformLocation( _shader_scene_route.id, "uTexGarbage" );
    _uniform_scene_route_uTexGradients = glGetUniformLocation( _shader_scene_route.id, "uTexGradients" );
    _uniform_scene_route_uCamera = glGetUniformLocation( _shader_scene_route.id, "uCamera" );