Untitled
Loading...
Searching...
No Matches
lightmap_bounce.comp File Reference

Go to the source code of this file.

Data Structures

struct  Light
 The CPU side structure for Lights. More...
struct  Material
 The Materials parsed in from scene files that determine rendering pipeline setup, uploads, and ordering. More...
struct  Vertex
struct  Face
struct  MeshNode
 MeshNodes that describe the position of Meshes, GLTF nodes for GLTFAnimations, or hold references to other MeshNodes. More...
struct  AABB
struct  BVHNode
 Nodes for the acceleration structures of BVHs. More...
struct  RayHit

Macros

#define MINIMUM_LIGHT_VISIBILITY_DIST   0.1

Functions

 layout (local_size_x=16, local_size_y=16, local_size_z=1) in
 layout (rgba32f, binding=0) uniform image2D lightmapTex
 layout (std430, binding=0) buffer LightData
uint pcg_hash ()
uint wang_hash (uint seed)
float rand ()
void frisvad_basis (in vec3 n, out vec3 b1, out vec3 b2)
vec3 get_bounce_direction (vec3 normal)
bool ray_intersects_triangle (vec3 origin, vec3 dir, vec3 a, vec3 b, vec3 c, out RayHit out_hit)
bool slab_test (in BVHNode n, vec3 pos, vec3 inv_dir)
vec2 get_hit_uvs (in Face tri, in RayHit hit)
vec4 get_hit_albedo (in Material mat, vec2 hit_uv)
float get_hit_metallic (in Material mat, vec2 hit_uv)
vec3 get_hit_emissive (in Material mat, vec2 hit_uv)
void traverse_mesh_bvh (uint node_offset, uint mn_id, vec3 pp, vec3 pm, vec3 original_dir, vec3 dir, vec3 md, uint mesh, uint tri)
void traverse_scene_bvh (vec3 pp, vec3 dir, vec3 inv_dir, uint light_type, uint mesh, uint tri)
vec3 compute_3d_barycentric (vec3 a, vec3 b, vec3 c, vec3 p)
vec2 get_uvs (vec3 B, uint tri_idx)
float CalculateAttenuation (float distance, float radius, float intensity)
vec3 solve_light_source (in Light l, vec3 pos, vec3 normal, uint mesh, uint tri)
vec3 random_pos_on_triangle (vec3 a, vec3 b, vec3 c)
vec3 process_area_light (in Light light, vec3 pos, vec3 normal, vec3 brdf, float p_select)
vec3 process_light (vec3 pos, vec3 normal, uint mesh, uint tri, vec3 brdf, Light light, float p_select)
vec3 closest_point_on_aabb (vec3 pos, vec3 min, vec3 max)
bool pos_inside_aabb (vec3 pos, vec3 min, vec3 max)
vec3 traverse_light_bvh (vec3 pos, vec3 normal, uint mesh, uint tri, vec3 brdf)
vec3 traverse_light_bvh_direct_emissives (vec3 pos, vec3 normal, vec3 brdf)
vec3 resolve_transparents (vec3 throughput, vec3 pos, vec3 dir, vec3 inv_dir)
vec3 trace_path (vec3 pos, vec3 normal, ivec3 ids)
void main ()

Variables

uniform sampler2D uLightmapPosTex
uniform sampler2D uLightmapNormalTex
uniform isampler2D uLightmapIDTex
uniform samplerCube uSkybox
uniform ivec2 uTileOffset
uniform int uLightCount
uniform int uIteration
uniform int uLightmapWidth
uniform int uLightmapHeight
uint state = 0
RayHit hit
vec3 first_bounce_dir
int ao_hits
uniform int uAOIterations
uniform float uAOThreshold

Data Structure Documentation

◆ Vertex

struct Vertex

Definition at line 49 of file audio_probe_bake.comp.

Data Fields
vec3 pos
uint pad0
vec3 normal
uint pad1
vec2 uv
uint pad2
uint pad3

◆ Face

struct Face

Definition at line 65 of file audio_probe_bake.comp.

