Skip to content

Commit 9a6762f

Browse files
committed
Yup, shader variants were the issue. I set it up to track the shader variants used in the editor, and started removing some of the unnecessary variations
1 parent 740b4bd commit 9a6762f

File tree

9 files changed

+104
-47
lines changed

9 files changed

+104
-47
lines changed
Binary file not shown.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Shader "Custom/NewSurfaceShader" {
2+
Properties {
3+
_Color ("Color", Color) = (1,1,1,1)
4+
_MainTex ("Albedo (RGB)", 2D) = "white" {}
5+
_Glossiness ("Smoothness", Range(0,1)) = 0.5
6+
_Metallic ("Metallic", Range(0,1)) = 0.0
7+
}
8+
SubShader {
9+
Tags { "RenderType"="Opaque" }
10+
LOD 200
11+
12+
CGPROGRAM
13+
// Physically based Standard lighting model, and enable shadows on all light types
14+
#pragma surface surf Standard fullforwardshadows
15+
16+
// Use shader model 3.0 target, to get nicer looking lighting
17+
#pragma target 3.0
18+
19+
sampler2D _MainTex;
20+
21+
struct Input {
22+
float2 uv_MainTex;
23+
};
24+
25+
half _Glossiness;
26+
half _Metallic;
27+
fixed4 _Color;
28+
29+
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
30+
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
31+
// #pragma instancing_options assumeuniformscaling
32+
UNITY_INSTANCING_BUFFER_START(Props)
33+
// put more per-instance properties here
34+
UNITY_INSTANCING_BUFFER_END(Props)
35+
36+
void surf (Input IN, inout SurfaceOutputStandard o) {
37+
// Albedo comes from a texture tinted by color
38+
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
39+
o.Albedo = c.rgb;
40+
// Metallic and smoothness come from slider variables
41+
o.Metallic = _Metallic;
42+
o.Smoothness = _Glossiness;
43+
o.Alpha = c.a;
44+
}
45+
ENDCG
46+
}
47+
FallBack "Diffuse"
48+
}

Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation.shader

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
float _WindFrequency;
5959
float _WindAmplitude;
6060

