|
Space Sim
|
The system for planet surface generation and rendering. More...
Files | |
| file | src/mesh/density.comp |
| Creates a density field from a chunk. | |
| file | src/mesh/indirect.comp |
| Emits a draw command for the generated mesh. | |
| file | src/mesh/marching_cubes.comp |
| Meshes a chunk using marching cubes. | |
| file | src/mesh/marching_cubes.h |
| Marching cubes static header with constants. | |
| file | src/render/mesh.frag |
| Renders the mesh planet surface and calculates light. | |
| file | src/render/mesh.vert |
| Renders the mesh planet surface, pushing out by planet radius. | |
Functions | |
| void | render_mesh_planet () |
| Renders a planet's meshed surface. | |
| float | sample_density (vec3 p) |
| Samples a precomputed perlin volume. | |
| float | sample_fbm_density (vec3 p) |
| Samples a precomputed fbm volume. | |
| float | calc_density (vec3 p) |
| Copies the exact density function from the GPU to the CPU. | |
| void | create_new_planet_mesh (int lod, ivec3 chunk_center, int chunk_id, bool is_parent) |
| Creates a mesh for a certain chunk. | |
| int | find_current_lod (ivec3 center, ChunkHash **h) |
| Finds the highest LOD that we have cached from the current chunk. | |
| bool | free_current_parent (int lod, int i) |
| Frees the given LOD (as a parent). | |
| bool | free_parent (int lod, int i) |
| Frees the parent of given LOD. | |
| bool | free_child (int lod, int i) |
| Frees the child of given LOD. | |
| void | init_chunk_data () |
| Initializes and frees old ChunkData and hash tables. | |
| void | load_chunks (vec3 planet_origin, float planet_radius) |
| Checks all chunks based on new Camera position, building a job list and then executing them based on ChunkScore. | |
| int | CURRENT_LOD_BOUND = -1 |
| int | LOD_DENSITY_SIZES [LODMAX] |
| int | LOD_VERTEX_SIZES [LODMAX] |
| ChunkData | CHUNK_DATA [LODMAX][MAX_CHUNKS] |
| int * | CHUNK_DATA_PTR [3] |
| int | CHUNK_DATA_FLAG = 0 |
The system for planet surface generation and rendering.
| void render_mesh_planet | ( | ) |
Renders a planet's meshed surface.
Definition at line 1204 of file main.c.
References CHUNK_DATA, CURRENT_LOD_BOUND, DENSITY_SSBO, DENSITY_VERTEX_SSBO, INDIRECT_BUFFER, Uniform::location, LODMAX, MAX_CHUNKS_LOD, MESH_SHADER, ShaderProgram::program, render_mesh_planet(), and ShaderProgram::uniforms.
Referenced by render(), and render_mesh_planet().
| float sample_density | ( | vec3 | p | ) |
Samples a precomputed perlin volume.
| p | The position to sample. |
Definition at line 217 of file mesh.c.
References c0, c1, lerp(), perlin_tex, PERLIN_TEXTURE_SIZE, sample_density(), ivec3::x, vec3::x, ivec3::y, vec3::y, ivec3::z, and vec3::z.
| float sample_fbm_density | ( | vec3 | p | ) |
Samples a precomputed fbm volume.
| p | The position to sample. |
Definition at line 269 of file mesh.c.
References c0, c1, fbm_tex, FBM_TEXTURE_SIZE, lerp(), sample_fbm_density(), ivec3::x, vec3::x, ivec3::y, vec3::y, ivec3::z, and vec3::z.
Referenced by calc_density(), and sample_fbm_density().
| float calc_density | ( | vec3 | p | ) |
Copies the exact density function from the GPU to the CPU.
Used to calculate collision.
| p | The position to calculate density for. |
Definition at line 323 of file mesh.c.
References FBMLayer::amp, PerlinLayer::amp, WarpLayer::amp, calc_density(), CHUNK_WORLD_SIZE, PlanetData::fbm_count, PlanetData::fbm_layers, FBM_TEXTURE_SIZE, FBMLayer::freq, PerlinLayer::freq, WarpLayer::freq0, WarpLayer::freq1, WarpLayer::freq2, WarpLayer::offset0, WarpLayer::offset1, WarpLayer::offset2, PlanetData::perlin_count, PlanetData::perlin_layers, PERLIN_TEXTURE_SIZE, PLANET_DATA, sample_density(), sample_fbm_density(), t, vec3_add(), vec3_scale(), PlanetData::warp_count, PlanetData::warp_layers, vec3::x, vec3::y, and vec3::z.
Referenced by calc_density(), find_density_normal(), find_surface(), find_surface_entry(), and find_surface_z().
| void create_new_planet_mesh | ( | int | lod, |
| ivec3 | chunk_center, | ||
| int | chunk_id, | ||
| bool | is_parent ) |
Creates a mesh for a certain chunk.
| lod | The LOD level to generate. |
| chunk_center | The chunk center in world space. |
| chunk_id | The ID of the chunk in CHUNK_DATA. |
| is_parent | If the chunk is that of higher LOD than child. This makes it so that the parent always reports the vertex count. |
Definition at line 433 of file mesh.c.
References CHUNK_DATA, chunk_id, create_new_planet_mesh(), DENSITY_COMPUTE_SHADER, DENSITY_SSBO, DENSITY_VERTEX_SSBO, FBM_TEXTURE, INDIRECT_BUFFER, INDIRECT_COMPUTE_SHADER, is_parent, Uniform::location, lod, LOD_RES, MARCHING_CUBES_COMPUTE_SHADER, PERLIN_TEXTURE, ComputeShaderProgram::program, size, ChunkData::uID, ComputeShaderProgram::uniforms, ivec3::x, ivec3::y, and ivec3::z.
Referenced by create_new_planet_mesh(), and load_chunks().
Finds the highest LOD that we have cached from the current chunk.
Definition at line 630 of file mesh.c.
References find_chunk_hash(), find_current_lod(), and LODMAX.
Referenced by find_current_lod().
| bool free_current_parent | ( | int | lod, |
| int | i ) |
Frees the given LOD (as a parent).
Definition at line 661 of file mesh.c.
References CHUNK_DATA, delete_chunk_hash(), ChunkData::free, free_current_parent(), ChunkData::is_child, lod, and LODMAX.
Referenced by display_main_menu(), free_current_parent(), and load_chunks().
| bool free_parent | ( | int | lod, |
| int | i ) |
Frees the parent of given LOD.
Definition at line 690 of file mesh.c.
References already_emitted, CHUNK_DATA, delete_chunk_hash(), ChunkData::free, free_parent(), ChunkData::id1, ChunkData::is_child, lod, and LODMAX.
Referenced by display_main_menu(), free_parent(), and load_chunks().
| bool free_child | ( | int | lod, |
| int | i ) |
Frees the child of given LOD.
Definition at line 724 of file mesh.c.
References already_emitted, CHUNK_DATA, delete_chunk_hash(), ChunkData::free, free_child(), ChunkData::id0, ChunkData::is_child, lod, and LODMAX.
Referenced by display_main_menu(), free_child(), and load_chunks().
| void init_chunk_data | ( | ) |
Initializes and frees old ChunkData and hash tables.
Definition at line 796 of file mesh.c.
References authority_map, CHUNK_DATA, ChunkData::free, frees, hash_table, ChunkData::id0, ChunkData::id1, INDIRECT_BUFFER, init_chunk_data(), ChunkData::is_child, job_data, jobs, LODMAX, MAX_CHUNK_LIST, MAX_CHUNKS, MAX_CHUNKS_LOD, s, ChunkData::uID, and zero_hash_table.
Referenced by display_main_menu(), init(), and init_chunk_data().
| void load_chunks | ( | vec3 | planet_origin, |
| float | planet_radius ) |
Checks all chunks based on new Camera position, building a job list and then executing them based on ChunkScore.
| planet_origin | The origin to determine the relative noise value. |
| planet_radius | The radius to determine the height offset needed to find the planet surface from the planet center. |
Definition at line 893 of file mesh.c.
References aabb_in_frustum(), ChunkScore::active, already_emitted, assign_new_uID(), Camera::cam_data, CamData::cam_pos, CamData::cam_vel, ChunkData::center, CHUNK_DATA, CHUNK_DATA_FLAG, CHUNK_DATA_SSBO, CHUNK_RADIUS, chunk_uID, CHUNK_WORLD_SIZE, CHUNK_ZERO_COMPUTE_SHADER, compareFrees(), compareJobs(), create_new_planet_mesh(), current_cam, emitted_chunk_ids, emitted_chunk_lods, emitted_chunks, end_timer(), find_chunk_hash(), ChunkData::free, free_child(), free_current_parent(), free_parent(), frees, generation_id, get_current_lod(), get_view_planes(), ChunkHash::id, ChunkData::id0, ChunkData::id1, ChunkScore::index, ChunkData::is_child, is_parent, ivec3_add(), ivec3_dist(), ivec3_scale(), job_data, jobs, ZeroEntry::key, LIGHT_CAM, load_chunks(), ChunkData::lod, ChunkScore::lod, lod, lod_level, LODMAX, MAX, ChunkData::max, MAX_CHUNKS, MAX_CHUNKS_LOD, MAX_ZERO_LIST, MIN, ChunkData::min, planet_origin, planet_radius, replace_chunk_hash(), ChunkData::replacement_index, ChunkData::replacement_lod, replacement_mask, res, s, ChunkScore::score, set_current_lod(), start_timer(), ChunkData::uID, uID, vec3_scale(), VERTEX_COUNT_MAX, ChunkData::within_frustum, ivec3::x, vec3::x, vec4::x, ivec3::y, vec3::y, vec4::y, ivec3::z, vec3::z, vec4::z, zero_fence, zero_hash_table, and zero_list_count.
Referenced by load_chunks(), and main().
| int CURRENT_LOD_BOUND = -1 |
Definition at line 63 of file main.c.
Referenced by render_mesh_planet().
| ChunkData CHUNK_DATA[LODMAX][MAX_CHUNKS] |
Definition at line 67 of file main.c.
Referenced by create_new_planet_mesh(), free_child(), free_current_parent(), free_parent(), init_chunk_data(), load_chunks(), and render_mesh_planet().
| int CHUNK_DATA_FLAG = 0 |
Definition at line 69 of file main.c.
Referenced by init(), and load_chunks().