diff --git a/Assets/PCSS/Demo/Demo Assets/Palm Trees/Materials/Palm.mat b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Materials/Palm.mat index 060df24..a097ad2 100644 Binary files a/Assets/PCSS/Demo/Demo Assets/Palm Trees/Materials/Palm.mat and b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Materials/Palm.mat differ diff --git a/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader new file mode 100644 index 0000000..b7f2b55 --- /dev/null +++ b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader @@ -0,0 +1,48 @@ +Shader "Custom/NewSurfaceShader" { + Properties { + _Color ("Color", Color) = (1,1,1,1) + _MainTex ("Albedo (RGB)", 2D) = "white" {} + _Glossiness ("Smoothness", Range(0,1)) = 0.5 + _Metallic ("Metallic", Range(0,1)) = 0.0 + } + SubShader { + Tags { "RenderType"="Opaque" } + LOD 200 + + CGPROGRAM + // Physically based Standard lighting model, and enable shadows on all light types + #pragma surface surf Standard fullforwardshadows + + // Use shader model 3.0 target, to get nicer looking lighting + #pragma target 3.0 + + sampler2D _MainTex; + + struct Input { + float2 uv_MainTex; + }; + + half _Glossiness; + half _Metallic; + fixed4 _Color; + + // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader. + // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing. + // #pragma instancing_options assumeuniformscaling + UNITY_INSTANCING_BUFFER_START(Props) + // put more per-instance properties here + UNITY_INSTANCING_BUFFER_END(Props) + + void surf (Input IN, inout SurfaceOutputStandard o) { + // Albedo comes from a texture tinted by color + fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; + o.Albedo = c.rgb; + // Metallic and smoothness come from slider variables + o.Metallic = _Metallic; + o.Smoothness = _Glossiness; + o.Alpha = c.a; + } + ENDCG + } + FallBack "Diffuse" +} diff --git a/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader.meta b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader.meta new file mode 100644 index 0000000..4da9a46 --- /dev/null +++ b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/NewSurfaceShader.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 31b75bffa9708e44c88da2a86716a9b6 +timeCreated: 1516783516 +licenseType: Free +ShaderImporter: + externalObjects: {} + defaultTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation.shader b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation.shader index f7d1a07..3ec1d62 100644 --- a/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation.shader +++ b/Assets/PCSS/Demo/Demo Assets/Palm Trees/Shaders/Vegetation.shader @@ -58,6 +58,10 @@ float _WindFrequency; float _WindAmplitude; + UNITY_INSTANCING_BUFFER_START(Props) + // put more per-instance properties here + UNITY_INSTANCING_BUFFER_END(Props) + void vert(inout appdata v) { float3 pos = mul(v.vertex, unity_ObjectToWorld); diff --git a/Assets/PCSS/Demo/PCSS Demo.unity b/Assets/PCSS/Demo/PCSS Demo.unity index 1b2751d..a5bfb74 100644 Binary files a/Assets/PCSS/Demo/PCSS Demo.unity and b/Assets/PCSS/Demo/PCSS Demo.unity differ diff --git a/Assets/PCSS/Scripts/PCSSLight.cs b/Assets/PCSS/Scripts/PCSSLight.cs index 490afea..f0a4c6e 100644 --- a/Assets/PCSS/Scripts/PCSSLight.cs +++ b/Assets/PCSS/Scripts/PCSSLight.cs @@ -16,8 +16,8 @@ public class PCSSLight : MonoBehaviour public int PCF_SampleCount = 16; [Space(20f)] - public bool RotateSamples = true; - public bool UseNoiseTexture = true; +// public bool RotateSamples = true; +// public bool UseNoiseTexture = true; public Texture2D noiseTexture; [Space(20f)] @@ -95,13 +95,13 @@ public void Setup () _light.shadowCustomResolution = 0; shader = Shader.Find(shaderName); - if (!Application.isEditor) - { - if (shader) - Debug.LogErrorFormat("Custom Shadow Shader Found: {0} | Supported {1}", shader.name, shader.isSupported); - else - Debug.LogError("Custom Shadow Shader Not Found!!!"); - } +// if (!Application.isEditor) +// { +// if (shader) +// Debug.LogErrorFormat("Custom Shadow Shader Found: {0} | Supported {1}", shader.name, shader.isSupported); +// else +// Debug.LogError("Custom Shadow Shader Not Found!!!"); +// } shadowmapPropID = Shader.PropertyToID("_ShadowMap"); copyShadowBuffer = new CommandBuffer(); @@ -136,18 +136,14 @@ public void CreateShadowRenderTexture () [ContextMenu("Reset Shadows To Default")] public void ResetShadowMode () { -// //Unity 2017 seems to have issues with the 'ResetShadowMode()' being called during 'OnDisable()' in builds, though it works fine in the editor -// if (!Application.isEditor) -// return; - builtinShader = Shader.Find(builtinShaderName); - if (!Application.isEditor) - { - if (builtinShader) - Debug.LogErrorFormat("Built-In Shadow Shader Found: {0} | Supported {1}", builtinShader.name, builtinShader.isSupported); - else - Debug.LogError("Shadow Shader Not Found!!!"); - } +// if (!Application.isEditor) +// { +// if (builtinShader) +// Debug.LogErrorFormat("Built-In Shadow Shader Found: {0} | Supported {1}", builtinShader.name, builtinShader.isSupported); +// else +// Debug.LogError("Shadow Shader Not Found!!!"); +// } GraphicsSettings.SetCustomShader(BuiltinShaderType.ScreenSpaceShadows, builtinShader); GraphicsSettings.SetShaderMode(BuiltinShaderType.ScreenSpaceShadows, BuiltinShaderMode.Disabled); @@ -195,8 +191,8 @@ public void UpdateShaderValues () SetFlag("USE_BLOCKER_BIAS", Blocker_GradientBias > 0); SetFlag("USE_PCF_BIAS", PCF_GradientBias > 0); - SetFlag("ROTATE_SAMPLES", RotateSamples); - SetFlag("USE_NOISE_TEX", UseNoiseTexture); +// SetFlag("ROTATE_SAMPLES", RotateSamples); +// SetFlag("USE_NOISE_TEX", UseNoiseTexture); if (noiseTexture) { diff --git a/Assets/PCSS/Shaders/PCSS-ShaderVariants.shadervariants b/Assets/PCSS/Shaders/PCSS-ShaderVariants.shadervariants index ba874c5..bf5c9a2 100644 Binary files a/Assets/PCSS/Shaders/PCSS-ShaderVariants.shadervariants and b/Assets/PCSS/Shaders/PCSS-ShaderVariants.shadervariants differ diff --git a/Assets/PCSS/Shaders/PCSS.shader b/Assets/PCSS/Shaders/PCSS.shader index 619f948..8713771 100644 --- a/Assets/PCSS/Shaders/PCSS.shader +++ b/Assets/PCSS/Shaders/PCSS.shader @@ -432,9 +432,9 @@ float2 FindBlocker(float2 uv, float depth, float searchUV, float2 receiverPlaneD { float2 offset = PoissonOffsets[i] * searchUV; -#if defined(ROTATE_SAMPLES) +//#if defined(ROTATE_SAMPLES) offset = Rotate(offset, rotationTrig); -#endif +//#endif float shadowMapDepth = SampleShadowmapDepth(uv + offset); @@ -488,9 +488,9 @@ float PCF_Filter(float2 uv, float depth, float filterRadiusUV, float2 receiverPl { float2 offset = PoissonOffsets[i] * filterRadiusUV; -#if defined(ROTATE_SAMPLES) +//#if defined(ROTATE_SAMPLES) offset = Rotate(offset, rotationTrig); -#endif +//#endif float biasedDepth = depth; @@ -607,13 +607,12 @@ fixed4 frag_pcss (v2f i) : SV_Target fixed4 cascadeWeights = GET_CASCADE_WEIGHTS(wpos, vpos.z); float4 coord = GET_SHADOW_COORDINATES(wpos, cascadeWeights); -#if defined(USE_NOISE_TEX) +//#if defined(USE_NOISE_TEX) float random = tex2D(_NoiseTexture, i.uv.xy * NoiseCoords.xy * _ScreenParams.xy).a; random = mad(random, 2.0, -1.0); - //random = sign(random) * (1.0 - sqrt(1.0 - abs(random))); -#else - float random = ValueNoise(wpos.xyz); -#endif +//#else +// float random = ValueNoise(wpos.xyz); +//#endif float2 receiverPlaneDepthBiasCascade0 = 0.0; float2 receiverPlaneDepthBias = 0.0; @@ -765,14 +764,14 @@ Subshader #pragma multi_compile_shadowcollector #pragma multi_compile POISSON_32 POISSON_64 - #pragma shader_feature ORTHOGRAPHIC_SUPPORTED #pragma shader_feature USE_FALLOFF + #pragma shader_feature USE_CASCADE_BLENDING #pragma shader_feature USE_STATIC_BIAS #pragma shader_feature USE_BLOCKER_BIAS #pragma shader_feature USE_PCF_BIAS - #pragma shader_feature USE_CASCADE_BLENDING - #pragma shader_feature ROTATE_SAMPLES - #pragma shader_feature USE_NOISE_TEX + #pragma shader_feature ORTHOGRAPHIC_SUPPORTED +// #pragma shader_feature ROTATE_SAMPLES +// #pragma shader_feature USE_NOISE_TEX #pragma target 3.0 inline float3 computeCameraSpacePosFromDepth(v2f i) @@ -797,14 +796,14 @@ Subshader #pragma multi_compile_shadowcollector #pragma multi_compile POISSON_32 POISSON_64 - #pragma shader_feature ORTHOGRAPHIC_SUPPORTED #pragma shader_feature USE_FALLOFF + #pragma shader_feature USE_CASCADE_BLENDING #pragma shader_feature USE_STATIC_BIAS #pragma shader_feature USE_BLOCKER_BIAS #pragma shader_feature USE_PCF_BIAS - #pragma shader_feature USE_CASCADE_BLENDING - #pragma shader_feature ROTATE_SAMPLES - #pragma shader_feature USE_NOISE_TEX + #pragma shader_feature ORTHOGRAPHIC_SUPPORTED +// #pragma shader_feature ROTATE_SAMPLES +// #pragma shader_feature USE_NOISE_TEX #pragma target 3.0 inline float3 computeCameraSpacePosFromDepth(v2f i) @@ -833,14 +832,14 @@ Subshader #pragma multi_compile_shadowcollector #pragma multi_compile POISSON_32 POISSON_64 - #pragma shader_feature ORTHOGRAPHIC_SUPPORTED #pragma shader_feature USE_FALLOFF + #pragma shader_feature USE_CASCADE_BLENDING #pragma shader_feature USE_STATIC_BIAS #pragma shader_feature USE_BLOCKER_BIAS #pragma shader_feature USE_PCF_BIAS - #pragma shader_feature USE_CASCADE_BLENDING - #pragma shader_feature ROTATE_SAMPLES - #pragma shader_feature USE_NOISE_TEX + #pragma shader_feature ORTHOGRAPHIC_SUPPORTED +// #pragma shader_feature ROTATE_SAMPLES +// #pragma shader_feature USE_NOISE_TEX #pragma target 3.0 inline float3 computeCameraSpacePosFromDepth(v2f i) @@ -865,14 +864,14 @@ Subshader #pragma multi_compile_shadowcollector #pragma multi_compile POISSON_32 POISSON_64 - #pragma shader_feature ORTHOGRAPHIC_SUPPORTED #pragma shader_feature USE_FALLOFF + #pragma shader_feature USE_CASCADE_BLENDING #pragma shader_feature USE_STATIC_BIAS #pragma shader_feature USE_BLOCKER_BIAS #pragma shader_feature USE_PCF_BIAS - #pragma shader_feature USE_CASCADE_BLENDING - #pragma shader_feature ROTATE_SAMPLES - #pragma shader_feature USE_NOISE_TEX + #pragma shader_feature ORTHOGRAPHIC_SUPPORTED +// #pragma shader_feature ROTATE_SAMPLES +// #pragma shader_feature USE_NOISE_TEX #pragma target 3.0 inline float3 computeCameraSpacePosFromDepth(v2f i) diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 2deae2e..f74b74b 100644 Binary files a/ProjectSettings/GraphicsSettings.asset and b/ProjectSettings/GraphicsSettings.asset differ