diff options
| author | yum <yum.food.vr@gmail.com> | 2025-10-31 15:40:20 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-10-31 15:40:20 -0700 |
| commit | 2edd7a2333ebc36f19f8726cb2d2f79aa501cb18 (patch) | |
| tree | ae34b5707ca07d9c2b78d41fb6190a99cb7ab875 /vertex_deformation.slang | |
| parent | 15f9778a65a0f163627bd229b8f212cc5c7c0c22 (diff) | |
begin sketching out "undeform" codepath
Diffstat (limited to 'vertex_deformation.slang')
| -rw-r--r-- | vertex_deformation.slang | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/vertex_deformation.slang b/vertex_deformation.slang index 42cf6b8..63804de 100644 --- a/vertex_deformation.slang +++ b/vertex_deformation.slang @@ -35,7 +35,7 @@ DifferentialPair<float3> dp_y_out = fwd_diff(fun)(dp_y, __VA_ARGS__); \ DifferentialPair<float3> dp_z_out = fwd_diff(fun)(dp_z, __VA_ARGS__) -#define R3R3_DEFORM_NORMAL_AND_TANGENT(normal, tangent) \ +#define R3R3_DEFORM_NORMAL_AND_TANGENT(normal, tangent) \ float3x3 jacobian = float3x3( \ float3(dp_x_out.d.x, dp_y_out.d.x, dp_z_out.d.x), \ float3(dp_x_out.d.y, dp_y_out.d.y, dp_z_out.d.y), \ @@ -46,6 +46,18 @@ normal = mul(itjac, normal) * sign(jac_det); \ tangent = mul(jacobian, tangent) +#define R3R3_UNDEFORM_NORMAL_AND_TANGENT(normal, tangent) \ + float3x3 jacobian = float3x3( \ + float3(dp_x_out.d.x, dp_y_out.d.x, dp_z_out.d.x), \ + float3(dp_x_out.d.y, dp_y_out.d.y, dp_z_out.d.y), \ + float3(dp_x_out.d.z, dp_y_out.d.z, dp_z_out.d.z) \ + ); \ + float jac_det = determinant(jacobian); \ + float3x3 inv_jac = inverse(jacobian, jac_det); \ + float3x3 trans_jac = transpose(jacobian); \ + normal = mul(trans_jac, normal) * sign(jac_det); \ + tangent = mul(inv_jac, tangent) + // Syntactic sugar - wraps the previous three macros. #define R3R3_NORMALS(xyz, normal, tangent, fun, ...) \ R3R3_DECLARE_BASIS_VECTORS(xyz); \ |
