|
Untitled
|
UV Lightmap setup and baking, ReflectionProbe baking, and lighting ProbeVolume baking. More...
#include "core/engine_types.h"Go to the source code of this file.
Functions | |
| void | bake_reflection_probes () |
| Bakes ReflectionProbes for the entire scene onto cubemaps on RPROBE_CUBE_MAP_ARRAY. | |
| void | bake_lightmap (LightmapData *ld) |
| Bakes a UV Lightmap based on which UVIslands have UVIsland.currently_rasterizing set. | |
| void | init_lightmap_data (LightmapData *ld) |
| Frees current LightmapAtlas and UVIsland data and re-initializes the LightmapAtlas array and initializes the UVIsland Vector. | |
| void | init_uv_islands (LightmapData *ld) |
| Adds all current UVIslands to the lightmap by allocating LightmapRects. | |
| void | build_uv_islands (MeshNode *mn) |
| Builds UVIslands over a MeshNode by stepping through TriangleAdjacency and stopping when normals become too different. | |
| void | save_lightmap_to_binary (LightmapData *ld, const char *name) |
| Saves a UV lightmap and relevant UVIsland and MeshNode data to binary. | |
| void | load_lightmap_from_binary (LightmapData *ld, const char *name) |
| Loads a UV lightmap and relevant UVIsland and MeshNode data fro, binary. | |
| void | bake_lighting_probe_volume (ProbeVolume *pv) |
| Loads a UV lightmap and relevant UVIsland and MeshNode data fro, binary. | |
| void | reset_lighting_pvs () |
| Resets current LPVs from their slots in SceneData.LOADED_LIGHTING_PV. | |
| void | check_lighting_pv () |
| Determines which LPVs we may need to replace due to distance to new ones. | |
| void | LM_regenerate_texels () |
| Regenerates lightmap texels: re-inits LightmapData, then builds UVIslands, then calls add_all_meshes_to_draw_buffer. | |
| void | LM_allocate_empty_mns () |
| Allocates texels for MeshNodes that don't have UVIslands generated yet. | |
UV Lightmap setup and baking, ReflectionProbe baking, and lighting ProbeVolume baking.
Definition in file lightmap.h.
| void bake_reflection_probes | ( | ) |
Bakes ReflectionProbes for the entire scene onto cubemaps on RPROBE_CUBE_MAP_ARRAY.
Definition at line 786 of file lightmap.c.
References ReflectionProbe::aabb, bake_reflection_probes(), BUFFER_FRAMES, Camera::cam_data, CamData::cam_pos, ReflectionProbe::capture_pos, CAST_VEC, AABB::center, RProbe::center, compute_camera_basis(), Vector::count, current_frame, EDITOR_SETTINGS, Camera::forward, GLOBALS, CamData::inv_proj, CamData::inv_view, m4_inverse(), M_PI, make_look_at(), make_projection(), RProbe::max, AABB::max_x, AABB::max_y, AABB::max_z, RProbe::min, AABB::min_x, AABB::min_y, AABB::min_z, EditorSettings::MSAA, Camera::pitch, CamData::proj, SceneData::reflection_probes, render_to_cubemap_face(), RPROBE_CUBE_MAP_ARRAY, RPROBE_FBO, RPROBE_HEIGHT, RPROBE_SSBO, RPROBE_WIDTH, Globals::scene_data, CamData::unjittered_inv_proj, CamData::unjittered_proj, vec3_add(), vec3_to_vec4(), CamData::view, view, and Camera::yaw.
Referenced by bake_reflection_probes(), and render_light_menu().
| void bake_lightmap | ( | LightmapData * | ld | ) |
Bakes a UV Lightmap based on which UVIslands have UVIsland.currently_rasterizing set.
| The | LightmapData for the lightmap. |
Definition at line 1009 of file lightmap.c.
References EditorSettings::ao_iterations, EditorSettings::ao_threshold, LightmapData::atlas, bake_lightmap(), bind_baking_ssbos(), Vector::buffer, Mesh::bvh_indices, SceneData::bvh_indices, SceneData::bvh_indices_count, CAST_VEC, Vector::count, UVIsland::currently_rasterizing, DIRECTIONAL_MAP_NORMALIZE_SHADER, DIRECTIONAL_MAP_TEXTURE, EDITOR_SETTINGS, end_timer(), MeshNode::free, GLOBALS, LightmapAtlas::height, MeshFace::indices, LightmapData::islands, SceneData::light_bvh, LIGHTMAP_BOUNCE_SHADER, LIGHTMAP_DENOISE_SHADER, LIGHTMAP_DILATE_SHADER, LIGHTMAP_FBO, LIGHTMAP_HEIGHT, LIGHTMAP_ID_TEXTURE, LIGHTMAP_NORM_TEXTURE, LIGHTMAP_POS_TEXTURE, LIGHTMAP_SHADER, LIGHTMAP_VAO, LIGHTMAP_VBO, LIGHTMAP_WIDTH, Globals::lights, EditorSettings::lm_iterations, LightmapVertex::lm_uv, LightmapVertex::material_id, MeshFace::material_id, MeshNode::mesh, Globals::mesh_nodes, Globals::meshes, MIN, LightBVH::nodes, LightmapVertex::normal, Point::normal, LightmapVertex::pos, Point::pos, ShaderProgram::program, Globals::scene_data, SKYBOX, start_timer(), temp, LightmapData::texture_id, LightmapVertex::tri_id, Mesh::tris, unbind_baking_ssbos(), upload_bake_lights_gpu(), LightmapVertex::uv, Point::uv, UVMapping::uv_idx, UVMapping::uv_island, MeshNode::uv_map, UVIsland::uvs, Mesh::vertices, and LightmapAtlas::width.
Referenced by bake_lightmap(), and render_light_menu().
| void init_lightmap_data | ( | LightmapData * | ld | ) |
Frees current LightmapAtlas and UVIsland data and re-initializes the LightmapAtlas array and initializes the UVIsland Vector.
| The | LightmapData for the lightmap. |
Definition at line 93 of file lightmap.c.
References LightmapData::atlas, Vector::buffer, CAST_VEC, Vector::count, free_lightmap_atlas(), init_lightmap_atlas(), init_lightmap_data(), init_vector(), LightmapData::islands, LIGHTMAP_HEIGHT, LIGHTMAP_WIDTH, and LightmapData::sample_cubemap.
Referenced by execute_globals_undo(), init_lightmap_data(), LM_regenerate_texels(), and render_main_menu().
| void init_uv_islands | ( | LightmapData * | ld | ) |
Adds all current UVIslands to the lightmap by allocating LightmapRects.
| The | LightmapData for the lightmap. |
Definition at line 384 of file lightmap.c.
References add_uv_island_to_lightmap(), CAST_VEC, Vector::count, init_uv_islands(), and LightmapData::islands.
Referenced by init_uv_islands().
| void build_uv_islands | ( | MeshNode * | mn | ) |
Builds UVIslands over a MeshNode by stepping through TriangleAdjacency and stopping when normals become too different.
| The | MeshNode to traverse. |
Definition at line 400 of file lightmap.c.
References A, add_uv_island_to_lightmap(), TriangleAdjacency::adjacent_indices, B, build_uv_islands(), C, CAST_VEC, UVIsland::centroid, Vector::count, GLOBALS, MeshNode::id, MeshFace::indices, init_vector(), LightmapData::islands, SceneData::lightmap_data, MeshNode::mesh, UVIsland::mesh_node, Globals::meshes, MeshFace::normal, UVIsland::normal, Point::pos, Globals::scene_data, Mesh::tri_adjacency, triangle_area(), triangle_centroid(), Mesh::tris, UVIsland::tris, UVMapping::uv_island, MeshNode::uv_map, UVIsland::uvs, vec3_add(), vec3_normalize(), vec3_scale(), vector_expand(), Mesh::vertices, and walk_coplanar_adjacency().
Referenced by build_uv_islands(), execute_globals_undo(), LM_allocate_empty_mns(), LM_regenerate_texels(), and render_main_menu().
| void save_lightmap_to_binary | ( | LightmapData * | ld, |
| const char * | name ) |
Saves a UV lightmap and relevant UVIsland and MeshNode data to binary.
| The | LightmapData for the lightmap. |
| The | path to and name of the file. |
Definition at line 525 of file lightmap.c.
References Globals::assets, LightmapData::atlas, LightmapAtlas::block_size, Vector::buffer, CAST_VEC, Vector::count, DIRECTIONAL_MAP_TEXTURE, EDITOR_SETTINGS, GLOBALS, LightmapAtlas::height, LightmapData::islands, MeshNode::mesh, UVIsland::mesh_node, Globals::mesh_nodes, Globals::meshes, MeshNode::name, UVIsland::normal, LightmapAtlas::occupied, UVIsland::rect, LightmapData::sample_cubemap, save_lightmap_to_binary(), EditorSettings::texels_per_uv_unit, LightmapData::texture_id, Mesh::tris, UVIsland::tris, MeshNode::uv_map, UVIsland::uvs, and LightmapAtlas::width.
Referenced by render_light_menu(), save_lightmap_to_binary(), and scene_save().
| void load_lightmap_from_binary | ( | LightmapData * | ld, |
| const char * | name ) |
Loads a UV lightmap and relevant UVIsland and MeshNode data fro, binary.
| The | LightmapData for the lightmap. |
| The | path to and name of the file. |
Definition at line 610 of file lightmap.c.
References add_all_meshes_to_buffer(), LightmapData::atlas, LightmapAtlas::block_size, Vector::buffer, Vector::capacity, CAST_VEC, Vector::count, deallocate_lightmap_rect(), DIRECTIONAL_MAP_TEXTURE, EDITOR_SETTINGS, find_mn_by_name(), GLOBALS, LightmapAtlas::height, init_vector(), LightmapData::islands, load_lightmap_from_binary(), MeshNode::mesh, UVIsland::mesh_node, Globals::mesh_nodes, Globals::meshes, UVIsland::normal, LightmapAtlas::occupied, UVIsland::rect, LightmapData::sample_cubemap, EditorSettings::texels_per_uv_unit, LightmapData::texture_id, Mesh::tris, UVIsland::tris, MeshNode::uv_map, UVIsland::uvs, Globals::vertex_layouts, and LightmapAtlas::width.
Referenced by load_lightmap_from_binary(), render_light_menu(), and scene_load().
| void bake_lighting_probe_volume | ( | ProbeVolume * | pv | ) |
Loads a UV lightmap and relevant UVIsland and MeshNode data fro, binary.
| The | LightmapData for the lightmap. |
| The | path to and name of the file. |
Definition at line 1509 of file lightmap.c.
References bake_lighting_probe_volume(), bind_baking_ssbos(), Vector::buffer, ProbeVolume::byte_offset, CAST_VEC, Vector::count, EDITOR_SETTINGS, GLOBALS, SceneData::light_bvh, Globals::lights, SceneData::LPV_FILE, LPV_PADDED_COUNT, Globals::mesh_nodes, Globals::meshes, LightBVH::nodes, ProbeVolume::obb, OBB_min_corner(), SHDataGPU::pos, PROBE_BAKE_SHADER, EditorSettings::probe_iterations, Globals::probe_spacing, PROBE_SSBO, PROBE_UNPACK_SHADER, PROBE_VOLUME_DEPTH, PROBE_VOLUME_DEPTH_PADDED, PROBE_VOLUME_HEIGHT, PROBE_VOLUME_WIDTH, PV_step_size(), Globals::scene_data, SH_MAX, ProbeVolume::size, SKYBOX, unbind_baking_ssbos(), upload_bake_lights_gpu(), vec3::x, vec3::y, and vec3::z.
Referenced by bake_lighting_probe_volume(), and render_lprobe_menu().
| void reset_lighting_pvs | ( | ) |
Resets current LPVs from their slots in SceneData.LOADED_LIGHTING_PV.
Definition at line 1330 of file lightmap.c.
References GLOBALS, SceneData::LOADED_LIGHTING_PV, SceneData::LOADED_LIGHTING_PV_FLAG, LPV::lprobes, LPV_SLOTS, reset_lighting_pvs(), and Globals::scene_data.
Referenced by execute_lprobe_undo(), load_lprobes(), render_lprobe_menu(), and reset_lighting_pvs().
| void check_lighting_pv | ( | ) |
Determines which LPVs we may need to replace due to distance to new ones.
Definition at line 1391 of file lightmap.c.
References CAST_VEC, OBB::center, check_lighting_pv(), compare_current_distances(), compare_distances(), Vector::count, DistancePair::d, GLOBALS, hit, DistancePair::id, SceneData::lighting_probe_volumes, load_lighting_pv(), SceneData::LOADED_LIGHTING_PV, SceneData::LOADED_LIGHTING_PV_FLAG, SceneData::LPV_FILE, LPV_SLOTS, Skeleton::neck, ProbeVolume::obb, player, Spring::pos, LPV::pv_id, ray_intersects_obb_with_point(), remove_lighting_pv(), Globals::scene_data, Player::skeleton, vec3_dist(), vec3_normalize(), and vec3_sub().
Referenced by check_lighting_pv(), and main().
| void LM_regenerate_texels | ( | ) |
Regenerates lightmap texels: re-inits LightmapData, then builds UVIslands, then calls add_all_meshes_to_draw_buffer.
Definition at line 486 of file lightmap.c.
References add_all_meshes_to_buffer(), build_uv_islands(), CAST_VEC, Vector::count, GLOBALS, init_lightmap_data(), SceneData::lightmap_data, LM_regenerate_texels(), Globals::mesh_nodes, Globals::meshes, Globals::scene_data, and Globals::vertex_layouts.
Referenced by LM_regenerate_texels(), and render_light_menu().
| void LM_allocate_empty_mns | ( | ) |
Allocates texels for MeshNodes that don't have UVIslands generated yet.
Used when loading a binary that does not include certain MeshNodes.
Definition at line 502 of file lightmap.c.
References add_all_meshes_to_buffer(), build_uv_islands(), CAST_VEC, Vector::count, GLOBALS, LM_allocate_empty_mns(), Globals::mesh_nodes, Globals::meshes, and Globals::vertex_layouts.
Referenced by LM_allocate_empty_mns(), and render_light_menu().