summaryrefslogtreecommitdiffstats
path: root/vertex_deformation.slang
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-10-17 21:24:29 -0700
committeryum <yum.food.vr@gmail.com>2025-10-17 21:24:29 -0700
commitddf847e758d9766d33ccc9b1a560a84142e395e0 (patch)
tree3ac90042d3bdcfd73b93d6f2d374a6134bc0b7ab /vertex_deformation.slang
parent98e115ebfc40e72a8ee1c6453735d8f6076f7890 (diff)
fix how normals are calculated with multiple modifiers on
Diffstat (limited to 'vertex_deformation.slang')
-rw-r--r--vertex_deformation.slang9
1 files changed, 5 insertions, 4 deletions
diff --git a/vertex_deformation.slang b/vertex_deformation.slang
index f4d4132..354290c 100644
--- a/vertex_deformation.slang
+++ b/vertex_deformation.slang
@@ -39,7 +39,8 @@
#define R3R3_NORMALS(xyz, normal, tangent, fun, ...) \
R3R3_DECLARE_BASIS_VECTORS(xyz); \
R3R3_AUTODIFF_BASIS_VECTORS(fun, __VA_ARGS__); \
- R3R3_DEFORM_NORMAL_AND_TANGENT(normal, tangent)
+ R3R3_DEFORM_NORMAL_AND_TANGENT(normal, tangent); \
+ xyz = fun(xyz, __VA_ARGS__)
float3x3 inverse(float3x3 m, float det) {
det = max(1e-6 * abs(det), abs(det)) * sign(det);
@@ -78,7 +79,7 @@ public float3 plane_to_tube(float3 xyz, no_diff float t) {
return float3(x, y0, z);
}
-public void plane_to_tube_normal(float3 xyz, inout float3 normal,
+public void plane_to_tube_normal(inout float3 xyz, inout float3 normal,
inout float3 tangent, float t) {
R3R3_NORMALS(xyz, normal, tangent, plane_to_tube, t);
}
@@ -104,7 +105,7 @@ public float3 seal(float3 xyz, no_diff float A, no_diff float k, no_diff float t
);
}
-public void seal_normal(float3 xyz, inout float3 normal,
+public void seal_normal(inout float3 xyz, inout float3 normal,
inout float3 tangent, float A, float k, float t) {
R3R3_NORMALS(xyz, normal, tangent, seal, A, k, t);
}
@@ -120,7 +121,7 @@ public float3 sine_wave(float3 xyz,
return xyz;
}
-public void sine_wave_normal(float3 xyz, inout float3 normal, inout float3 tangent,
+public void sine_wave_normal(inout float3 xyz, inout float3 normal, inout float3 tangent,
float3 amplitude, float3 direction, float3 k, float3 omega, float t) {
R3R3_NORMALS(xyz, normal, tangent, sine_wave, amplitude, direction, k, omega, t);
}