summaryrefslogtreecommitdiff
path: root/assets/final/shaders/math/sdf_utils.wgsl
blob: ce902bf0516ba6640320be65cbf3a49f0dfe34ce (plain)
1
2
3
4
5
6
7
8
9
fn get_normal_basic(p: vec3<f32>, obj_type: f32) -> vec3<f32> {
    if (obj_type == 1.0) { return normalize(p); }
    let e = vec2<f32>(0.001, 0.0);
    return normalize(vec3<f32>(
        get_dist(p + e.xyy, obj_type) - get_dist(p - e.xyy, obj_type),
        get_dist(p + e.yxy, obj_type) - get_dist(p - e.yxy, obj_type),
        get_dist(p + e.yyx, obj_type) - get_dist(p - e.yyx, obj_type)
    ));
}