Untitled
Loading...
Searching...
No Matches
probe_bake.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  SHData
struct  RayHit

Macros

#define MINIMUM_LIGHT_VISIBILITY_DIST   0.1

Functions

 layout (local_size_x=8, local_size_y=8, local_size_z=8) in
 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)
vec3 generate_sphere_dir (int i, int N)
bool ray_intersects_triangle (vec3 origin, vec3 dir, vec3 a, vec3 b, vec3 c, out RayHit out_hit)
bool slab_test (BVHNode n, vec3 pos, vec3 inv_dir)
vec2 get_uvs (vec3 B, uint tri_idx)
vec2 get_hit_uvs (in Face tri, in RayHit hit)
vec4 get_hit_albedo (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)
float CalculateAttenuation (float distance, float radius, float intensity)
vec3 solve_light_source (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, bool skip_normal)
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)
void solve_SH (vec3 color, vec3 dir, int index, vec3 pos)
void main ()

Variables

uniform samplerCube uSkybox
uniform ivec2 uTileOffset
uniform int uLightCount
uniform vec3 uWorldMin
uniform ivec3 uProbeSize
uniform int uCurrentIteration
uniform int uIterations
uniform float uSpacing
uint state = 0
RayHit hit
vec3 first_dir

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.

◆ SHData

struct SHData

Definition at line 189 of file probe_bake.comp.

Data Fields
vec3 pos
uint pad0
vec4 coefficients[9]

◆ 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 218 of file probe_bake.comp.

Function Documentation

◆ layout() [1/2]

layout ( local_size_x = 8,
local_size_y = 8,
local_size_z = 8 )

References color, and layout().

◆ layout() [2/2]

layout ( std430 ,
binding = 0 )

Definition at line 37 of file probe_bake.comp.

References layout().

◆ pcg_hash()

uint pcg_hash ( )

Definition at line 240 of file probe_bake.comp.

References pcg_hash(), and state.

◆ wang_hash()

uint wang_hash ( uint seed)

Definition at line 247 of file probe_bake.comp.

References wang_hash().

◆ rand()

float rand ( )

Definition at line 256 of file probe_bake.comp.

References pcg_hash(), and rand().

◆ frisvad_basis()

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

Definition at line 260 of file probe_bake.comp.

References frisvad_basis(), and n.

◆ get_bounce_direction()

vec3 get_bounce_direction ( vec3 normal)

Definition at line 279 of file probe_bake.comp.

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

◆ generate_sphere_dir()

vec3 generate_sphere_dir ( int i,
int N )

Definition at line 308 of file probe_bake.comp.

References generate_sphere_dir().

◆ ray_intersects_triangle()

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

Definition at line 324 of file probe_bake.comp.

References RayHit::hit, and ray_intersects_triangle().

◆ slab_test()

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

Definition at line 370 of file probe_bake.comp.

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

◆ get_uvs()

vec2 get_uvs ( vec3 B,
uint tri_idx )

Definition at line 382 of file probe_bake.comp.

References B, get_uvs(), Vertex::uv, Face::v0, Face::v1, Face::v2, vec3::x, vec3::y, and vec3::z.

◆ get_hit_uvs()

vec2 get_hit_uvs ( in Face tri,
in RayHit hit )

Definition at line 394 of file probe_bake.comp.

References RayHit::barycentrics, get_hit_uvs(), hit, vec3::x, vec3::y, and vec3::z.

◆ get_hit_albedo()

vec4 get_hit_albedo ( in Material mat,
vec2 hit_uv )

Definition at line 402 of file probe_bake.comp.

References get_hit_albedo().

◆ get_hit_emissive()

vec3 get_hit_emissive ( in Material mat,
vec2 hit_uv )

Definition at line 408 of file probe_bake.comp.

References get_hit_emissive().

◆ traverse_mesh_bvh()

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 )

◆ traverse_scene_bvh()

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

◆ compute_3d_barycentric()

vec3 compute_3d_barycentric ( vec3 a,
vec3 b,
vec3 c,
vec3 p )

Definition at line 544 of file probe_bake.comp.

References compute_3d_barycentric().

◆ CalculateAttenuation()

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

Definition at line 561 of file probe_bake.comp.

References CalculateAttenuation(), clamp(), and window.

◆ solve_light_source()

◆ random_pos_on_triangle()

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

Definition at line 688 of file probe_bake.comp.

References rand(), and random_pos_on_triangle().

◆ 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 )

Definition at line 824 of file probe_bake.comp.

References clamp(), and closest_point_on_aabb().

◆ pos_inside_aabb()

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

Definition at line 829 of file probe_bake.comp.

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

◆ traverse_light_bvh()

vec3 traverse_light_bvh ( vec3 pos,
vec3 normal,
uint mesh,
uint tri,
vec3 brdf )

◆ traverse_light_bvh_direct_emissives()

vec3 traverse_light_bvh_direct_emissives ( vec3 pos,
vec3 normal,
vec3 brdf )

◆ resolve_transparents()

◆ trace_path()

◆ solve_SH()

void solve_SH ( vec3 color,
vec3 dir,
int index,
vec3 pos )

Definition at line 1229 of file probe_bake.comp.

References color, solve_SH(), vec3::x, vec3::y, and vec3::z.

Referenced by main(), and solve_SH().

◆ main()

void main ( )

Variable Documentation

◆ uSkybox

uniform samplerCube uSkybox

Definition at line 205 of file probe_bake.comp.

◆ uTileOffset

uniform ivec2 uTileOffset

Definition at line 207 of file probe_bake.comp.

◆ uLightCount

uniform int uLightCount

Definition at line 208 of file probe_bake.comp.

◆ uWorldMin

uniform vec3 uWorldMin

Definition at line 209 of file probe_bake.comp.

◆ uProbeSize

uniform ivec3 uProbeSize

Definition at line 211 of file probe_bake.comp.

◆ uCurrentIteration

uniform int uCurrentIteration

Definition at line 212 of file probe_bake.comp.

Referenced by main(), and trace_path().

◆ uIterations

uniform int uIterations

Definition at line 213 of file probe_bake.comp.

◆ uSpacing

uniform float uSpacing

Definition at line 215 of file probe_bake.comp.

◆ state

uint state = 0

Definition at line 238 of file probe_bake.comp.

◆ hit

RayHit hit

Definition at line 322 of file probe_bake.comp.

◆ first_dir

vec3 first_dir

Definition at line 1075 of file probe_bake.comp.

Referenced by main(), and trace_path().