.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"
"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"
" 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"
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;
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);
}
_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" );
}
}
-static void render_gate_markers( int run_id, ent_gate *gate ){
+static void render_gate_markers( m4x3f world_mmdl, int run_id, ent_gate *gate ){
for( u32 j=0; j<4; j++ ){
if( gate->routes[j] == run_id ){
m4x3f mmdl;
ent_gate_get_mdl_mtx( gate, mmdl );
+ m4x3_mul( world_mmdl, mmdl, mmdl );
shader_model_gate_uMdl( mmdl );
mdl_draw_submesh( &world_gates.sm_marker[j] );
break;
}
}
-static void render_world_routes( world_instance *world, camera *cam,
- int viewing_from_gate ){
- m4x3f identity_matrix;
- m4x3_identity( identity_matrix );
+static void render_world_routes( world_instance *world,
+ world_instance *host_world,
+ m4x3f mmdl, camera *cam,
+ int viewing_from_gate, int viewing_from_hub ){
shader_scene_route_use();
shader_scene_route_uTexGarbage(0);
- world_link_lighting_ub( world, _shader_scene_route.id );
- world_bind_position_texture( world, _shader_scene_route.id,
+ world_link_lighting_ub( host_world, _shader_scene_route.id );
+ world_bind_position_texture( host_world, _shader_scene_route.id,
_uniform_scene_route_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_route.id,
+ world_bind_light_array( host_world, _shader_scene_route.id,
_uniform_scene_route_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_route.id,
+ world_bind_light_index( host_world, _shader_scene_route.id,
_uniform_scene_route_uLightsIndex, 4 );
bind_terrain_noise();
shader_scene_route_uPv( cam->mtx.pv );
- shader_scene_route_uPvmPrev( cam->mtx_prev.pv );
- shader_scene_route_uMdl( identity_matrix );
+
+ if( viewing_from_hub ){
+ m4x4f m4mdl, pvm;
+ m4x3_expand( mmdl, m4mdl );
+ m4x4_mul( cam->mtx_prev.pv, m4mdl, pvm );
+ shader_scene_route_uMdl( mmdl );
+ shader_scene_route_uPvmPrev( pvm );
+
+ m3x3f mnormal;
+ m3x3_inv( mmdl, mnormal );
+ m3x3_transpose( mnormal, mnormal );
+ v3_normalize( mnormal[0] );
+ v3_normalize( mnormal[1] );
+ v3_normalize( mnormal[2] );
+ shader_scene_route_uNormalMtx( mnormal );
+ }
+ else{
+ shader_scene_route_uMdl( mmdl );
+ shader_scene_route_uPvmPrev( cam->mtx_prev.pv );
+ m3x3f ident;
+ m3x3_identity( ident );
+ shader_scene_route_uNormalMtx( ident );
+ }
+
shader_scene_route_uCamera( cam->transform[3] );
mesh_bind( &world->mesh_route_lines );
for( u32 i=0; i<mdl_arrcount(&world->ent_route); i++ ){
ent_route *route = mdl_arritm( &world->ent_route, i );
+ f32 t = viewing_from_hub? 1.0f: route->factive;
+
v4f colour;
- v3_lerp( (v3f){0.7f,0.7f,0.7f}, route->colour, route->factive, colour );
- colour[3] = route->factive*0.2f;
+ v3_lerp( (v3f){0.7f,0.7f,0.7f}, route->colour, t, colour );
+ colour[3] = t*0.2f;
shader_scene_route_uColour( colour );
mdl_draw_submesh( &route->sm );
/* timers
* ---------------------------------------------------- */
- if( !viewing_from_gate ){
+ if( !viewing_from_gate && !viewing_from_hub ){
font3d_bind( &gui.font, k_font_shader_default, 0, world, cam );
for( u32 i=0; i<world_render.timer_text_count; i++ ){
glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
glDisable( GL_CULL_FACE );
- if( skaterift.activity == k_skaterift_respawning ){
+ if( viewing_from_hub ){
for( u32 i=0; i<mdl_arrcount(&world->ent_route); i++ ){
ent_route *route = mdl_arritm( &world->ent_route, i );
for( u32 j=0; j<mdl_arrcount(&world->ent_gate); j ++ ){
ent_gate *gate = mdl_arritm( &world->ent_gate, j );
if( !(gate->flags & k_ent_gate_nonlocal_DELETED) )
- render_gate_markers( i, gate );
+ render_gate_markers( mmdl, i, gate );
}
}
}
ent_checkpoint *cp = mdl_arritm( &world->ent_checkpoint, next );
ent_gate *gate = mdl_arritm( &world->ent_gate, cp->gate_index );
- render_gate_markers( i, gate );
+ render_gate_markers( mmdl, i, gate );
}
}
}