summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-11-01 12:07:18 -0700
committeryum <yum.food.vr@gmail.com>2025-11-01 12:07:18 -0700
commit74b584ac77384613226854fe368cdce2a5612939 (patch)
treea6e3bfdfc41b44b28e0897c1a10c50332f7bdca8
parent04c1976f17cb766961ed4dc0ad3ef26848188c00 (diff)
Adjust deform/undeform jacobian determinant factors
-rw-r--r--ray_marching.cginc2
-rw-r--r--ray_marching_maps.slang9
-rw-r--r--vertex_deformation.slang4
3 files changed, 8 insertions, 7 deletions
diff --git a/ray_marching.cginc b/ray_marching.cginc
index 17777ed..66d0845 100644
--- a/ray_marching.cginc
+++ b/ray_marching.cginc
@@ -33,7 +33,7 @@ RayMarchResult ray_march(v2f i) {
float3 rd_tan = rd - rd_perp;
float3 tmp = ro;
undeform_normal(tmp, rd_perp, rd_tan);
- rd = normalize(rd_perp + rd_tan);
+ rd = rd_perp + rd_tan;
#endif
const float kMinDist = 1e-3;
diff --git a/ray_marching_maps.slang b/ray_marching_maps.slang
index 649a557..87481a0 100644
--- a/ray_marching_maps.slang
+++ b/ray_marching_maps.slang
@@ -1,6 +1,7 @@
#ifndef __RAY_MARCHING_MAPS_INC
#define __RAY_MARCHING_MAPS_INC
+
#include "math.cginc"
#include "pema99.cginc"
@@ -34,8 +35,8 @@
// Just trace a sphere of radius 0.1 for now.
[Differentiable]
public float map(float3 p) {
- float3 count = float3(5,5,1);
- float3 period = 0.2f;
+ float3 count = float3(20,20,1);
+ float3 period = 0.05f;
float3 half_period = period*0.5f;
float3 which = abs(floor((p + half_period) / period));
if (any(abs(which) >= count)) {
@@ -44,8 +45,8 @@ public float map(float3 p) {
p = glsl_mod(p + half_period, period) - half_period;
}
- p.z += 0.1f;
- return length(p) - 0.1f;
+ p.z += half_period.x;
+ return length(p) - half_period.x;
}
public void map_normal(inout float3 xyz, inout float3 normal,
diff --git a/vertex_deformation.slang b/vertex_deformation.slang
index 0791aa7..c683982 100644
--- a/vertex_deformation.slang
+++ b/vertex_deformation.slang
@@ -43,7 +43,7 @@
); \
float jac_det = determinant(jacobian); \
float3x3 itjac = inverse(transpose(jacobian), jac_det); \
- normal = mul(itjac, normal) * sign(jac_det); \
+ normal = mul(itjac, normal) * jac_det; \
tangent = mul(jacobian, tangent)
#define R3R3_UNDEFORM_NORMAL_AND_TANGENT(normal, tangent) \
@@ -55,7 +55,7 @@
float jac_det = determinant(jacobian); \
float3x3 inv_jac = inverse(jacobian, jac_det); \
float3x3 trans_jac = transpose(jacobian); \
- normal = mul(trans_jac, normal); \
+ normal = mul(trans_jac, normal) * jac_det; \
tangent = mul(inv_jac, tangent)
// Syntactic sugar - wraps the previous three macros.