2 * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
6 #include "world_render.h"
10 #include "ent_miniworld.h"
11 #include "player_remote.h"
12 #include "ent_skateshop.h"
14 #include "shaders/model_entity.h"
16 struct world_render world_render
;
18 static int ccmd_set_time( int argc
, const char *argv
[] ){
19 world_instance
*world
= world_current_instance();
21 world
->time
= atof( argv
[0] );
23 vg_error( "Usage set_time <0-1.0> (current time: %f)\n", world
->time
);
27 static void async_world_render_init( void *payload
, u32 size
){
28 vg_info( "Allocate uniform buffers\n" );
29 for( int i
=0; i
<k_world_max
; i
++ ){
30 world_instance
*world
= &world_static
.instances
[i
];
31 world
->ubo_bind_point
= i
;
33 glGenBuffers( 1, &world
->ubo_lighting
);
34 glBindBuffer( GL_UNIFORM_BUFFER
, world
->ubo_lighting
);
35 glBufferData( GL_UNIFORM_BUFFER
, sizeof(struct ub_world_lighting
),
36 NULL
, GL_DYNAMIC_DRAW
);
38 glBindBufferBase( GL_UNIFORM_BUFFER
, i
, world
->ubo_lighting
);
42 vg_info( "Allocate frame buffers\n" );
43 for( int i
=0; i
<k_world_max
; i
++ ){
44 world_instance
*world
= &world_static
.instances
[i
];
45 struct framebuffer
*fb
= &world
->heightmap
;
47 fb
->display_name
= NULL
;
51 fb
->resolution_div
= 0;
53 fb
->attachments
[0].display_name
= NULL
;
54 fb
->attachments
[0].purpose
= k_framebuffer_attachment_type_texture
;
55 fb
->attachments
[0].internalformat
= GL_RG16F
;
56 fb
->attachments
[0].format
= GL_RG
;
57 fb
->attachments
[0].type
= GL_FLOAT
;
58 fb
->attachments
[0].attachment
= GL_COLOR_ATTACHMENT0
;
60 fb
->attachments
[1].purpose
= k_framebuffer_attachment_type_none
;
61 fb
->attachments
[2].purpose
= k_framebuffer_attachment_type_none
;
62 fb
->attachments
[3].purpose
= k_framebuffer_attachment_type_none
;
63 fb
->attachments
[4].purpose
= k_framebuffer_attachment_type_none
;
65 render_fb_allocate( fb
);
69 void world_render_init(void)
71 VG_VAR_F32( k_day_length
);
72 VG_VAR_I32( k_debug_light_indices
);
73 VG_VAR_I32( k_debug_light_complexity
);
74 VG_VAR_I32( k_light_preview
);
75 VG_VAR_I32( k_light_editor
);
76 vg_console_reg_cmd( "set_time", ccmd_set_time
, NULL
);
78 world_render
.sky_rate
= 1.0;
79 world_render
.sky_target_rate
= 1.0;
81 vg_info( "Loading world resources\n" );
82 vg_linear_clear( vg_mem
.scratch
);
85 mdl_open( &msky
, "models/rs_skydome.mdl", vg_mem
.scratch
);
86 mdl_load_metadata_block( &msky
, vg_mem
.scratch
);
87 mdl_async_load_glmesh( &msky
, &world_render
.skydome
, NULL
);
90 vg_info( "Loading default world textures\n" );
91 vg_tex2d_load_qoi_async_file( "textures/garbage.qoi",
92 VG_TEX2D_NEAREST
|VG_TEX2D_REPEAT
,
93 &world_render
.tex_terrain_noise
);
95 vg_async_call( async_world_render_init
, NULL
, 0 );
99 * standard uniform bindings
100 * ----------------------------------------------------------------------------
102 void world_link_lighting_ub( world_instance
*world
, GLuint shader
)
104 GLuint idx
= glGetUniformBlockIndex( shader
, "ub_world_lighting" );
105 glUniformBlockBinding( shader
, idx
, world
->ubo_bind_point
);
108 void world_bind_position_texture( world_instance
*world
,
109 GLuint shader
, GLuint location
,
112 render_fb_bind_texture( &world
->heightmap
, 0, slot
);
113 glUniform1i( location
, slot
);
116 void world_bind_light_array( world_instance
*world
,
117 GLuint shader
, GLuint location
,
120 glActiveTexture( GL_TEXTURE0
+ slot
);
121 glBindTexture( GL_TEXTURE_BUFFER
, world
->tex_light_entities
);
122 glUniform1i( location
, slot
);
125 void world_bind_light_index( world_instance
*world
,
126 GLuint shader
, GLuint location
,
129 glActiveTexture( GL_TEXTURE0
+ slot
);
130 glBindTexture( GL_TEXTURE_3D
, world
->tex_light_cubes
);
131 glUniform1i( location
, slot
);
134 void bind_terrain_noise(void)
136 glActiveTexture( GL_TEXTURE0
);
137 glBindTexture( GL_TEXTURE_2D
, world_render
.tex_terrain_noise
);
141 * Get OpenGL texture name from texture ID.
143 static GLuint
world_get_texture( world_instance
*world
, u32 id
){
144 if( id
& 0x80000000 ) return skaterift
.rt_textures
[id
& ~0x80000000];
145 else return world
->textures
[ id
];
150 * ----------------------------------------------------------------------------
156 enum mdl_shader shader
;
157 enum world_geo_type geo_type
;
159 void (*fn_bind
)( world_instance
*world
, struct world_surface
*mat
);
160 void (*fn_set_mdl
)( m4x3f mdl
);
161 void (*fn_set_uPvmPrev
)( m4x4f pvm
);
162 void (*fn_set_uNormalMtx
)( m3x3f mnorm
);
165 void render_world_depth( world_instance
*world
, vg_camera
*cam
);
168 * Render a run of submeshes, only of those which match material_id
170 static void world_render_submeshes( world_instance
*world
,
171 struct world_pass
*pass
,
172 mdl_transform
*transform
,
173 u32 start
, u32 count
, u32 material_id
)
175 for( u32 k
=0; k
<count
; k
++ )
177 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
, start
+k
);
178 if( sm
->material_id
!= material_id
)
182 mdl_transform_m4x3( transform
, mmdl
);
185 m4x3_expand( mmdl
, m4mdl
);
186 m4x4_mul( pass
->cam
->mtx_prev
.pv
, m4mdl
, m4mdl
);
188 pass
->fn_set_mdl( mmdl
);
189 pass
->fn_set_uPvmPrev( m4mdl
);
191 mdl_draw_submesh( sm
);
196 * Render props attached to this material
198 static void world_render_props( world_instance
*world
, u32 material_id
,
199 struct world_pass
*pass
)
201 struct world_surface
*mat
= &world
->surfaces
[ material_id
];
202 if( !(mat
->flags
& WORLD_SURFACE_HAS_PROPS
) ) return;
204 pass
->fn_bind( world
, mat
);
206 for( u32 j
=0; j
<mdl_arrcount( &world
->ent_prop
); j
++ ){
207 ent_prop
*prop
= mdl_arritm( &world
->ent_prop
, j
);
208 if( prop
->flags
& 0x1 ) continue;
210 world_render_submeshes( world
, pass
, &prop
->transform
,
211 prop
->submesh_start
, prop
->submesh_count
, material_id
);
216 * Render traffic models attactched to this material
218 static void world_render_traffic( world_instance
*world
, u32 material_id
,
219 struct world_pass
*pass
)
221 struct world_surface
*mat
= &world
->surfaces
[ material_id
];
222 if( !(mat
->flags
& WORLD_SURFACE_HAS_TRAFFIC
) ) return;
224 pass
->fn_bind( world
, mat
);
226 for( u32 j
=0; j
<mdl_arrcount( &world
->ent_traffic
); j
++ ){
227 ent_traffic
*traffic
= mdl_arritm( &world
->ent_traffic
, j
);
229 world_render_submeshes( world
, pass
, &traffic
->transform
,
230 traffic
->submesh_start
, traffic
->submesh_count
,
236 * Iterate and render all materials which match the passes shader and geometry
237 * type. Includes props/traffic.
239 static void world_render_pass( world_instance
*world
, struct world_pass
*pass
)
241 for( int i
=0; i
<world
->surface_count
; i
++ )
243 struct world_surface
*mat
= &world
->surfaces
[i
];
245 if( mat
->info
.shader
== pass
->shader
)
249 if( pass
->geo_type
== k_world_geo_type_solid
)
255 world_render_traffic( world
, i
, pass
);
256 world_render_props( world
, i
, pass
);
257 sm
= &mat
->sm_no_collide
;
260 if( !sm
->indice_count
)
264 m4x3_identity( mmdl
);
265 pass
->fn_set_mdl( mmdl
);
266 pass
->fn_set_uPvmPrev( pass
->cam
->mtx_prev
.pv
);
267 pass
->fn_bind( world
, mat
);
268 mdl_draw_submesh( sm
);
274 * Specific shader instructions
275 * ----------------------------------------------------------------------------
278 static void world_render_both_stages( world_instance
*world
,
279 struct world_pass
*pass
)
281 mesh_bind( &world
->mesh_geo
);
282 pass
->geo_type
= k_world_geo_type_solid
;
283 world_render_pass( world
, pass
);
285 glDisable( GL_CULL_FACE
);
286 mesh_bind( &world
->mesh_no_collide
);
287 pass
->geo_type
= k_world_geo_type_nonsolid
;
288 world_render_pass( world
, pass
);
289 glEnable( GL_CULL_FACE
);
292 static void bindpoint_world_vb( world_instance
*world
,
293 struct world_surface
*mat
)
295 struct shader_props_vertex_blend
*props
= mat
->info
.props
.compiled
;
297 glActiveTexture( GL_TEXTURE1
);
298 glBindTexture( GL_TEXTURE_2D
, world_get_texture(world
, props
->tex_diffuse
) );
301 shader_scene_vertex_blend_uOffset( props
->blend_offset
);
305 static void render_world_vb( world_instance
*world
, vg_camera
*cam
)
307 shader_scene_vertex_blend_use();
308 shader_scene_vertex_blend_uTexGarbage(0);
309 shader_scene_vertex_blend_uTexGradients(1);
310 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_vertex_blend
);
312 glActiveTexture( GL_TEXTURE0
);
313 glBindTexture( GL_TEXTURE_2D
, world_render
.tex_terrain_noise
);
315 shader_scene_vertex_blend_uPv( cam
->mtx
.pv
);
316 shader_scene_vertex_blend_uCamera( cam
->transform
[3] );
318 struct world_pass pass
=
320 .shader
= k_shader_standard_vertex_blend
,
322 .fn_bind
= bindpoint_world_vb
,
323 .fn_set_mdl
= shader_scene_vertex_blend_uMdl
,
324 .fn_set_uPvmPrev
= shader_scene_vertex_blend_uPvmPrev
,
327 world_render_both_stages( world
, &pass
);
330 static void world_shader_standard_bind( world_instance
*world
, vg_camera
*cam
)
332 shader_scene_standard_use();
333 shader_scene_standard_uTexGarbage(0);
334 shader_scene_standard_uTexMain(1);
335 shader_scene_standard_uPv( cam
->mtx
.pv
);
336 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_standard
);
338 bind_terrain_noise();
339 shader_scene_standard_uCamera( cam
->transform
[3] );
342 static void bindpoint_standard( world_instance
*world
,
343 struct world_surface
*mat
)
345 struct shader_props_standard
*props
= mat
->info
.props
.compiled
;
347 glActiveTexture( GL_TEXTURE1
);
348 glBindTexture( GL_TEXTURE_2D
, world_get_texture(world
, props
->tex_diffuse
) );
351 static void render_world_standard( world_instance
*world
, vg_camera
*cam
)
353 world_shader_standard_bind( world
, cam
);
354 struct world_pass pass
=
356 .shader
= k_shader_standard
,
358 .fn_bind
= bindpoint_standard
,
359 .fn_set_mdl
= shader_scene_standard_uMdl
,
360 .fn_set_uPvmPrev
= shader_scene_standard_uPvmPrev
,
363 world_render_both_stages( world
, &pass
);
366 static void bindpoint_world_cubemapped( world_instance
*world
,
367 struct world_surface
*mat
)
369 struct shader_props_cubemapped
*props
= mat
->info
.props
.compiled
;
371 glActiveTexture( GL_TEXTURE1
);
372 glBindTexture( GL_TEXTURE_2D
,
373 world_get_texture( world
,props
->tex_diffuse
) );
375 u32 cubemap_id
= props
->cubemap_entity
,
378 if( mdl_entity_id_type( cubemap_id
) == k_ent_cubemap
)
380 cubemap_index
= mdl_entity_id_id( cubemap_id
);
383 ent_cubemap
*cm
= mdl_arritm( &world
->ent_cubemap
, cubemap_index
);
384 glActiveTexture( GL_TEXTURE10
);
385 glBindTexture( GL_TEXTURE_CUBE_MAP
, cm
->texture_id
);
387 shader_scene_cubemapped_uColour( props
->tint
);
390 static void bindpoint_world_cubemapped_disabled( world_instance
*world
,
391 struct world_surface
*mat
)
393 struct shader_props_cubemapped
*props
= mat
->info
.props
.compiled
;
395 glActiveTexture( GL_TEXTURE1
);
396 glBindTexture( GL_TEXTURE_2D
,
397 world_get_texture( world
, props
->tex_diffuse
) );
400 static void render_world_cubemapped( world_instance
*world
, vg_camera
*cam
,
403 if( !mdl_arrcount( &world
->ent_cubemap
) )
408 world_shader_standard_bind( world
, cam
);
410 struct world_pass pass
=
412 .shader
= k_shader_cubemap
,
414 .fn_bind
= bindpoint_world_cubemapped_disabled
,
415 .fn_set_mdl
= shader_scene_standard_uMdl
,
416 .fn_set_uPvmPrev
= shader_scene_standard_uPvmPrev
,
419 world_render_both_stages( world
, &pass
);
423 shader_scene_cubemapped_use();
424 shader_scene_cubemapped_uTexGarbage(0);
425 shader_scene_cubemapped_uTexMain(1);
426 shader_scene_cubemapped_uTexCubemap(10);
427 shader_scene_cubemapped_uPv( cam
->mtx
.pv
);
429 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_cubemapped
);
431 bind_terrain_noise();
432 shader_scene_cubemapped_uCamera( cam
->transform
[3] );
434 struct world_pass pass
=
436 .shader
= k_shader_cubemap
,
438 .fn_bind
= bindpoint_world_cubemapped
,
439 .fn_set_mdl
= shader_scene_cubemapped_uMdl
,
440 .fn_set_uPvmPrev
= shader_scene_cubemapped_uPvmPrev
,
443 world_render_both_stages( world
, &pass
);
447 static void render_world_alphatest( world_instance
*world
, vg_camera
*cam
)
449 shader_scene_standard_alphatest_use();
450 shader_scene_standard_alphatest_uTexGarbage(0);
451 shader_scene_standard_alphatest_uTexMain(1);
452 shader_scene_standard_alphatest_uPv( cam
->mtx
.pv
);
454 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_standard_alphatest
);
456 bind_terrain_noise();
457 shader_scene_standard_alphatest_uCamera( cam
->transform
[3] );
458 glDisable(GL_CULL_FACE
);
460 struct world_pass pass
=
462 .shader
= k_shader_standard_cutout
,
464 .fn_bind
= bindpoint_standard
,
465 .fn_set_mdl
= shader_scene_standard_alphatest_uMdl
,
466 .fn_set_uPvmPrev
= shader_scene_standard_alphatest_uPvmPrev
,
469 world_render_both_stages( world
, &pass
);
470 glEnable(GL_CULL_FACE
);
473 static void render_world_foliage( world_instance
*world
, vg_camera
*cam
)
475 shader_scene_foliage_use();
476 shader_scene_foliage_uTexGarbage(0);
477 shader_scene_foliage_uTexMain(1);
478 shader_scene_foliage_uPv( cam
->mtx
.pv
);
479 shader_scene_foliage_uTime( vg
.time
);
481 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_foliage
);
482 bind_terrain_noise();
484 shader_scene_foliage_uCamera( cam
->transform
[3] );
485 glDisable(GL_CULL_FACE
);
486 struct world_pass pass
=
488 .shader
= k_shader_foliage
,
490 .fn_bind
= bindpoint_standard
,
491 .fn_set_mdl
= shader_scene_foliage_uMdl
,
492 .fn_set_uPvmPrev
= shader_scene_foliage_uPvmPrev
,
494 world_render_both_stages( world
, &pass
);
495 glEnable(GL_CULL_FACE
);
498 static void world_render_challenges( world_instance
*world
,
499 struct world_pass
*pass
, v3f pos
)
502 if( skaterift
.activity
== k_skaterift_replay
) return;
503 if( world
!= world_current_instance() ) return;
508 u32 objective_list
[ 32 ],
509 challenge_list
[ 16 ];
511 v2f objective_uv_offsets
[ 32 ];
513 u32 objective_count
= 0,
516 ent_challenge
*active_challenge
= NULL
;
518 if( mdl_entity_id_type( world_static
.focused_entity
) == k_ent_challenge
){
519 if( (skaterift
.activity
== k_skaterift_default
) &&
520 world_static
.challenge_target
){
524 if( !((skaterift
.activity
!= k_skaterift_ent_focus
) &&
525 !world_static
.challenge_target
) ){
526 world_instance
*challenge_world
= world_current_instance();
527 u32 index
= mdl_entity_id_id( world_static
.focused_entity
);
528 active_challenge
= mdl_arritm(&challenge_world
->ent_challenge
, index
);
532 if( active_challenge
){
533 shader_scene_fxglow_uUvOffset( (v2f
){ 8.0f
/256.0f
, 0.0f
} );
534 challenge_list
[ challenge_count
++ ] = world_static
.focused_entity
;
536 u32 next
= active_challenge
->first
;
537 while( mdl_entity_id_type(next
) == k_ent_objective
){
538 u32 index
= mdl_entity_id_id( next
);
539 objective_list
[ objective_count
++ ] = index
;
541 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
542 next
= objective
->id_next
;
548 shader_scene_fxglow_uUvOffset( (v2f
){ 0.0f
, 0.0f
} );
550 bh_iter_init_range( 0, &it
, pos
, radius
+10.0f
);
552 while( bh_next( world
->entity_bh
, &it
, &idx
) ){
553 u32 id
= world
->entity_list
[ idx
],
554 type
= mdl_entity_id_type( id
),
555 index
= mdl_entity_id_id( id
);
557 if( type
== k_ent_objective
) {
558 if( objective_count
< vg_list_size(objective_list
) )
559 objective_list
[ objective_count
++ ] = index
;
561 else if( type
== k_ent_challenge
){
562 if( challenge_count
< vg_list_size(challenge_list
) )
563 challenge_list
[ challenge_count
++ ] = index
;
568 /* render objectives */
569 glDisable( GL_CULL_FACE
);
570 mesh_bind( &world
->mesh_no_collide
);
571 u32 last_material
= 0;
572 for( u32 i
=0; i
<objective_count
; i
++ )
574 u32 index
= objective_list
[ i
];
575 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
576 if( (objective
->flags
& k_ent_objective_hidden
) &&
577 !active_challenge
) continue;
583 u32 passed
= objective
->flags
& k_ent_objective_passed
;
584 f32 target
= passed
? 0.0f
: 1.0f
;
585 vg_slewf(&objective
->transform
.s
[0], target
, vg
.time_frame_delta
*4.0f
);
586 scale
= vg_smoothstepf( objective
->transform
.s
[0] );
588 if( (objective
== world_static
.challenge_target
) || passed
)
589 shader_scene_fxglow_uUvOffset( (v2f
){ 16.0f
/256.0f
, 0.0f
} );
591 shader_scene_fxglow_uUvOffset( (v2f
){ 8.0f
/256.0f
, 0.0f
} );
595 f32 dist
= v3_dist( objective
->transform
.co
, pos
) * (1.0f
/radius
);
596 scale
= vg_smoothstepf( vg_clampf( 5.0f
-dist
*5.0f
, 0.0f
,1.0f
) );
600 q_m3x3( objective
->transform
.q
, mmdl
);
601 m3x3_scalef( mmdl
, scale
);
602 v3_copy( objective
->transform
.co
, mmdl
[3] );
603 shader_scene_fxglow_uMdl( mmdl
);
605 for( u32 j
=0; j
<objective
->submesh_count
; j
++ )
607 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
,
608 objective
->submesh_start
+ j
);
610 if( sm
->material_id
!= last_material
)
612 last_material
= sm
->material_id
;
613 pass
->fn_bind( world
, &world
->surfaces
[sm
->material_id
] );
615 mdl_draw_submesh( sm
);
620 font3d_bind( &gui
.font
, k_font_shader_world
, 0, world
, &skaterift
.cam
);
624 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_challenge
); i
++ )
626 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, i
);
627 if( challenge
->status
) count
++;
632 vg_strnull( &str
, buf
, sizeof(buf
) );
633 vg_strcati32( &str
, count
);
634 vg_strcatch( &str
, '/' );
635 vg_strcati32( &str
, mdl_arrcount(&world
->ent_challenge
) );
637 f32 w
= font3d_string_width( 1, buf
);
639 m3x3_identity( mlocal
);
640 mlocal
[3][0] = -w
*0.5f
;
644 for( u32 i
=0; i
<challenge_count
; i
++ )
646 u32 index
= challenge_list
[ i
];
647 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
649 mdl_transform_m4x3( &challenge
->transform
, mmdl
);
650 m4x3_mul( mmdl
, mlocal
, mmdl
);
652 vg_line_point( challenge
->transform
.co
, 0.25f
, VG__RED
);
654 f32 dist
= v3_dist( challenge
->transform
.co
, pos
) * (1.0f
/radius
),
655 scale
= vg_smoothstepf( vg_clampf( 10.0f
-dist
*10.0f
, 0.0f
,1.0f
) ),
658 if( challenge
->status
)
661 shader_scene_font_uOpacity( scale
);
662 shader_scene_font_uColourize( colour
);
663 font3d_simple_draw( 1, buf
, &skaterift
.cam
, mmdl
);
667 static void bindpoint_fxglow( world_instance
*world
,
668 struct world_surface
*mat
)
670 struct shader_props_standard
*props
= mat
->info
.props
.compiled
;
672 glActiveTexture( GL_TEXTURE1
);
673 glBindTexture( GL_TEXTURE_2D
, world_get_texture(world
, props
->tex_diffuse
) );
676 static void render_world_fxglow( world_instance
*host_world
,
677 world_instance
*world
, vg_camera
*cam
,
679 int generic
, int challenges
, int regions
)
681 shader_scene_fxglow_use();
682 shader_scene_fxglow_uUvOffset( (v2f
){ 0.0f
, 0.0f
} );
683 shader_scene_fxglow_uTexMain(1);
684 shader_scene_fxglow_uPv( cam
->mtx
.pv
);
685 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_fxglow
);
687 shader_scene_fxglow_uCamera( cam
->transform
[3] );
688 glDisable(GL_CULL_FACE
);
690 struct world_pass pass
=
692 .shader
= k_shader_fxglow
,
694 .fn_bind
= bindpoint_fxglow
,
695 .fn_set_mdl
= shader_scene_fxglow_uMdl
,
696 .fn_set_uPvmPrev
= shader_scene_fxglow_uPvmPrev
,
700 world_render_both_stages( world
, &pass
);
703 mesh_bind( &world
->mesh_no_collide
);
705 u32 last_material
= 0;
706 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_region
); i
++ ){
707 shader_scene_fxglow_uUvOffset( (v2f
){ 0.0f
, 0.0f
} );
708 ent_region
*region
= mdl_arritm( &world
->ent_region
, i
);
711 if( region
->flags
& k_ent_route_flag_achieve_gold
)
713 else if( region
->flags
& k_ent_route_flag_achieve_silver
)
716 shader_scene_fxglow_uUvOffset( (v2f
){ (8.0f
/256.0f
)*offset
, 0.0f
} );
719 mdl_transform_m4x3( ®ion
->transform
, mmdl
);
720 m4x3_mul( world_mmdl
, mmdl
, mmdl
);
721 shader_scene_fxglow_uMdl( mmdl
);
723 for( u32 j
=0; j
<region
->submesh_count
; j
++ )
725 mdl_submesh
*sm
= mdl_arritm( &world
->meta
.submeshs
,
726 region
->submesh_start
+ j
);
728 if( sm
->material_id
!= last_material
)
730 last_material
= sm
->material_id
;
731 pass
.fn_bind( world
, &world
->surfaces
[sm
->material_id
] );
733 mdl_draw_submesh( sm
);
739 world_render_challenges( world
, &pass
, cam
->pos
);
741 glEnable(GL_CULL_FACE
);
744 static void bindpoint_terrain( world_instance
*world
,
745 struct world_surface
*mat
)
747 struct shader_props_terrain
*props
= mat
->info
.props
.compiled
;
749 glActiveTexture( GL_TEXTURE1
);
750 glBindTexture( GL_TEXTURE_2D
, world_get_texture(world
, props
->tex_diffuse
) );
751 shader_scene_terrain_uBlendOffset( props
->blend_offset
);
752 shader_scene_terrain_uSandColour( props
->sand_colour
);
755 static void bindpoint_override( world_instance
*world
,
756 struct world_surface
*mat
)
758 if( mat
->info
.flags
& k_material_flag_collision
)
760 shader_scene_override_uAlphatest(0);
764 glActiveTexture( GL_TEXTURE1
);
765 glBindTexture( GL_TEXTURE_2D
, world_get_texture(world
, mat
->alpha_tex
) );
766 shader_scene_override_uAlphatest(1);
770 static void render_terrain( world_instance
*world
, vg_camera
*cam
)
772 shader_scene_terrain_use();
773 shader_scene_terrain_uTexGarbage(0);
774 shader_scene_terrain_uTexGradients(1);
776 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, scene_terrain
);
777 glActiveTexture( GL_TEXTURE0
);
778 glBindTexture( GL_TEXTURE_2D
, world_render
.tex_terrain_noise
);
780 shader_scene_terrain_uPv( cam
->mtx
.pv
);
781 shader_scene_terrain_uCamera( cam
->transform
[3] );
783 struct world_pass pass
=
785 .shader
= k_shader_terrain_blend
,
787 .fn_bind
= bindpoint_terrain
,
788 .fn_set_mdl
= shader_scene_terrain_uMdl
,
789 .fn_set_uPvmPrev
= shader_scene_terrain_uPvmPrev
,
792 world_render_both_stages( world
, &pass
);
795 static void render_sky( world_instance
*world
, vg_camera
*cam
)
798 * Modify matrix to remove clipping and view translation
805 m4x4_copy( cam
->mtx
.v
, v
);
806 m4x4_copy( cam
->mtx_prev
.v
, v_prev
);
808 for( int i
=0; i
<3; i
++ ){
810 v3_normalize(v_prev
[i
]);
813 v3_zero( v_prev
[3] );
815 m4x4_copy( cam
->mtx
.p
, pv
);
816 m4x4_copy( cam
->mtx_prev
.p
, pv_prev
);
817 m4x4_reset_clipping( pv
, 100.0f
, 0.1f
);
818 m4x4_reset_clipping( pv_prev
, 100.0f
, 0.1f
);
820 m4x4_mul( pv
, v
, pv
);
821 m4x4_mul( pv_prev
, v_prev
, pv_prev
);
823 m4x3f identity_matrix
;
824 m4x3_identity( identity_matrix
);
829 if( world
->skybox
== k_skybox_default
){
830 shader_model_sky_use();
831 shader_model_sky_uMdl( identity_matrix
);
832 shader_model_sky_uPv( pv
);
833 shader_model_sky_uPvmPrev( pv_prev
);
834 shader_model_sky_uTexGarbage(0);
835 world_link_lighting_ub( world
, _shader_model_sky
.id
);
837 glActiveTexture( GL_TEXTURE0
);
838 glBindTexture( GL_TEXTURE_2D
, world_render
.tex_terrain_noise
);
840 else if( world
->skybox
== k_skybox_space
){
841 shader_model_sky_space_use();
843 shader_model_sky_space_uMdl( identity_matrix
);
844 shader_model_sky_space_uPv( pv
);
845 shader_model_sky_space_uPvmPrev( pv_prev
);
846 shader_model_sky_space_uTexGarbage(0);
847 world_link_lighting_ub( world
, _shader_model_sky_space
.id
);
849 glActiveTexture( GL_TEXTURE0
);
850 glBindTexture( GL_TEXTURE_2D
, world_render
.tex_terrain_noise
);
853 vg_fatal_error( "Programming error\n" );
856 glDepthMask( GL_FALSE
);
857 glDisable( GL_DEPTH_TEST
);
859 mesh_bind( &world_render
.skydome
);
860 mesh_draw( &world_render
.skydome
);
862 glEnable( GL_DEPTH_TEST
);
863 glDepthMask( GL_TRUE
);
866 void render_world_gates( world_instance
*world
, vg_camera
*cam
)
868 float closest
= INFINITY
;
869 struct ent_gate
*gate
= NULL
;
871 for( u32 i
=0; i
<mdl_arrcount(&world
->ent_gate
); i
++ ){
872 ent_gate
*gi
= mdl_arritm( &world
->ent_gate
, i
);
874 if( !(gi
->flags
& k_ent_gate_nonlocal
) )
875 if( !(gi
->flags
& k_ent_gate_linked
) )
878 float dist
= v3_dist2( gi
->co
[0], cam
->transform
[3] );
880 vg_line_point( gi
->co
[0], 0.25f
, VG__BLUE
);
882 if( dist
< closest
){
888 world
->rendering_gate
= gate
;
891 if( gate
->flags
& k_ent_gate_locked
){
892 world
->rendering_gate
= NULL
;
896 if( gate
->flags
& k_ent_gate_nonlocal
){
897 if( !(gate
->flags
& k_ent_gate_linked
) ||
898 (world_static
.load_state
!= k_world_loader_none
) ){
899 world
->rendering_gate
= NULL
;
900 render_gate_unlinked( world
, gate
, cam
);
904 world_instance
*dest_world
= &world_static
.instances
[ gate
->target
];
905 render_gate( world
, dest_world
, gate
, cam
);
908 render_gate( world
, world
, gate
, cam
);
912 void world_prerender( world_instance
*world
)
914 if( mdl_arrcount( &world
->ent_light
) ){
915 f32 rate
= vg_maxf(0.1f
, fabsf(k_day_length
)) * vg_signf(k_day_length
);
916 world
->time
+= vg
.time_frame_delta
* (1.0/(rate
*60.0));
922 if( world
->info
.flags
& 0x1 ){
923 world
->time
= world
->info
.timezone
;
926 struct ub_world_lighting
*state
= &world
->ub_lighting
;
928 state
->g_time
= world
->time
;
929 state
->g_realtime
= vg
.time_real
;
930 state
->g_debug_indices
= k_debug_light_indices
;
931 state
->g_light_preview
= k_light_preview
;
932 state
->g_debug_complexity
= k_debug_light_complexity
;
933 state
->g_time_of_day
= vg_fractf( world
->time
);
935 if( vg
.quality_profile
== k_quality_profile_high
)
936 state
->g_shadow_samples
= 8;
937 else if( vg
.quality_profile
== k_quality_profile_low
)
938 state
->g_shadow_samples
= 2;
940 state
->g_shadow_samples
= 0;
942 state
->g_day_phase
= cosf( state
->g_time_of_day
* VG_PIf
* 2.0f
);
943 state
->g_sunset_phase
= cosf( state
->g_time_of_day
* VG_PIf
* 4.0f
+ VG_PIf
);
945 state
->g_day_phase
= state
->g_day_phase
* 0.5f
+ 0.5f
;
946 state
->g_sunset_phase
= powf( state
->g_sunset_phase
* 0.5f
+ 0.5f
, 6.0f
);
948 float a
= state
->g_time_of_day
* VG_PIf
* 2.0f
;
949 state
->g_sun_dir
[0] = sinf( a
);
950 state
->g_sun_dir
[1] = cosf( a
);
951 state
->g_sun_dir
[2] = 0.2f
;
952 v3_normalize( state
->g_sun_dir
);
954 world
->probabilities
[ k_probability_curve_constant
] = 1.0f
;
955 float dp
= state
->g_day_phase
;
957 world
->probabilities
[ k_probability_curve_wildlife_day
] =
958 (dp
*dp
*0.8f
+state
->g_sunset_phase
)*0.8f
;
959 world
->probabilities
[ k_probability_curve_wildlife_night
] =
960 1.0f
-powf(fabsf((state
->g_time_of_day
-0.5f
)*5.0f
),5.0f
);
962 glBindBuffer( GL_UNIFORM_BUFFER
, world
->ubo_lighting
);
963 glBufferSubData( GL_UNIFORM_BUFFER
, 0,
964 sizeof(struct ub_world_lighting
), &world
->ub_lighting
);
967 static void render_other_entities( world_instance
*world
, vg_camera
*cam
)
971 bh_iter_init_range( 0, &it
, cam
->pos
, radius
+10.0f
);
979 while( bh_next( world
->entity_bh
, &it
, &idx
) ){
980 u32 id
= world
->entity_list
[ idx
],
981 type
= mdl_entity_id_type( id
),
982 index
= mdl_entity_id_id( id
);
984 if( type
== k_ent_glider
)
986 if( glider_count
< vg_list_size(glider_list
) )
987 glider_list
[ glider_count
++ ] = index
;
989 else if( type
== k_ent_npc
)
991 if( npc_count
< vg_list_size(npc_list
) )
992 npc_list
[ npc_count
++ ] = index
;
996 shader_model_entity_use();
997 shader_model_entity_uTexMain( 0 );
998 shader_model_entity_uCamera( cam
->transform
[3] );
999 shader_model_entity_uPv( cam
->mtx
.pv
);
1000 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( world
, model_entity
);
1002 for( u32 j
=0; j
<glider_count
; j
++ )
1004 ent_glider
*glider
= mdl_arritm( &world
->ent_glider
, glider_list
[j
] );
1006 if( !(glider
->flags
& 0x1) )
1010 mdl_transform_m4x3( &glider
->transform
, mdl
);
1012 f32 dist
= v3_dist( glider
->transform
.co
, cam
->pos
) * (1.0f
/radius
),
1013 scale
= vg_smoothstepf( vg_clampf( 5.0f
-dist
*5.0f
, 0.0f
,1.0f
) );
1014 m3x3_scalef( mdl
, scale
);
1016 render_glider_model( cam
, world
, mdl
, k_board_shader_entity
);
1019 for( u32 j
=0; j
<npc_count
; j
++ )
1021 u32 index
= npc_list
[j
];
1022 ent_npc
*npc
= mdl_arritm( &world
->ent_npc
, npc_list
[j
] );
1024 npc_render( npc
, world
, cam
);
1028 void render_world( world_instance
*world
, vg_camera
*cam
,
1029 int stenciled
, int viewing_from_gate
,
1030 int with_water
, int with_cubemaps
)
1033 glClear( GL_DEPTH_BUFFER_BIT
);
1034 glStencilFunc( GL_EQUAL
, 1, 0xFF );
1035 glStencilMask( 0x00 );
1036 glEnable( GL_CULL_FACE
);
1037 glEnable( GL_STENCIL_TEST
);
1040 glStencilMask( 0xFF );
1041 glStencilFunc( GL_ALWAYS
, 1, 0xFF );
1042 glDisable( GL_STENCIL_TEST
);
1045 render_sky( world
, cam
);
1048 m4x3_identity(identity
);
1049 render_world_routes( world
, world
, identity
, cam
, viewing_from_gate
, 0 );
1050 render_world_standard( world
, cam
);
1051 render_world_cubemapped( world
, cam
, with_cubemaps
);
1053 render_world_vb( world
, cam
);
1054 render_world_alphatest( world
, cam
);
1055 render_world_foliage( world
, cam
);
1056 render_terrain( world
, cam
);
1058 if( !viewing_from_gate
){
1059 world_entity_focus_render();
1063 float min_dist
= INFINITY
;
1065 if( mdl_arrcount( &world
->ent_route
) ){
1066 for( u32 i
=0; i
<mdl_arrcount( &world
->ent_route
); i
++ ){
1067 ent_route
*route
= mdl_arritm( &world
->ent_route
, i
);
1068 float dist
= v3_dist2( route
->board_transform
[3], cam
->pos
);
1070 if( dist
< min_dist
){
1076 ent_route
*route
= mdl_arritm( &world
->ent_route
, closest
);
1077 sfd_render( world
, cam
, route
->board_transform
);
1081 if( !viewing_from_gate
){
1083 if( mdl_entity_id_type(world_static
.focused_entity
) == k_ent_challenge
)
1084 greyout
= world_static
.focus_strength
;
1086 if( greyout
> 0.0f
){
1087 glDrawBuffers( 1, (GLenum
[]){ GL_COLOR_ATTACHMENT0
} );
1089 glDisable(GL_DEPTH_TEST
);
1090 glDepthMask(GL_FALSE
);
1091 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
1092 glBlendEquation(GL_FUNC_ADD
);
1094 shader_blitcolour_use();
1095 shader_blitcolour_uColour( (v4f
){ 0.5f
, 0.5f
, 0.5f
, greyout
*0.56f
} );
1098 glDisable(GL_BLEND
);
1099 glEnable(GL_DEPTH_TEST
);
1100 glDepthMask(GL_TRUE
);
1101 glDrawBuffers( 2, (GLenum
[]){ GL_COLOR_ATTACHMENT0
,
1102 GL_COLOR_ATTACHMENT1
} );
1105 render_world_fxglow( world
, world
, cam
, NULL
, 1, 1, 0 );
1109 render_water_texture( world
, cam
);
1110 render_fb_bind( gpipeline
.fb_main
, 1 );
1114 glStencilFunc( GL_EQUAL
, 1, 0xFF );
1115 glStencilMask( 0x00 );
1116 glEnable( GL_CULL_FACE
);
1117 glEnable( GL_STENCIL_TEST
);
1121 render_water_surface( world
, cam
);
1124 render_remote_players( world
, cam
);
1125 render_other_entities( world
, cam
);
1126 ent_miniworld_render( world
, cam
);
1129 glStencilMask( 0xFF );
1130 glStencilFunc( GL_ALWAYS
, 1, 0xFF );
1131 glDisable( GL_STENCIL_TEST
);
1136 static void render_world_override_pass( world_instance
*world
,
1137 struct world_pass
*pass
,
1138 m4x3f mmdl
, m3x3f mnormal
,
1141 for( int i
=0; i
<world
->surface_count
; i
++ )
1143 struct world_surface
*mat
= &world
->surfaces
[i
];
1144 if( mat
->info
.flags
& k_material_flag_ghosts
) continue;
1147 if( pass
->geo_type
== k_world_geo_type_solid
)
1150 sm
= &mat
->sm_no_collide
;
1152 if( !sm
->indice_count
)
1155 pass
->fn_set_mdl( mmdl
);
1156 pass
->fn_set_uNormalMtx( mnormal
);
1157 pass
->fn_set_uPvmPrev( mpvm_prev
);
1158 pass
->fn_bind( world
, mat
);
1159 mdl_draw_submesh( sm
);
1163 void render_world_override( world_instance
*world
,
1164 world_instance
*lighting_source
,
1167 ent_spawn
*dest_spawn
, v4f map_info
)
1169 struct world_pass pass
=
1172 .fn_bind
= bindpoint_override
,
1173 .fn_set_mdl
= shader_scene_override_uMdl
,
1174 .fn_set_uPvmPrev
= shader_scene_override_uPvmPrev
,
1175 .fn_set_uNormalMtx
= shader_scene_override_uNormalMtx
,
1176 .shader
= k_shader_override
1179 shader_scene_override_use();
1180 shader_scene_override_uTexGarbage(0);
1181 shader_scene_override_uTexMain(1);
1182 shader_scene_override_uPv( pass
.cam
->mtx
.pv
);
1183 shader_scene_override_uMapInfo( map_info
);
1185 WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( lighting_source
, scene_override
);
1186 bind_terrain_noise();
1188 shader_scene_override_uCamera( pass
.cam
->transform
[3] );
1191 m4x3_expand( mmdl
, mpvm_prev
);
1192 m4x4_mul( cam
->mtx_prev
.pv
, mpvm_prev
, mpvm_prev
);
1195 m3x3_inv( mmdl
, mnormal
);
1196 m3x3_transpose( mnormal
, mnormal
);
1197 v3_normalize( mnormal
[0] );
1198 v3_normalize( mnormal
[1] );
1199 v3_normalize( mnormal
[2] );
1201 v4f uPlayerPos
, uSpawnPos
;
1202 v4_zero( uPlayerPos
);
1203 v4_zero( uSpawnPos
);
1205 v3_copy( world
->player_co
, uPlayerPos
);
1207 if( dest_spawn
&& (v3_dist2(dest_spawn
->transform
.co
,uPlayerPos
) > 0.1f
) )
1208 v3_copy( dest_spawn
->transform
.co
, uSpawnPos
);
1210 v3_add( uPlayerPos
, (v3f
){0,-1,0}, uSpawnPos
);
1212 uPlayerPos
[3] = v3_dist(uPlayerPos
,uSpawnPos
);
1213 uSpawnPos
[3] = 1.0f
/uPlayerPos
[3];
1215 shader_scene_override_uPlayerPos( uPlayerPos
);
1216 shader_scene_override_uSpawnPos( uSpawnPos
);
1219 glDisable( GL_CULL_FACE
);
1220 mesh_bind( &world
->mesh_geo
);
1221 pass
.geo_type
= k_world_geo_type_solid
;
1222 render_world_override_pass( world
, &pass
, mmdl
, mnormal
, mpvm_prev
);
1223 mesh_bind( &world
->mesh_no_collide
);
1224 pass
.geo_type
= k_world_geo_type_nonsolid
;
1225 render_world_override_pass( world
, &pass
, mmdl
, mnormal
, mpvm_prev
);
1226 glEnable( GL_CULL_FACE
);
1228 render_world_fxglow( world
, world
, cam
, mmdl
, 0, 0, 1 );
1231 static void render_cubemap_side( world_instance
*world
, ent_cubemap
*cm
,
1234 glFramebufferTexture2D( GL_FRAMEBUFFER
, GL_COLOR_ATTACHMENT0
,
1235 GL_TEXTURE_CUBE_MAP_POSITIVE_X
+ side
, cm
->texture_id
, 0 );
1236 glClear( GL_DEPTH_BUFFER_BIT
);
1239 { -1.0f
, 0.0f
, 0.0f
},
1240 { 1.0f
, 0.0f
, 0.0f
},
1241 { 0.0f
, -1.0f
, 0.0f
},
1242 { 0.0f
, 1.0f
, 0.0f
},
1243 { 0.0f
, 0.0f
, -1.0f
},
1244 { 0.0f
, 0.0f
, 1.0f
}
1247 { 0.0f
, -1.0f
, 0.0f
},
1248 { 0.0f
, -1.0f
, 0.0f
},
1249 { 0.0f
, 0.0f
, 1.0f
},
1250 { 0.0f
, 0.0f
, -1.0f
},
1251 { 0.0f
, -1.0f
, 0.0f
},
1252 { 0.0f
, -1.0f
, 0.0f
}
1255 v3_zero( cam
.angles
);
1256 v3_copy( cm
->co
, cam
.pos
);
1258 v3_copy( forward
[side
], cam
.transform
[2] );
1259 v3_copy( up
[side
], cam
.transform
[1] );
1260 v3_cross( up
[side
], forward
[side
], cam
.transform
[0] );
1261 v3_copy( cm
->co
, cam
.transform
[3] );
1262 m4x3_invert_affine( cam
.transform
, cam
.transform_inverse
);
1264 vg_camera_update_view( &cam
);
1269 m4x4_copy( cam
.mtx
.p
, cam
.mtx_prev
.p
);
1270 m4x4_projection( cam
.mtx
.p
, cam
.fov
, 1.0f
, cam
.nearz
, cam
.farz
);
1271 vg_camera_finalize( &cam
);
1272 vg_camera_finalize( &cam
);
1274 render_world( world
, &cam
, 0, 1, 1, 0 );
1277 void render_world_cubemaps( world_instance
*world
)
1279 if( world
->cubemap_cooldown
)
1280 world
->cubemap_cooldown
--;
1282 world
->cubemap_cooldown
= 60;
1284 glViewport( 0, 0, WORLD_CUBEMAP_RES
, WORLD_CUBEMAP_RES
);
1285 for( u32 i
=0; i
<mdl_arrcount( &world
->ent_cubemap
); i
++ ){
1286 ent_cubemap
*cm
= mdl_arritm( &world
->ent_cubemap
, i
);
1287 glBindFramebuffer( GL_FRAMEBUFFER
, cm
->framebuffer_id
);
1289 world
->cubemap_side
++;
1290 if( world
->cubemap_side
>= 6 )
1291 world
->cubemap_side
= 0;
1293 render_cubemap_side( world
, cm
, world
->cubemap_side
);
1300 * ---------------------------------------------
1303 void render_world_depth( world_instance
*world
, vg_camera
*cam
)
1305 m4x3f identity_matrix
;
1306 m4x3_identity( identity_matrix
);
1308 shader_scene_depth_use();
1309 shader_scene_depth_uCamera( cam
->transform
[3] );
1310 shader_scene_depth_uPv( cam
->mtx
.pv
);
1311 shader_scene_depth_uPvmPrev( cam
->mtx_prev
.pv
);
1312 shader_scene_depth_uMdl( identity_matrix
);
1313 world_link_lighting_ub( world
, _shader_scene_depth
.id
);
1315 mesh_bind( &world
->mesh_geo
);
1316 mesh_draw( &world
->mesh_geo
);
1319 void render_world_position( world_instance
*world
, vg_camera
*cam
)
1321 m4x3f identity_matrix
;
1322 m4x3_identity( identity_matrix
);
1324 shader_scene_position_use();
1325 shader_scene_position_uCamera( cam
->transform
[3] );
1326 shader_scene_position_uPv( cam
->mtx
.pv
);
1327 shader_scene_position_uPvmPrev( cam
->mtx_prev
.pv
);
1328 shader_scene_position_uMdl( identity_matrix
);
1329 world_link_lighting_ub( world
, _shader_scene_position
.id
);
1331 mesh_bind( &world
->mesh_geo
);
1332 mesh_draw( &world
->mesh_geo
);
1335 struct ui_enum_opt skybox_setting_options
[] = {
1336 { 0, "g_daysky_colour" },
1337 { 1, "g_nightsky_colour" },
1338 { 2, "g_sunset_colour" },
1339 { 3, "g_ambient_colour" },
1340 { 4, "g_sun_colour" },
1343 static f32
*skybox_prop_location( world_instance
*world
, i32 index
){
1345 case 0: return world
->ub_lighting
.g_daysky_colour
; break;
1346 case 1: return world
->ub_lighting
.g_nightsky_colour
; break;
1347 case 2: return world
->ub_lighting
.g_sunset_colour
; break;
1348 case 3: return world
->ub_lighting
.g_ambient_colour
; break;
1349 case 4: return world
->ub_lighting
.g_sun_colour
; break;
1350 default: return NULL
;
1354 void imgui_world_light_edit( world_instance
*world
)
1356 ui_rect panel
= { vg
.window_x
-400, 0, 400, vg
.window_y
};
1357 ui_fill( panel
, ui_colour( k_ui_bg
+1 ) );
1358 ui_outline( panel
, 1, ui_colour( k_ui_bg
+7 ), 0 );
1359 ui_rect_pad( panel
, (ui_px
[2]){ 8, 8 } );
1360 vg_ui
.wants_mouse
= 1;
1362 static i32 option_to_edit
= 0;
1363 ui_enum( panel
, "option", skybox_setting_options
, 5, &option_to_edit
);
1364 ui_colourpicker( panel
, "colour",
1365 skybox_prop_location( world
, option_to_edit
) );
1367 if( ui_button( panel
, "save tweaker file ('/tmp/tweaker.txt')\n" ) == 1 ){
1368 FILE *fp
= fopen( "/tmp/tweaker.txt", "w" );
1370 for( i32 i
=0; i
<5; i
++ ){
1371 struct ui_enum_opt
*opt
= &skybox_setting_options
[i
];
1372 f32
*val
= skybox_prop_location( world
, i
);
1373 fprintf( fp
, "%s = {%.3ff, %.3ff, %.3ff, %.3ff},\n",
1374 opt
->alias
, val
[0], val
[1], val
[2], val
[3] );