{.path = "sound/step_concrete3.ogg" }
};
+audio_clip audio_footsteps_grass[] = {
+ {.path = "sound/step_bush0.ogg" },
+ {.path = "sound/step_bush1.ogg" },
+ {.path = "sound/step_bush2.ogg" },
+ {.path = "sound/step_bush3.ogg" },
+ {.path = "sound/step_bush4.ogg" },
+ {.path = "sound/step_bush5.ogg" }
+};
+
+audio_clip audio_footsteps_wood[] = {
+ {.path = "sound/step_wood0.ogg" },
+ {.path = "sound/step_wood1.ogg" },
+ {.path = "sound/step_wood2.ogg" },
+ {.path = "sound/step_wood3.ogg" },
+ {.path = "sound/step_wood4.ogg" },
+ {.path = "sound/step_wood5.ogg" }
+};
+
audio_clip audio_lands[] = {
{ .path = "sound/land0.ogg" },
{ .path = "sound/land1.ogg" },
audio_clip_loadn( audio_water, vg_list_size(audio_water), NULL );
audio_clip_loadn( audio_grass, vg_list_size(audio_grass), NULL );
audio_clip_loadn( audio_footsteps, vg_list_size(audio_footsteps), NULL );
+ audio_clip_loadn( audio_footsteps_grass,
+ vg_list_size(audio_footsteps_grass), NULL );
+ audio_clip_loadn( audio_footsteps_wood,
+ vg_list_size(audio_footsteps_wood), NULL );
audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind), NULL );
audio_clip_loadn( audio_ui, vg_list_size(audio_ui), NULL );
* Trace out a random point, near the player to try and determine water areas
*/
VG_STATIC enum audio_sprite_type audio_sample_sprite_random( v3f origin,
- v3f output )
+ v3f output )
{
v3f chance = { (vg_randf()-0.5f) * 30.0f,
8.0f,
if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &contact ) )
{
- if( ray_hit_is_ramp( &contact ) )
+ struct world_material *mat = ray_hit_material( &contact );
+
+ if( mat->info.surface_prop == k_surface_prop_grass)
+ {
+ v3_copy( contact.pos, output );
+ return k_audio_sprite_type_grass;
+ }
+ else
{
vg_line( pos, contact.pos, 0xff0000ff );
vg_line_pt3( contact.pos, 0.3f, 0xff0000ff );
return k_audio_sprite_type_none;
}
-
- v3_copy( contact.pos, output );
- return k_audio_sprite_type_grass;
}
output[0] = pos[0];
output[1] = 0.0f;
output[2] = pos[2];
-
- return k_audio_sprite_type_water;
+
+ if( world.water.enabled )
+ return k_audio_sprite_type_water;
+ else
+ return k_audio_sprite_type_none;
}
VG_STATIC void audio_debug_soundscapes(void)
_fields_ = [("pstr_name",c_uint32),
("shader",c_uint32),
("flags",c_uint32),
+ ("surface_prop",c_uint32),
("colour",c_float*4),
("colour1",c_float*4),
("tex_diffuse",c_uint32),
flags = 0x00
if mat.cv_data.skate_surface: flags |= 0x1
if mat.cv_data.collision: flags |= 0x2
+ if mat.cv_data.grow_grass: flags |= 0x4
dest.flags = flags
+ if mat.cv_data.surface_prop == 'concrete': dest.surface_prop = 0
+ if mat.cv_data.surface_prop == 'wood': dest.surface_prop = 1
+ if mat.cv_data.surface_prop == 'grass': dest.surface_prop = 2
+
if mat.cv_data.shader == 'standard': dest.shader = 0
if mat.cv_data.shader == 'standard_cutout': dest.shader = 1
if mat.cv_data.shader == 'terrain_blend':
#{
dest.shader = 3
- dest.colour1[0] = mat.cv_data.uv_offset[0]
- dest.colour1[1] = mat.cv_data.uv_offset[1]
+ dest.colour1[0] = mat.cv_data.blend_offset[0]
+ dest.colour1[1] = mat.cv_data.blend_offset[1]
#}
if mat.cv_data.shader == 'water':
('vertex_blend', "vertex_blend", "", 3),
('water',"water","",4),
])
+
+ surface_prop: bpy.props.EnumProperty(
+ name="Surface Property",
+ items = [
+ ('concrete','concrete','',0),
+ ('wood','wood','',1),
+ ('grass','grass','',2)
+ ])
collision: bpy.props.BoolProperty( \
name="Collisions Enabled",\
default=True,\
description = "Should the game try to target this surface?" \
)
+ grow_grass: bpy.props.BoolProperty( \
+ name="Grow Grass", \
+ default=False,\
+ description = "Spawn grass sprites on this surface?" \
+ )
blend_offset: bpy.props.FloatVectorProperty( \
name="Blend Offset", \
size=2, \
info = material_info( active_mat )
_.layout.prop( active_mat.cv_data, "shader" )
+ _.layout.prop( active_mat.cv_data, "surface_prop" )
_.layout.prop( active_mat.cv_data, "collision" )
if active_mat.cv_data.collision:
_.layout.prop( active_mat.cv_data, "skate_surface" )
+ _.layout.prop( active_mat.cv_data, "grow_grass" )
if active_mat.cv_data.shader == "terrain_blend":
#{
world_audio_init();
/* 'systems' are completely loaded now */
- strcpy( world.world_name, "models/mp_test.mdl" );
+ strcpy( world.world_name, "models/mp_dev.mdl" );
world_load();
vg_console_load_autos();
}
VG_STATIC v2f menu_extra_angles;
VG_STATIC int menu_loc = 1,
- menu_loc_last = 1;
+ menu_loc_last = 1;
VG_STATIC u32 menu_page = 0;
VG_STATIC int cl_menu = 0,
- cl_menu_go_away = 0;
+ cl_menu_go_away = 0;
VG_STATIC const char *playermodels[] = { "ch_new", "ch_jordan", "ch_outlaw" };
+vg_tex2d tex_menu = { .path = "textures/menu.qoi",.flags = VG_TEXTURE_NEAREST };
+
VG_STATIC void menu_btn_paused( int event );
VG_STATIC void menu_btn_quit( int event );
VG_STATIC void menu_btn_skater( int event );
mdl_close( &menu_model );
vg_acquire_thread_sync();
- mdl_unpack_glmesh( &menu_model, &menu_glmesh );
+ {
+ mdl_unpack_glmesh( &menu_model, &menu_glmesh );
+ vg_tex2d_init( (vg_tex2d *[]){ &tex_menu }, 1 );
+ }
vg_release_thread_sync();
for( int i=0; i<vg_list_size(menu_buttons); i++ )
shader_menu_use();
shader_menu_uColour( (v4f){ 1.0f,1.0f,1.0f,1.0f} );
shader_menu_uTexMain( 1 );
- vg_tex2d_bind( &tex_graffiti, 1 );
+ vg_tex2d_bind( &tex_menu, 1 );
shader_menu_uPv( projection );
mesh_bind( &menu_glmesh );
enum classtype
{
- k_classtype_none = 0,
- k_classtype_gate = 1,
- k_classtype_spawn = 3,
- k_classtype_water = 4,
- k_classtype_route_node = 8,
- k_classtype_route = 9,
- k_classtype_bone = 10,
- k_classtype_skeleton = 11,
- k_classtype_skin = 12,
- k_classtype_audio = 14,
- k_classtype_trigger = 100,
- k_classtype_logic_achievement = 101,
- k_classtype_logic_relay = 102
+ k_classtype_none = 0,
+ k_classtype_gate = 1,
+ k_classtype_spawn = 3,
+ k_classtype_water = 4,
+ k_classtype_route_node = 8,
+ k_classtype_route = 9,
+ k_classtype_bone = 10,
+ k_classtype_skeleton = 11,
+ k_classtype_skin = 12,
+ k_classtype_audio = 14,
+ k_classtype_trigger = 100,
+ k_classtype_logic_achievement = 101,
+ k_classtype_logic_relay = 102
};
enum mdl_shader
k_shader_water = 4
};
+enum mdl_surface_prop
+{
+ k_surface_prop_concrete = 0,
+ k_surface_prop_wood = 1,
+ k_surface_prop_grass = 2
+};
+
+enum material_flag
+{
+ k_material_flag_skate_surface = 0x1,
+ k_material_flag_collision = 0x2,
+ k_material_flag_grow_grass = 0x4
+};
+
#pragma pack(push,1)
struct mdl_vert
{
u32 pstr_name,
shader,
- flags;
+ flags,
+ surface_prop;
v4f colour,
colour1;
float walk;
int step_phase;
+ enum mdl_surface_prop surface_prop;
/* player model */
struct player_model
audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
audio_player_set_position( &audio_player_extra, phys->rb.co );
audio_player_set_vol( &audio_player_extra, 6.0f );
- audio_player_playclip( &audio_player_extra,
- &audio_footsteps[rand()%4] );
+
+ if( player.surface_prop == k_surface_prop_concrete )
+ {
+ audio_player_playclip(
+ &audio_player_extra,
+ &audio_footsteps[rand()%vg_list_size(audio_footsteps)]
+ );
+ }
+ else if( player.surface_prop == k_surface_prop_grass )
+ {
+ audio_player_playclip(
+ &audio_player_extra,
+ &audio_footsteps_grass[rand()%vg_list_size(audio_footsteps_grass)]
+ );
+ }
+ else if( player.surface_prop == k_surface_prop_wood )
+ {
+ audio_player_playclip(
+ &audio_player_extra,
+ &audio_footsteps_wood[rand()%vg_list_size(audio_footsteps_wood)]
+ );
+ }
}
player.step_phase = walk_phase;
u32 scolour = (u8)(vg_minf(-land_delta * 2.0f, 255.0f));
/* Bias prediction towords ramps */
- if( ray_hit_is_ramp( &contact ) )
+ if( ray_hit_material( &contact )->info.flags
+ & k_material_flag_skate_surface )
{
land_delta *= 0.1f;
scolour |= 0x0000a000;
}
}
- phys->in_air = len==0?1:0;
+ if( len == 0 )
+ phys->in_air = 1;
+ else
+ {
+ phys->in_air = 0;
+ struct world_material *surface_mat = world_contact_material( manifold );
+ player.surface_prop = surface_mat->info.surface_prop;
+ }
if( !phys->in_air )
{
out vec4 FragColor;
+uniform sampler2D uTexGarbage;
uniform sampler2D uTexMain;
-uniform vec4 uColour;
+uniform vec3 uCamera;
+uniform vec4 uPlane;
in vec4 aColour;
in vec2 aUv;
in vec3 aNorm;
in vec3 aCo;
+in vec3 aWorldCo;
+
+#include "common_world.glsl"
void main()
{
- vec3 diffuse = texture( uTexMain, aUv ).rgb;
- float light1 = max(0.0,dot(-vec3(0.5,-0.8,0.25), aNorm));
- float light2 = max(0.0,dot(-vec3(-0.8,0.5,-0.25), aNorm));
- diffuse += vec3(0.2,0.2,0.2) +
- vec3(1.0,1.0,0.9)*light1 +
- vec3(0.1,0.3,0.4)*light2;
- FragColor = vec4(diffuse*uColour.rgb, aColour.a*uColour.a);
+ vec3 vfrag = vec3(0.5,0.5,0.5);
+ vec4 vsamplemain = texture( uTexMain, aUv );
+ vec3 qnorm = normalize(aNorm);
+
+ vfrag = vsamplemain.rgb;
+
+ if( g_light_preview == 1 )
+ {
+ vfrag = vec3(0.5);
+ }
+
+ // Lighting
+ vec3 halfview = uCamera - aWorldCo;
+ float fdist = length( halfview );
+ halfview /= fdist;
+
+ vfrag = do_light_diffuse( vfrag, qnorm );
+ vfrag = do_light_spec( vfrag, qnorm, halfview, 0.1 );
+ vfrag = do_light_shadowing( vfrag );
+ vfrag = apply_fog( vfrag, fdist );
+
+ FragColor = vec4(vfrag, 1.0);
}
.static_src =
"out vec4 FragColor;\n"
"\n"
+"uniform sampler2D uTexGarbage;\n"
"uniform sampler2D uTexMain;\n"
-"uniform vec4 uColour;\n"
+"uniform vec3 uCamera;\n"
+"uniform vec4 uPlane;\n"
"\n"
"in vec4 aColour;\n"
"in vec2 aUv;\n"
"in vec3 aNorm;\n"
"in vec3 aCo;\n"
+"in vec3 aWorldCo;\n"
+"\n"
+"#line 1 1 \n"
+"layout (std140) uniform ub_world_lighting\n"
+"{\n"
+" vec4 g_light_colours[3];\n"
+" vec4 g_light_directions[3];\n"
+" vec4 g_ambient_colour;\n"
+"\n"
+" vec4 g_water_plane;\n"
+" vec4 g_depth_bounds;\n"
+" float g_water_fog;\n"
+" int g_light_count;\n"
+" int g_light_preview;\n"
+"};\n"
+"\n"
+"uniform sampler2D g_world_depth;\n"
+"\n"
+"// Standard diffuse + spec models\n"
+"// ==============================\n"
+"\n"
+"vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n"
+"{\n"
+" vec3 vtotal = g_ambient_colour.rgb;\n"
+"\n"
+" for( int i=0; i<g_light_count; i++ )\n"
+" {\n"
+" vec3 vcolour = g_light_colours[i].rgb;\n"
+" vec3 vdir = g_light_directions[i].xyz;\n"
+"\n"
+" float flight = max(dot( vdir, wnormal )*0.75+0.25,0.0);\n"
+" vtotal += vcolour*flight;\n"
+" }\n"
+"\n"
+" return vfrag * vtotal;\n"
+"}\n"
+"\n"
+"vec3 do_light_spec( vec3 vfrag, vec3 wnormal, vec3 halfview, float fintensity )\n"
+"{\n"
+" vec3 vcolour = g_light_colours[0].rgb;\n"
+" vec3 vdir = g_light_directions[0].xyz;\n"
+"\n"
+" vec3 specdir = reflect( -vdir, wnormal );\n"
+" float spec = pow(max(dot( halfview, specdir ), 0.0), 10.0);\n"
+" return vfrag + vcolour*spec*fintensity;\n"
+"}\n"
+"\n"
+"float world_depth_sample( vec3 pos )\n"
+"{\n"
+" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
+" return texture( g_world_depth, depth_coord ).r;\n"
+"}\n"
+"\n"
+"float shadow_sample( vec3 vdir )\n"
+"{\n"
+" vec3 sample_pos = aWorldCo + vdir;\n"
+" float height_sample = world_depth_sample( sample_pos );\n"
+"\n"
+" float fdelta = height_sample - sample_pos.y;\n"
+" return clamp( fdelta, 0.1, 0.2 )-0.1;\n"
+"}\n"
+"\n"
+"vec3 do_light_shadowing_old( vec3 vfrag )\n"
+"{\n"
+" float faccum = 0.0;\n"
+" faccum += shadow_sample( vec3( 0.0, 0.5, 0.0 ));\n"
+" faccum += shadow_sample( vec3( 2.0, 0.3, 0.0 ));\n"
+" faccum += shadow_sample( vec3( 3.0, 1.0, 0.0 ));\n"
+" faccum += shadow_sample( vec3( 5.0, 1.0, 0.0 ));\n"
+" faccum += shadow_sample( vec3( 0.0, 0.5, 0.0 )*1.5);\n"
+" faccum += shadow_sample( vec3( 2.0, 0.3, 0.0 )*1.5);\n"
+" faccum += shadow_sample( vec3( 3.0, 1.0, 0.0 )*1.5);\n"
+" faccum += shadow_sample( vec3( 5.0, 1.0, 0.0 )*1.5);\n"
+" return mix( vfrag, g_ambient_colour.rgb, faccum );\n"
+"}\n"
+"\n"
+"vec3 do_light_shadowing( vec3 vfrag )\n"
+"{\n"
+" float fspread = g_light_colours[0].w;\n"
+" vec3 vdir = g_light_directions[0].xyz;\n"
+" float flength = g_light_directions[0].w;\n"
+"\n"
+" float famt = 0.0;\n"
+" famt+=shadow_sample((vdir+vec3(-0.563, 0.550, 0.307)*fspread)*flength*0.1);\n"
+" famt+=shadow_sample((vdir+vec3( 0.808, 0.686, 0.346)*fspread)*flength*0.2);\n"
+" famt+=shadow_sample((vdir+vec3( 0.787, 0.074,-0.065)*fspread)*flength*0.3);\n"
+" famt+=shadow_sample((vdir+vec3(-0.593, 0.071,-0.425)*fspread)*flength*0.4);\n"
+" famt+=shadow_sample((vdir+vec3(-0.790,-0.933,-0.875)*fspread)*flength*0.5);\n"
+" famt+=shadow_sample((vdir+vec3( 0.807,-0.690, 0.472)*fspread)*flength*0.6);\n"
+" famt+=shadow_sample((vdir+vec3( 0.522,-0.379, 0.350)*fspread)*flength*0.7);\n"
+" famt+=shadow_sample((vdir+vec3( 0.483, 0.201, 0.306)*fspread)*flength*0.8);\n"
+" return mix( vfrag, g_ambient_colour.rgb, famt );\n"
+"}\n"
+"\n"
+"vec3 apply_fog( vec3 vfrag, float fdist )\n"
+"{\n"
+" float dist = pow(fdist*0.0008,1.2);\n"
+" return mix( vfrag, vec3(0.55,0.76,1.0), min( 1.0, dist ) );\n"
+"}\n"
+"\n"
+"#line 15 0 \n"
"\n"
"void main()\n"
"{\n"
-" vec3 diffuse = texture( uTexMain, aUv ).rgb;\n"
-" float light1 = max(0.0,dot(-vec3(0.5,-0.8,0.25), aNorm));\n"
-" float light2 = max(0.0,dot(-vec3(-0.8,0.5,-0.25), aNorm));\n"
-" diffuse += vec3(0.2,0.2,0.2) +\n"
-" vec3(1.0,1.0,0.9)*light1 + \n"
-" vec3(0.1,0.3,0.4)*light2;\n"
-" FragColor = vec4(diffuse*uColour.rgb, aColour.a*uColour.a);\n"
+" vec3 vfrag = vec3(0.5,0.5,0.5);\n"
+" vec4 vsamplemain = texture( uTexMain, aUv );\n"
+" vec3 qnorm = normalize(aNorm);\n"
+"\n"
+" vfrag = vsamplemain.rgb;\n"
+"\n"
+" if( g_light_preview == 1 )\n"
+" {\n"
+" vfrag = vec3(0.5);\n"
+" }\n"
+"\n"
+" // Lighting\n"
+" vec3 halfview = uCamera - aWorldCo;\n"
+" float fdist = length( halfview );\n"
+" halfview /= fdist;\n"
+"\n"
+" vfrag = do_light_diffuse( vfrag, qnorm );\n"
+" vfrag = do_light_spec( vfrag, qnorm, halfview, 0.1 );\n"
+" vfrag = do_light_shadowing( vfrag );\n"
+" vfrag = apply_fog( vfrag, fdist );\n"
+"\n"
+" FragColor = vec4(vfrag, 1.0);\n"
"}\n"
""},
};
static GLuint _uniform_standard_uMdl;
static GLuint _uniform_standard_uPv;
+static GLuint _uniform_standard_uTexGarbage;
static GLuint _uniform_standard_uTexMain;
-static GLuint _uniform_standard_uColour;
+static GLuint _uniform_standard_uCamera;
+static GLuint _uniform_standard_uPlane;
+static GLuint _uniform_standard_g_world_depth;
static void shader_standard_uMdl(m4x3f m){
glUniformMatrix4x3fv( _uniform_standard_uMdl, 1, GL_FALSE, (float *)m );
}
static void shader_standard_uPv(m4x4f m){
glUniformMatrix4fv( _uniform_standard_uPv, 1, GL_FALSE, (float *)m );
}
+static void shader_standard_uTexGarbage(int i){
+ glUniform1i( _uniform_standard_uTexGarbage, i );
+}
static void shader_standard_uTexMain(int i){
glUniform1i( _uniform_standard_uTexMain, i );
}
-static void shader_standard_uColour(v4f v){
- glUniform4fv( _uniform_standard_uColour, 1, v );
+static void shader_standard_uCamera(v3f v){
+ glUniform3fv( _uniform_standard_uCamera, 1, v );
+}
+static void shader_standard_uPlane(v4f v){
+ glUniform4fv( _uniform_standard_uPlane, 1, v );
+}
+static void shader_standard_g_world_depth(int i){
+ glUniform1i( _uniform_standard_g_world_depth, i );
}
static void shader_standard_register(void){
vg_shader_register( &_shader_standard );
static void shader_standard_link(void){
_uniform_standard_uMdl = glGetUniformLocation( _shader_standard.id, "uMdl" );
_uniform_standard_uPv = glGetUniformLocation( _shader_standard.id, "uPv" );
+ _uniform_standard_uTexGarbage = glGetUniformLocation( _shader_standard.id, "uTexGarbage" );
_uniform_standard_uTexMain = glGetUniformLocation( _shader_standard.id, "uTexMain" );
- _uniform_standard_uColour = glGetUniformLocation( _shader_standard.id, "uColour" );
+ _uniform_standard_uCamera = glGetUniformLocation( _shader_standard.id, "uCamera" );
+ _uniform_standard_uPlane = glGetUniformLocation( _shader_standard.id, "uPlane" );
+ _uniform_standard_g_world_depth = glGetUniformLocation( _shader_standard.id, "g_world_depth" );
}
#endif /* SHADER_standard_H */
k_geo_type_water = 2
};
-enum material_flag
-{
- k_material_flag_skate_surface = 0x1,
- k_material_flag_collision = 0x2
-};
-
VG_STATIC struct gworld
{
/*
*/
VG_STATIC int ray_hit_is_ramp( ray_hit *hit );
-VG_STATIC int ray_hit_is_terrain( ray_hit *hit );
+VG_STATIC struct world_material *ray_hit_material( ray_hit *hit );
VG_STATIC void ray_world_get_tri( ray_hit *hit, v3f tri[3] );
VG_STATIC int ray_world( v3f pos, v3f dir, ray_hit *hit );
vg_loader_highwater( world_routes_init, NULL, NULL );
/* Allocate dynamic world memory arena */
- u32 max_size = 72*1024*1024;
+ u32 max_size = 76*1024*1024;
world.dynamic_vgl = vg_create_linear_allocator( vg_mem.rtmemory, max_size,
VG_MEMORY_SYSTEM );
}
return scene_raycast( world.scene_geo, world.geo_bh, pos, dir, hit );
}
-VG_STATIC int ray_hit_is_terrain( ray_hit *hit )
+VG_STATIC struct world_material *world_tri_index_material( u32 index )
{
- return 0;
-#if 0
- u32 valid_start = 0,
- valid_end = world.sm_terrain.vertex_count;
+ for( int i=1; i<world.material_count; i++ )
+ {
+ struct world_material *mat = &world.materials[i];
- return (hit->tri[0] >= valid_start) &&
- (hit->tri[0] < valid_end);
-#endif
+ if( (index >= mat->sm_geo.vertex_start) &&
+ (index < mat->sm_geo.vertex_start+mat->sm_geo.vertex_count ) )
+ {
+ return mat;
+ }
+ }
+
+ /* error material */
+ return &world.materials[0];
}
-VG_STATIC int ray_hit_is_ramp( ray_hit *hit )
+VG_STATIC struct world_material *world_contact_material( rb_ct *ct )
{
- return 1;
-#if 0
- u32 valid_start = world.sm_geo_std.vertex_start,
- valid_end = world.sm_geo_vb.vertex_start;
+ return world_tri_index_material( ct->element_id );
+}
- return (hit->tri[0] >= valid_start) &&
- (hit->tri[0] < valid_end);
-#endif
+VG_STATIC struct world_material *ray_hit_material( ray_hit *hit )
+{
+ return world_tri_index_material( hit->tri[0] );
}
#endif /* WORLD_H */
}
/* Sprinkle foliage models over the map on terrain material */
-VG_STATIC void world_apply_procedural_foliage(void)
+VG_STATIC void world_apply_procedural_foliage( struct world_material *mat )
{
vg_linear_clear( vg_mem.scratch );
if( ray_world( pos, (v3f){0.0f,-1.0f,0.0f}, &hit ))
{
- if( (hit.normal[1] > 0.8f) && ray_hit_is_terrain(&hit) &&
- (hit.pos[1] > 0.0f+10.0f) )
+ struct world_material *m1 = ray_hit_material( &hit );
+ if((hit.normal[1] > 0.8f) && (m1 == mat) && (hit.pos[1] > 0.0f+10.0f))
{
v4f qsurface, qrandom;
v3f axis;
return;
}
- mdl_submesh *sm = mdl_node_submesh( world.meta, pnode, 0 );
-
- if( sm )
- {
- vg_acquire_thread_sync();
- {
- mdl_unpack_submesh( world.meta, &world.mesh_water, sm );
- world.water.enabled = 1;
- water_set_surface( pnode->co[1] );
- }
- vg_release_thread_sync();
- }
- else
- {
- vg_warn( "Water entity has no submeshes!\n" );
- }
+ world.water.enabled = 1;
+ water_set_surface( pnode->co[1] );
}
VG_STATIC void world_pct_audio( mdl_node *pnode )
/*
* Compile meshes into the world scenes
*/
- world.scene_geo = scene_init( world.dynamic_vgl, 350000, 1200000 );
+ world.scene_geo = scene_init( world.dynamic_vgl, 320000, 1200000 );
m4x3f midentity;
m4x3_identity( midentity );
struct world_material *mat = &world.materials[ i ];
if( mat->info.flags & k_material_flag_collision )
- {
world_add_all_if_material( midentity, world.scene_geo, world.meta, i );
- scene_copy_slice( world.scene_geo, &mat->sm_geo );
- }
- }
-
+ scene_copy_slice( world.scene_geo, &mat->sm_geo );
+ }
scene_copy_slice( world.scene_no_collide, &world.sm_foliage_main );
#endif
+ for( int i=0; i<world.material_count; i++ )
+ {
+ struct world_material *mat = &world.materials[ i ];
+
+ if( !(mat->info.flags & k_material_flag_collision) )
+ {
+ world_add_all_if_material( midentity, world.scene_no_collide,
+ world.meta, i );
+ }
+ if( mat->info.flags & k_material_flag_grow_grass )
+ world_apply_procedural_foliage( mat );
+
+ scene_copy_slice( world.scene_no_collide, &mat->sm_no_collide );
+ }
/* upload and free that */
vg_acquire_thread_sync();
mesh_free( &world.mesh_route_lines );
mesh_free( &world.mesh_geo );
mesh_free( &world.mesh_no_collide );
- mesh_free( &world.mesh_water );
world.time = 0.0;
world.rewind_from = 0.0;
#include "world.h"
-vg_tex2d tex_terrain_colours = { .path = "textures/gradients.qoi",
- .flags = VG_TEXTURE_CLAMP|VG_TEXTURE_NEAREST };
-
vg_tex2d tex_terrain_noise = { .path = "textures/garbage.qoi",
.flags = VG_TEXTURE_NEAREST };
-vg_tex2d tex_alphatest = { .path = "textures/alphatest.qoi",
- .flags = VG_TEXTURE_NEAREST };
-
-vg_tex2d tex_graffiti = { .path = "textures/graffitibox.qoi",
- .flags = VG_TEXTURE_NEAREST };
-
VG_STATIC void world_render_init(void)
{
vg_info( "Loading default world textures\n" );
vg_acquire_thread_sync();
{
- vg_tex2d_init( (vg_tex2d *[]){ &tex_terrain_colours,
- &tex_terrain_noise,
- &tex_alphatest,
- &tex_graffiti }, 4 );
+ vg_tex2d_init( (vg_tex2d *[]){ &tex_terrain_noise }, 1 );
}
vg_release_thread_sync();
}
* Rendering
*/
-VG_STATIC void bind_terrain_textures(void)
+VG_STATIC void bind_terrain_noise(void)
{
vg_tex2d_bind( &tex_terrain_noise, 0 );
- vg_tex2d_bind( &tex_terrain_colours, 1 );
}
VG_STATIC void world_render_if( enum mdl_shader shader,
bindpoint_diffuse_texture1 );
}
+VG_STATIC void render_world_standard( m4x4f projection, v3f camera )
+{
+ m4x3f identity_matrix;
+ m4x3_identity( identity_matrix );
+
+ shader_standard_use();
+ shader_standard_uTexGarbage(0);
+ shader_standard_uTexMain(1);
+ shader_link_standard_ub( _shader_standard.id, 2 );
+ bind_terrain_noise();
+
+ shader_standard_uPv( projection );
+ shader_standard_uMdl( identity_matrix );
+ shader_standard_uCamera( camera );
+
+ world_render_both_stages( k_shader_standard,
+ bindpoint_diffuse_texture1 );
+}
VG_STATIC void render_world_alphatest( m4x4f projection, v3f camera )
{
shader_alphatest_uTexGarbage(0);
shader_alphatest_uTexMain(1);
shader_link_standard_ub( _shader_alphatest.id, 2 );
-
- vg_tex2d_bind( &tex_terrain_noise, 0 );
+ bind_terrain_noise();
shader_alphatest_uPv( projection );
shader_alphatest_uMdl( identity_matrix );
}
}
-VG_STATIC void bind_terrain_textures(void);
+VG_STATIC void bind_terrain_noise(void);
VG_STATIC void render_world_routes( m4x4f projection, v3f camera )
{
m4x3f identity_matrix;
shader_route_use();
shader_route_uTexGarbage(0);
shader_link_standard_ub( _shader_route.id, 2 );
- bind_terrain_textures();
+ bind_terrain_noise();
shader_route_uPv( projection );
shader_route_uMdl( identity_matrix );
}
}
+VG_STATIC void bind_terrain_noise(void);
VG_STATIC void sfd_render( m4x4f projection, v3f camera, m4x3f transform )
{
mesh_bind( &world.sfd.mesh_display );
shader_scoretext_uTexGarbage(0);
shader_scoretext_uTexGradients(1);
shader_link_standard_ub( _shader_scoretext.id, 2 );
- bind_terrain_textures();
+ bind_terrain_noise();
vg_tex2d_bind( &tex_scoretext, 1 );
shader_scoretext_uPv( projection );
shader_vblend_uTexGarbage(0);
shader_vblend_uTexGradients(1);
shader_link_standard_ub( _shader_vblend.id, 2 );
- bind_terrain_textures();
+ bind_terrain_noise();
+ vg_tex2d_bind( &tex_scoretext, 1 );
shader_vblend_uPv( projection );
shader_vblend_uMdl( transform );
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
- mesh_bind( &world.mesh_water );
+ mesh_bind( &world.mesh_no_collide );
for( int i=0; i<world.material_count; i++ )
{