From: hgn Date: Thu, 23 Feb 2023 02:29:58 +0000 (+0000) Subject: fuckin hell X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=aa4c26eae2208872824e0eb5b71bc05c16d43242;hp=3e8fda9c7cbc50d1ae95195905c953bdeedf71b9;p=carveJwlIkooP6JGAAIwe30JlM.git fuckin hell --- diff --git a/blender_export.py b/blender_export.py index 538ed6c..06d90a4 100644 --- a/blender_export.py +++ b/blender_export.py @@ -2,7 +2,7 @@ # ============================================================================= # # Copyright . . . -----, ,----- ,---. .---. -# 2021-2022 |\ /| | / | | | | /| +# 2021-2023 |\ /| | / | | | | /| # | \ / | +-- / +----- +---' | / | # | \ / | | / | | \ | / | # | \/ | | / | | \ | / | @@ -771,6 +771,33 @@ class classtype_audio(Structure): #} #} +# Classtype 200 +# +# Purpose: point light +# +class classtype_point_light(Structure): +#{ + _pack_ = 1 + _fields_ = [("colour",c_float*4)] + + def encode_obj(_, node, node_def): + #{ + node.classtype = 200 + + data = node_def['obj'].data + _.colour[0] = data.color[0] + _.colour[1] = data.color[1] + _.colour[2] = data.color[2] + _.colour[3] = data.energy + #} + + @staticmethod + def editor_interface( layout, obj ): + #{ + pass + #} +#} + class classtype_spawn_link(Structure): #{ _pack_ = 1 @@ -1816,6 +1843,11 @@ def encoder_process_definition( node_def ): if obj_type == 'ARMATURE': obj_classtype = 'classtype_skeleton' + elif obj_type == 'LIGHT': + #{ + if obj.data.type == 'POINT': + obj_classtype = 'classtype_point_light' + #} else: #{ obj_classtype = obj.cv_data.classtype diff --git a/build.c b/build.c index c0a79b6..5f050df 100644 --- a/build.c +++ b/build.c @@ -109,37 +109,37 @@ int main( int argc, char *argv[] ) } } -void _shader( char *name, char *vs, char *fs ) -{ - vg_build_shader( vs, fs, NULL, "shaders", name ); -} +#define _S( NAME, VS, FS ) \ + vg_build_shader( "shaders/" VS, "shaders/" FS, NULL, "shaders", NAME ) void build_shaders(void) { vg_shader_set_include_dir( "shaders" ); - // 2D - _shader( "blit", "shaders/blit.vs", "shaders/blit.fs" ); - _shader( "blitblur", "shaders/blit.vs", "shaders/blitblur.fs" ); - _shader( "blitcolour","shaders/blit.vs", "shaders/colour.fs" ); - _shader( "routeui", "shaders/routeui.vs", "shaders/routeui.fs" ); + /* Scene */ + _S( "scene_standard", "scene.vs", "scene_standard.fs" ); + _S( "scene_standard_alphatest", "scene.vs", "scene_standard_alphatest.fs" ); + _S( "scene_vertex_blend", "scene.vs", "scene_vertex_blend.fs" ); + _S( "scene_terrain", "scene.vs", "scene_terrain.fs" ); + _S( "scene_route", "scene.vs", "scene_route.fs" ); + _S( "scene_depth", "scene.vs", "scene_depth.fs" ); + + /* Models */ + _S( "model_sky", "model.vs", "model_sky.fs" ); + _S( "model_water", "model.vs", "model_water.fs" ); + _S( "model_water_fast", "model.vs", "model_water_fast.fs" ); + _S( "model_menu", "model.vs", "model_menu.fs" ); + _S( "model_character_view", "model_skinned.vs", "model_character_view.fs" ); + _S( "model_gate", "model_gate.vs", "model_gate_lq.fs" ); + + /* 2D */ + _S( "blit", "blit.vs", "blit.fs" ); + _S( "blitblur", "blit.vs", "blitblur.fs" ); + _S( "blitcolour","blit.vs", "colour.fs" ); + _S( "routeui", "routeui.vs", "routeui.fs" ); +#if 0 // 3D Standard - _shader( "standard", "shaders/standard.vs", "shaders/standard.fs" ); - _shader( "vblend", "shaders/standard.vs", "shaders/vblend.fs" ); - _shader( "scoretext", "shaders/scoretext.vs", "shaders/vblend.fs" ); - _shader( "terrain", "shaders/standard.vs", "shaders/terrain.fs" ); - _shader( "alphatest", "shaders/standard.vs", "shaders/std_alphatest.fs" ); - _shader( "route", "shaders/standard.vs", "shaders/route.fs" ); - _shader( "menu", "shaders/standard.vs", "shaders/menu.fs" ); - - // 3D Skinned - _shader( "viewchar", "shaders/standard_skinned.vs", "shaders/viewchar.fs" ); - - // 3D extra/effects - _shader( "gpos", "shaders/standard.vs", "shaders/gpos.fs" ); - _shader( "sky", "shaders/standard.vs", "shaders/sky.fs" ); - _shader( "water", "shaders/standard.vs", "shaders/water.fs" ); - _shader( "water_fast","shaders/standard.vs", "shaders/water_fast.fs" ); - _shader( "gatelq", "shaders/gate.vs", "shaders/gate_lq.fs" ); + _S( "scoretext", "shaders/scoretext.vs", "shaders/vblend.fs" ); +#endif } diff --git a/maps_src/mp_arizona.mdl b/maps_src/mp_arizona.mdl new file mode 100644 index 0000000..9d1ce85 Binary files /dev/null and b/maps_src/mp_arizona.mdl differ diff --git a/maps_src/mp_gridmap.mdl b/maps_src/mp_gridmap.mdl index 465de6c..cb5211b 100644 Binary files a/maps_src/mp_gridmap.mdl and b/maps_src/mp_gridmap.mdl differ diff --git a/maps_src/mp_mtzero.mdl b/maps_src/mp_mtzero.mdl index 219be46..96165c9 100644 Binary files a/maps_src/mp_mtzero.mdl and b/maps_src/mp_mtzero.mdl differ diff --git a/model.h b/model.h index 12a05b1..5498723 100644 --- a/model.h +++ b/model.h @@ -41,7 +41,8 @@ enum classtype k_classtype_audio = 14, k_classtype_trigger = 100, k_classtype_logic_achievement = 101, - k_classtype_logic_relay = 102 + k_classtype_logic_relay = 102, + k_classtype_point_light = 200 }; enum mdl_shader @@ -269,6 +270,11 @@ struct classtype_audio float volume; }; +struct classtype_point_light +{ + v4f colour; /* RGB, Energy */ +}; + #pragma pack(pop) diff --git a/player.c b/player.c index 10f5cc5..4c8f76a 100644 --- a/player.c +++ b/player.c @@ -263,13 +263,13 @@ VG_STATIC void player__pre_render( player_instance *player ) PLAYER_API void player__render( camera *cam, player_instance *player ) { - shader_viewchar_use(); + shader_model_character_view_use(); vg_tex2d_bind( player->playertex, 0 ); - shader_viewchar_uTexMain( 0 ); - shader_viewchar_uCamera( cam->transform[3] ); - shader_viewchar_uPv( cam->mtx.pv ); - shader_link_standard_ub( _shader_viewchar.id, 2 ); - glUniformMatrix4x3fv( _uniform_viewchar_uTransforms, + shader_model_character_view_uTexMain( 0 ); + shader_model_character_view_uCamera( cam->transform[3] ); + shader_model_character_view_uPv( cam->mtx.pv ); + shader_link_standard_ub( _shader_model_character_view.id, 2 ); + glUniformMatrix4x3fv( _uniform_model_character_view_uTransforms, player->playeravatar->sk.bone_count, 0, (float *)player->playeravatar->sk.final_mtx ); diff --git a/player_model.h b/player_model.h index e7114cf..5982eae 100644 --- a/player_model.h +++ b/player_model.h @@ -13,7 +13,7 @@ #include "player_ragdoll.h" #include "rigidbody.h" -#include "shaders/viewchar.h" +#include "shaders/model_character_view.h" struct player_avatar { diff --git a/render.h b/render.h index cd41ec3..7b5b473 100644 --- a/render.h +++ b/render.h @@ -8,8 +8,12 @@ #include "shaders/blit.h" #include "shaders/blitblur.h" +#include "shaders/blitcolour.h" + +#if 0 #include "shaders/standard.h" #include "shaders/vblend.h" +#endif VG_STATIC void render_water_texture( camera *cam ); VG_STATIC void render_water_surface( camera *cam ); @@ -50,6 +54,9 @@ VG_STATIC struct pipeline int g_light_count; int g_light_preview; int g_shadow_samples; + + v4f g_point_light_positions[32]; + v4f g_point_light_colours[32]; } ub_world_lighting; @@ -668,8 +675,7 @@ VG_STATIC void render_init(void) { shader_blit_register(); shader_blitblur_register(); - shader_standard_register(); - shader_vblend_register(); + shader_blitcolour_register(); vg_acquire_thread_sync(); { diff --git a/scene.h b/scene.h index d0615d5..902aedb 100644 --- a/scene.h +++ b/scene.h @@ -10,13 +10,14 @@ typedef struct scene_vert scene_vert; #pragma pack(push,1) -/* 24 byte vertexs, we don't care about the normals too much, +/* 28 byte vertexs, we don't care about the normals too much, * maybe possible to bring down uv to i16s too */ struct scene_vert { v3f co; /* 3*32 */ v2f uv; /* 2*32 */ i8 norm[4]; /* 4*8 */ + u8 lights[4]; /* 4*8 */ }; #pragma pack(pop) @@ -259,6 +260,11 @@ VG_STATIC void scene_upload( scene *pscene, glmesh *mesh ) stride, (void *)offsetof(scene_vert, uv) ); glEnableVertexAttribArray( 2 ); + /* 3: light cluster */ + glVertexAttribIPointer( 3, 4, GL_UNSIGNED_BYTE, + stride, (void *)offsetof(scene_vert, lights) ); + glEnableVertexAttribArray( 3 ); + VG_CHECK_GL_ERR(); mesh->indice_count = pscene->indice_count; diff --git a/shaders.sh b/shaders.sh index 79604a6..e7a6f61 100755 --- a/shaders.sh +++ b/shaders.sh @@ -10,24 +10,32 @@ shader(){ target_shaders="$target_shaders $1 $2 $3" } -shader blit blit.vs blit.fs -shader standard standard.vs standard.fs -shader vblend standard.vs vblend.fs -shader terrain standard.vs terrain.fs -shader sky standard.vs sky.fs -shader planeinf standard.vs planeinf.fs -shader gpos standard.vs gpos.fs -shader fscolour blit.vs colour.fs -shader alphatest standard.vs std_alphatest.fs -shader scoretext scoretext.vs vblend.fs -shader water standard.vs water.fs -shader water_fast standard.vs water_fast.fs -shader gate gate.vs gate.fs -shader gatelq gate.vs gate_lq.fs -shader route standard.vs route.fs -shader routeui routeui.vs routeui.fs -shader viewchar standard_skinned.vs viewchar.fs -shader menu standard.vs menu.fs +# uses scene +shader scene_standard scene.vs scene_standard.fs +shader scene_standard_alphatest scene.vs scene_standard_alphatest.fs +shader scene_vertex_blend scene.vs scene_vertex_blend.fs +shader scene_terrain scene.vs scene_terrain.fs +shader scene_route scene.vs scene_route.fs +shader scene_depth scene.vs scene_depth.fs + +# model shaders +shader model_sky model.vs model_sky.fs +shader model_water model.vs model_water.fs +shader model_water_fast model.vs model_water_fast.fs +shader model_menu model.vs model_menu.fs +shader model_character_view model_skinned.vs model_character_view.fs +shader model_gate model_gate.vs model_gate.fs +shader model_gatelq model_gate.vs model_gate_lq.fs + +# fullscreen +shader blit blit.vs blit.fs +shader fscolour blit.vs colour.fs + +#shader planeinf standard.vs planeinf.fs +#shader scoretext scoretext.vs vblend.fs +# Special + +shader routeui routeui.vs routeui.fs cd shaders ../bin/linux/tools/shader $target_shaders diff --git a/shaders/alphatest.h b/shaders/alphatest.h deleted file mode 100644 index 9847894..0000000 --- a/shaders/alphatest.h +++ /dev/null @@ -1,314 +0,0 @@ -#ifndef SHADER_alphatest_H -#define SHADER_alphatest_H -static void shader_alphatest_link(void); -static void shader_alphatest_register(void); -static struct vg_shader _shader_alphatest = { - .name = "alphatest", - .link = shader_alphatest_link, - .vs = -{ -.static_src = -"layout (location=0) in vec3 a_co;\n" -"layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec2 a_uv;\n" -"layout (location=3) in vec4 a_colour;\n" -"layout (location=4) in vec4 a_weights;\n" -"layout (location=5) in ivec4 a_groups;\n" -"\n" -"#line 2 0 \n" -"#line 1 2 \n" -"const float k_motion_lerp_amount = 0.01;\n" -"\n" -"#line 2 0 \n" -"\n" -"out vec3 aMotionVec0;\n" -"out vec3 aMotionVec1;\n" -"\n" -"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" -"{\n" -" // This magically solves some artifacting errors!\n" -" //\n" -" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" -"\n" -" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" -" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" -"}\n" -"\n" -"#line 3 0 \n" -"\n" -"uniform mat4x3 uMdl;\n" -"uniform mat4 uPv;\n" -"uniform mat4 uPvmPrev;\n" -"\n" -"out vec4 aColour;\n" -"out vec2 aUv;\n" -"out vec3 aNorm;\n" -"out vec3 aCo;\n" -"out vec3 aWorldCo;\n" -"\n" -"void main()\n" -"{\n" -" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" -" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" -" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" -"\n" -" vs_motion_out( vproj0, vproj1 );\n" -"\n" -" gl_Position = vproj0;\n" -" aWorldCo = world_pos0;\n" -" aColour = a_colour;\n" -" aUv = a_uv;\n" -" aNorm = mat3(uMdl) * a_norm;\n" -" aCo = a_co;\n" -"}\n" -""}, - .fs = -{ -.static_src = -"uniform sampler2D uTexGarbage;\n" -"uniform sampler2D uTexMain;\n" -"uniform vec3 uBoard0;\n" -"uniform vec3 uBoard1;\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 (location = 0) out vec4 oColour;\n" -"\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" -" int g_shadow_samples;\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; icolour[0] * 255.0f, + g = light->colour[1] * 255.0f, + b = light->colour[2] * 255.0f; + + colour |= r; + colour |= g << 8; + colour |= b << 16; + + vg_line_pt3( light->co, 0.25f, colour ); + } + world.in_trigger = in_trigger; sfd_update(); } diff --git a/world_gate.h b/world_gate.h index 1bf8afe..d92537e 100644 --- a/world_gate.h +++ b/world_gate.h @@ -10,10 +10,9 @@ #include "render.h" #include "camera.h" -#include "shaders/gatelq.h" +#include "shaders/model_gate.h" #include "world_water.h" - VG_STATIC void gate_transform_update( teleport_gate *gate ) { m4x3f to_local; @@ -32,7 +31,7 @@ VG_STATIC void world_gates_init(void) { vg_info( "world_gates_init\n" ); - shader_gatelq_register(); + shader_model_gate_register(); vg_linear_clear( vg_mem.scratch ); mdl_context *mgate = mdl_load_full( vg_mem.scratch, "models/rs_gate.mdl" ); @@ -110,12 +109,12 @@ VG_STATIC int render_gate( teleport_gate *gate, camera *cam ) m4x3_copy( gate->to_world, gate_xform ); m4x3_scalev( gate_xform, (v3f){ gate->dims[0], gate->dims[1], 1.0f } ); - shader_gatelq_use(); - shader_gatelq_uPv( cam->mtx.pv ); - shader_gatelq_uMdl( gate_xform ); - shader_gatelq_uCam( cam->pos ); - shader_gatelq_uTime( vg.time*0.25f ); - shader_gatelq_uInvRes( (v2f){ + shader_model_gate_use(); + shader_model_gate_uPv( cam->mtx.pv ); + shader_model_gate_uMdl( gate_xform ); + shader_model_gate_uCam( cam->pos ); + shader_model_gate_uTime( vg.time*0.25f ); + shader_model_gate_uInvRes( (v2f){ 1.0f / (float)vg.window_x, 1.0f / (float)vg.window_y }); diff --git a/world_gen.h b/world_gen.h index 89fea39..f5e7599 100644 --- a/world_gen.h +++ b/world_gen.h @@ -182,6 +182,11 @@ VG_STATIC void world_ents_allocate(void) k_classtype_logic_achievement, (void*)&world.logic_achievements, sizeof(struct logic_achievement) + }, + { + k_classtype_point_light, + (void*)&world.lights, + sizeof(struct world_light) } }; @@ -325,6 +330,16 @@ VG_STATIC void world_pct_achievement( mdl_node *pnode ) world.achievement_count ++; } +VG_STATIC void world_pct_point_light( mdl_node *pnode ) +{ + struct world_light *light = &world.lights[ world.light_count ]; + v3_copy( pnode->co, light->co ); + + struct classtype_point_light *inf = mdl_get_entdata( world.meta, pnode ); + v4_copy( inf->colour, light->colour ); + + world.light_count ++; +} VG_STATIC void world_entities_process(void) { @@ -340,7 +355,8 @@ VG_STATIC void world_entities_process(void) { k_classtype_audio, world_pct_audio }, { k_classtype_trigger, world_pct_trigger }, { k_classtype_logic_relay, world_pct_relay }, - { k_classtype_logic_achievement, world_pct_achievement } + { k_classtype_logic_achievement, world_pct_achievement }, + { k_classtype_point_light, world_pct_point_light } }; for( int i=0; iinfo.node_count; i++ ) @@ -360,6 +376,42 @@ VG_STATIC void world_entities_process(void) } } +VG_STATIC void world_scene_compute_light_clusters( scene *sc ) +{ + for( int i=0; ivertex_count; i++ ) + { + scene_vert *vert = &sc->arrvertices[i]; + vert->lights[0] = 255; + vert->lights[1] = 255; + vert->lights[2] = 255; + vert->lights[3] = 255; + + float distances[4] = { INFINITY, INFINITY, INFINITY, INFINITY }; + + for( int j=0; jco ); + + int best_pos = 4; + for( int k=best_pos-1; k>=0; k -- ) + if( dist < distances[k] ) + best_pos = k; + + if( best_pos < 4 ) + { + for( int k=3; k>best_pos; k -- ) + { + distances[k] = distances[k-1]; + vert->lights[k] = vert->lights[k-1]; + } + + distances[best_pos] = dist; + vert->lights[best_pos] = j; + } + } + } +} + VG_STATIC void world_generate(void) { /* @@ -387,10 +439,8 @@ VG_STATIC void world_generate(void) scene_copy_slice( world.scene_geo, &mat->sm_geo ); } + world_scene_compute_light_clusters( world.scene_geo ); - - - /* compress that bad boy */ world.scene_geo = scene_fix( world.dynamic_vgl, world.scene_geo ); @@ -434,6 +484,7 @@ VG_STATIC void world_generate(void) scene_copy_slice( world.scene_no_collide, &mat->sm_no_collide ); } + world_scene_compute_light_clusters( world.scene_no_collide ); /* upload and free that */ vg_acquire_thread_sync(); @@ -531,6 +582,17 @@ VG_STATIC void world_post_process(void) v4_copy( info_vec, winfo->g_depth_bounds ); winfo->g_water_fog = 0.04f; + + for( int i=0; icolour, light->colour[3] * 2.0f, + gpipeline.ub_world_lighting.g_point_light_colours[i] ); + v3_copy( light->co, + gpipeline.ub_world_lighting.g_point_light_positions[i] ); + } + render_update_lighting_ub(); } @@ -664,6 +726,9 @@ VG_STATIC void world_unload(void) world.triggers = NULL; world.trigger_count = 0; + world.lights = NULL; + world.light_count = 0; + world.logic_relays = NULL; world.relay_count = 0; diff --git a/world_render.h b/world_render.h index e1c17c8..e738d37 100644 --- a/world_render.h +++ b/world_render.h @@ -84,20 +84,20 @@ VG_STATIC void render_world_vb( camera *cam ) m4x3f identity_matrix; m4x3_identity( identity_matrix ); - shader_vblend_use(); - shader_vblend_uTexGarbage(0); - shader_vblend_uTexGradients(1); - shader_link_standard_ub( _shader_vblend.id, 2 ); + shader_scene_vertex_blend_use(); + shader_scene_vertex_blend_uTexGarbage(0); + shader_scene_vertex_blend_uTexGradients(1); + shader_link_standard_ub( _shader_scene_vertex_blend.id, 2 ); vg_tex2d_bind( &tex_terrain_noise, 0 ); - shader_vblend_uPv( cam->mtx.pv ); - shader_vblend_uPvmPrev( cam->mtx_prev.pv ); - shader_vblend_uMdl( identity_matrix ); - shader_vblend_uCamera( cam->transform[3] ); - shader_vblend_uBoard0( TEMP_BOARD_0 ); - shader_vblend_uBoard1( TEMP_BOARD_1 ); + shader_scene_vertex_blend_uPv( cam->mtx.pv ); + shader_scene_vertex_blend_uPvmPrev( cam->mtx_prev.pv ); + shader_scene_vertex_blend_uMdl( identity_matrix ); + shader_scene_vertex_blend_uCamera( cam->transform[3] ); + shader_scene_vertex_blend_uBoard0( TEMP_BOARD_0 ); + shader_scene_vertex_blend_uBoard1( TEMP_BOARD_1 ); - world_render_both_stages( k_shader_standard_vertex_blend, + world_render_both_stages( k_shader_standard_vertex_blend, bindpoint_diffuse_texture1 ); } @@ -106,18 +106,18 @@ VG_STATIC void render_world_standard( camera *cam ) m4x3f identity_matrix; m4x3_identity( identity_matrix ); - shader_standard_use(); - shader_standard_uTexGarbage(0); - shader_standard_uTexMain(1); - shader_standard_uPv( cam->mtx.pv ); - shader_standard_uPvmPrev( cam->mtx_prev.pv ); - shader_link_standard_ub( _shader_standard.id, 2 ); + shader_scene_standard_use(); + shader_scene_standard_uTexGarbage(0); + shader_scene_standard_uTexMain(1); + shader_scene_standard_uPv( cam->mtx.pv ); + shader_scene_standard_uPvmPrev( cam->mtx_prev.pv ); + shader_link_standard_ub( _shader_scene_standard.id, 2 ); bind_terrain_noise(); - shader_standard_uMdl( identity_matrix ); - shader_standard_uCamera( cam->transform[3] ); - shader_standard_uBoard0( TEMP_BOARD_0 ); - shader_standard_uBoard1( TEMP_BOARD_1 ); + shader_scene_standard_uMdl( identity_matrix ); + shader_scene_standard_uCamera( cam->transform[3] ); + shader_scene_standard_uBoard0( TEMP_BOARD_0 ); + shader_scene_standard_uBoard1( TEMP_BOARD_1 ); world_render_both_stages( k_shader_standard, bindpoint_diffuse_texture1 ); @@ -128,18 +128,18 @@ VG_STATIC void render_world_alphatest( camera *cam ) m4x3f identity_matrix; m4x3_identity( identity_matrix ); - shader_alphatest_use(); - shader_alphatest_uTexGarbage(0); - shader_alphatest_uTexMain(1); - shader_alphatest_uPv( cam->mtx.pv ); - shader_alphatest_uPvmPrev( cam->mtx_prev.pv ); - shader_link_standard_ub( _shader_alphatest.id, 2 ); + shader_scene_standard_alphatest_use(); + shader_scene_standard_alphatest_uTexGarbage(0); + shader_scene_standard_alphatest_uTexMain(1); + shader_scene_standard_alphatest_uPv( cam->mtx.pv ); + shader_scene_standard_alphatest_uPvmPrev( cam->mtx_prev.pv ); + shader_link_standard_ub( _shader_scene_standard_alphatest.id, 2 ); bind_terrain_noise(); - shader_alphatest_uMdl( identity_matrix ); - shader_alphatest_uCamera( cam->transform[3] ); - shader_alphatest_uBoard0( TEMP_BOARD_0 ); - shader_alphatest_uBoard1( TEMP_BOARD_1 ); + shader_scene_standard_alphatest_uMdl( identity_matrix ); + shader_scene_standard_alphatest_uCamera( cam->transform[3] ); + shader_scene_standard_alphatest_uBoard0( TEMP_BOARD_0 ); + shader_scene_standard_alphatest_uBoard1( TEMP_BOARD_1 ); glDisable(GL_CULL_FACE); @@ -154,8 +154,8 @@ VG_STATIC void bindpoint_terrain( struct world_material *mat ) glActiveTexture( GL_TEXTURE1 ); glBindTexture( GL_TEXTURE_2D, world.textures[ mat->info.tex_diffuse ] ); - shader_terrain_uSandColour( mat->info.colour ); - shader_terrain_uBlendOffset( mat->info.colour1 ); + shader_scene_terrain_uSandColour( mat->info.colour ); + shader_scene_terrain_uBlendOffset( mat->info.colour1 ); } VG_STATIC void render_terrain( camera *cam ) @@ -163,20 +163,20 @@ VG_STATIC void render_terrain( camera *cam ) m4x3f identity_matrix; m4x3_identity( identity_matrix ); - shader_terrain_use(); - shader_terrain_uTexGarbage(0); - shader_terrain_uTexGradients(1); - shader_link_standard_ub( _shader_terrain.id, 2 ); + shader_scene_terrain_use(); + shader_scene_terrain_uTexGarbage(0); + shader_scene_terrain_uTexGradients(1); + shader_link_standard_ub( _shader_scene_terrain.id, 2 ); vg_tex2d_bind( &tex_terrain_noise, 0 ); - shader_terrain_uPv( cam->mtx.pv ); - shader_terrain_uPvmPrev( cam->mtx_prev.pv ); + shader_scene_terrain_uPv( cam->mtx.pv ); + shader_scene_terrain_uPvmPrev( cam->mtx_prev.pv ); - shader_terrain_uMdl( identity_matrix ); - shader_terrain_uCamera( cam->transform[3] ); - shader_terrain_uBoard0( TEMP_BOARD_0 ); - shader_terrain_uBoard1( TEMP_BOARD_1 ); + shader_scene_terrain_uMdl( identity_matrix ); + shader_scene_terrain_uCamera( cam->transform[3] ); + shader_scene_terrain_uBoard0( TEMP_BOARD_0 ); + shader_scene_terrain_uBoard1( TEMP_BOARD_1 ); world_render_both_stages( k_shader_terrain_blend, bindpoint_terrain ); } @@ -210,12 +210,12 @@ VG_STATIC void render_sky( camera *cam ) /* * Draw */ - shader_sky_use(); - shader_sky_uMdl( identity_matrix ); - shader_sky_uPv( pv ); - shader_sky_uPvmPrev( pv_prev ); - shader_sky_uTexGarbage(0); - shader_sky_uTime( world.sky_time ); + shader_model_sky_use(); + shader_model_sky_uMdl( identity_matrix ); + shader_model_sky_uPv( pv ); + shader_model_sky_uPvmPrev( pv_prev ); + shader_model_sky_uTexGarbage(0); + shader_model_sky_uTime( world.sky_time ); vg_tex2d_bind( &tex_terrain_noise, 0 ); @@ -292,11 +292,11 @@ VG_STATIC void render_world_depth( camera *cam ) m4x3f identity_matrix; m4x3_identity( identity_matrix ); - shader_gpos_use(); - shader_gpos_uCamera( cam->transform[3] ); - shader_gpos_uPv( cam->mtx.pv ); - shader_gpos_uPvmPrev( cam->mtx_prev.pv ); - shader_gpos_uMdl( identity_matrix ); + shader_scene_depth_use(); + shader_scene_depth_uCamera( cam->transform[3] ); + shader_scene_depth_uPv( cam->mtx.pv ); + shader_scene_depth_uPvmPrev( cam->mtx_prev.pv ); + shader_scene_depth_uMdl( identity_matrix ); mesh_bind( &world.mesh_geo ); mesh_draw( &world.mesh_geo ); diff --git a/world_routes.h b/world_routes.h index 4e455d3..35f38f0 100644 --- a/world_routes.h +++ b/world_routes.h @@ -9,8 +9,11 @@ #include "world.h" #include "world_gate.h" +#if 0 #include "shaders/vblend.h" -#include "shaders/route.h" +#endif + +#include "shaders/scene_route.h" #include "shaders/routeui.h" @@ -1079,7 +1082,7 @@ VG_STATIC void world_routes_init(void) world.time = RESET_MAX_TIME*2.0; world.last_use = 0.0; - shader_route_register(); + shader_scene_route_register(); shader_routeui_register(); vg_acquire_thread_sync(); @@ -1138,17 +1141,17 @@ VG_STATIC void render_world_routes( camera *cam ) m4x3f identity_matrix; m4x3_identity( identity_matrix ); - shader_route_use(); - shader_route_uTexGarbage(0); - shader_link_standard_ub( _shader_route.id, 2 ); + shader_scene_route_use(); + shader_scene_route_uTexGarbage(0); + shader_link_standard_ub( _shader_scene_route.id, 2 ); bind_terrain_noise(); - shader_route_uPv( cam->mtx.pv ); - shader_route_uPvmPrev( cam->mtx_prev.pv ); - shader_route_uMdl( identity_matrix ); - shader_route_uCamera( cam->transform[3] ); - shader_route_uBoard0( TEMP_BOARD_0 ); - shader_route_uBoard1( TEMP_BOARD_1 ); + shader_scene_route_uPv( cam->mtx.pv ); + shader_scene_route_uPvmPrev( cam->mtx_prev.pv ); + shader_scene_route_uMdl( identity_matrix ); + shader_scene_route_uCamera( cam->transform[3] ); + shader_scene_route_uBoard0( TEMP_BOARD_0 ); + shader_scene_route_uBoard1( TEMP_BOARD_1 ); mesh_bind( &world.mesh_route_lines ); @@ -1160,7 +1163,7 @@ VG_STATIC void render_world_routes( camera *cam ) v3_lerp( (v3f){0.7f,0.7f,0.7f}, route->colour, route->factive, colour ); colour[3] = 1.0f; - shader_route_uColour( colour ); + shader_scene_route_uColour( colour ); mdl_draw_submesh( &route->sm ); } } diff --git a/world_sfd.h b/world_sfd.h index d7aeb55..3fbbe94 100644 --- a/world_sfd.h +++ b/world_sfd.h @@ -7,8 +7,10 @@ #include "world.h" +#if 0 #include "shaders/scoretext.h" #include "shaders/vblend.h" +#endif vg_tex2d tex_scoretext = { .path = "textures/scoretext.qoi", .flags = VG_TEXTURE_CLAMP|VG_TEXTURE_NEAREST }; @@ -104,8 +106,8 @@ VG_STATIC void sfd_update(void) VG_STATIC void bind_terrain_noise(void); VG_STATIC void sfd_render( camera *cam, m4x3f transform ) { +#if 0 mesh_bind( &world.sfd.mesh_display ); - shader_scoretext_use(); shader_scoretext_uTexGarbage(0); shader_scoretext_uTexGradients(1); @@ -147,6 +149,7 @@ VG_STATIC void sfd_render( camera *cam, m4x3f transform ) mesh_bind( &world.sfd.mesh_base ); mesh_draw( &world.sfd.mesh_base ); +#endif } VG_STATIC int world_sfd_test( int argc, const char *argv[] ) @@ -163,7 +166,10 @@ VG_STATIC int world_sfd_test( int argc, const char *argv[] ) VG_STATIC void world_sfd_init(void) { vg_info( "world_sfd_init\n" ); + +#if 0 shader_scoretext_register(); +#endif vg_function_push( (struct vg_cmd){ .name = "sfd", diff --git a/world_water.h b/world_water.h index cd4836a..d2447b5 100644 --- a/world_water.h +++ b/world_water.h @@ -7,8 +7,8 @@ #include "world.h" #include "render.h" -#include "shaders/water.h" -#include "shaders/water_fast.h" +#include "shaders/model_water.h" +#include "shaders/model_water_fast.h" #include "scene.h" vg_tex2d tex_water_surf = { .path = "textures/water_surf.qoi" }; @@ -16,8 +16,8 @@ vg_tex2d tex_water_surf = { .path = "textures/water_surf.qoi" }; VG_STATIC void world_water_init(void) { vg_info( "world_water_init\n" ); - shader_water_register(); - shader_water_fast_register(); + shader_model_water_register(); + shader_model_water_fast_register(); vg_acquire_thread_sync(); { @@ -115,31 +115,31 @@ VG_STATIC void render_water_surface( camera *cam ) if( vg.quality_profile == k_quality_profile_high ) { /* Draw surface */ - shader_water_use(); + shader_model_water_use(); render_fb_bind_texture( gpipeline.fb_water_reflection, 0, 0 ); - shader_water_uTexMain( 0 ); + shader_model_water_uTexMain( 0 ); vg_tex2d_bind( &tex_water_surf, 1 ); - shader_water_uTexDudv( 1 ); - shader_water_uInvRes( (v2f){ + shader_model_water_uTexDudv( 1 ); + shader_model_water_uInvRes( (v2f){ 1.0f / (float)vg.window_x, 1.0f / (float)vg.window_y }); - shader_link_standard_ub( _shader_water.id, 2 ); + shader_link_standard_ub( _shader_model_water.id, 2 ); render_fb_bind_texture( gpipeline.fb_water_beneath, 0, 3 ); - shader_water_uTexBack( 3 ); - shader_water_uTime( world.time ); - shader_water_uCamera( cam->transform[3] ); - shader_water_uSurfaceY( world.water.height ); + shader_model_water_uTexBack( 3 ); + shader_model_water_uTime( world.time ); + shader_model_water_uCamera( cam->transform[3] ); + shader_model_water_uSurfaceY( world.water.height ); - shader_water_uPv( cam->mtx.pv ); - shader_water_uPvmPrev( cam->mtx_prev.pv ); + shader_model_water_uPv( cam->mtx.pv ); + shader_model_water_uPvmPrev( cam->mtx_prev.pv ); m4x3f full; m4x3_identity( full ); - shader_water_uMdl( full ); + shader_model_water_uMdl( full ); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); @@ -153,8 +153,8 @@ VG_STATIC void render_water_surface( camera *cam ) if( mat->info.shader == k_shader_water ) { - shader_water_uShoreColour( mat->info.colour ); - shader_water_uOceanColour( mat->info.colour1 ); + shader_model_water_uShoreColour( mat->info.colour ); + shader_model_water_uOceanColour( mat->info.colour1 ); mdl_draw_submesh( &mat->sm_no_collide ); } @@ -164,20 +164,20 @@ VG_STATIC void render_water_surface( camera *cam ) } else if( vg.quality_profile == k_quality_profile_low ) { - shader_water_fast_use(); + shader_model_water_fast_use(); vg_tex2d_bind( &tex_water_surf, 1 ); - shader_water_fast_uTexDudv( 1 ); - shader_water_fast_uTime( world.time ); - shader_water_fast_uCamera( cam->transform[3] ); - shader_water_fast_uSurfaceY( world.water.height ); - shader_link_standard_ub( _shader_water_fast.id, 2 ); + shader_model_water_fast_uTexDudv( 1 ); + shader_model_water_fast_uTime( world.time ); + shader_model_water_fast_uCamera( cam->transform[3] ); + shader_model_water_fast_uSurfaceY( world.water.height ); + shader_link_standard_ub( _shader_model_water_fast.id, 2 ); m4x3f full; m4x3_identity( full ); - shader_water_fast_uMdl( full ); - shader_water_fast_uPv( cam->mtx.pv ); - shader_water_fast_uPvmPrev( cam->mtx_prev.pv ); + shader_model_water_fast_uMdl( full ); + shader_model_water_fast_uPv( cam->mtx.pv ); + shader_model_water_fast_uPvmPrev( cam->mtx_prev.pv ); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); @@ -191,8 +191,8 @@ VG_STATIC void render_water_surface( camera *cam ) if( mat->info.shader == k_shader_water ) { - shader_water_fast_uShoreColour( mat->info.colour ); - shader_water_fast_uOceanColour( mat->info.colour1 ); + shader_model_water_fast_uShoreColour( mat->info.colour ); + shader_model_water_fast_uOceanColour( mat->info.colour1 ); mdl_draw_submesh( &mat->sm_no_collide ); }