add command for spawning glider
[carveJwlIkooP6JGAAIwe30JlM.git] / world_render.h
1 /*
2 * Copyright (C) 2021-2023 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 */
4
5 #ifndef WORLD_RENDER_H
6 #define WORLD_RENDER_H
7
8 #define WORLD_CUBEMAP_RES 32
9
10 #include "camera.h"
11 #include "world.h"
12
13 #include "shaders/scene_standard.h"
14 #include "shaders/scene_standard_alphatest.h"
15 #include "shaders/scene_foliage.h"
16 #include "shaders/scene_override.h"
17 #include "shaders/scene_cubemapped.h"
18 #include "shaders/scene_vertex_blend.h"
19 #include "shaders/scene_terrain.h"
20 #include "shaders/scene_fxglow.h"
21 #include "shaders/scene_depth.h"
22 #include "shaders/scene_position.h"
23 #include "shaders/scene_font.h"
24 #include "shaders/model_sky.h"
25 #include "shaders/model_sky_space.h"
26
27 static const float k_world_light_cube_size = 8.0f;
28
29 struct world_render{
30 GLuint tex_terrain_noise;
31
32 /* rendering */
33 glmesh skydome;
34
35 double sky_time, sky_rate, sky_target_rate;
36
37 /* water rendering */
38 struct{
39 struct framebuffer fbreflect, fbdepth;
40 }
41 water;
42
43 v3f render_gate_pos;
44 struct timer_text{
45 char text[8];
46 m4x3f transform;
47 ent_gate *gate;
48 ent_route *route;
49 }
50 timer_texts[4];
51 u32 timer_text_count;
52
53 struct text_particle{
54 rigidbody rb;
55 m4x3f mlocal;
56 ent_glyph *glyph;
57 v4f colour;
58 m4x3f mdl;
59 f32 radius;
60 }
61 text_particles[6*4];
62 u32 text_particle_count;
63 }
64 static world_render;
65 static void world_render_init(void);
66
67 static void world_link_lighting_ub( world_instance *world, GLuint shader );
68 static void world_bind_position_texture( world_instance *world,
69 GLuint shader, GLuint location,
70 int slot );
71 static void world_bind_light_array( world_instance *world,
72 GLuint shader, GLuint location,
73 int slot );
74 static void world_bind_light_index( world_instance *world,
75 GLuint shader, GLuint location,
76 int slot );
77 static void render_world_position( world_instance *world, camera *cam );
78 static void render_world_depth( world_instance *world, camera *cam );
79 static void render_world( world_instance *world, camera *cam,
80 int stenciled, int viewing_from_gate,
81 int with_water, int with_cubemaps );
82 static void render_world_cubemaps( world_instance *world );
83 static void bind_terrain_noise(void);
84 static void render_world_override( world_instance *world,
85 world_instance *lighting_source,
86 m4x3f mmdl,
87 camera *cam,
88 ent_spawn *dest_spawn, v4f map_info );
89
90 #define WORLD_BIND_LIGHT_BUFFERS_UB0_TEX234( WORLD, SHADER ) \
91 world_link_lighting_ub( WORLD, _shader_##SHADER.id ); \
92 world_bind_position_texture( WORLD, _shader_##SHADER.id, \
93 _uniform_##SHADER##_g_world_depth, 2 ); \
94 world_bind_light_array( WORLD, _shader_##SHADER.id, \
95 _uniform_##SHADER##_uLightsArray, 3 ); \
96 world_bind_light_index( WORLD, _shader_##SHADER.id, \
97 _uniform_##SHADER##_uLightsIndex, 4 );
98
99 #endif /* WORLD_RENDER_H */