summaryrefslogtreecommitdiff
path: root/common/shaders/render/raymarching_id.wgsl
diff options
context:
space:
mode:
Diffstat (limited to 'common/shaders/render/raymarching_id.wgsl')
-rw-r--r--common/shaders/render/raymarching_id.wgsl12
1 files changed, 6 insertions, 6 deletions
diff --git a/common/shaders/render/raymarching_id.wgsl b/common/shaders/render/raymarching_id.wgsl
index d16445e..42be02d 100644
--- a/common/shaders/render/raymarching_id.wgsl
+++ b/common/shaders/render/raymarching_id.wgsl
@@ -1,7 +1,7 @@
// Common functions for Signed Distance Field (SDF) raymarching with object ID.
//
// Required user-defined functions:
-// - dfWithID(vec3<f32>) -> RayMarchResult
+// - dfWithID(vec3f) -> RayMarchResult
//
// Requires constants from raymarching.wgsl:
// TOLERANCE, MAX_RAY_LENGTH, MAX_RAY_MARCHES, NORM_OFF
@@ -21,7 +21,7 @@ struct RayMarchResult {
}
// Raymarch with object ID tracking.
-fn rayMarchWithID(ro: vec3<f32>, rd: vec3<f32>, init: RayMarchResult) -> RayMarchResult {
+fn rayMarchWithID(ro: vec3f, rd: vec3f, init: RayMarchResult) -> RayMarchResult {
var t = init.distance;
var result = init;
@@ -45,14 +45,14 @@ fn rayMarchWithID(ro: vec3<f32>, rd: vec3<f32>, init: RayMarchResult) -> RayMarc
}
// Reconstruct world position from stored result.
-fn reconstructPosition(ray: Ray, result: RayMarchResult) -> vec3<f32> {
+fn reconstructPosition(ray: Ray, result: RayMarchResult) -> vec3f {
return ray.origin + ray.direction * result.distance;
}
// Normal calculation using dfWithID.
-fn normalWithID(pos: vec3<f32>) -> vec3<f32> {
+fn normalWithID(pos: vec3f) -> vec3f {
let eps = vec2<f32>(NORM_OFF, 0.0);
- var nor: vec3<f32>;
+ var nor: vec3f;
nor.x = dfWithID(pos + eps.xyy).distance - dfWithID(pos - eps.xyy).distance;
nor.y = dfWithID(pos + eps.yxy).distance - dfWithID(pos - eps.yxy).distance;
nor.z = dfWithID(pos + eps.yyx).distance - dfWithID(pos - eps.yyx).distance;
@@ -60,7 +60,7 @@ fn normalWithID(pos: vec3<f32>) -> vec3<f32> {
}
// Shadow using stored intersection distance.
-fn shadowWithStoredDistance(lp: vec3<f32>, ld: vec3<f32>, stored_dist: f32) -> f32 {
+fn shadowWithStoredDistance(lp: vec3f, ld: vec3f, stored_dist: f32) -> f32 {
let ds = 1.0 - 0.4;
var t = 0.01;
var nd = 1e6;