summaryrefslogtreecommitdiffstats
path: root/3ner.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-10-12 16:28:53 -0700
committeryum <yum.food.vr@gmail.com>2025-10-12 16:28:53 -0700
commita4bf31470f7e2855f13d922e3e7ad1c7767d9afd (patch)
treeeeefe31633142978c609c2dd2b4d6890349526a6 /3ner.cginc
parent6ac3da1b0bd363d70c2f6e4b7b921f2f929dedac (diff)
add geometry shader
Diffstat (limited to '3ner.cginc')
-rw-r--r--3ner.cginc46
1 files changed, 46 insertions, 0 deletions
diff --git a/3ner.cginc b/3ner.cginc
index 0536fb5..bac74ad 100644
--- a/3ner.cginc
+++ b/3ner.cginc
@@ -9,6 +9,7 @@
#include "AutoLight.cginc"
#include "brdf.cginc"
+#include "geometry.cginc"
#include "pbr.cginc"
#include "lighting.cginc"
#include "globals.cginc"
@@ -50,6 +51,7 @@ v2f vert(appdata v) {
return o;
}
+//ifex _Tessellation_Enabled==0
struct tess_factors {
float edge[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
@@ -170,6 +172,50 @@ v2f domain(
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
return o;
}
+//endex
+
+//ifex _Geometry_Shader_Enabled==0
+// maxvertexcount == the number of vertices we create
+[maxvertexcount(3)]
+void geom(triangle v2f tri_in[3],
+ uint pid: SV_PrimitiveID,
+ inout TriangleStream<v2f> tri_out)
+{
+ v2f v0 = tri_in[0];
+ v2f v1 = tri_in[1];
+ v2f v2 = tri_in[2];
+
+#if defined(_CENTER_OFFSET)
+ float3 n0 = v0.normal;
+ float3 n1 = v1.normal;
+ float3 n2 = v2.normal;
+#if defined(_CUSTOM31_FRAGMENT_NORMALS) || defined(_CUSTOM31_TESSELLATION)
+ float3 tmp;
+ deform_normal(v0.objPos_orig, n0, tmp);
+ deform_normal(v1.objPos_orig, n1, tmp);
+ deform_normal(v2.objPos_orig, n2, tmp);
+ // the average direction doesn't have to be precise, so don't bother with
+ // normalize().
+ float3 n = (n0 + n1 + n2) * 0.333f;
+#else
+ float3 n = (v0.normal + v1.normal + v2.normal) * 0.333f;
+#endif
+ float height = center_offset(v0.uv0);
+ v0.objPos += n * height;
+ v1.objPos += n * height;
+ v2.objPos += n * height;
+ propagateObjPos(v0);
+ propagateObjPos(v1);
+ propagateObjPos(v2);
+#endif
+
+ // Output transformed geometry.
+ tri_out.Append(v0);
+ tri_out.Append(v1);
+ tri_out.Append(v2);
+ tri_out.RestartStrip();
+}
+//endex
float4 frag(v2f i, uint facing : SV_IsFrontFace
#if defined(_CUSTOM31_TUBES)