Advanced search tips: use spaces to require multiple terms (AND), | for alternatives (OR), wrap phrases in quotes (="a b"), =term for exact match, 'term to include, !term to exclude, ^term to match prefix, !^term to exclude prefix, .ext$ to match suffix, and !.ext$ to exclude suffix.

raytracing_scene_bindings.wgsl

Import path

Constants

TEXTURE_MAP_NONE

#
const TEXTURE_MAP_NONE: u32 = 0xFFFFFFFFu

MIRROR_ROUGHNESS_THRESHOLD

#
const MIRROR_ROUGHNESS_THRESHOLD: AbstractFloat = 0.001f

LIGHT_SOURCE_KIND_EMISSIVE_MESH

#
const LIGHT_SOURCE_KIND_EMISSIVE_MESH: u32 = 0u

LIGHT_SOURCE_KIND_DIRECTIONAL

#
const LIGHT_SOURCE_KIND_DIRECTIONAL: u32 = 1u

LIGHT_NOT_PRESENT_THIS_FRAME

#
const LIGHT_NOT_PRESENT_THIS_FRAME: u32 = 0xFFFFFFFFu

RAY_T_MIN

#
const RAY_T_MIN: AbstractFloat = 0.001f

RAY_T_MAX

#
const RAY_T_MAX: AbstractFloat = 100000.0f

RAY_NO_CULL

#
const RAY_NO_CULL: u32 = 0xFFu

Bindings

vertex_buffers

#
@group(0)
@binding(0)
var<storage> vertex_buffers: binding_array<VertexBuffer>

index_buffers

#
@group(0)
@binding(1)
var<storage> index_buffers: binding_array<IndexBuffer>

textures

#
@group(0)
@binding(2)
var textures: binding_array<texture_2d<f32>>

samplers

#
@group(0)
@binding(3)
var samplers: binding_array<sampler>

materials

#
@group(0)
@binding(4)
var<storage> materials: array<Material>

tlas

#
@group(0)
@binding(5)
var tlas: acceleration_structure

transforms

#
@group(0)
@binding(6)
var<storage> transforms: array<mat4x4<f32>>

previous_frame_transforms

#
@group(0)
@binding(7)
var<storage> previous_frame_transforms: array<mat4x4<f32>>

geometry_ids

#
@group(0)
@binding(8)
var<storage> geometry_ids: array<InstanceGeometryIds>

material_ids

#
@group(0)
@binding(9)
var<storage> material_ids: array<u32>

light_sources

#
@group(0)
@binding(10)
var<storage> light_sources: array<LightSource>

directional_lights

#
@group(0)
@binding(11)
var<storage> directional_lights: array<DirectionalLight>

previous_frame_light_id_translations

#
@group(0)
@binding(12)
var<storage> previous_frame_light_id_translations: array<u32>

brdf_dfg_lut

#
@group(0)
@binding(13)
var brdf_dfg_lut: texture_2d<f32>

brdf_dfg_lut_sampler

#
@group(0)
@binding(14)
var brdf_dfg_lut_sampler: sampler

Structures

InstanceGeometryIds

#
struct InstanceGeometryIds {
vertex_buffer_id: u32 ,
vertex_buffer_offset: u32 ,
index_buffer_id: u32 ,
index_buffer_offset: u32 ,
triangle_count: u32 ,
}

VertexBuffer

#
struct VertexBuffer { }

IndexBuffer

#
struct IndexBuffer {
indices: array<u32> ,
}

PackedVertex

#
struct PackedVertex { }

Vertex

#
struct Vertex {
position: vec3<f32> ,
normal: vec3<f32> ,
tangent: vec4<f32> ,
}

Material

#
struct Material {
normal_map_texture_id: u32 ,
base_color_texture_id: u32 ,
emissive_texture_id: u32 ,
metallic_roughness_texture_id: u32 ,
base_color: vec3<f32> ,
perceptual_roughness: f32 ,
emissive: vec3<f32> ,
metallic: f32 ,
_padding: vec3<f32> ,
reflectance: f32 ,
}

LightSource

#
struct LightSource {
kind: u32 ,
id: u32 ,
}

DirectionalLight

#
struct DirectionalLight {
direction_to_light: vec3<f32> ,
cos_theta_max: f32 ,
luminance: vec3<f32> ,
inverse_pdf: f32 ,
}

ResolvedMaterial

#
struct ResolvedMaterial {
base_color: vec3<f32> ,
emissive: vec3<f32> ,
reflectance: f32 ,
perceptual_roughness: f32 ,
roughness: f32 ,
metallic: f32 ,
}

ResolvedRayHitFull

#
struct ResolvedRayHitFull {
world_position: vec3<f32> ,
previous_frame_world_position: vec3<f32> ,
world_normal: vec3<f32> ,
geometric_world_normal: vec3<f32> ,
world_tangent: vec4<f32> ,
triangle_area: f32 ,
triangle_count: u32 ,
material: ResolvedMaterial ,
}

Functions

unpack_vertex

#
fn unpack_vertex ( ) -> Vertex

trace_ray

#
fn trace_ray (
ray_origin: vec3<f32>
ray_direction: vec3<f32>
ray_t_min: f32
ray_t_max: f32
ray_flag: u32
) -> RayIntersection

sample_texture

#
fn sample_texture ( ) -> vec3<f32>

resolve_material

#
fn resolve_material (
material: Material
) -> ResolvedMaterial

resolve_ray_hit_full

#
fn resolve_ray_hit_full (
ray_hit: RayIntersection
) -> ResolvedRayHitFull

load_vertices

#
fn load_vertices (
instance_geometry_ids: InstanceGeometryIds
triangle_id: u32
) -> array<Vertex, 3>

transform_positions

#
fn transform_positions (
transform: mat4x4<f32>
) -> array<vec3<f32>, 3>

resolve_triangle_data_full

#
fn resolve_triangle_data_full (
instance_id: u32
triangle_id: u32
barycentrics: vec3<f32>
) -> ResolvedRayHitFull