summaryrefslogtreecommitdiffstats
path: root/vertex.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-02-17 18:52:17 -0800
committeryum <yum.food.vr@gmail.com>2026-02-17 18:52:17 -0800
commit00553b3f305d0e2217659993f237ff3da604ef85 (patch)
tree76d048fcfb005cf7427f43bb6539d1ef59b75bf3 /vertex.cginc
parent0783345c23701149b807d2063410e329ba1fbed6 (diff)
Fold: add plane to octahedron code
Diffstat (limited to 'vertex.cginc')
-rwxr-xr-xvertex.cginc70
1 files changed, 70 insertions, 0 deletions
diff --git a/vertex.cginc b/vertex.cginc
index 7c448ab..c4da8ca 100755
--- a/vertex.cginc
+++ b/vertex.cginc
@@ -17,6 +17,9 @@
#define OPCODE_HEMI_OCTAHEDRON_TO_PLANE 10
#define OPCODE_SCALE 11
#define OPCODE_TRANSLATE 12
+#define OPCODE_PLANE_TO_OCTAHEDRON 13
+#define OPCODE_OCTAHEDRON_TO_PLANE 14
+#define OPCODE_ROTATE 15
#if defined(_VERTEX_DEFORMATION)
@@ -210,6 +213,55 @@ void apply_translate_normal(inout float3 objPos, inout float3 objNorm,
translate_normal(objPos, objNorm, objTan, offset, t);
}
+void apply_plane_to_octahedron(inout float3 objPos, float4 v0, float4 v1, float4 v2, float f0) {
+ float3 p = v0.xyz;
+ float3 r = v1.xyz;
+ float3 s = v2.xyz;
+ float t = f0;
+ objPos = plane_to_octahedron(objPos, p, r, s, t);
+}
+
+void apply_plane_to_octahedron_normal(inout float3 objPos, inout float3 objNorm, inout float3 objTan, float4 v0, float4 v1, float4 v2, float f0) {
+ float3 p = v0.xyz;
+ float3 r = v1.xyz;
+ float3 s = v2.xyz;
+ float t = f0;
+ plane_to_octahedron_normal(objPos, objNorm, objTan, p, r, s, t);
+}
+
+void apply_octahedron_to_plane(inout float3 objPos, float4 v0, float4 v1, float4 v2, float f0) {
+ float3 p = v0.xyz;
+ float3 r = v1.xyz;
+ float3 s = v2.xyz;
+ float t = f0;
+ objPos = octahedron_to_plane(objPos, p, r, s, t);
+}
+
+void apply_octahedron_to_plane_normal(inout float3 objPos, inout float3 objNorm, inout float3 objTan, float4 v0, float4 v1, float4 v2, float f0) {
+ float3 p = v0.xyz;
+ float3 r = v1.xyz;
+ float3 s = v2.xyz;
+ float t = f0;
+ octahedron_to_plane_normal(objPos, objNorm, objTan, p, r, s, t);
+}
+
+void apply_rotate(inout float3 objPos, float4 v0, float4 v1, float f0, float f1) {
+ float3 p = v0.xyz;
+ float3 axis = v1.xyz;
+ float angle = f0;
+ float t = f1;
+ objPos = rotate(objPos, p, axis, angle, t);
+}
+
+void apply_rotate_normal(inout float3 objPos, inout float3 objNorm,
+ inout float3 objTan, float4 v0, float4 v1, float f0, float f1) {
+ float3 p = v0.xyz;
+ float3 axis = v1.xyz;
+ float angle = f0;
+ float t = f1;
+ rotate_normal(objPos, objNorm, objTan, p, axis, angle, t);
+}
+
void deform(inout float3 objPos) {
const float t = getTime();
@@ -454,6 +506,15 @@ void deform(inout float3 objPos) {
case OPCODE_TRANSLATE:
apply_translate(objPos, v0, f0);
break;
+ case OPCODE_PLANE_TO_OCTAHEDRON:
+ apply_plane_to_octahedron(objPos, v0, v1, v2, f0);
+ break;
+ case OPCODE_OCTAHEDRON_TO_PLANE:
+ apply_octahedron_to_plane(objPos, v0, v1, v2, f0);
+ break;
+ case OPCODE_ROTATE:
+ apply_rotate(objPos, v0, v1, f0, f1);
+ break;
}
}
}
@@ -705,6 +766,15 @@ void deform_normal(inout float3 objPos, inout float3 objNorm, inout float3 objTa
case OPCODE_TRANSLATE:
apply_translate_normal(objPos, objNorm, objTan, v0, f0);
break;
+ case OPCODE_PLANE_TO_OCTAHEDRON:
+ apply_plane_to_octahedron_normal(objPos, objNorm, objTan, v0, v1, v2, f0);
+ break;
+ case OPCODE_OCTAHEDRON_TO_PLANE:
+ apply_octahedron_to_plane_normal(objPos, objNorm, objTan, v0, v1, v2, f0);
+ break;
+ case OPCODE_ROTATE:
+ apply_rotate_normal(objPos, objNorm, objTan, v0, v1, f0, f1);
+ break;
}
}
}