Data Fields
uvec3 indices
uint material_id
vec3 normal
uint mesh_id
uint bvh_index
uint tri_idx
uint pad0
uint pad1
Vertex v0
Vertex v1
Vertex v2

◆ AABB

struct AABB

Definition at line 110 of file audio_probe_bake.comp.

Data Fields
vec3 min
uint pad0
vec3 max
uint pad1
vec3 center
uint pad2
vec3 extents
uint pad3
vec4 min
vec4 max
float min_x
float max_x
float min_y
float max_y
float min_z
float max_z

◆ BVHNode

struct BVHNode

Nodes for the acceleration structures of BVHs.

See also
Scene MeshNode BVH: Globals.scene_data.bvh_nodes
Light BVH: Globals.scene_data.light_bvh.nodes
Mesh MeshFace BVH: Mesh.nodes
core/acceleration.c

Definition at line 125 of file audio_probe_bake.comp.

Data Fields
int left Left child.

-1 if empty.

int right Right child.

-1 if empty.

int parent Parent.

-1 if empty.

int index The index of the node inside of the array.
int first_index
int count
int next The pointer to the next node (either right child or parent's right child) for recursion-less traversal.

See: assign_next_nodes().

uint pad0
vec3 min
uint pad1
vec3 max
uint pad2
vec3 center
uint pad3
vec3 extents
uint pad4
AABB aabb The bounding box of all of this node's children.
size_t first_index The first index into the bvh_indices array.
size_t count How many children are inside this node.
float flux The total light flux of this node.

Used for Light BVH importance sampling.

float emissive_flux The only-emissive flux.

Used for Light BVH importance sampling.

◆ RayHit

struct RayHit

Definition at line 271 of file audio_probe_bake.comp.

Data Fields
vec3 pos
float t
vec3 barycentrics
uint mn_idx
vec3 normal
uint tri_idx
float best_t
float blocked_t
bool hit
bool occluded
uint pad1
size_t mesh_node_idx
size_t tri
HitType hit
float b0
float b1
float b2

Macro Definition Documentation

◆ MINIMUM_LIGHT_VISIBILITY_DIST

#define MINIMUM_LIGHT_VISIBILITY_DIST   0.1

Definition at line 256 of file lightmap_bounce.comp.

Function Documentation

◆ layout() [1/3]

layout ( local_size_x = 16,
local_size_y = 16,
local_size_z = 1 )

References layout().

◆ layout() [2/3]

layout ( rgba32f ,
binding = 0 )

References layout().

◆ layout() [3/3]

layout ( std430 ,
binding = 0 )

Definition at line 39 of file lightmap_bounce.comp.

References layout().

◆ pcg_hash()

uint pcg_hash ( )

Definition at line 278 of file lightmap_bounce.comp.

References pcg_hash(), and state.

◆ wang_hash()

uint wang_hash ( uint seed)

Definition at line 285 of file lightmap_bounce.comp.

References wang_hash().

◆ rand()

float rand ( )

Definition at line 293 of file lightmap_bounce.comp.

References pcg_hash(), and rand().

◆ frisvad_basis()

void frisvad_basis ( in vec3 n,
out vec3 b1,
out vec3 b2 )

Definition at line 320 of file lightmap_bounce.comp.

References frisvad_basis(), and n.

◆ get_bounce_direction()

vec3 get_bounce_direction ( vec3 normal)

Definition at line 339 of file lightmap_bounce.comp.

References frisvad_basis(), get_bounce_direction(), rand(), TBN, and vec3::z.

◆ ray_intersects_triangle()

bool ray_intersects_triangle ( vec3 origin,
vec3 dir,
vec3 a,
vec3 b,
vec3 c,
out RayHit out_hit )

Definition at line 403 of file lightmap_bounce.comp.

References RayHit::hit, and ray_intersects_triangle().

◆ slab_test()

bool slab_test ( in BVHNode n,
vec3 pos,
vec3 inv_dir )

Definition at line 445 of file lightmap_bounce.comp.

References hit, n, slab_test(), RayHit::t, vec3::x, vec3::y, and vec3::z.

◆ get_hit_uvs()

◆ get_hit_albedo()

◆ get_hit_metallic()

float get_hit_metallic ( in Material mat,
vec2 hit_uv )

Definition at line 486 of file lightmap_bounce.comp.

References get_hit_metallic().

Referenced by get_hit_metallic().

◆ get_hit_emissive()

vec3 get_hit_emissive ( in Material mat,
vec2 hit_uv )

◆ traverse_mesh_bvh()

◆ traverse_scene_bvh()

void traverse_scene_bvh ( vec3 pp,
vec3 dir,
vec3 inv_dir,
uint light_type,
uint mesh,
uint tri )

◆ compute_3d_barycentric()

◆ get_uvs()

vec2 get_uvs ( vec3 B,
uint tri_idx )

◆ CalculateAttenuation()

float CalculateAttenuation ( float distance,
float radius,
float intensity )

◆ solve_light_source()

◆ random_pos_on_triangle()

vec3 random_pos_on_triangle ( vec3 a,
vec3 b,
vec3 c )

◆ process_area_light()

◆ process_light()

vec3 process_light ( vec3 pos,
vec3 normal,
uint mesh,
uint tri,
vec3 brdf,
Light light,
float p_select )

◆ closest_point_on_aabb()

vec3 closest_point_on_aabb ( vec3 pos,
vec3 min,
vec3 max )

◆ pos_inside_aabb()

bool pos_inside_aabb ( vec3 pos,
vec3 min,
vec3 max )

Definition at line 1007 of file lightmap_bounce.comp.

References pos_inside_aabb(), vec3::x, vec3::y, and vec3::z.

Referenced by pos_inside_aabb().

◆ traverse_light_bvh()

◆ traverse_light_bvh_direct_emissives()

◆ resolve_transparents()

◆ trace_path()

◆ main()

Variable Documentation

◆ uLightmapPosTex

uniform sampler2D uLightmapPosTex

Definition at line 243 of file lightmap_bounce.comp.

Referenced by main().

◆ uLightmapNormalTex

uniform sampler2D uLightmapNormalTex

Definition at line 244 of file lightmap_bounce.comp.

Referenced by main().

◆ uLightmapIDTex

uniform isampler2D uLightmapIDTex

Definition at line 245 of file lightmap_bounce.comp.

Referenced by main().

◆ uSkybox

uniform samplerCube uSkybox

Definition at line 246 of file lightmap_bounce.comp.

Referenced by trace_path(), and trace_path().

◆ uTileOffset

uniform ivec2 uTileOffset

Definition at line 248 of file lightmap_bounce.comp.

Referenced by main().

◆ uLightCount

uniform int uLightCount

Definition at line 249 of file lightmap_bounce.comp.

Referenced by main(), and traverse_light_bvh().

◆ uIteration

uniform int uIteration

Definition at line 250 of file lightmap_bounce.comp.

Referenced by main().

◆ uLightmapWidth

uniform int uLightmapWidth

Definition at line 251 of file lightmap_bounce.comp.

◆ uLightmapHeight

uniform int uLightmapHeight

Definition at line 252 of file lightmap_bounce.comp.

◆ state

uint state = 0

Definition at line 276 of file lightmap_bounce.comp.

◆ hit

RayHit hit

Definition at line 401 of file lightmap_bounce.comp.

◆ first_bounce_dir

vec3 first_bounce_dir

Definition at line 1335 of file lightmap_bounce.comp.

Referenced by main(), and trace_path().

◆ ao_hits

int ao_hits

Definition at line 1338 of file lightmap_bounce.comp.

Referenced by main(), and trace_path().

◆ uAOIterations

uniform int uAOIterations

Definition at line 1340 of file lightmap_bounce.comp.

Referenced by main(), and trace_path().

◆ uAOThreshold

uniform float uAOThreshold

Definition at line 1341 of file lightmap_bounce.comp.

Referenced by trace_path().