Untitled
Loading...
Searching...
No Matches
lightmap.h File Reference

UV Lightmap setup and baking, ReflectionProbe baking, and lighting ProbeVolume baking. More...

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.

Detailed Description

UV Lightmap setup and baking, ReflectionProbe baking, and lighting ProbeVolume baking.

Definition in file lightmap.h.

Function Documentation

◆ bake_reflection_probes()

◆ bake_lightmap()

void bake_lightmap ( LightmapData * ld)

Bakes a UV Lightmap based on which UVIslands have UVIsland.currently_rasterizing set.

Parameters
TheLightmapData 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().

◆ init_lightmap_data()

◆ init_uv_islands()

void init_uv_islands ( LightmapData * ld)

Adds all current UVIslands to the lightmap by allocating LightmapRects.

Parameters
TheLightmapData 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().

◆ build_uv_islands()

◆ save_lightmap_to_binary()

◆ load_lightmap_from_binary()

◆ bake_lighting_probe_volume()

◆ reset_lighting_pvs()

◆ check_lighting_pv()

◆ LM_regenerate_texels()

void LM_regenerate_texels ( )

◆ LM_allocate_empty_mns()

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().