summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2024-10-26 18:39:36 -0700
committeryum <yum.food.vr@gmail.com>2024-10-26 18:39:36 -0700
commit8d9d6e374a3dfb5d639034dbd9bb6310c329f147 (patch)
tree61b99b4244ab762e91cfa4b769d7704b1b2410d8
parent07b1aca3f096a520cbae1d4cca18692fc69d2944 (diff)
Begin optimizing gerstner demo
-rw-r--r--feature_macros.cginc1
-rw-r--r--interpolators.cginc10
-rw-r--r--tooner.shader5
-rw-r--r--tooner_lighting.cginc10
-rw-r--r--tooner_outline_pass.cginc2
5 files changed, 26 insertions, 2 deletions
diff --git a/feature_macros.cginc b/feature_macros.cginc
index c7ac050..ed082ae 100644
--- a/feature_macros.cginc
+++ b/feature_macros.cginc
@@ -2,6 +2,7 @@
#define __FEATURE_MACROS_INC
#define EXPERIMENT__CUSTOM_DEPTH
+#define _OPTIMIZE_INTERPOLATORS
#pragma shader_feature_local _ _BASECOLOR_MAP
#pragma shader_feature_local _ _NORMAL_MAP
diff --git a/interpolators.cginc b/interpolators.cginc
index 43e69e9..709b29b 100644
--- a/interpolators.cginc
+++ b/interpolators.cginc
@@ -1,4 +1,6 @@
#include "AutoLight.cginc"
+#include "feature_macros.cginc"
+#define _OPTIMIZE_INTERPOLATORS
#ifndef __INTERPOLATORS_INC
#define __INTERPOLATORS_INC
@@ -10,6 +12,7 @@ struct appdata
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv0 : TEXCOORD0;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
float2 uv3 : TEXCOORD3;
@@ -17,6 +20,7 @@ struct appdata
float2 uv5 : TEXCOORD5;
float2 uv6 : TEXCOORD6;
float2 uv7 : TEXCOORD7;
+#endif
UNITY_VERTEX_INPUT_INSTANCE_ID
};
@@ -25,6 +29,7 @@ struct v2f
{
linear noperspective centroid float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
#if defined(LIGHTMAP_ON)
@@ -36,6 +41,7 @@ struct v2f
float2 uv6 : TEXCOORD6;
float2 uv7 : TEXCOORD7;
#endif
+#endif
float2 fogCoord: TEXCOORD8;
SHADOW_COORDS(9)
float3 worldPos : TEXCOORD10;
@@ -55,6 +61,7 @@ struct appdata
{
float4 vertex : POSITION;
float2 uv0 : TEXCOORD0;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
float2 uv3 : TEXCOORD3;
@@ -62,6 +69,7 @@ struct appdata
float2 uv5 : TEXCOORD5;
float2 uv6 : TEXCOORD6;
float2 uv7 : TEXCOORD7;
+#endif
float3 normal : NORMAL;
float4 tangent : TANGENT;
@@ -72,6 +80,7 @@ struct v2f
{
linear noperspective centroid float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
float2 uv1 : TEXCOORD1;
float2 uv2 : TEXCOORD2;
#if defined(LIGHTMAP_ON)
@@ -83,6 +92,7 @@ struct v2f
float2 uv6 : TEXCOORD6;
float2 uv7 : TEXCOORD7;
#endif
+#endif
float2 fogCoord: TEXCOORD8;
#if !defined(LIGHTMAP_ON)
unityShadowCoord4 _ShadowCoord : TEXCOORD9;
diff --git a/tooner.shader b/tooner.shader
index 39f13ba..c33320f 100644
--- a/tooner.shader
+++ b/tooner.shader
@@ -720,9 +720,9 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
+ #pragma multi_compile_instancing
#pragma multi_compile_fwdbase
- #pragma multi_compile_instancing
#pragma multi_compile_fog
#pragma multi_compile _ VERTEXLIGHT_ON
@@ -756,9 +756,9 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
+ #pragma multi_compile_instancing
#pragma multi_compile_fwdadd_fullshadows
- #pragma multi_compile_instancing
#include "feature_macros.cginc"
#pragma vertex vert
@@ -784,6 +784,7 @@ Shader "yum_food/tooner"
CGPROGRAM
#pragma target 5.0
#pragma multi_compile_instancing
+
#include "feature_macros.cginc"
#pragma vertex vert
diff --git a/tooner_lighting.cginc b/tooner_lighting.cginc
index 6e4e2ac..4206cef 100644
--- a/tooner_lighting.cginc
+++ b/tooner_lighting.cginc
@@ -179,6 +179,7 @@ v2f vert(appdata v)
o.tangent = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);
o.uv0 = v.uv0;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
o.uv1 = v.uv1;
#if defined(LIGHTMAP_ON)
o.uv2 = v.uv2 * unity_LightmapST.xy + unity_LightmapST.zw;
@@ -191,10 +192,12 @@ v2f vert(appdata v)
o.uv6 = v.uv6;
o.uv7 = v.uv7;
#endif
+#endif // _OPTIMIZE_INTERPOLATORS
#if defined(_MIRROR_UV_FLIP)
if (_Mirror_UV_Flip_Enable_Dynamic) {
bool in_mirror = isInMirror();
o.uv0.x = lerp(o.uv0.x, 1 - o.uv0.x, in_mirror);
+#if !defined(_OPTIMIZE_INTERPOLATORS)
o.uv1.x = lerp(o.uv1.x, 1 - o.uv1.x, in_mirror);
o.uv2.x = lerp(o.uv2.x, 1 - o.uv2.x, in_mirror);
o.uv3.x = lerp(o.uv3.x, 1 - o.uv3.x, in_mirror);
@@ -202,6 +205,7 @@ v2f vert(appdata v)
o.uv5.x = lerp(o.uv5.x, 1 - o.uv5.x, in_mirror);
o.uv6.x = lerp(o.uv6.x, 1 - o.uv6.x, in_mirror);
o.uv7.x = lerp(o.uv7.x, 1 - o.uv7.x, in_mirror);
+#endif
}
#endif
#if defined(SHADOWS_SCREEN)
@@ -281,6 +285,10 @@ void geom(triangle v2f tri_in[3],
v1.worldPos -= avg_pos;
v2.worldPos -= avg_pos;
+ v0.worldPos *= 1 + 2 * pid_rand;
+ v1.worldPos *= 1 + 2 * pid_rand;
+ v2.worldPos *= 1 + 2 * pid_rand;
+
float theta = explode_phase * 3.14159 * 4 + explode_phase * (sin(_Time[1] * (1 + pid_rand) / 2.0 + pid_rand) + cos(_Time[1] * (1 + pid_rand) / 6.1 + pid_rand) * 2) * pid_rand * 2;
float4 quat = get_quaternion(axis, theta);
v0.worldPos = rotate_vector(v0.worldPos, quat);
@@ -552,6 +560,7 @@ float2 get_uv_by_channel(v2f i, uint which_channel) {
case 0:
return i.uv0;
break;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
case 1:
return i.uv1;
break;
@@ -575,6 +584,7 @@ float2 get_uv_by_channel(v2f i, uint which_channel) {
return i.uv7;
break;
#endif
+#endif // _OPTIMIZE_INTERPOLATORS
default:
return 0;
break;
diff --git a/tooner_outline_pass.cginc b/tooner_outline_pass.cginc
index c68c57b..1d05763 100644
--- a/tooner_outline_pass.cginc
+++ b/tooner_outline_pass.cginc
@@ -92,6 +92,7 @@ v2f vert(appdata v)
o.pos = UnityObjectToClipPos(objPos);
o.normal = UnityObjectToWorldNormal(v.normal);
o.uv0 = v.uv0;
+#if !defined(_OPTIMIZE_INTERPOLATORS)
o.uv1 = v.uv1;
#if defined(LIGHTMAP_ON)
o.uv2 = v.uv2 * unity_LightmapST.xy + unity_LightmapST.zw;
@@ -104,6 +105,7 @@ v2f vert(appdata v)
o.uv6 = v.uv6;
o.uv7 = v.uv7;
#endif
+#endif // _OPTIMIZE_INTERPOLATORS
o.centerCamPos = getCenterCamPos();
return o;