diff options
| author | yum <yum.food.vr@gmail.com> | 2025-11-01 11:45:25 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-11-01 11:45:25 -0700 |
| commit | 12c223b5b8bf1860d77f41551cf9e5374196aed7 (patch) | |
| tree | 093233b97e2f4f91377de17817ba5f5fc45143f3 /vertex_deformation.slang | |
| parent | 2edd7a2333ebc36f19f8726cb2d2f79aa501cb18 (diff) | |
meow
Diffstat (limited to 'vertex_deformation.slang')
| -rw-r--r-- | vertex_deformation.slang | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vertex_deformation.slang b/vertex_deformation.slang index 63804de..678cc24 100644 --- a/vertex_deformation.slang +++ b/vertex_deformation.slang @@ -107,6 +107,13 @@ public void plane_to_tube_normal(inout float3 xyz, inout float3 normal, R3R3_NORMALS(xyz, normal, tangent, plane_to_tube, t); } +public void plane_to_tube_undeform_normal(float3 xyz, inout float3 normal, + inout float3 tangent, float t) { + R3R3_DECLARE_BASIS_VECTORS(xyz); + R3R3_AUTODIFF_BASIS_VECTORS(plane_to_tube, t); + R3R3_UNDEFORM_NORMAL_AND_TANGENT(normal, tangent); +} + [Differentiable] public float3 seal(float3 xyz, no_diff float A, no_diff float k, no_diff float t) { float x = xyz.x; @@ -133,6 +140,13 @@ public void seal_normal(inout float3 xyz, inout float3 normal, R3R3_NORMALS(xyz, normal, tangent, seal, A, k, t); } +public void seal_undeform_normal(float3 xyz, inout float3 normal, + inout float3 tangent, float A, float k, float t) { + R3R3_DECLARE_BASIS_VECTORS(xyz); + R3R3_AUTODIFF_BASIS_VECTORS(seal, A, k, t); + R3R3_UNDEFORM_NORMAL_AND_TANGENT(normal, tangent); +} + [Differentiable] public float3 sine_wave(float3 xyz, no_diff float3 amplitude, @@ -149,6 +163,14 @@ public void sine_wave_normal(inout float3 xyz, inout float3 normal, inout float3 R3R3_NORMALS(xyz, normal, tangent, sine_wave, amplitude, direction, k, omega, t); } +public void sine_wave_undeform_normal(float3 xyz, inout float3 normal, + inout float3 tangent, float3 amplitude, float3 direction, float3 k, + float3 omega, float t) { + R3R3_DECLARE_BASIS_VECTORS(xyz); + R3R3_AUTODIFF_BASIS_VECTORS(sine_wave, amplitude, direction, k, omega, t); + R3R3_UNDEFORM_NORMAL_AND_TANGENT(normal, tangent); +} + [Differentiable] float3 rand3_hash3(float3 p) { @@ -292,4 +314,22 @@ public void fbm_normal(inout float3 xyz, inout float3 normal, inout float3 tange tangent = mul(jac, tangent); } +public void fbm_undeform_normal(float3 xyz, float t, + float amplitude, float gain, float lacunarity, + float scale, float octaves, float3 velocity, + inout float3 normal, inout float3 tangent) { + float3 dx, dy, dz; + fbm_with_derivatives(xyz, t, amplitude, gain, lacunarity, scale, octaves, + velocity, dx, dy, dz); + float3x3 jac = float3x3( + dx.x, dy.x, dz.x, + dx.y, dy.y, dz.y, + dx.z, dy.z, dz.z); + float jac_det = determinant(jac); + float3x3 inv_jac = inverse(jac, jac_det); + float3x3 trans_jac = transpose(jac); + normal = mul(trans_jac, normal) * sign(jac_det); + tangent = mul(inv_jac, tangent); +} + #endif // __CUSTOM31_INC |