61+
UNITY_INSTANCING_BUFFER_START(Props)
62+
// put more per-instance properties here
63+
UNITY_INSTANCING_BUFFER_END(Props)
64+
6165
void vert(inout appdata v)
6266
{
6367
float3 pos = mul(v.vertex, unity_ObjectToWorld);

Assets/PCSS/Demo/PCSS Demo.unity

0 Bytes
Binary file not shown.

Assets/PCSS/Scripts/PCSSLight.cs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public class PCSSLight : MonoBehaviour
1616
public int PCF_SampleCount = 16;
1717

1818
[Space(20f)]
19-
public bool RotateSamples = true;
20-
public bool UseNoiseTexture = true;
19+
// public bool RotateSamples = true;
20+
// public bool UseNoiseTexture = true;
2121
public Texture2D noiseTexture;
2222

2323
[Space(20f)]
@@ -95,13 +95,13 @@ public void Setup ()
9595
_light.shadowCustomResolution = 0;
9696

9797
shader = Shader.Find(shaderName);
98-
if (!Application.isEditor)
99-
{
100-
if (shader)
101-
Debug.LogErrorFormat("Custom Shadow Shader Found: {0} | Supported {1}", shader.name, shader.isSupported);
102-
else
103-
Debug.LogError("Custom Shadow Shader Not Found!!!");
104-
}
98+
// if (!Application.isEditor)
99+
// {
100+
// if (shader)
101+
// Debug.LogErrorFormat("Custom Shadow Shader Found: {0} | Supported {1}", shader.name, shader.isSupported);
102+
// else
103+
// Debug.LogError("Custom Shadow Shader Not Found!!!");
104+
// }
105105
shadowmapPropID = Shader.PropertyToID("_ShadowMap");
106106

107107
copyShadowBuffer = new CommandBuffer();
@@ -136,18 +136,14 @@ public void CreateShadowRenderTexture ()
136136
[ContextMenu("Reset Shadows To Default")]
137137
public void ResetShadowMode ()
138138
{
139-
// //Unity 2017 seems to have issues with the 'ResetShadowMode()' being called during 'OnDisable()' in builds, though it works fine in the editor
140-
// if (!Application.isEditor)
141-
// return;
142-
143139
builtinShader = Shader.Find(builtinShaderName);
144-
if (!Application.isEditor)
145-
{
146-
if (builtinShader)
147-
Debug.LogErrorFormat("Built-In Shadow Shader Found: {0} | Supported {1}", builtinShader.name, builtinShader.isSupported);
148-
else
149-
Debug.LogError("Shadow Shader Not Found!!!");
150-
}
140+
// if (!Application.isEditor)
141+
// {
142+
// if (builtinShader)
143+
// Debug.LogErrorFormat("Built-In Shadow Shader Found: {0} | Supported {1}", builtinShader.name, builtinShader.isSupported);
144+
// else
145+
// Debug.LogError("Shadow Shader Not Found!!!");
146+
// }
151147

152148
GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, builtinShader);
153149
GraphicsSettings.SetShaderMode(BuiltinShaderType.ScreenSpaceShadows, BuiltinShaderMode.Disabled);
@@ -195,8 +191,8 @@ public void UpdateShaderValues ()
195191
SetFlag("USE_BLOCKER_BIAS", Blocker_GradientBias > 0);
196192
SetFlag("USE_PCF_BIAS", PCF_GradientBias > 0);
197193

198-
SetFlag("ROTATE_SAMPLES", RotateSamples);
199-
SetFlag("USE_NOISE_TEX", UseNoiseTexture);
194+
// SetFlag("ROTATE_SAMPLES", RotateSamples);
195+
// SetFlag("USE_NOISE_TEX", UseNoiseTexture);
200196

201197
if (noiseTexture)
202198
{
Binary file not shown.

Assets/PCSS/Shaders/PCSS.shader

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ float2 FindBlocker(float2 uv, float depth, float searchUV, float2 receiverPlaneD
432432
{
433433
float2 offset = PoissonOffsets[i] * searchUV;
434434

435-
#if defined(ROTATE_SAMPLES)
435+
//#if defined(ROTATE_SAMPLES)
436436
offset = Rotate(offset, rotationTrig);
437-
#endif
437+
//#endif
438438

439439
float shadowMapDepth = SampleShadowmapDepth(uv + offset);
440440

@@ -488,9 +488,9 @@ float PCF_Filter(float2 uv, float depth, float filterRadiusUV, float2 receiverPl
488488
{
489489
float2 offset = PoissonOffsets[i] * filterRadiusUV;
490490

491-
#if defined(ROTATE_SAMPLES)
491+
//#if defined(ROTATE_SAMPLES)
492492
offset = Rotate(offset, rotationTrig);
493-
#endif
493+
//#endif
494494

495495
float biasedDepth = depth;
496496

@@ -607,13 +607,12 @@ fixed4 frag_pcss (v2f i) : SV_Target
607607
fixed4 cascadeWeights = GET_CASCADE_WEIGHTS(wpos, vpos.z);
608608
float4 coord = GET_SHADOW_COORDINATES(wpos, cascadeWeights);
609609

610-
#if defined(USE_NOISE_TEX)
610+
//#if defined(USE_NOISE_TEX)
611611
float random = tex2D(_NoiseTexture, i.uv.xy * NoiseCoords.xy * _ScreenParams.xy).a;
612612
random = mad(random, 2.0, -1.0);
613-
//random = sign(random) * (1.0 - sqrt(1.0 - abs(random)));
614-
#else
615-
float random = ValueNoise(wpos.xyz);
616-
#endif
613+
//#else
614+
// float random = ValueNoise(wpos.xyz);
615+
//#endif
617616

618617
float2 receiverPlaneDepthBiasCascade0 = 0.0;
619618
float2 receiverPlaneDepthBias = 0.0;
@@ -765,14 +764,14 @@ Subshader
765764
#pragma multi_compile_shadowcollector
766765
#pragma multi_compile POISSON_32 POISSON_64
767766

768-
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
769767
#pragma shader_feature USE_FALLOFF
768+
#pragma shader_feature USE_CASCADE_BLENDING
770769
#pragma shader_feature USE_STATIC_BIAS
771770
#pragma shader_feature USE_BLOCKER_BIAS
772771
#pragma shader_feature USE_PCF_BIAS
773-
#pragma shader_feature USE_CASCADE_BLENDING
774-
#pragma shader_feature ROTATE_SAMPLES
775-
#pragma shader_feature USE_NOISE_TEX
772+
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
773+
// #pragma shader_feature ROTATE_SAMPLES
774+
// #pragma shader_feature USE_NOISE_TEX
776775
#pragma target 3.0
777776

778777
inline float3 computeCameraSpacePosFromDepth(v2f i)
@@ -797,14 +796,14 @@ Subshader
797796
#pragma multi_compile_shadowcollector
798797
#pragma multi_compile POISSON_32 POISSON_64
799798

800-
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
801799
#pragma shader_feature USE_FALLOFF
800+
#pragma shader_feature USE_CASCADE_BLENDING
802801
#pragma shader_feature USE_STATIC_BIAS
803802
#pragma shader_feature USE_BLOCKER_BIAS
804803
#pragma shader_feature USE_PCF_BIAS
805-
#pragma shader_feature USE_CASCADE_BLENDING
806-
#pragma shader_feature ROTATE_SAMPLES
807-
#pragma shader_feature USE_NOISE_TEX
804+
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
805+
// #pragma shader_feature ROTATE_SAMPLES
806+
// #pragma shader_feature USE_NOISE_TEX
808807
#pragma target 3.0
809808

810809
inline float3 computeCameraSpacePosFromDepth(v2f i)
@@ -833,14 +832,14 @@ Subshader
833832
#pragma multi_compile_shadowcollector
834833
#pragma multi_compile POISSON_32 POISSON_64
835834

836-
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
837835
#pragma shader_feature USE_FALLOFF
836+
#pragma shader_feature USE_CASCADE_BLENDING
838837
#pragma shader_feature USE_STATIC_BIAS
839838
#pragma shader_feature USE_BLOCKER_BIAS
840839
#pragma shader_feature USE_PCF_BIAS
841-
#pragma shader_feature USE_CASCADE_BLENDING
842-
#pragma shader_feature ROTATE_SAMPLES
843-
#pragma shader_feature USE_NOISE_TEX
840+
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
841+
// #pragma shader_feature ROTATE_SAMPLES
842+
// #pragma shader_feature USE_NOISE_TEX
844843
#pragma target 3.0
845844

846845
inline float3 computeCameraSpacePosFromDepth(v2f i)
@@ -865,14 +864,14 @@ Subshader
865864
#pragma multi_compile_shadowcollector
866865
#pragma multi_compile POISSON_32 POISSON_64
867866

868-
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
869867
#pragma shader_feature USE_FALLOFF
868+
#pragma shader_feature USE_CASCADE_BLENDING
870869
#pragma shader_feature USE_STATIC_BIAS
871870
#pragma shader_feature USE_BLOCKER_BIAS
872871
#pragma shader_feature USE_PCF_BIAS
873-
#pragma shader_feature USE_CASCADE_BLENDING
874-
#pragma shader_feature ROTATE_SAMPLES
875-
#pragma shader_feature USE_NOISE_TEX
872+
#pragma shader_feature ORTHOGRAPHIC_SUPPORTED
873+
// #pragma shader_feature ROTATE_SAMPLES
874+
// #pragma shader_feature USE_NOISE_TEX
876875
#pragma target 3.0
877876

878877
inline float3 computeCameraSpacePosFromDepth(v2f i)
28 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)