summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-08-06 16:50:12 -0700
committeryum <yum.food.vr@gmail.com>2025-08-06 16:50:16 -0700
commitcc54dca9cd98ca7020ccc8768a51d78ab117da79 (patch)
treea71ded2e9c17105aaa972e1296c5b07d6b5b9c2a
parent99d161288bfe2d10c331c97e6b7571f9c884e912 (diff)
more cleanup; add mesh normals
-rw-r--r--3ner.cginc9
-rw-r--r--3ner.shader120
-rw-r--r--globals.cginc86
-rw-r--r--interpolators.cginc6
-rw-r--r--pbr.cginc2
5 files changed, 14 insertions, 209 deletions
diff --git a/3ner.cginc b/3ner.cginc
index bfaeded..00d98a0 100644
--- a/3ner.cginc
+++ b/3ner.cginc
@@ -29,6 +29,9 @@ v2f vert(appdata v) {
o.objPos = v.vertex;
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
o.eyeVec.xyz = o.worldPos.xyz - _WorldSpaceCameraPos;
+ o.normal = UnityObjectToWorldNormal(v.normal);
+ o.tangent.xyz = UnityObjectToWorldNormal(v.tangent.xyz);
+ o.tangent.w = v.tangent.w;
UNITY_TRANSFER_LIGHTING(o, v.uv1);
UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o, o.pos);
@@ -146,6 +149,9 @@ v2f domain(
o.objPos = DOMAIN_INTERP(objPos);
#endif
+ o.normal = DOMAIN_INTERP(normal);
+ o.tangent = DOMAIN_INTERP(tangent);
+
o.worldPos = mul(unity_ObjectToWorld, float4(o.objPos, 1));
o.pos = UnityObjectToClipPos(o.objPos);
o.eyeVec.xyz = o.worldPos - _WorldSpaceCameraPos;
@@ -155,7 +161,8 @@ v2f domain(
return o;
}
-float4 frag(v2f i) : SV_Target {
+float4 frag(v2f i, uint facing : SV_IsFrontFace) : SV_Target {
+ i.normal *= facing ? 1 : -1;
Pbr pbr = getPbr(i);
LightData light_data;
GetLighting(i, pbr, light_data);
diff --git a/3ner.shader b/3ner.shader
index 00602df..727d733 100644
--- a/3ner.shader
+++ b/3ner.shader
@@ -32,126 +32,6 @@ Shader "yum_food/3ner"
_Metallic("Metallic", Range(0, 1)) = 0
_Smoothness("Smoothness", Range(0, 1)) = 0
- //ifex _Sea_FX_Enabled==0
- [HideInInspector] m_start_Sea_FX("Sea FX", Float) = 0
- [ThryToggle(_SEA_FX)] _Sea_FX_Enabled("Enable", Float) = 0
-
- [HideInInspector] m_start_Sea_FX_Heightmaps("Heightmaps", Float) = 0
- //ifex _Sea_FX_Heightmaps_Y_0_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_Y_0)] _Sea_FX_Heightmaps_Y_0_Enabled("Enable (Y 0)", Float) = 0
- _Sea_FX_Heightmaps_Y_0("Y 0", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_Y_1_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_Y_1)] _Sea_FX_Heightmaps_Y_1_Enabled("Enable (Y 1)", Float) = 0
- _Sea_FX_Heightmaps_Y_1("Y 1", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_Y_2_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_Y_2)] _Sea_FX_Heightmaps_Y_2_Enabled("Enable (Y 2)", Float) = 0
- _Sea_FX_Heightmaps_Y_2("Y 2", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_Y_3_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_Y_3)] _Sea_FX_Heightmaps_Y_3_Enabled("Enable (Y 3)", Float) = 0
- _Sea_FX_Heightmaps_Y_3("Y 3", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_XZ_0_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_XZ_0)] _Sea_FX_Heightmaps_XZ_0_Enabled("Enable (XZ 0)", Float) = 0
- _Sea_FX_Heightmaps_XZ_0("XZ 0", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_XZ_1_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_XZ_1)] _Sea_FX_Heightmaps_XZ_1_Enabled("Enable (XZ 1)", Float) = 0
- _Sea_FX_Heightmaps_XZ_1("XZ 1", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_XZ_2_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_XZ_2)] _Sea_FX_Heightmaps_XZ_2_Enabled("Enable (XZ 2)", Float) = 0
- _Sea_FX_Heightmaps_XZ_2("XZ 2", 2D) = "black" {}
- //endex
- //ifex _Sea_FX_Heightmaps_XZ_3_Enabled==0
- [ThryToggle(_SEA_FX_HEIGHTMAPS_XZ_3)] _Sea_FX_Heightmaps_XZ_3_Enabled("Enable (XZ 3)", Float) = 0
- _Sea_FX_Heightmaps_XZ_3("XZ 3", 2D) = "black" {}
- //endex
- [HideInInspector] m_end_Sea_FX_Heightmaps("Heightmaps", Float) = 0
-
- [HideInInspector] m_start_Sea_FX_Derivatives("Derivatives", Float) = 0
- _Sea_FX_Derivatives_SS_Filtering_Factor("SS filtering factor", Range(0, 50)) = 15
- //ifex _Sea_FX_Vertical_Derivatives_0_Enabled==0
- [HideInInspector] m_start_Sea_FX_Vertical_Derivatives_0("Vertical derivatives 0", Float) = 0
- [ThryToggle(_SEA_FX_VERTICAL_DERIVATIVES_0)] _Sea_FX_Vertical_Derivatives_0_Enabled("Enable", Float) = 0
- _Sea_FX_Vertical_Derivatives_0("Vertical derivatives 0", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Vertical_Derivatives_0("Vertical derivatives 0", Float) = 0
- //endex
- //ifex _Sea_FX_Horizontal_Derivatives_0_Enabled==0
- [HideInInspector] m_start_Sea_FX_Horizontal_Derivatives_0("Horizontal derivatives 0", Float) = 0
- [ThryToggle(_SEA_FX_HORIZONTAL_DERIVATIVES_0)] _Sea_FX_Horizontal_Derivatives_0_Enabled("Enable", Float) = 0
- _Sea_FX_Horizontal_Derivatives_0("Horizontal derivatives 0", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Horizontal_Derivatives_0("Horizontal derivatives 0", Float) = 0
- //endex
- //ifex _Sea_FX_Vertical_Derivatives_1_Enabled==0
- [HideInInspector] m_start_Sea_FX_Vertical_Derivatives_1("Vertical derivatives 1", Float) = 0
- [ThryToggle(_SEA_FX_VERTICAL_DERIVATIVES_1)] _Sea_FX_Vertical_Derivatives_1_Enabled("Enable", Float) = 0
- _Sea_FX_Vertical_Derivatives_1("Vertical derivatives 1", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Vertical_Derivatives_1("Vertical derivatives 1", Float) = 0
- //endex
- //ifex _Sea_FX_Horizontal_Derivatives_1_Enabled==0
- [HideInInspector] m_start_Sea_FX_Horizontal_Derivatives_1("Horizontal derivatives 1", Float) = 0
- [ThryToggle(_SEA_FX_HORIZONTAL_DERIVATIVES_1)] _Sea_FX_Horizontal_Derivatives_1_Enabled("Enable", Float) = 0
- _Sea_FX_Horizontal_Derivatives_1("Horizontal derivatives 1", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Horizontal_Derivatives_1("Horizontal derivatives 1", Float) = 0
- //endex
- //ifex _Sea_FX_Vertical_Derivatives_2_Enabled==0
- [HideInInspector] m_start_Sea_FX_Vertical_Derivatives_2("Vertical derivatives 2", Float) = 0
- [ThryToggle(_SEA_FX_VERTICAL_DERIVATIVES_2)] _Sea_FX_Vertical_Derivatives_2_Enabled("Enable", Float) = 0
- _Sea_FX_Vertical_Derivatives_2("Vertical derivatives 2", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Vertical_Derivatives_2("Vertical derivatives 2", Float) = 0
- //endex
- //ifex _Sea_FX_Horizontal_Derivatives_2_Enabled==0
- [HideInInspector] m_start_Sea_FX_Horizontal_Derivatives_2("Horizontal derivatives 2", Float) = 0
- [ThryToggle(_SEA_FX_HORIZONTAL_DERIVATIVES_2)] _Sea_FX_Horizontal_Derivatives_2_Enabled("Enable", Float) = 0
- _Sea_FX_Horizontal_Derivatives_2("Horizontal derivatives 2", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Horizontal_Derivatives_2("Horizontal derivatives 2", Float) = 0
- //endex
- //ifex _Sea_FX_Vertical_Derivatives_3_Enabled==0
- [HideInInspector] m_start_Sea_FX_Vertical_Derivatives_3("Vertical derivatives 3", Float) = 0
- [ThryToggle(_SEA_FX_VERTICAL_DERIVATIVES_3)] _Sea_FX_Vertical_Derivatives_3_Enabled("Enable", Float) = 0
- _Sea_FX_Vertical_Derivatives_3("Vertical derivatives 3", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Vertical_Derivatives_3("Vertical derivatives 3", Float) = 0
- //endex
- //ifex _Sea_FX_Horizontal_Derivatives_3_Enabled==0
- [HideInInspector] m_start_Sea_FX_Horizontal_Derivatives_3("Horizontal derivatives 3", Float) = 0
- [ThryToggle(_SEA_FX_HORIZONTAL_DERIVATIVES_3)] _Sea_FX_Horizontal_Derivatives_3_Enabled("Enable", Float) = 0
- _Sea_FX_Horizontal_Derivatives_3("Horizontal derivatives 3", 2D) = "black" {}
- [HideInInspector] m_end_Sea_FX_Horizontal_Derivatives_3("Horizontal derivatives 3", Float) = 0
- //endex
- [HideInInspector] m_end_Sea_FX_Derivatives("Derivatives", Float) = 0
-
- //ifex _Gradient_Normals_Enabled==0
- [HideInInspector] m_start_Gradient_Normals("Gradient Normals", Float) = 0
- [ThryToggle(_GRADIENT_NORMALS)] _Gradient_Normals_Enabled("Enable", Float) = 0
- [HideInInspector] m_end_Gradient_Normals("Gradient Normals", Float) = 0
- //endex
-
- //ifex _Sea_Foam_Enabled==0
- [HideInInspector] m_start_Sea_Foam("Sea foam", Float) = 0
- [ThryToggle(_SEA_FOAM)] _Sea_Foam_Enabled("Enable", Float) = 0
- _Sea_Foam_Color("Color", Color) = (1, 1, 1, 1)
- _Sea_Foam_Roughness("Roughness", Range(0, 1)) = 0.85
- _Sea_Foam_Bias("Bias", Range(-5, 5)) = 0
- [HideInInspector] m_end_Sea_Foam("Sea foam", Float) = 0
- //endex
-
- //ifex _Sea_SSS_Enabled==0
- [HideInInspector] m_start_Sea_SSS("Sea SSS", Float) = 0
- [ThryToggle(_SEA_SSS)] _Sea_SSS_Enabled("Enable", Float) = 0
- _Sea_SSS_Color("Color", Color) = (0.5, 0.9, 1, 1)
- _Sea_SSS_Bias("Bias", Range(-.5, .5)) = 0
- _Sea_SSS_Factor("Factor", Range(0, 10)) = 1
- _Sea_SSS_X_Amount("X_Amount", Range(0, 1)) = 0
- _Sea_SSS_Power("Power", Range(0, 10)) = 1
- _Sea_SSS_LoV_Wrap("LoV wrap", Range(0, 1)) = 0.8
- [HideInInspector] m_end_Sea_SSS("Sea SSS", Float) = 0
- //endex
- [HideInInspector] m_end_Sea_FX("Sea FX", Float) = 0
- //endex
-
//ifex _Tessellation_Enabled==0
[HideInInspector] m_start_Tessellation("Tessellation", Float) = 0
[ThryToggle(_TESSELLATION)] _Tessellation_Enabled("Enable", Float) = 0
diff --git a/globals.cginc b/globals.cginc
index 2ce282b..fefeb46 100644
--- a/globals.cginc
+++ b/globals.cginc
@@ -19,92 +19,6 @@ float _Specular_AA_Variance;
float _Specular_AA_Threshold;
float _BRDF_Specular_Min_Denom;
-#if defined(_SEA_FX)
-float _Sea_FX_Derivatives_SS_Filtering_Factor;
-#endif
-
-#if defined(_SEA_FX_HEIGHTMAPS_Y_0)
-texture2D _Sea_FX_Heightmaps_Y_0;
-float4 _Sea_FX_Heightmaps_Y_0_ST;
-#endif
-#if defined(_SEA_FX_HEIGHTMAPS_Y_1)
-texture2D _Sea_FX_Heightmaps_Y_1;
-float4 _Sea_FX_Heightmaps_Y_1_ST;
-#endif
-#if defined(_SEA_FX_HEIGHTMAPS_Y_2)
-texture2D _Sea_FX_Heightmaps_Y_2;
-float4 _Sea_FX_Heightmaps_Y_2_ST;
-#endif
-#if defined(_SEA_FX_HEIGHTMAPS_Y_3)
-texture2D _Sea_FX_Heightmaps_Y_3;
-float4 _Sea_FX_Heightmaps_Y_3_ST;
-#endif
-
-#if defined(_SEA_FX_HEIGHTMAPS_XZ_0)
-texture2D _Sea_FX_Heightmaps_XZ_0;
-float4 _Sea_FX_Heightmaps_XZ_0_ST;
-#endif
-#if defined(_SEA_FX_HEIGHTMAPS_XZ_1)
-texture2D _Sea_FX_Heightmaps_XZ_1;
-float4 _Sea_FX_Heightmaps_XZ_1_ST;
-#endif
-#if defined(_SEA_FX_HEIGHTMAPS_XZ_2)
-texture2D _Sea_FX_Heightmaps_XZ_2;
-float4 _Sea_FX_Heightmaps_XZ_2_ST;
-#endif
-#if defined(_SEA_FX_HEIGHTMAPS_XZ_3)
-texture2D _Sea_FX_Heightmaps_XZ_3;
-float4 _Sea_FX_Heightmaps_XZ_3_ST;
-#endif
-
-#if defined(_SEA_FX_VERTICAL_DERIVATIVES_0)
-texture2D _Sea_FX_Vertical_Derivatives_0;
-float4 _Sea_FX_Vertical_Derivatives_0_ST;
-#endif
-#if defined(_SEA_FX_HORIZONTAL_DERIVATIVES_0)
-texture2D _Sea_FX_Horizontal_Derivatives_0;
-float4 _Sea_FX_Horizontal_Derivatives_0_ST;
-#endif
-#if defined(_SEA_FX_VERTICAL_DERIVATIVES_1)
-texture2D _Sea_FX_Vertical_Derivatives_1;
-float4 _Sea_FX_Vertical_Derivatives_1_ST;
-#endif
-#if defined(_SEA_FX_HORIZONTAL_DERIVATIVES_1)
-texture2D _Sea_FX_Horizontal_Derivatives_1;
-float4 _Sea_FX_Horizontal_Derivatives_1_ST;
-#endif
-#if defined(_SEA_FX_VERTICAL_DERIVATIVES_2)
-texture2D _Sea_FX_Vertical_Derivatives_2;
-float4 _Sea_FX_Vertical_Derivatives_2_ST;
-#endif
-#if defined(_SEA_FX_HORIZONTAL_DERIVATIVES_2)
-texture2D _Sea_FX_Horizontal_Derivatives_2;
-float4 _Sea_FX_Horizontal_Derivatives_2_ST;
-#endif
-#if defined(_SEA_FX_VERTICAL_DERIVATIVES_3)
-texture2D _Sea_FX_Vertical_Derivatives_3;
-float4 _Sea_FX_Vertical_Derivatives_3_ST;
-#endif
-#if defined(_SEA_FX_HORIZONTAL_DERIVATIVES_3)
-texture2D _Sea_FX_Horizontal_Derivatives_3;
-float4 _Sea_FX_Horizontal_Derivatives_3_ST;
-#endif
-
-#if defined(_SEA_FOAM)
-float4 _Sea_Foam_Color;
-float _Sea_Foam_Roughness;
-float _Sea_Foam_Bias;
-#endif
-
-#if defined(_SEA_SSS)
-float4 _Sea_SSS_Color;
-float _Sea_SSS_X_Amount;
-float _Sea_SSS_Bias;
-float _Sea_SSS_Factor;
-float _Sea_SSS_Power;
-float _Sea_SSS_LoV_Wrap;
-#endif
-
#if defined(_TESSELLATION)
float _Tessellation_Factor;
float _Tessellation_Frustum_Culling_Bias;
diff --git a/interpolators.cginc b/interpolators.cginc
index 94f2613..7fa53d5 100644
--- a/interpolators.cginc
+++ b/interpolators.cginc
@@ -7,6 +7,8 @@ struct appdata {
float4 vertex : POSITION;
float2 uv0 : TEXCOORD0;
float4 color : COLOR; // vertex color
+ float3 normal : NORMAL;
+ float4 tangent : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
@@ -20,7 +22,9 @@ struct v2f {
float3 objPos : TEXCOORD1;
float3 worldPos : TEXCOORD2;
float4 eyeVec : TEXCOORD3; // eyeVec.xyz | fogCoord
- UNITY_LIGHTING_COORDS(4,5)
+ float3 normal : TEXCOORD4;
+ float4 tangent : TEXCOORD5;
+ UNITY_LIGHTING_COORDS(6,7)
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
diff --git a/pbr.cginc b/pbr.cginc
index 6e37942..b297a0f 100644
--- a/pbr.cginc
+++ b/pbr.cginc
@@ -22,7 +22,7 @@ void propagateSmoothness(inout Pbr pbr) {
Pbr getPbr(v2f i) {
Pbr pbr = (Pbr) 0;
- pbr.normal = float3(0, 1, 0);
+ pbr.normal = normalize(i.normal);
pbr.albedo = _Color;
pbr.smoothness = _Smoothness;
propagateSmoothness(pbr);