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