--- /dev/null
+#ifndef DEPTH_COMPARE_H
+#define DEPTH_COMPARE_H
+
+#include "vg/vg_m.h"
+#include "render.h"
+
+static void depth_compare_bind(
+ void (*uTexSceneDepth)(int),
+ void (*uInverseRatioDepth)(v3f),
+ void (*uInverseRatioMain)(v3f),
+ camera *cam ){
+ uTexSceneDepth( 5 );
+ render_fb_bind_texture( gpipeline.fb_main, 2, 5 );
+ v3f inverse;
+ render_fb_inverse_ratio( gpipeline.fb_main, inverse );
+ inverse[2] = skaterift.cam.farz-skaterift.cam.nearz;
+
+ uInverseRatioDepth( inverse );
+ render_fb_inverse_ratio( NULL, inverse );
+ inverse[2] = cam->farz-cam->nearz;
+ uInverseRatioMain( inverse );
+}
+
+#endif /* DEPTH_COMPARE_H */
};
struct ent_route{
-
union{
mdl_transform transform;
u32 official_track_id;
- };
+ }
+ anon;
u32 pstr_name;
u16 checkpoints_start,
#include "shaders/model_font.h"
#include "shaders/scene_font.h"
#include "world_render.h"
+#include "depth_compare.h"
enum efont_SRglyph{
k_SRglyph_end = 0x00, /* control characters */
shader_model_font_uDepthCompare( depth_compare );
if( depth_compare ){
- /* TODO: Compress with code in player_render.c */
- shader_model_font_uTexSceneDepth( 2 );
- render_fb_bind_texture( gpipeline.fb_main, 2, 2 );
- v3f inverse;
- render_fb_inverse_ratio( gpipeline.fb_main, inverse );
- inverse[2] = skaterift.cam.farz-skaterift.cam.nearz;
-
- shader_model_font_uInverseRatioDepth( inverse );
- render_fb_inverse_ratio( NULL, inverse );
- inverse[2] = cam->farz-cam->nearz;
- shader_model_font_uInverseRatioMain( inverse );
+ depth_compare_bind(
+ shader_model_font_uTexSceneDepth,
+ shader_model_font_uInverseRatioDepth,
+ shader_model_font_uInverseRatioMain, cam );
}
shader_model_font_uPv( cam->mtx.pv );
shader_scene_font_uPv( skaterift.cam.mtx.pv );
shader_scene_font_uTime( vg.time );
- /* TODO: Code dupe... */
- world_link_lighting_ub( world, _shader_scene_font.id );
- world_bind_position_texture( world, _shader_scene_font.id,
- _uniform_scene_font_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_font.id,
- _uniform_scene_font_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_font.id,
- _uniform_scene_font_uLightsIndex, 4 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_font );
bind_terrain_noise();
shader_scene_font_uCamera( skaterift.cam.transform[3] );
#include "shaders/model_board_view.h"
#include "shaders/model_entity.h"
#include "shaders/model_board_view.h"
+#include "depth_compare.h"
static void player_avatar_load( struct player_avatar *av, const char *path ){
mdl_open( &av->meta, path, vg_mem.rtmemory );
shader_model_board_view_uTexMain( 0 );
shader_model_board_view_uCamera( cam->transform[3] );
shader_model_board_view_uPv( cam->mtx.pv );
- shader_model_board_view_uTexSceneDepth( 1 );
- render_fb_bind_texture( gpipeline.fb_main, 2, 1 );
- render_fb_inverse_ratio( gpipeline.fb_main, inverse );
+ shader_model_board_view_uDepthCompare(1);
+ depth_compare_bind(
+ shader_model_board_view_uTexSceneDepth,
+ shader_model_board_view_uInverseRatioDepth,
+ shader_model_board_view_uInverseRatioMain,
+ cam );
- inverse[2] = skaterift.cam.farz-skaterift.cam.nearz;
-
- shader_model_board_view_uInverseRatioDepth( inverse );
- render_fb_inverse_ratio( NULL, inverse );
- inverse[2] = cam->farz-cam->nearz;
- shader_model_board_view_uInverseRatioMain( inverse );
-
- world_link_lighting_ub( world, _shader_model_board_view.id );
- world_bind_position_texture( world, _shader_model_board_view.id,
- _uniform_model_board_view_g_world_depth, 2 );
- world_bind_light_array( world, _shader_model_board_view.id,
- _uniform_model_board_view_uLightsArray, 3 );
- world_bind_light_index( world, _shader_model_board_view.id,
- _uniform_model_board_view_uLightsIndex, 4 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_board_view );
}
else if( shader == k_board_shader_entity ){
shader_model_entity_use();
shader_model_entity_uCamera( cam->transform[3] );
shader_model_entity_uPv( cam->mtx.pv );
- world_link_lighting_ub( world, _shader_model_entity.id );
- world_bind_position_texture( world, _shader_model_entity.id,
- _uniform_model_entity_g_world_depth, 2 );
- world_bind_light_array( world, _shader_model_entity.id,
- _uniform_model_entity_uLightsArray, 3 );
- world_bind_light_index( world, _shader_model_entity.id,
- _uniform_model_entity_uLightsIndex, 4 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_entity );
}
mesh_bind( &board->mdl.mesh );
shader_model_character_view_uCamera( cam->transform[3] );
shader_model_character_view_uPv( cam->mtx.pv );
+ shader_model_character_view_uDepthCompare( depth_compare );
if( depth_compare ){
- shader_model_character_view_uTexSceneDepth( 1 );
- render_fb_bind_texture( gpipeline.fb_main, 2, 1 );
- v3f inverse;
- render_fb_inverse_ratio( gpipeline.fb_main, inverse );
- inverse[2] = skaterift.cam.farz-skaterift.cam.nearz;
-
- shader_model_character_view_uInverseRatioDepth( inverse );
- render_fb_inverse_ratio( NULL, inverse );
- inverse[2] = cam->farz-cam->nearz;
- shader_model_character_view_uInverseRatioMain( inverse );
+ depth_compare_bind(
+ shader_model_character_view_uTexSceneDepth,
+ shader_model_character_view_uInverseRatioDepth,
+ shader_model_character_view_uInverseRatioMain,
+ cam );
}
- shader_model_character_view_uDepthCompare( depth_compare );
- world_link_lighting_ub( world, _shader_model_character_view.id );
- world_bind_position_texture( world, _shader_model_character_view.id,
- _uniform_model_character_view_g_world_depth, 2 );
- world_bind_light_array( world, _shader_model_character_view.id,
- _uniform_model_character_view_uLightsArray, 3 );
- world_bind_light_index( world, _shader_model_character_view.id,
- _uniform_model_character_view_uLightsIndex, 4 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, model_character_view );
glUniformMatrix4x3fv( _uniform_model_character_view_uTransforms,
skeleton->bone_count,
8.0f * player_skate.substep_delta, state->up_dir );
}
else{
- v3_lerp( state->up_dir, localplayer.basis[1],
- 12.0f * player_skate.substep_delta, state->up_dir );
+ v3f avg;
+ v3_add( localplayer.rb.to_world[1], localplayer.basis[1], avg );
+ v3_normalize( avg );
+
+ v3_lerp( state->up_dir, avg,
+ 6.0f * player_skate.substep_delta, state->up_dir );
}
}
vg_async_call( async_world_render_init, NULL, 0 );
}
-static void world_link_lighting_ub( world_instance *world, GLuint shader )
-{
+static void world_link_lighting_ub( world_instance *world, GLuint shader ){
GLuint idx = glGetUniformBlockIndex( shader, "ub_world_lighting" );
glUniformBlockBinding( shader, idx, world->ubo_bind_point );
}
static void world_bind_position_texture( world_instance *world,
GLuint shader, GLuint location,
- int slot )
-{
+ int slot ){
render_fb_bind_texture( &world->heightmap, 0, slot );
glUniform1i( location, slot );
}
static void world_bind_light_array( world_instance *world,
GLuint shader, GLuint location,
- int slot )
-{
+ int slot ){
glActiveTexture( GL_TEXTURE0 + slot );
glBindTexture( GL_TEXTURE_BUFFER, world->tex_light_entities );
glUniform1i( location, slot );
static void world_bind_light_index( world_instance *world,
GLuint shader, GLuint location,
- int slot )
-{
+ int slot ){
glActiveTexture( GL_TEXTURE0 + slot );
glBindTexture( GL_TEXTURE_3D, world->tex_light_cubes );
glUniform1i( location, slot );
shader_scene_cubemapped_uColour( mat->info.colour );
}
-static void render_world_vb( world_instance *world, camera *cam )
-{
+static void render_world_vb( world_instance *world, camera *cam ){
shader_scene_vertex_blend_use();
shader_scene_vertex_blend_uTexGarbage(0);
shader_scene_vertex_blend_uTexGradients(1);
}
}
-static void render_terrain( world_instance *world, camera *cam )
-{
+static void render_terrain( world_instance *world, camera *cam ){
shader_scene_terrain_use();
shader_scene_terrain_uTexGarbage(0);
shader_scene_terrain_uTexGradients(1);
- world_link_lighting_ub( world, _shader_scene_terrain.id );
- world_bind_position_texture( world, _shader_scene_terrain.id,
- _uniform_scene_terrain_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_terrain.id,
- _uniform_scene_terrain_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_terrain.id,
- _uniform_scene_terrain_uLightsIndex, 4 );
-
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_terrain );
glActiveTexture( GL_TEXTURE0 );
glBindTexture( GL_TEXTURE_2D, world_render.tex_terrain_noise );
shader_scene_override_uTexMain(1);
shader_scene_override_uPv( pass.cam->mtx.pv );
- world_link_lighting_ub( world, _shader_scene_override.id );
- world_bind_position_texture( world, _shader_scene_override.id,
- _uniform_scene_override_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_override.id,
- _uniform_scene_override_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_override.id,
- _uniform_scene_override_uLightsIndex, 4 );
-
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_override );
bind_terrain_noise();
shader_scene_override_uCamera( pass.cam->transform[3] );
}
}
-static void render_world_depth( world_instance *world, camera *cam )
-{
+static void render_world_depth( world_instance *world, camera *cam ){
m4x3f identity_matrix;
m4x3_identity( identity_matrix );
mesh_draw( &world->mesh_geo );
}
-static void render_world_position( world_instance *world, camera *cam )
-{
+static void render_world_position( world_instance *world, camera *cam ){
m4x3f identity_matrix;
m4x3_identity( identity_matrix );
static void render_world_cubemaps( world_instance *world );
static void bind_terrain_noise(void);
+#define WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( WORLD, SHADER ) \
+ world_link_lighting_ub( WORLD, _shader_##SHADER.id ); \
+ world_bind_position_texture( WORLD, _shader_##SHADER.id, \
+ _uniform_##SHADER##_g_world_depth, 2 ); \
+ world_bind_light_array( WORLD, _shader_##SHADER.id, \
+ _uniform_##SHADER##_uLightsArray, 3 ); \
+ world_bind_light_index( WORLD, _shader_##SHADER.id, \
+ _uniform_##SHADER##_uLightsIndex, 4 );
+
#endif /* WORLD_RENDER_H */
{
vg_success( " NEW LAP TIME: %f\n", lap_time );
- if( route->official_track_id != 0xffffffff ){
+ if( route->anon.official_track_id != 0xffffffff ){
double time_centiseconds = lap_time * 100.0;
if( time_centiseconds > (float)0xfffe ) /* skill issue */
return;
- struct track_info *ti = &track_infos[ route->official_track_id ];
+ struct track_info *ti = &track_infos[ route->anon.official_track_id ];
highscore_record *record = &ti->record;
- record->trackid = route->official_track_id;
+ record->trackid = route->anon.official_track_id;
record->datetime = time(NULL);
record->playerid = 0;
record->points = 0;
for( u32 i=0; i<mdl_arrcount(&world->ent_route); i++ ){
ent_route *route = mdl_arritm(&world->ent_route,i);
- mdl_transform_m4x3( &route->transform, route->board_transform );
+ mdl_transform_m4x3( &route->anon.transform, route->board_transform );
- route->official_track_id = 0xffffffff;
+ route->anon.official_track_id = 0xffffffff;
for( u32 j=0; j<vg_list_size(track_infos); j ++ ){
if( !strcmp(track_infos[j].name,
mdl_pstr(&world->meta,route->pstr_name))){
- route->official_track_id = j;
+ route->anon.official_track_id = j;
}
}
#include "world_sfd.h"
#include "shaders/scene_scoretext.h"
#include "shaders/scene_vertex_blend.h"
+#include "network.h"
+#include "entity.h"
-static f32 sfd_encode_glyph( char c )
-{
+static f32 sfd_encode_glyph( char c ){
int value = 0;
if( c >= 'a' && c <= 'z' )
value = c-'a'+11;
}
}
- if( (world_sfd.active_route_board != closest) || network_scores_updated )
- {
+ if( (world_sfd.active_route_board != closest) || network_scores_updated ){
network_scores_updated = 0;
world_sfd.active_route_board = closest;
ent_route *route = mdl_arritm( &world->ent_route, closest );
- u32 id = route->official_track_id;
+ u32 id = route->anon.official_track_id;
if( id != 0xffffffff ){
struct netmsg_board *local_board =
}
static void bind_terrain_noise(void);
-static void sfd_render( world_instance *world, camera *cam, m4x3f transform )
-{
+static void sfd_render( world_instance *world, camera *cam, m4x3f transform ){
mesh_bind( &world_sfd.mesh_display );
shader_scene_scoretext_use();
shader_scene_scoretext_uTexMain(1);
-
- world_link_lighting_ub( world, _shader_scene_scoretext.id );
- world_bind_position_texture( world, _shader_scene_scoretext.id,
- _uniform_scene_scoretext_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_scoretext.id,
- _uniform_scene_scoretext_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_scoretext.id,
- _uniform_scene_scoretext_uLightsIndex, 4 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_scoretext );
bind_terrain_noise();
shader_scene_vertex_blend_use();
shader_scene_vertex_blend_uTexGarbage(0);
shader_scene_vertex_blend_uTexGradients(1);
- world_link_lighting_ub( world, _shader_scene_vertex_blend.id );
- world_bind_position_texture( world, _shader_scene_vertex_blend.id,
- _uniform_scene_vertex_blend_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_vertex_blend.id,
- _uniform_scene_vertex_blend_uLightsArray, 3 );
- world_bind_light_index( world, _shader_scene_vertex_blend.id,
- _uniform_scene_vertex_blend_uLightsIndex, 4 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_vertex_blend );
+
bind_terrain_noise();
glActiveTexture( GL_TEXTURE1 );
glBindTexture( GL_TEXTURE_2D, world_sfd.tex_scoretex );
mdl_draw_submesh( &world_sfd.sm_base );
}
-static int world_sfd_test( int argc, const char *argv[] )
-{
+static int world_sfd_test( int argc, const char *argv[] ){
if( argc == 2 ){
int row = vg_min( vg_max(atoi(argv[0]),0), world_sfd.h);
sfd_encode( row, argv[1] );
return 0;
}
-static void world_sfd_init(void)
-{
+static void world_sfd_init(void){
vg_info( "world_sfd_init\n" );
shader_scene_scoretext_register();
vg_console_reg_cmd( "sfd", world_sfd_test, NULL );
#include "shaders/scene_water_fast.h"
#include "scene.h"
-static void world_water_init(void)
-{
+static void world_water_init(void){
vg_info( "world_water_init\n" );
shader_scene_water_register();
shader_scene_water_fast_register();
vg_success( "done\n" );
}
-static void water_set_surface( world_instance *world, float height )
-{
+static void water_set_surface( world_instance *world, float height ){
world->water.height = height;
v4_copy( (v4f){ 0.0f, 1.0f, 0.0f, height }, world->water.plane );
}
* Does not write motion vectors
*/
static void render_water_texture( world_instance *world, camera *cam,
- int layer_depth )
-{
+ int layer_depth ){
if( !world->water.enabled || (vg.quality_profile == k_quality_profile_low) )
return;
//glViewport( 0,0, g_render_x, g_render_y );
}
-static void render_water_surface( world_instance *world, camera *cam )
-{
+static void render_water_surface( world_instance *world, camera *cam ){
if( !world->water.enabled )
return;
1.0f / (float)vg.window_x,
1.0f / (float)vg.window_y });
- world_link_lighting_ub( world, _shader_scene_water.id );
- world_bind_position_texture( world, _shader_scene_water.id,
- _uniform_scene_water_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_water.id,
- _uniform_scene_water_uLightsArray, 4 );
- world_bind_light_index( world, _shader_scene_water.id,
- _uniform_scene_water_uLightsIndex, 5 );
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_water );
- render_fb_bind_texture( gpipeline.fb_water_beneath, 0, 3 );
- shader_scene_water_uTexBack( 3 );
+ render_fb_bind_texture( gpipeline.fb_water_beneath, 0, 5 );
+ shader_scene_water_uTexBack( 5 );
shader_scene_water_uTime( world_static.time );
shader_scene_water_uCamera( cam->transform[3] );
shader_scene_water_uSurfaceY( world->water.height );
shader_scene_water_fast_uTime( world_static.time );
shader_scene_water_fast_uCamera( cam->transform[3] );
shader_scene_water_fast_uSurfaceY( world->water.height );
- world_link_lighting_ub( world, _shader_scene_water_fast.id );
- world_bind_position_texture( world, _shader_scene_water_fast.id,
- _uniform_scene_water_fast_g_world_depth, 2 );
- world_bind_light_array( world, _shader_scene_water_fast.id,
- _uniform_scene_water_fast_uLightsArray, 4 );
+
+ WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world, scene_water_fast );
m4x3f full;
m4x3_identity( full );