From 7a0e0f350cc2ba2bd773b260ca4ea06230e16025 Mon Sep 17 00:00:00 2001 From: MattOstgard Date: Wed, 3 Oct 2018 19:03:30 -0700 Subject: [PATCH] Updated Built-in Shaders to 2018.2.10f1 --- CGIncludes/AutoLight.cginc | 69 +++------ CGIncludes/GLSLSupport.glslinc | 2 + CGIncludes/HLSLSupport.cginc | 79 +++------- CGIncludes/UnityCG.cginc | 5 + CGIncludes/UnityCustomRenderTexture.cginc | 2 +- CGIncludes/UnityDeferredLibrary.cginc | 4 +- CGIncludes/UnityInstancing.cginc | 143 ++++++++++-------- CGIncludes/UnityShaderVariables.cginc | 2 +- CGIncludes/UnityShadowLibrary.cginc | 13 +- CGIncludes/UnityStandardBRDF.cginc | 2 +- CGIncludes/UnityStandardConfig.cginc | 4 +- CGIncludes/UnityStandardCore.cginc | 45 +++--- CGIncludes/UnityStandardUtils.cginc | 20 +-- DefaultResourcesExtra/Alpha-BumpSpec.shader | 2 +- DefaultResourcesExtra/Alpha-Glossy.shader | 2 +- .../Alpha-ParallaxSpec.shader | 2 +- DefaultResourcesExtra/Alpha-VertexLit.shader | 2 +- .../AlphaTest-BumpSpec.shader | 2 +- DefaultResourcesExtra/AlphaTest-Glossy.shader | 2 +- .../AlphaTest-VertexLit.shader | 2 +- .../GIDebug/ShowLightMask.shader | 4 +- DefaultResourcesExtra/Illumin-BumpSpec.shader | 2 +- DefaultResourcesExtra/Illumin-Glossy.shader | 2 +- .../Illumin-ParallaxSpec.shader | 2 +- .../Illumin-VertexLit.shader | 2 +- .../Lightmap-BumpSpec.shader | 2 +- DefaultResourcesExtra/Lightmap-Glossy.shader | 2 +- .../Lightmap-VertexLit.shader | 2 +- .../Mobile-BumpSpec-1DirectionalLight.shader | 2 +- .../Mobile/Mobile-BumpSpec.shader | 2 +- DefaultResourcesExtra/Nature/SpeedTree.shader | 16 +- .../TreeCreatorAlbedoRenderTex.shader | 3 +- .../Nature/TreeCreator/TreeCreatorBark.shader | 2 +- .../TreeCreator/TreeCreatorLeaves.shader | 2 +- .../TreeCreatorNormalRendertex.shader | 11 +- DefaultResourcesExtra/Normal-BumpSpec.shader | 2 +- DefaultResourcesExtra/Normal-Glossy.shader | 2 +- .../Normal-ParallaxSpec.shader | 2 +- DefaultResourcesExtra/Normal-VertexLit.shader | 2 +- DefaultResourcesExtra/Particle Add.shader | 2 + .../Particle Alpha Blend.shader | 2 + .../Particle Anim Alpha Blend.shader | 2 + DefaultResourcesExtra/Reflect-BumpSpec.shader | 2 +- .../Reflect-BumpVertexLit.shader | 2 +- DefaultResourcesExtra/Reflect-Bumped.shader | 1 - DefaultResourcesExtra/Reflect-Glossy.shader | 2 +- .../Reflect-ParallaxSpec.shader | 2 +- .../Splats/Specular-AddPass.shader | 2 +- .../Splats/Specular-Base.shader | 2 +- .../Splats/Specular-FirstPass.shader | 2 +- .../Trees/CameraFacingBillboardTree.shader | 37 +++-- DefaultResourcesExtra/UI/UI-Lit-Bumped.shader | 2 +- DefaultResourcesExtra/UI/UI-Lit-Detail.shader | 2 +- .../UI/UI-Lit-Refraction.shader | 2 +- .../UI/UI-Lit-RefractionDetail.shader | 2 +- Editor/StandardParticlesShaderGUI.cs | 30 ++-- README.md | 2 +- 57 files changed, 265 insertions(+), 301 deletions(-) diff --git a/CGIncludes/AutoLight.cginc b/CGIncludes/AutoLight.cginc index 9083d9f..271b24d 100644 --- a/CGIncludes/AutoLight.cginc +++ b/CGIncludes/AutoLight.cginc @@ -108,7 +108,7 @@ half UnityComputeForwardShadows(float2 lightmapUV, float3 worldPos, float4 scree return UnityMixRealtimeAndBakedShadows(realtimeShadowAttenuation, shadowMaskAttenuation, realtimeToBakedShadowFade); } -#if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) +#if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) # define UNITY_SHADOW_W(_w) _w #else # define UNITY_SHADOW_W(_w) (1.0/_w) @@ -126,9 +126,8 @@ half UnityComputeForwardShadows(float2 lightmapUV, float3 worldPos, float4 scree # define UNITY_SHADOW_ATTENUATION(a, worldPos) SHADOW_ATTENUATION(a) #elif defined(SHADOWS_SCREEN) && !defined(LIGHTMAP_ON) && !defined(UNITY_NO_SCREENSPACE_SHADOWS) // no lightmap uv thus store screenPos instead // can happen if we have two directional lights. main light gets handled in GI code, but 2nd dir light can have shadow screen and mask. - // - Disabled on DX9 as we don't get valid .zw in vpos // - Disabled on ES2 because WebGL 1.0 seems to have junk in .w (even though it shouldn't) -# if defined(SHADOWS_SHADOWMASK) && !defined(SHADER_API_D3D9) && !defined(SHADER_API_GLES) +# if defined(SHADOWS_SHADOWMASK) && !defined(SHADER_API_GLES) # define UNITY_SHADOW_COORDS(idx1) unityShadowCoord4 _ShadowCoord : TEXCOORD##idx1; # define UNITY_TRANSFER_SHADOW(a, coord) {a._ShadowCoord.xy = coord * unity_LightmapST.xy + unity_LightmapST.zw; a._ShadowCoord.zw = ComputeScreenPos(a.pos).xy;} # define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(a._ShadowCoord.xy, worldPos, float4(a._ShadowCoord.zw, 0.0, UNITY_SHADOW_W(a.pos.w))); @@ -138,8 +137,8 @@ half UnityComputeForwardShadows(float2 lightmapUV, float3 worldPos, float4 scree # define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(0, worldPos, a._ShadowCoord) # endif #else +# define UNITY_SHADOW_COORDS(idx1) unityShadowCoord4 _ShadowCoord : TEXCOORD##idx1; # if defined(SHADOWS_SHADOWMASK) -# define UNITY_SHADOW_COORDS(idx1) unityShadowCoord4 _ShadowCoord : TEXCOORD##idx1; # define UNITY_TRANSFER_SHADOW(a, coord) a._ShadowCoord.xy = coord.xy * unity_LightmapST.xy + unity_LightmapST.zw; # if (defined(SHADOWS_DEPTH) || defined(SHADOWS_SCREEN) || defined(SHADOWS_CUBE) || UNITY_LIGHT_PROBE_PROXY_VOLUME) # define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(a._ShadowCoord.xy, worldPos, UNITY_READ_SHADOW_COORDS(a)) @@ -147,7 +146,6 @@ half UnityComputeForwardShadows(float2 lightmapUV, float3 worldPos, float4 scree # define UNITY_SHADOW_ATTENUATION(a, worldPos) UnityComputeForwardShadows(a._ShadowCoord.xy, 0, 0) # endif # else -# define UNITY_SHADOW_COORDS(idx1) SHADOW_COORDS(idx1) # if !defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) # define UNITY_TRANSFER_SHADOW(a, coord) # else @@ -171,7 +169,7 @@ unityShadowCoord4x4 unity_WorldToLight; # define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xyz; \ fixed shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ - fixed destName = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * shadow; + fixed destName = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).r * shadow; #endif #ifdef SPOT @@ -184,7 +182,7 @@ inline fixed UnitySpotCookie(unityShadowCoord4 LightCoord) } inline fixed UnitySpotAttenuate(unityShadowCoord3 LightCoord) { - return tex2D(_LightTextureB0, dot(LightCoord, LightCoord).xx).UNITY_ATTEN_CHANNEL; + return tex2D(_LightTextureB0, dot(LightCoord, LightCoord).xx).r; } #if !defined(UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) #define DECLARE_LIGHT_COORD(input, worldPos) unityShadowCoord4 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)) @@ -213,7 +211,7 @@ sampler2D_float _LightTextureB0; # define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ DECLARE_LIGHT_COORD(input, worldPos); \ fixed shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ - fixed destName = tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, lightCoord).w * shadow; + fixed destName = tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).r * texCUBE(_LightTexture0, lightCoord).w * shadow; #endif #ifdef DIRECTIONAL_COOKIE @@ -264,57 +262,33 @@ unityShadowCoord4x4 unity_WorldToLight; #endif #ifdef POINT -# if !defined (UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) -# define DECLARE_LIGHT_COORDS(idx) -# define COMPUTE_LIGHT_COORDS(a) -# define LIGHT_ATTENUATION(a) -# else -# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord3 _LightCoord : TEXCOORD##idx; -# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz; -# define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL * SHADOW_ATTENUATION(a)) -# endif +# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord3 _LightCoord : TEXCOORD##idx; +# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz; +# define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, dot(a._LightCoord,a._LightCoord).rr).r * SHADOW_ATTENUATION(a)) #endif #ifdef SPOT -# if !defined (UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) -# define DECLARE_LIGHT_COORDS(idx) -# define COMPUTE_LIGHT_COORDS(a) -# define LIGHT_ATTENUATION(a) -# else -# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord4 _LightCoord : TEXCOORD##idx; -# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)); -# define LIGHT_ATTENUATION(a) ( (a._LightCoord.z > 0) * UnitySpotCookie(a._LightCoord) * UnitySpotAttenuate(a._LightCoord.xyz) * SHADOW_ATTENUATION(a) ) -# endif +# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord4 _LightCoord : TEXCOORD##idx; +# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)); +# define LIGHT_ATTENUATION(a) ( (a._LightCoord.z > 0) * UnitySpotCookie(a._LightCoord) * UnitySpotAttenuate(a._LightCoord.xyz) * SHADOW_ATTENUATION(a) ) #endif #ifdef DIRECTIONAL -#define DECLARE_LIGHT_COORDS(idx) -#define COMPUTE_LIGHT_COORDS(a) -#define LIGHT_ATTENUATION(a) SHADOW_ATTENUATION(a) +# define DECLARE_LIGHT_COORDS(idx) +# define COMPUTE_LIGHT_COORDS(a) +# define LIGHT_ATTENUATION(a) SHADOW_ATTENUATION(a) #endif #ifdef POINT_COOKIE -# if !defined (UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) -# define DECLARE_LIGHT_COORDS(idx) -# define COMPUTE_LIGHT_COORDS(a) -# define LIGHT_ATTENUATION(a) -# else -# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord3 _LightCoord : TEXCOORD##idx; -# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz; -# define LIGHT_ATTENUATION(a) (tex2D(_LightTextureB0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, a._LightCoord).w * SHADOW_ATTENUATION(a)) -# endif +# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord3 _LightCoord : TEXCOORD##idx; +# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xyz; +# define LIGHT_ATTENUATION(a) (tex2D(_LightTextureB0, dot(a._LightCoord,a._LightCoord).rr).r * texCUBE(_LightTexture0, a._LightCoord).w * SHADOW_ATTENUATION(a)) #endif #ifdef DIRECTIONAL_COOKIE -# if !defined (UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) -# define DECLARE_LIGHT_COORDS(idx) -# define COMPUTE_LIGHT_COORDS(a) -# define LIGHT_ATTENUATION(a) -# else -# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord2 _LightCoord : TEXCOORD##idx; -# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xy; -# define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, a._LightCoord).w * SHADOW_ATTENUATION(a)) -# endif +# define DECLARE_LIGHT_COORDS(idx) unityShadowCoord2 _LightCoord : TEXCOORD##idx; +# define COMPUTE_LIGHT_COORDS(a) a._LightCoord = mul(unity_WorldToLight, mul(unity_ObjectToWorld, v.vertex)).xy; +# define LIGHT_ATTENUATION(a) (tex2D(_LightTexture0, a._LightCoord).w * SHADOW_ATTENUATION(a)) #endif #define UNITY_LIGHTING_COORDS(idx1, idx2) DECLARE_LIGHT_COORDS(idx1) UNITY_SHADOW_COORDS(idx2) @@ -322,5 +296,4 @@ unityShadowCoord4x4 unity_WorldToLight; #define UNITY_TRANSFER_LIGHTING(a, coord) COMPUTE_LIGHT_COORDS(a) UNITY_TRANSFER_SHADOW(a, coord) #define TRANSFER_VERTEX_TO_FRAGMENT(a) COMPUTE_LIGHT_COORDS(a) TRANSFER_SHADOW(a) - #endif diff --git a/CGIncludes/GLSLSupport.glslinc b/CGIncludes/GLSLSupport.glslinc index 2a04026..c747573 100644 --- a/CGIncludes/GLSLSupport.glslinc +++ b/CGIncludes/GLSLSupport.glslinc @@ -27,6 +27,7 @@ uniform mat4 glstate_matrix_projection; #define gl_ProjectionMatrix glstate_matrix_projection #if __VERSION__ < 120 +#ifndef UNITY_GLSL_STRIP_TRANSPOSE mat3 transpose(mat3 mtx) { vec3 c0 = mtx[0]; @@ -53,6 +54,7 @@ mat4 transpose(mat4 mtx) vec4(c0.w, c1.w, c2.w, c3.w) ); } +#endif #endif // __VERSION__ < 120 #endif // GLSL_SUPPORT_INCLUDED diff --git a/CGIncludes/HLSLSupport.cginc b/CGIncludes/HLSLSupport.cginc index 681d5d2..3e8fbb5 100644 --- a/CGIncludes/HLSLSupport.cginc +++ b/CGIncludes/HLSLSupport.cginc @@ -15,9 +15,9 @@ #elif defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || (defined(UNITY_PREFER_HLSLCC) && defined(SHADER_API_GLES)) #define UNITY_COMPILER_HLSL #define UNITY_COMPILER_HLSLCC -#elif defined(SHADER_API_D3D11) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_XBOXONE) +#elif defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) #define UNITY_COMPILER_HLSL -#elif defined(SHADER_TARGET_GLSL) || defined(SHADER_API_WIIU) +#elif defined(SHADER_TARGET_GLSL) #define UNITY_COMPILER_HLSL2GLSL #else #define UNITY_COMPILER_CG @@ -27,7 +27,7 @@ #define UNITY_STEREO_MULTIVIEW_ENABLED #endif -#if (defined(SHADER_API_D3D11) || defined(SHADER_API_PSSL)) && defined(STEREO_INSTANCING_ON) +#if (defined(SHADER_API_D3D11) || defined(SHADER_API_PSSL) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3)) && defined(STEREO_INSTANCING_ON) #define UNITY_STEREO_INSTANCING_ENABLED #endif @@ -85,17 +85,17 @@ # endif #endif #if !defined(SV_Target1) -# if !defined(SHADER_API_XBOXONE) +# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2) # define SV_Target1 COLOR1 # endif #endif #if !defined(SV_Target2) -# if !defined(SHADER_API_XBOXONE) +# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2) # define SV_Target2 COLOR2 # endif #endif #if !defined(SV_Target3) -# if !defined(SHADER_API_XBOXONE) +# if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSP2) # define SV_Target3 COLOR3 # endif #endif @@ -125,13 +125,13 @@ # endif #endif -#if (defined(SHADER_API_GLES3) && !defined(SHADER_API_DESKTOP)) || defined(SHADER_API_GLES) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS) +#if (defined(SHADER_API_GLES3) && !defined(SHADER_API_DESKTOP)) || defined(SHADER_API_GLES) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS) #define UNITY_ALLOWED_MRT_COUNT 4 #else #define UNITY_ALLOWED_MRT_COUNT 8 #endif -#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLES) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS) +#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES3) || defined(SHADER_API_GLES) || defined(SHADER_API_PSP2) || defined(SHADER_API_N3DS) //no fast coherent dynamic branching on these hardware #else #define UNITY_FAST_COHERENT_DYNAMIC_BRANCHING 1 @@ -210,7 +210,7 @@ // This allows people to use min16float and friends in their shader code if they // really want to (making that will make shaders not load before DX11.1, e.g. on Win7, // but if they target WSA/WP exclusively that's fine). -#if !defined(SHADER_API_D3D11) && !defined(SHADER_API_D3D11_9X) && !defined(SHADER_API_GLES3) && !defined(SHADER_API_VULKAN) && !defined(SHADER_API_METAL) && !(defined(SHADER_API_GLES) && defined(UNITY_COMPILER_HLSLCC)) && !defined(SHADER_API_SWITCH) +#if !defined(SHADER_API_D3D11) && !defined(SHADER_API_GLES3) && !defined(SHADER_API_VULKAN) && !defined(SHADER_API_METAL) && !(defined(SHADER_API_GLES) && defined(UNITY_COMPILER_HLSLCC)) && !defined(SHADER_API_SWITCH) #define min16float half #define min16float2 half2 #define min16float3 half3 @@ -272,7 +272,7 @@ #if defined(SHADER_API_PSSL) #define CBUFFER_START(name) ConstantBuffer name { #define CBUFFER_END }; -#elif defined(SHADER_API_D3D11) || defined(SHADER_API_D3D11_9X) +#elif defined(SHADER_API_D3D11) #define CBUFFER_START(name) cbuffer name { #define CBUFFER_END }; #else @@ -281,7 +281,7 @@ #define CBUFFER_END #endif -#if defined(UNITY_STEREO_MULTIVIEW_ENABLED) || (defined(UNITY_SINGLE_PASS_STEREO) && (defined(SHADER_API_GLCORE) || defined(SHADER_API_METAL))) +#if defined(UNITY_STEREO_MULTIVIEW_ENABLED) || ((defined(UNITY_SINGLE_PASS_STEREO) || defined(UNITY_STEREO_INSTANCING_ENABLED)) && (defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL))) #define GLOBAL_CBUFFER_START(name) cbuffer name { #define GLOBAL_CBUFFER_END } #else @@ -341,15 +341,15 @@ // SAMPLE_DEPTH_TEXTURE_LOD(sampler,uv): sample with LOD level #if defined(SHADER_API_PSP2) - half4 SAMPLE_DEPTH_TEXTURE(sampler2D s, float4 uv) { return tex2D(s, (float3)uv); } - half4 SAMPLE_DEPTH_TEXTURE(sampler2D s, float3 uv) { return tex2D(s, uv); } - half4 SAMPLE_DEPTH_TEXTURE(sampler2D s, float2 uv) { return tex2D(s, uv); } + half SAMPLE_DEPTH_TEXTURE(sampler2D s, float4 uv) { return tex2D(s, (float3)uv); } + half SAMPLE_DEPTH_TEXTURE(sampler2D s, float3 uv) { return tex2D(s, uv); } + half SAMPLE_DEPTH_TEXTURE(sampler2D s, float2 uv) { return tex2D(s, uv); } # define SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) (tex2DprojShadow(sampler, uv)) # define SAMPLE_DEPTH_TEXTURE_LOD(sampler, uv) (tex2Dlod(sampler, uv)) # define SAMPLE_RAW_DEPTH_TEXTURE(sampler, uv) SAMPLE_DEPTH_TEXTURE(sampler, uv) # define SAMPLE_RAW_DEPTH_TEXTURE_PROJ(sampler, uv) SAMPLE_DEPTH_TEXTURE_PROJ(sampler, uv) # define SAMPLE_RAW_DEPTH_TEXTURE_LOD(sampler, uv) SAMPLE_DEPTH_TEXTURE_LOD(sampler, uv) - half4 SAMPLE_DEPTH_CUBE_TEXTURE(samplerCUBE s, float3 uv) { return texCUBE(s, uv); } + half SAMPLE_DEPTH_CUBE_TEXTURE(samplerCUBE s, float3 uv) { return texCUBE(s, uv); } #else // Sample depth, just the red component. # define SAMPLE_DEPTH_TEXTURE(sampler, uv) (tex2D(sampler, uv).r) @@ -385,18 +385,10 @@ #define SHADOWS_NATIVE #endif -#if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D11_9X) || (defined(UNITY_COMPILER_HLSLCC) && defined(SHADOWS_NATIVE)) +#if defined(SHADER_API_D3D11) || (defined(UNITY_COMPILER_HLSLCC) && defined(SHADOWS_NATIVE)) // DX11 & hlslcc platforms: built-in PCF - #if defined(SHADER_API_D3D11_9X) - // FL9.x has some bug where the runtime really wants resource & sampler to be bound to the same slot, - // otherwise it is skipping draw calls that use shadowmap sampling. Let's bind to #15 - // and hope all works out. - #define UNITY_DECLARE_SHADOWMAP(tex) Texture2D tex : register(t15); SamplerComparisonState sampler##tex : register(s15) - #define UNITY_DECLARE_TEXCUBE_SHADOWMAP(tex) TextureCube tex : register(t15); SamplerComparisonState sampler##tex : register(s15) - #else - #define UNITY_DECLARE_SHADOWMAP(tex) Texture2D tex; SamplerComparisonState sampler##tex - #define UNITY_DECLARE_TEXCUBE_SHADOWMAP(tex) TextureCube tex; SamplerComparisonState sampler##tex - #endif + #define UNITY_DECLARE_SHADOWMAP(tex) Texture2D tex; SamplerComparisonState sampler##tex + #define UNITY_DECLARE_TEXCUBE_SHADOWMAP(tex) TextureCube tex; SamplerComparisonState sampler##tex #define UNITY_SAMPLE_SHADOW(tex,coord) tex.SampleCmpLevelZero (sampler##tex,(coord).xy,(coord).z) #define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) tex.SampleCmpLevelZero (sampler##tex,(coord).xy/(coord).w,(coord).z/(coord).w) #if defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH) @@ -412,16 +404,6 @@ #define UNITY_SAMPLE_SHADOW(tex,coord) shadow2D (tex,(coord).xyz) #define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) shadow2Dproj (tex,coord) #define UNITY_SAMPLE_TEXCUBE_SHADOW(tex,coord) ((texCUBE(tex,(coord).xyz) < (coord).w) ? 0.0 : 1.0) -#elif defined(SHADER_API_D3D9) - // D3D9: Native shadow maps FOURCC "driver hack", looks just like a regular - // texture sample. Have to always do a projected sample - // so that HLSL compiler doesn't try to be too smart and mess up swizzles - // (thinking that Z is unused). - #define UNITY_DECLARE_SHADOWMAP(tex) sampler2D tex - #define UNITY_DECLARE_TEXCUBE_SHADOWMAP(tex) samplerCUBE tex - #define UNITY_SAMPLE_SHADOW(tex,coord) tex2Dproj (tex,float4((coord).xyz,1)).r - #define UNITY_SAMPLE_SHADOW_PROJ(tex,coord) tex2Dproj (tex,coord).r - #define UNITY_SAMPLE_TEXCUBE_SHADOW(tex,coord) (texCUBEproj(tex,coord).r) #elif defined(SHADER_API_PSSL) // PS4: built-in PCF #define UNITY_DECLARE_SHADOWMAP(tex) Texture2D tex; SamplerComparisonState sampler##tex @@ -563,15 +545,8 @@ #define UNITY_DECLARE_TEXCUBE_NOSAMPLER(tex) samplerCUBE tex #define UNITY_SAMPLE_TEXCUBE(tex,coord) texCUBE (tex,coord) - // DX11 FL 9.x do not have texture LOD sampling. - // We will approximate that with mip bias (very poor approximation, but not much we can do) - #if defined(SHADER_API_D3D11_9X) - # define UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) texCUBEbias(tex, half4(coord, lod)) - # define UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(tex,samplertex,coord,lod) UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) - #else - # define UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) texCUBElod (tex, half4(coord, lod)) - # define UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(tex,samplertex,coord,lod) UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) - #endif + #define UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) texCUBElod (tex, half4(coord, lod)) + #define UNITY_SAMPLE_TEXCUBE_SAMPLER_LOD(tex,samplertex,coord,lod) UNITY_SAMPLE_TEXCUBE_LOD(tex,coord,lod) #define UNITY_SAMPLE_TEXCUBE_SAMPLER(tex,samplertex,coord) texCUBE (tex,coord) // 3D textures @@ -651,7 +626,7 @@ #endif -#if !defined(SHADER_API_D3D11) && !defined(SHADER_API_D3D11_9X) && !defined(UNITY_COMPILER_HLSLCC) && !defined(SHADER_API_PSSL) +#if !defined(SHADER_API_D3D11) && !defined(UNITY_COMPILER_HLSLCC) && !defined(SHADER_API_PSSL) #define SV_POSITION POSITION #endif @@ -664,14 +639,10 @@ #define UNITY_POSITION(pos) float4 pos : SV_POSITION #endif - -#if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_PSP2) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) +// Kept for backwards-compatibility #define UNITY_ATTEN_CHANNEL r -#else -#define UNITY_ATTEN_CHANNEL a -#endif -#if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_PSP2) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_WIIU) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH) +#if defined(SHADER_API_D3D11) || defined(SHADER_API_PSP2) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH) #define UNITY_UV_STARTS_AT_TOP 1 #endif @@ -682,8 +653,6 @@ #if defined(UNITY_REVERSED_Z) #define UNITY_NEAR_CLIP_VALUE (1.0) -#elif defined(SHADER_API_WIIU) || defined(SHADER_API_D3D11_9X) -#define UNITY_NEAR_CLIP_VALUE (0.0) #else #define UNITY_NEAR_CLIP_VALUE (-1.0) #endif @@ -761,7 +730,7 @@ #endif // define use to identify platform with modern feature like texture 3D with filtering, texture array etc... -#define UNITY_SM40_PLUS_PLATFORM (!((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined(SHADER_API_D3D11_9X) || defined (SHADER_API_PSP2) || defined(SHADER_API_GLES))) +#define UNITY_SM40_PLUS_PLATFORM (!((SHADER_TARGET < 30) || defined (SHADER_API_MOBILE) || defined (SHADER_API_PSP2) || defined(SHADER_API_GLES))) // Ability to manually set descriptor set and binding numbers (Vulkan only) #if defined(SHADER_API_VULKAN) diff --git a/CGIncludes/UnityCG.cginc b/CGIncludes/UnityCG.cginc index e3e5d48..86bccbc 100644 --- a/CGIncludes/UnityCG.cginc +++ b/CGIncludes/UnityCG.cginc @@ -1016,17 +1016,20 @@ float4 UnityApplyLinearShadowBias(float4 clipPos) #define UNITY_TRANSFER_FOG(o,outpos) UNITY_CALC_FOG_FACTOR((outpos).z); o.fogCoord.x = unityFogFactor #define UNITY_TRANSFER_FOG_COMBINED_WITH_TSPACE(o,outpos) UNITY_CALC_FOG_FACTOR((outpos).z); o.tSpace1.y = tangentSign; o.tSpace2.y = unityFogFactor #define UNITY_TRANSFER_FOG_COMBINED_WITH_WORLD_POS(o,outpos) UNITY_CALC_FOG_FACTOR((outpos).z); o.worldPos.w = unityFogFactor + #define UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o,outpos) UNITY_CALC_FOG_FACTOR((outpos).z); o.eyeVec.w = unityFogFactor #else // SM3.0 and PC/console: calculate fog distance per-vertex, and fog factor per-pixel #define UNITY_TRANSFER_FOG(o,outpos) o.fogCoord.x = (outpos).z #define UNITY_TRANSFER_FOG_COMBINED_WITH_TSPACE(o,outpos) o.tSpace2.y = (outpos).z #define UNITY_TRANSFER_FOG_COMBINED_WITH_WORLD_POS(o,outpos) o.worldPos.w = (outpos).z + #define UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o,outpos) o.eyeVec.w = (outpos).z #endif #else #define UNITY_FOG_COORDS(idx) #define UNITY_TRANSFER_FOG(o,outpos) #define UNITY_TRANSFER_FOG_COMBINED_WITH_TSPACE(o,outpos) #define UNITY_TRANSFER_FOG_COMBINED_WITH_WORLD_POS(o,outpos) + #define UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o,outpos) #endif #define UNITY_FOG_LERP_COLOR(col,fogCol,fogFac) col.rgb = lerp((fogCol).rgb, (col).rgb, saturate(fogFac)) @@ -1043,11 +1046,13 @@ float4 UnityApplyLinearShadowBias(float4 clipPos) #define UNITY_EXTRACT_FOG(name) float _unity_fogCoord = name.fogCoord #define UNITY_EXTRACT_FOG_FROM_TSPACE(name) float _unity_fogCoord = name.tSpace2.y #define UNITY_EXTRACT_FOG_FROM_WORLD_POS(name) float _unity_fogCoord = name.worldPos.w + #define UNITY_EXTRACT_FOG_FROM_EYE_VEC(name) float _unity_fogCoord = name.eyeVec.w #else #define UNITY_APPLY_FOG_COLOR(coord,col,fogCol) #define UNITY_EXTRACT_FOG(name) #define UNITY_EXTRACT_FOG_FROM_TSPACE(name) #define UNITY_EXTRACT_FOG_FROM_WORLD_POS(name) + #define UNITY_EXTRACT_FOG_FROM_EYE_VEC(name) #endif #ifdef UNITY_PASS_FORWARDADD diff --git a/CGIncludes/UnityCustomRenderTexture.cginc b/CGIncludes/UnityCustomRenderTexture.cginc index 6f422de..61ccc65 100644 --- a/CGIncludes/UnityCustomRenderTexture.cginc +++ b/CGIncludes/UnityCustomRenderTexture.cginc @@ -209,7 +209,7 @@ struct appdata_init_customrendertexture struct v2f_init_customrendertexture { float4 vertex : SV_POSITION; - float2 texcoord : TEXCOORD0; + float3 texcoord : TEXCOORD0; float3 direction : TEXCOORD1; }; diff --git a/CGIncludes/UnityDeferredLibrary.cginc b/CGIncludes/UnityDeferredLibrary.cginc index 3b81ab3..6edbeca 100644 --- a/CGIncludes/UnityDeferredLibrary.cginc +++ b/CGIncludes/UnityDeferredLibrary.cginc @@ -169,7 +169,7 @@ void UnityDeferredCalculateLightParams ( float atten = tex2Dbias (_LightTexture0, float4(uvCookie.xy / uvCookie.w, 0, -8)).w; atten *= uvCookie.w < 0; float att = dot(tolight, tolight) * _LightPos.w; - atten *= tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL; + atten *= tex2D (_LightTextureB0, att.rr).r; atten *= UnityDeferredComputeShadow (wpos, fadeDist, uv); @@ -190,7 +190,7 @@ void UnityDeferredCalculateLightParams ( half3 lightDir = -normalize (tolight); float att = dot(tolight, tolight) * _LightPos.w; - float atten = tex2D (_LightTextureB0, att.rr).UNITY_ATTEN_CHANNEL; + float atten = tex2D (_LightTextureB0, att.rr).r; atten *= UnityDeferredComputeShadow (tolight, fadeDist, uv); diff --git a/CGIncludes/UnityInstancing.cginc b/CGIncludes/UnityInstancing.cginc index 85d3071..df42240 100644 --- a/CGIncludes/UnityInstancing.cginc +++ b/CGIncludes/UnityInstancing.cginc @@ -34,16 +34,12 @@ #define UNITY_FORCE_MAX_INSTANCE_COUNT 1 #endif -#if defined(SHADER_API_D3D11) +#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) #define UNITY_SUPPORT_STEREO_INSTANCING #endif -#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_VULKAN) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) || defined(SHADER_API_SWITCH) - #define UNITY_INSTANCING_AOS -#endif - // These platforms support dynamically adjusting the instancing CB size according to the current batch. -#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) +#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) || defined(SHADER_API_METAL) || defined(SHADER_API_PSSL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_SWITCH) #define UNITY_INSTANCING_SUPPORT_FLEXIBLE_ARRAY_SIZE #endif @@ -117,8 +113,13 @@ // - UNITY_TRANSFER_VERTEX_OUTPUT_STEREO Copy stero target from input struct to output struct. Used in vertex shader. // - UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX #ifdef UNITY_STEREO_INSTANCING_ENABLED +#if defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE) + #define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndexSV : SV_RenderTargetArrayIndex; uint stereoTargetEyeIndex : BLENDINDICES0; + #define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndexSV = unity_StereoEyeIndex; output.stereoTargetEyeIndex = unity_StereoEyeIndex; +#else #define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndex : SV_RenderTargetArrayIndex; #define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndex = unity_StereoEyeIndex +#endif #define DEFAULT_UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(input, output) output.stereoTargetEyeIndex = input.stereoTargetEyeIndex; #define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex = input.stereoTargetEyeIndex; #elif defined(UNITY_STEREO_MULTIVIEW_ENABLED) @@ -129,7 +130,7 @@ #if defined(SHADER_STAGE_VERTEX) #define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) #else - #define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex = (uint) input.stereoTargetEyeIndex; + #define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex.x = input.stereoTargetEyeIndex; #endif #else #define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO @@ -162,9 +163,21 @@ void UnitySetupInstanceID(uint inputInstanceID) { #ifdef UNITY_STEREO_INSTANCING_ENABLED - // stereo eye index is automatically figured out from the instance ID - unity_StereoEyeIndex = inputInstanceID & 0x01; - unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); + #if defined(SHADER_API_GLES3) + // We must calculate the stereo eye index differently for GLES3 + // because otherwise, the unity shader compiler will emit a bitfieldInsert function. + // bitfieldInsert requires support for glsl version 400 or later. Therefore the + // generated glsl code will fail to compile on lower end devices. By changing the + // way we calculate the stereo eye index, we can help the shader compiler to avoid + // emitting the bitfieldInsert function and thereby increase the number of devices we + // can run stereo instancing on. + unity_StereoEyeIndex = round(fmod(inputInstanceID, 2.0)); + unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); + #else + // stereo eye index is automatically figured out from the instance ID + unity_StereoEyeIndex = inputInstanceID & 0x01; + unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); + #endif #else unity_InstanceID = inputInstanceID + unity_BaseInstanceID; #endif @@ -208,17 +221,10 @@ #endif #endif - #ifdef UNITY_INSTANCING_AOS - #define UNITY_INSTANCING_BUFFER_START(buf) UNITY_INSTANCING_CBUFFER_SCOPE_BEGIN(UnityInstancing_##buf) struct { - #define UNITY_INSTANCING_BUFFER_END(arr) } arr##Array[UNITY_INSTANCED_ARRAY_SIZE]; UNITY_INSTANCING_CBUFFER_SCOPE_END - #define UNITY_DEFINE_INSTANCED_PROP(type, var) type var; - #define UNITY_ACCESS_INSTANCED_PROP(arr, var) arr##Array[unity_InstanceID].var - #else - #define UNITY_INSTANCING_BUFFER_START(buf) UNITY_INSTANCING_CBUFFER_SCOPE_BEGIN(UnityInstancing_##buf) - #define UNITY_INSTANCING_BUFFER_END(arr) UNITY_INSTANCING_CBUFFER_SCOPE_END - #define UNITY_DEFINE_INSTANCED_PROP(type, var) type var[UNITY_INSTANCED_ARRAY_SIZE]; - #define UNITY_ACCESS_INSTANCED_PROP(arr, var) var[unity_InstanceID] - #endif + #define UNITY_INSTANCING_BUFFER_START(buf) UNITY_INSTANCING_CBUFFER_SCOPE_BEGIN(UnityInstancing_##buf) struct { + #define UNITY_INSTANCING_BUFFER_END(arr) } arr##Array[UNITY_INSTANCED_ARRAY_SIZE]; UNITY_INSTANCING_CBUFFER_SCOPE_END + #define UNITY_DEFINE_INSTANCED_PROP(type, var) type var; + #define UNITY_ACCESS_INSTANCED_PROP(arr, var) arr##Array[unity_InstanceID].var // Put worldToObject array to a separate CB if UNITY_ASSUME_UNIFORM_SCALING is defined. Most of the time it will not be used. #ifdef UNITY_ASSUME_UNIFORM_SCALING @@ -250,25 +256,27 @@ #endif UNITY_INSTANCING_BUFFER_START(PerDraw0) - UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_ObjectToWorldArray) - #if UNITY_WORLDTOOBJECTARRAY_CB == 0 - UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_WorldToObjectArray) + #ifndef UNITY_DONT_INSTANCE_OBJECT_MATRICES + UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_ObjectToWorldArray) + #if UNITY_WORLDTOOBJECTARRAY_CB == 0 + UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_WorldToObjectArray) + #endif #endif #if defined(UNITY_USE_LODFADE_ARRAY) && defined(UNITY_INSTANCING_SUPPORT_FLEXIBLE_ARRAY_SIZE) - UNITY_DEFINE_INSTANCED_PROP(float, unity_LODFadeArray) + UNITY_DEFINE_INSTANCED_PROP(float2, unity_LODFadeArray) // the quantized fade value (unity_LODFade.y) is automatically used for cross-fading instances - #define unity_LODFade UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_LODFadeArray).xxxx + #define unity_LODFade UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_LODFadeArray).xyxx #endif UNITY_INSTANCING_BUFFER_END(unity_Builtins0) UNITY_INSTANCING_BUFFER_START(PerDraw1) - #if UNITY_WORLDTOOBJECTARRAY_CB == 1 + #if !defined(UNITY_DONT_INSTANCE_OBJECT_MATRICES) && UNITY_WORLDTOOBJECTARRAY_CB == 1 UNITY_DEFINE_INSTANCED_PROP(float4x4, unity_WorldToObjectArray) #endif #if defined(UNITY_USE_LODFADE_ARRAY) && !defined(UNITY_INSTANCING_SUPPORT_FLEXIBLE_ARRAY_SIZE) - UNITY_DEFINE_INSTANCED_PROP(float, unity_LODFadeArray) + UNITY_DEFINE_INSTANCED_PROP(float2, unity_LODFadeArray) // the quantized fade value (unity_LODFade.y) is automatically used for cross-fading instances - #define unity_LODFade UNITY_ACCESS_INSTANCED_PROP(unity_Builtins1, unity_LODFadeArray).xxxx + #define unity_LODFade UNITY_ACCESS_INSTANCED_PROP(unity_Builtins1, unity_LODFadeArray).xyxx #endif UNITY_INSTANCING_BUFFER_END(unity_Builtins1) @@ -303,21 +311,21 @@ #endif UNITY_INSTANCING_BUFFER_END(unity_Builtins2) - #define unity_ObjectToWorld UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_ObjectToWorldArray) - - #define MERGE_UNITY_BUILTINS_INDEX(X) unity_Builtins##X - - #define unity_WorldToObject UNITY_ACCESS_INSTANCED_PROP(MERGE_UNITY_BUILTINS_INDEX(UNITY_WORLDTOOBJECTARRAY_CB), unity_WorldToObjectArray) - - inline float4 UnityObjectToClipPosInstanced(in float3 pos) - { - return mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, float4(pos, 1.0))); - } - inline float4 UnityObjectToClipPosInstanced(float4 pos) - { - return UnityObjectToClipPosInstanced(pos.xyz); - } - #define UnityObjectToClipPos UnityObjectToClipPosInstanced + #ifndef UNITY_DONT_INSTANCE_OBJECT_MATRICES + #define unity_ObjectToWorld UNITY_ACCESS_INSTANCED_PROP(unity_Builtins0, unity_ObjectToWorldArray) + #define MERGE_UNITY_BUILTINS_INDEX(X) unity_Builtins##X + #define unity_WorldToObject UNITY_ACCESS_INSTANCED_PROP(MERGE_UNITY_BUILTINS_INDEX(UNITY_WORLDTOOBJECTARRAY_CB), unity_WorldToObjectArray) + + inline float4 UnityObjectToClipPosInstanced(in float3 pos) + { + return mul(UNITY_MATRIX_VP, mul(unity_ObjectToWorld, float4(pos, 1.0))); + } + inline float4 UnityObjectToClipPosInstanced(float4 pos) + { + return UnityObjectToClipPosInstanced(pos.xyz); + } + #define UnityObjectToClipPos UnityObjectToClipPosInstanced + #endif #else // UNITY_INSTANCING_ENABLED @@ -337,26 +345,31 @@ #endif // UNITY_INSTANCING_ENABLED #if defined(UNITY_INSTANCING_ENABLED) || defined(UNITY_PROCEDURAL_INSTANCING_ENABLED) || defined(UNITY_STEREO_INSTANCING_ENABLED) - // The following matrix evaluations depend on the static var unity_InstanceID & unity_StereoEyeIndex. They need to be initialized after UnitySetupInstanceID. - static float4x4 unity_MatrixMVP_Instanced; - static float4x4 unity_MatrixMV_Instanced; - static float4x4 unity_MatrixTMV_Instanced; - static float4x4 unity_MatrixITMV_Instanced; - void UnitySetupCompoundMatrices() - { - unity_MatrixMVP_Instanced = mul(unity_MatrixVP, unity_ObjectToWorld); - unity_MatrixMV_Instanced = mul(unity_MatrixV, unity_ObjectToWorld); - unity_MatrixTMV_Instanced = transpose(unity_MatrixMV_Instanced); - unity_MatrixITMV_Instanced = transpose(mul(unity_WorldToObject, unity_MatrixInvV)); - } - #undef UNITY_MATRIX_MVP - #undef UNITY_MATRIX_MV - #undef UNITY_MATRIX_T_MV - #undef UNITY_MATRIX_IT_MV - #define UNITY_MATRIX_MVP unity_MatrixMVP_Instanced - #define UNITY_MATRIX_MV unity_MatrixMV_Instanced - #define UNITY_MATRIX_T_MV unity_MatrixTMV_Instanced - #define UNITY_MATRIX_IT_MV unity_MatrixITMV_Instanced -#endif + + #ifdef UNITY_DONT_INSTANCE_OBJECT_MATRICES + void UnitySetupCompoundMatrices() {} + #else + // The following matrix evaluations depend on the static var unity_InstanceID & unity_StereoEyeIndex. They need to be initialized after UnitySetupInstanceID. + static float4x4 unity_MatrixMVP_Instanced; + static float4x4 unity_MatrixMV_Instanced; + static float4x4 unity_MatrixTMV_Instanced; + static float4x4 unity_MatrixITMV_Instanced; + void UnitySetupCompoundMatrices() + { + unity_MatrixMVP_Instanced = mul(unity_MatrixVP, unity_ObjectToWorld); + unity_MatrixMV_Instanced = mul(unity_MatrixV, unity_ObjectToWorld); + unity_MatrixTMV_Instanced = transpose(unity_MatrixMV_Instanced); + unity_MatrixITMV_Instanced = transpose(mul(unity_WorldToObject, unity_MatrixInvV)); + } + #undef UNITY_MATRIX_MVP + #undef UNITY_MATRIX_MV + #undef UNITY_MATRIX_T_MV + #undef UNITY_MATRIX_IT_MV + #define UNITY_MATRIX_MVP unity_MatrixMVP_Instanced + #define UNITY_MATRIX_MV unity_MatrixMV_Instanced + #define UNITY_MATRIX_T_MV unity_MatrixTMV_Instanced + #define UNITY_MATRIX_IT_MV unity_MatrixITMV_Instanced + #endif // UNITY_DONT_INSTANCE_OBJECT_MATRICES +#endif // UNITY_INSTANCING_ENABLED || UNITY_PROCEDURAL_INSTANCING_ENABLED || UNITY_STEREO_INSTANCING_ENABLED #endif // UNITY_INSTANCING_INCLUDED diff --git a/CGIncludes/UnityShaderVariables.cginc b/CGIncludes/UnityShaderVariables.cginc index b6bf5eb..d80c988 100644 --- a/CGIncludes/UnityShaderVariables.cginc +++ b/CGIncludes/UnityShaderVariables.cginc @@ -292,7 +292,7 @@ CBUFFER_END #undef UNITY_LIGHT_PROBE_PROXY_VOLUME // Requires quite modern graphics support (3D float textures with filtering) // Note: Keep this in synch with the list from LightProbeProxyVolume::HasHardwareSupport && SurfaceCompiler::IsLPPVAvailableForAnyTargetPlatform - #if !defined(UNITY_NO_LPPV) && (defined (SHADER_API_D3D11) || defined (SHADER_API_D3D12) || defined (SHADER_API_GLCORE) || defined (SHADER_API_XBOXONE) || defined (SHADER_API_PSSL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL)) + #if !defined(UNITY_NO_LPPV) && (defined (SHADER_API_D3D11) || defined (SHADER_API_D3D12) || defined (SHADER_API_GLCORE) || defined (SHADER_API_XBOXONE) || defined (SHADER_API_PSSL) || defined(SHADER_API_VULKAN) || defined(SHADER_API_METAL) || defined(SHADER_API_SWITCH)) #define UNITY_LIGHT_PROBE_PROXY_VOLUME 1 #else #define UNITY_LIGHT_PROBE_PROXY_VOLUME 0 diff --git a/CGIncludes/UnityShadowLibrary.cginc b/CGIncludes/UnityShadowLibrary.cginc index 7e29fc5..cd40a76 100644 --- a/CGIncludes/UnityShadowLibrary.cginc +++ b/CGIncludes/UnityShadowLibrary.cginc @@ -40,11 +40,7 @@ float3 UnityGetReceiverPlaneDepthBias(float3 shadowCoord, float biasbiasMultipl inline fixed UnitySampleShadowmap (float4 shadowCoord) { - // DX11 feature level 9.x shader compiler (d3dcompiler_47 at least) - // has a bug where trying to do more than one shadowmap sample fails compilation - // with "inconsistent sampler usage". Until that is fixed, just never compile - // multi-tap shadow variant on d3d11_9x. - #if defined (SHADOWS_SOFT) && !defined (SHADER_API_D3D11_9X) + #if defined (SHADOWS_SOFT) half shadow = 1; @@ -104,12 +100,7 @@ inline fixed UnitySampleShadowmap (float4 shadowCoord) UNITY_DECLARE_TEXCUBE(_ShadowMapTexture); inline float SampleCubeDistance (float3 vec) { - // DX9 with SM2.0, and DX11 FL 9.x do not have texture LOD sampling. - #if ((SHADER_TARGET < 25) && defined(SHADER_API_D3D9)) || defined(SHADER_API_D3D11_9X) - return UnityDecodeCubeShadowDepth(texCUBE(_ShadowMapTexture, vec)); - #else - return UnityDecodeCubeShadowDepth(UNITY_SAMPLE_TEXCUBE_LOD(_ShadowMapTexture, vec, 0)); - #endif + return UnityDecodeCubeShadowDepth(UNITY_SAMPLE_TEXCUBE_LOD(_ShadowMapTexture, vec, 0)); } #endif diff --git a/CGIncludes/UnityStandardBRDF.cginc b/CGIncludes/UnityStandardBRDF.cginc index ba491c1..62a0abd 100644 --- a/CGIncludes/UnityStandardBRDF.cginc +++ b/CGIncludes/UnityStandardBRDF.cginc @@ -409,7 +409,7 @@ half3 BRDF3_Direct(half3 diffColor, half3 specColor, half rlPow4, half smoothnes { half LUT_RANGE = 16.0; // must match range in NHxRoughness() function in GeneratedTextures.cpp // Lookup texture to save instructions - half specular = tex2D(unity_NHxRoughness, half2(rlPow4, SmoothnessToPerceptualRoughness(smoothness))).UNITY_ATTEN_CHANNEL * LUT_RANGE; + half specular = tex2D(unity_NHxRoughness, half2(rlPow4, SmoothnessToPerceptualRoughness(smoothness))).r * LUT_RANGE; #if defined(_SPECULARHIGHLIGHTS_OFF) specular = 0.0; #endif diff --git a/CGIncludes/UnityStandardConfig.cginc b/CGIncludes/UnityStandardConfig.cginc index e40c625..5baeab9 100644 --- a/CGIncludes/UnityStandardConfig.cginc +++ b/CGIncludes/UnityStandardConfig.cginc @@ -41,7 +41,7 @@ #undef _PARALLAXMAP #endif #endif -#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES) || defined(SHADER_API_D3D11_9X) || defined (SHADER_API_PSP2) +#if (SHADER_TARGET < 30) || defined(SHADER_API_GLES) || defined (SHADER_API_PSP2) #undef UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS #endif @@ -87,7 +87,7 @@ // Should we pack worldPos along tangent (saving an interpolator) // We want to skip this on mobile platforms, because worldpos gets packed into mediump -#if UNITY_REQUIRE_FRAG_WORLDPOS && !defined(_PARALLAXMAP) && !(defined(SHADER_API_MOBILE) && !defined(SHADER_API_D3D11_9X)) +#if UNITY_REQUIRE_FRAG_WORLDPOS && !defined(_PARALLAXMAP) && !defined(SHADER_API_MOBILE) #define UNITY_PACK_WORLDPOS_WITH_TANGENT 1 #else #define UNITY_PACK_WORLDPOS_WITH_TANGENT 0 diff --git a/CGIncludes/UnityStandardCore.cginc b/CGIncludes/UnityStandardCore.cginc index 16f7bb9..e341ce4 100644 --- a/CGIncludes/UnityStandardCore.cginc +++ b/CGIncludes/UnityStandardCore.cginc @@ -30,7 +30,7 @@ float3 NormalizePerPixelNormal (float3 n) #if (SHADER_TARGET < 30) || UNITY_STANDARD_SIMPLE return n; #else - return normalize(n); + return normalize((float3)n); // takes float to avoid overflow #endif } @@ -161,10 +161,10 @@ float3 PerPixelWorldNormal(float4 i_tex, float4 tangentToWorld[3]) #define IN_LIGHTDIR_FWDADD(i) half3(i.tangentToWorldAndLightDir[0].w, i.tangentToWorldAndLightDir[1].w, i.tangentToWorldAndLightDir[2].w) #define FRAGMENT_SETUP(x) FragmentCommonData x = \ - FragmentSetup(i.tex, i.eyeVec, IN_VIEWDIR4PARALLAX(i), i.tangentToWorldAndPackedData, IN_WORLDPOS(i)); + FragmentSetup(i.tex, i.eyeVec.xyz, IN_VIEWDIR4PARALLAX(i), i.tangentToWorldAndPackedData, IN_WORLDPOS(i)); #define FRAGMENT_SETUP_FWDADD(x) FragmentCommonData x = \ - FragmentSetup(i.tex, i.eyeVec, IN_VIEWDIR4PARALLAX_FWDADD(i), i.tangentToWorldAndLightDir, IN_WORLDPOS_FWDADD(i)); + FragmentSetup(i.tex, i.eyeVec.xyz, IN_VIEWDIR4PARALLAX_FWDADD(i), i.tangentToWorldAndLightDir, IN_WORLDPOS_FWDADD(i)); struct FragmentCommonData { @@ -358,20 +358,15 @@ struct VertexOutputForwardBase { UNITY_POSITION(pos); float4 tex : TEXCOORD0; - float3 eyeVec : TEXCOORD1; + float4 eyeVec : TEXCOORD1; // eyeVec.xyz | fogCoord float4 tangentToWorldAndPackedData[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:viewDirForParallax or worldPos] half4 ambientOrLightmapUV : TEXCOORD5; // SH or Lightmap UV -#if !defined (UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) - UNITY_SHADOW_COORDS(6) - UNITY_FOG_COORDS(7) -#else UNITY_LIGHTING_COORDS(6,7) - UNITY_FOG_COORDS(8) + + // next ones would not fit into SM2.0 limits, but they are always for SM3.0+ +#if UNITY_REQUIRE_FRAG_WORLDPOS && !UNITY_PACK_WORLDPOS_WITH_TANGENT + float3 posWorld : TEXCOORD8; #endif - // next ones would not fit into SM2.0 limits, but they are always for SM3.0+ - #if UNITY_REQUIRE_FRAG_WORLDPOS && !UNITY_PACK_WORLDPOS_WITH_TANGENT - float3 posWorld : TEXCOORD9; - #endif UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_OUTPUT_STEREO @@ -398,7 +393,7 @@ VertexOutputForwardBase vertForwardBase (VertexInput v) o.pos = UnityObjectToClipPos(v.vertex); o.tex = TexCoords(v); - o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos); + o.eyeVec.xyz = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos); float3 normalWorld = UnityObjectToWorldNormal(v.normal); #ifdef _TANGENT_TO_WORLD float4 tangentWorld = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w); @@ -426,7 +421,7 @@ VertexOutputForwardBase vertForwardBase (VertexInput v) o.tangentToWorldAndPackedData[2].w = viewDirForParallax.z; #endif - UNITY_TRANSFER_FOG(o,o.pos); + UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o,o.pos); return o; } @@ -448,7 +443,8 @@ half4 fragForwardBaseInternal (VertexOutputForwardBase i) half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, gi.light, gi.indirect); c.rgb += Emission(i.tex.xy); - UNITY_APPLY_FOG(i.fogCoord, c.rgb); + UNITY_EXTRACT_FOG_FROM_EYE_VEC(i); + UNITY_APPLY_FOG(_unity_fogCoord, c.rgb); return OutputForward (c, s.alpha); } @@ -464,16 +460,10 @@ struct VertexOutputForwardAdd { UNITY_POSITION(pos); float4 tex : TEXCOORD0; - float3 eyeVec : TEXCOORD1; + float4 eyeVec : TEXCOORD1; // eyeVec.xyz | fogCoord float4 tangentToWorldAndLightDir[3] : TEXCOORD2; // [3x3:tangentToWorld | 1x3:lightDir] float3 posWorld : TEXCOORD5; -#if !defined (UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS) - UNITY_SHADOW_COORDS(6) - UNITY_FOG_COORDS(7) -#else UNITY_LIGHTING_COORDS(6, 7) - UNITY_FOG_COORDS(8) -#endif // next ones would not fit into SM2.0 limits, but they are always for SM3.0+ #if defined(_PARALLAXMAP) @@ -494,7 +484,7 @@ VertexOutputForwardAdd vertForwardAdd (VertexInput v) o.pos = UnityObjectToClipPos(v.vertex); o.tex = TexCoords(v); - o.eyeVec = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos); + o.eyeVec.xyz = NormalizePerVertexNormal(posWorld.xyz - _WorldSpaceCameraPos); o.posWorld = posWorld.xyz; float3 normalWorld = UnityObjectToWorldNormal(v.normal); #ifdef _TANGENT_TO_WORLD @@ -525,7 +515,7 @@ VertexOutputForwardAdd vertForwardAdd (VertexInput v) o.viewDirForParallax = mul (rotation, ObjSpaceViewDir(v.vertex)); #endif - UNITY_TRANSFER_FOG(o,o.pos); + UNITY_TRANSFER_FOG_COMBINED_WITH_EYE_VEC(o, o.pos); return o; } @@ -533,6 +523,8 @@ half4 fragForwardAddInternal (VertexOutputForwardAdd i) { UNITY_APPLY_DITHER_CROSSFADE(i.pos.xy); + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); + FRAGMENT_SETUP_FWDADD(s) UNITY_LIGHT_ATTENUATION(atten, i, s.posWorld) @@ -541,7 +533,8 @@ half4 fragForwardAddInternal (VertexOutputForwardAdd i) half4 c = UNITY_BRDF_PBS (s.diffColor, s.specColor, s.oneMinusReflectivity, s.smoothness, s.normalWorld, -s.eyeVec, light, noIndirect); - UNITY_APPLY_FOG_COLOR(i.fogCoord, c.rgb, half4(0,0,0,0)); // fog towards black in additive pass + UNITY_EXTRACT_FOG_FROM_EYE_VEC(i); + UNITY_APPLY_FOG_COLOR(_unity_fogCoord, c.rgb, half4(0,0,0,0)); // fog towards black in additive pass return OutputForward (c, s.alpha); } diff --git a/CGIncludes/UnityStandardUtils.cginc b/CGIncludes/UnityStandardUtils.cginc index b6f5801..a79fcee 100644 --- a/CGIncludes/UnityStandardUtils.cginc +++ b/CGIncludes/UnityStandardUtils.cginc @@ -224,30 +224,30 @@ half3 ShadeSHPerPixel (half3 normal, half3 ambient, float3 worldPos) } //------------------------------------------------------------------------------------- -inline half3 BoxProjectedCubemapDirection (half3 worldRefl, float3 worldPos, float4 cubemapCenter, float4 boxMin, float4 boxMax) +inline float3 BoxProjectedCubemapDirection (float3 worldRefl, float3 worldPos, float4 cubemapCenter, float4 boxMin, float4 boxMax) { // Do we have a valid reflection probe? UNITY_BRANCH if (cubemapCenter.w > 0.0) { - half3 nrdir = normalize(worldRefl); + float3 nrdir = normalize(worldRefl); #if 1 - half3 rbmax = (boxMax.xyz - worldPos) / nrdir; - half3 rbmin = (boxMin.xyz - worldPos) / nrdir; + float3 rbmax = (boxMax.xyz - worldPos) / nrdir; + float3 rbmin = (boxMin.xyz - worldPos) / nrdir; - half3 rbminmax = (nrdir > 0.0f) ? rbmax : rbmin; + float3 rbminmax = (nrdir > 0.0f) ? rbmax : rbmin; #else // Optimized version - half3 rbmax = (boxMax.xyz - worldPos); - half3 rbmin = (boxMin.xyz - worldPos); + float3 rbmax = (boxMax.xyz - worldPos); + float3 rbmin = (boxMin.xyz - worldPos); - half3 select = step (half3(0,0,0), nrdir); - half3 rbminmax = lerp (rbmax, rbmin, select); + float3 select = step (float3(0,0,0), nrdir); + float3 rbminmax = lerp (rbmax, rbmin, select); rbminmax /= nrdir; #endif - half fa = min(min(rbminmax.x, rbminmax.y), rbminmax.z); + float fa = min(min(rbminmax.x, rbminmax.y), rbminmax.z); worldPos -= cubemapCenter.xyz; worldRefl = worldPos + nrdir * fa; diff --git a/DefaultResourcesExtra/Alpha-BumpSpec.shader b/DefaultResourcesExtra/Alpha-BumpSpec.shader index f5fa1b3..9e45520 100644 --- a/DefaultResourcesExtra/Alpha-BumpSpec.shader +++ b/DefaultResourcesExtra/Alpha-BumpSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Transparent/Bumped Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } diff --git a/DefaultResourcesExtra/Alpha-Glossy.shader b/DefaultResourcesExtra/Alpha-Glossy.shader index 01d9f15..838b500 100644 --- a/DefaultResourcesExtra/Alpha-Glossy.shader +++ b/DefaultResourcesExtra/Alpha-Glossy.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Transparent/Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} } diff --git a/DefaultResourcesExtra/Alpha-ParallaxSpec.shader b/DefaultResourcesExtra/Alpha-ParallaxSpec.shader index bcf1fb2..ac3bdd8 100644 --- a/DefaultResourcesExtra/Alpha-ParallaxSpec.shader +++ b/DefaultResourcesExtra/Alpha-ParallaxSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Transparent/Parallax Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _Parallax ("Height", Range (0.005, 0.08)) = 0.02 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} diff --git a/DefaultResourcesExtra/Alpha-VertexLit.shader b/DefaultResourcesExtra/Alpha-VertexLit.shader index 91e0ea8..16a3ab6 100644 --- a/DefaultResourcesExtra/Alpha-VertexLit.shader +++ b/DefaultResourcesExtra/Alpha-VertexLit.shader @@ -5,7 +5,7 @@ Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,0) _Emission ("Emissive Color", Color) = (0,0,0,0) - _Shininess ("Shininess", Range (0.1, 1)) = 0.7 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.1, 1)) = 0.7 _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} } diff --git a/DefaultResourcesExtra/AlphaTest-BumpSpec.shader b/DefaultResourcesExtra/AlphaTest-BumpSpec.shader index 66cf5a7..6c973ef 100644 --- a/DefaultResourcesExtra/AlphaTest-BumpSpec.shader +++ b/DefaultResourcesExtra/AlphaTest-BumpSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Transparent/Cutout/Bumped Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 diff --git a/DefaultResourcesExtra/AlphaTest-Glossy.shader b/DefaultResourcesExtra/AlphaTest-Glossy.shader index 35e7458..f278f79 100644 --- a/DefaultResourcesExtra/AlphaTest-Glossy.shader +++ b/DefaultResourcesExtra/AlphaTest-Glossy.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Transparent/Cutout/Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 0) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) TransGloss (A)", 2D) = "white" {} _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } diff --git a/DefaultResourcesExtra/AlphaTest-VertexLit.shader b/DefaultResourcesExtra/AlphaTest-VertexLit.shader index d197b46..41e3b07 100644 --- a/DefaultResourcesExtra/AlphaTest-VertexLit.shader +++ b/DefaultResourcesExtra/AlphaTest-VertexLit.shader @@ -5,7 +5,7 @@ Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,0) _Emission ("Emissive Color", Color) = (0,0,0,0) - _Shininess ("Shininess", Range (0.1, 1)) = 0.7 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.1, 1)) = 0.7 _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5 } diff --git a/DefaultResourcesExtra/GIDebug/ShowLightMask.shader b/DefaultResourcesExtra/GIDebug/ShowLightMask.shader index d95f429..76e4c6c 100644 --- a/DefaultResourcesExtra/GIDebug/ShowLightMask.shader +++ b/DefaultResourcesExtra/GIDebug/ShowLightMask.shader @@ -57,7 +57,7 @@ Shader "Hidden/GIDebug/ShowLightMask" { fixed UnitySpotAttenuate(float3 LightCoord) { - return tex2D(_LightTextureB, dot(LightCoord, LightCoord).xx).UNITY_ATTEN_CHANNEL; + return tex2D(_LightTextureB, dot(LightCoord, LightCoord).xx).r; } float4 frag_surf (v2f_surf IN) : COLOR @@ -78,7 +78,7 @@ Shader "Hidden/GIDebug/ShowLightMask" { else if (_LightType == 1) { // point - atten = tex2D(_LightTexture, dot(lightCoord.xyz, lightCoord.xyz).xx).UNITY_ATTEN_CHANNEL; + atten = tex2D(_LightTexture, dot(lightCoord.xyz, lightCoord.xyz).xx).r; } else if (_LightType == 2) { diff --git a/DefaultResourcesExtra/Illumin-BumpSpec.shader b/DefaultResourcesExtra/Illumin-BumpSpec.shader index 9c92c6e..937ac6b 100644 --- a/DefaultResourcesExtra/Illumin-BumpSpec.shader +++ b/DefaultResourcesExtra/Illumin-BumpSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Self-Illumin/Bumped Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _Illum ("Illumin (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} diff --git a/DefaultResourcesExtra/Illumin-Glossy.shader b/DefaultResourcesExtra/Illumin-Glossy.shader index 4e5d0bc..5fdd5cd 100644 --- a/DefaultResourcesExtra/Illumin-Glossy.shader +++ b/DefaultResourcesExtra/Illumin-Glossy.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Self-Illumin/Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _Illum ("Illumin (A)", 2D) = "white" {} _Emission ("Emission (Lightmapper)", Float) = 1.0 diff --git a/DefaultResourcesExtra/Illumin-ParallaxSpec.shader b/DefaultResourcesExtra/Illumin-ParallaxSpec.shader index 8ba06b4..95d0cb3 100644 --- a/DefaultResourcesExtra/Illumin-ParallaxSpec.shader +++ b/DefaultResourcesExtra/Illumin-ParallaxSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Self-Illumin/Parallax Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _Parallax ("Height", Range (0.005, 0.08)) = 0.02 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _Illum ("Illumin (A)", 2D) = "white" {} diff --git a/DefaultResourcesExtra/Illumin-VertexLit.shader b/DefaultResourcesExtra/Illumin-VertexLit.shader index 75249cc..62b3bcc 100644 --- a/DefaultResourcesExtra/Illumin-VertexLit.shader +++ b/DefaultResourcesExtra/Illumin-VertexLit.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Self-Illumin/VertexLit" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,1) - _Shininess ("Shininess", Range (0.1, 1)) = 0.7 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.1, 1)) = 0.7 _MainTex ("Base (RGB)", 2D) = "white" {} _Illum ("Illumin (A)", 2D) = "white" {} _Emission ("Emission (Lightmapper)", Float) = 1.0 diff --git a/DefaultResourcesExtra/Lightmap-BumpSpec.shader b/DefaultResourcesExtra/Lightmap-BumpSpec.shader index 7b15a47..b49fffe 100644 --- a/DefaultResourcesExtra/Lightmap-BumpSpec.shader +++ b/DefaultResourcesExtra/Lightmap-BumpSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Lightmapped/Bumped Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} _LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode } diff --git a/DefaultResourcesExtra/Lightmap-Glossy.shader b/DefaultResourcesExtra/Lightmap-Glossy.shader index 97bddee..673a13b 100644 --- a/DefaultResourcesExtra/Lightmap-Glossy.shader +++ b/DefaultResourcesExtra/Lightmap-Glossy.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Lightmapped/Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode } } diff --git a/DefaultResourcesExtra/Lightmap-VertexLit.shader b/DefaultResourcesExtra/Lightmap-VertexLit.shader index 1f01452..9d13ac9 100644 --- a/DefaultResourcesExtra/Lightmap-VertexLit.shader +++ b/DefaultResourcesExtra/Lightmap-VertexLit.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Lightmapped/VertexLit" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.7 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.7 _MainTex ("Base (RGB)", 2D) = "white" {} _LightMap ("Lightmap (RGB)", 2D) = "lightmap" { LightmapMode } } diff --git a/DefaultResourcesExtra/Mobile/Mobile-BumpSpec-1DirectionalLight.shader b/DefaultResourcesExtra/Mobile/Mobile-BumpSpec-1DirectionalLight.shader index 466a939..e6f6bef 100644 --- a/DefaultResourcesExtra/Mobile/Mobile-BumpSpec-1DirectionalLight.shader +++ b/DefaultResourcesExtra/Mobile/Mobile-BumpSpec-1DirectionalLight.shader @@ -11,7 +11,7 @@ Shader "Mobile/Bumped Specular (1 Directional Light)" { Properties { - _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} [NoScaleOffset] _BumpMap ("Normalmap", 2D) = "bump" {} } diff --git a/DefaultResourcesExtra/Mobile/Mobile-BumpSpec.shader b/DefaultResourcesExtra/Mobile/Mobile-BumpSpec.shader index a4fc1b1..8049ed2 100644 --- a/DefaultResourcesExtra/Mobile/Mobile-BumpSpec.shader +++ b/DefaultResourcesExtra/Mobile/Mobile-BumpSpec.shader @@ -11,7 +11,7 @@ Shader "Mobile/Bumped Specular" { Properties { - _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} [NoScaleOffset] _BumpMap ("Normalmap", 2D) = "bump" {} } diff --git a/DefaultResourcesExtra/Nature/SpeedTree.shader b/DefaultResourcesExtra/Nature/SpeedTree.shader index 347c2be..d70ee9f 100644 --- a/DefaultResourcesExtra/Nature/SpeedTree.shader +++ b/DefaultResourcesExtra/Nature/SpeedTree.shader @@ -30,8 +30,8 @@ Shader "Nature/SpeedTree" CGPROGRAM #pragma surface surf Lambert vertex:SpeedTreeVert nodirlightmap nodynlightmap dithercrossfade fullforwardshadows #pragma target 3.0 - #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE #pragma instancing_options assumeuniformscaling maxcount:50 + #pragma multi_compile_vertex LOD_FADE_PERCENTAGE #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH #pragma shader_feature EFFECT_BUMP #pragma shader_feature EFFECT_HUE_VARIATION @@ -54,10 +54,10 @@ Shader "Nature/SpeedTree" #pragma vertex vert #pragma fragment frag #pragma target 3.0 - #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE + #pragma instancing_options assumeuniformscaling maxcount:50 + #pragma multi_compile_vertex LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE #pragma multi_compile_fragment __ LOD_FADE_CROSSFADE #pragma multi_compile_instancing - #pragma instancing_options assumeuniformscaling maxcount:50 #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH #pragma multi_compile_shadowcaster #define ENABLE_WIND @@ -108,11 +108,11 @@ Shader "Nature/SpeedTree" #pragma vertex vert #pragma fragment frag #pragma target 3.0 + #pragma instancing_options assumeuniformscaling maxcount:50 #pragma multi_compile_fog - #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE + #pragma multi_compile_vertex LOD_FADE_PERCENTAGE LOD_FADE_CROSSFADE #pragma multi_compile_fragment __ LOD_FADE_CROSSFADE #pragma multi_compile_instancing - #pragma instancing_options assumeuniformscaling maxcount:50 #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH #pragma shader_feature EFFECT_HUE_VARIATION #define ENABLE_WIND @@ -169,7 +169,7 @@ Shader "Nature/SpeedTree" CGPROGRAM #pragma surface surf Lambert vertex:SpeedTreeVert nodirlightmap nodynlightmap fullforwardshadows noinstancing - #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE + #pragma multi_compile_vertex LOD_FADE_PERCENTAGE #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH #include "SpeedTreeCommon.cginc" @@ -188,7 +188,7 @@ Shader "Nature/SpeedTree" CGPROGRAM #pragma vertex vert #pragma fragment frag - #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE + #pragma multi_compile_vertex LOD_FADE_PERCENTAGE #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH #pragma multi_compile_shadowcaster #include "SpeedTreeCommon.cginc" @@ -230,7 +230,7 @@ Shader "Nature/SpeedTree" #pragma vertex vert #pragma fragment frag #pragma multi_compile_fog - #pragma multi_compile_vertex __ LOD_FADE_PERCENTAGE + #pragma multi_compile_vertex LOD_FADE_PERCENTAGE #pragma shader_feature GEOM_TYPE_BRANCH GEOM_TYPE_BRANCH_DETAIL GEOM_TYPE_FROND GEOM_TYPE_LEAF GEOM_TYPE_MESH #include "SpeedTreeCommon.cginc" diff --git a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorAlbedoRenderTex.shader b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorAlbedoRenderTex.shader index 2c57cf8..fa7e686 100644 --- a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorAlbedoRenderTex.shader +++ b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorAlbedoRenderTex.shader @@ -52,7 +52,8 @@ fixed _Cutoff; fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D (_MainTex, i.uv); clip (col.a - _Cutoff); - col.a = 1; + fixed4 translucency = tex2D(_TranslucencyMap, i.uv); + col.a = translucency.b; return col; } ENDCG diff --git a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBark.shader b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBark.shader index 316ba16..be3d736 100644 --- a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBark.shader +++ b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorBark.shader @@ -3,7 +3,7 @@ Shader "Nature/Tree Creator Bark" { Properties { _Color ("Main Color", Color) = (1,1,1,1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} _GlossMap ("Gloss (A)", 2D) = "black" {} diff --git a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeaves.shader b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeaves.shader index 109784d..0cdb05e 100644 --- a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeaves.shader +++ b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorLeaves.shader @@ -3,7 +3,7 @@ Shader "Nature/Tree Creator Leaves" { Properties { _Color ("Main Color", Color) = (1,1,1,1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} _GlossMap ("Gloss (A)", 2D) = "black" {} diff --git a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorNormalRendertex.shader b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorNormalRendertex.shader index a11cf17..69bd6e1 100644 --- a/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorNormalRendertex.shader +++ b/DefaultResourcesExtra/Nature/TreeCreator/TreeCreatorNormalRendertex.shader @@ -38,7 +38,6 @@ v2f vert (appdata_full v) { v2f o; UNITY_SETUP_INSTANCE_ID(v); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); - ExpandBillboard (UNITY_MATRIX_IT_MV, v.vertex, v.normal, v.tangent); o.pos = UnityObjectToClipPos(v.vertex); o.uv = v.texcoord.xy; o.n = v.normal; @@ -51,14 +50,12 @@ sampler2D _BumpSpecMap; sampler2D _TranslucencyMap; fixed _Cutoff; -fixed4 frag (v2f i) : SV_Target { +half4 frag (v2f i) : SV_Target { fixed4 col = tex2D (_MainTex, i.uv); clip (col.a - _Cutoff); - half specular = tex2D(_BumpSpecMap, i.uv).r; - - fixed4 c; - c.rgb = 0.5*i.n + 0.5; - c.a = specular; + half4 c = 0; + half3 normal = normalize(i.n); + c.xyz = normal.xyz; return c; } ENDCG diff --git a/DefaultResourcesExtra/Normal-BumpSpec.shader b/DefaultResourcesExtra/Normal-BumpSpec.shader index a7d52c6..d7a68db 100644 --- a/DefaultResourcesExtra/Normal-BumpSpec.shader +++ b/DefaultResourcesExtra/Normal-BumpSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Bumped Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} } diff --git a/DefaultResourcesExtra/Normal-Glossy.shader b/DefaultResourcesExtra/Normal-Glossy.shader index 2d0e7c0..6c61051 100644 --- a/DefaultResourcesExtra/Normal-Glossy.shader +++ b/DefaultResourcesExtra/Normal-Glossy.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} } diff --git a/DefaultResourcesExtra/Normal-ParallaxSpec.shader b/DefaultResourcesExtra/Normal-ParallaxSpec.shader index 4ee4819..b68cd0e 100644 --- a/DefaultResourcesExtra/Normal-ParallaxSpec.shader +++ b/DefaultResourcesExtra/Normal-ParallaxSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Parallax Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _Parallax ("Height", Range (0.005, 0.08)) = 0.02 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _BumpMap ("Normalmap", 2D) = "bump" {} diff --git a/DefaultResourcesExtra/Normal-VertexLit.shader b/DefaultResourcesExtra/Normal-VertexLit.shader index 46baa24..70aa24f 100644 --- a/DefaultResourcesExtra/Normal-VertexLit.shader +++ b/DefaultResourcesExtra/Normal-VertexLit.shader @@ -5,7 +5,7 @@ Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,1) _Emission ("Emissive Color", Color) = (0,0,0,0) - _Shininess ("Shininess", Range (0.01, 1)) = 0.7 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.7 _MainTex ("Base (RGB)", 2D) = "white" {} } diff --git a/DefaultResourcesExtra/Particle Add.shader b/DefaultResourcesExtra/Particle Add.shader index 09eec40..1c63762 100644 --- a/DefaultResourcesExtra/Particle Add.shader +++ b/DefaultResourcesExtra/Particle Add.shader @@ -77,6 +77,8 @@ Category { #endif fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex, i.texcoord); + col.a = saturate(col.a); // alpha should not have double-brightness applied to it, but we can't fix that legacy behaior without breaking everyone's effects, so instead clamp the output to get sensible HDR behavior (case 967476) + UNITY_APPLY_FOG_COLOR(i.fogCoord, col, fixed4(0,0,0,0)); // fog towards black due to our blend mode return col; } diff --git a/DefaultResourcesExtra/Particle Alpha Blend.shader b/DefaultResourcesExtra/Particle Alpha Blend.shader index f3b8d24..65591ac 100644 --- a/DefaultResourcesExtra/Particle Alpha Blend.shader +++ b/DefaultResourcesExtra/Particle Alpha Blend.shader @@ -77,6 +77,8 @@ Category { #endif fixed4 col = 2.0f * i.color * tex2D(_MainTex, i.texcoord); + col.a = saturate(col.a); // alpha should not have double-brightness applied to it, but we can't fix that legacy behaior without breaking everyone's effects, so instead clamp the output to get sensible HDR behavior (case 967476) + UNITY_APPLY_FOG(i.fogCoord, col); return col; } diff --git a/DefaultResourcesExtra/Particle Anim Alpha Blend.shader b/DefaultResourcesExtra/Particle Anim Alpha Blend.shader index 008a2b3..78bea56 100644 --- a/DefaultResourcesExtra/Particle Anim Alpha Blend.shader +++ b/DefaultResourcesExtra/Particle Anim Alpha Blend.shader @@ -84,6 +84,8 @@ Category { fixed4 colA = tex2D(_MainTex, i.texcoord); fixed4 colB = tex2D(_MainTex, i.texcoord2); fixed4 col = 2.0f * i.color * lerp(colA, colB, i.blend); + col.a = saturate(col.a); // alpha should not have double-brightness applied to it, but we can't fix that legacy behaior without breaking everyone's effects, so instead clamp the output to get sensible HDR behavior (case 967476) + UNITY_APPLY_FOG(i.fogCoord, col); return col; } diff --git a/DefaultResourcesExtra/Reflect-BumpSpec.shader b/DefaultResourcesExtra/Reflect-BumpSpec.shader index 02d0f4d..8828f51 100644 --- a/DefaultResourcesExtra/Reflect-BumpSpec.shader +++ b/DefaultResourcesExtra/Reflect-BumpSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Reflective/Bumped Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) _MainTex ("Base (RGB) RefStrGloss (A)", 2D) = "white" {} _Cube ("Reflection Cubemap", Cube) = "" {} diff --git a/DefaultResourcesExtra/Reflect-BumpVertexLit.shader b/DefaultResourcesExtra/Reflect-BumpVertexLit.shader index 2940c15..9bdf8a2 100644 --- a/DefaultResourcesExtra/Reflect-BumpVertexLit.shader +++ b/DefaultResourcesExtra/Reflect-BumpVertexLit.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Reflective/Bumped VertexLit" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Spec Color", Color) = (1,1,1,1) - _Shininess ("Shininess", Range (0.1, 1)) = 0.7 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.1, 1)) = 0.7 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {} _Cube ("Reflection Cubemap", Cube) = "" {} diff --git a/DefaultResourcesExtra/Reflect-Bumped.shader b/DefaultResourcesExtra/Reflect-Bumped.shader index 3c17881..06822ba 100644 --- a/DefaultResourcesExtra/Reflect-Bumped.shader +++ b/DefaultResourcesExtra/Reflect-Bumped.shader @@ -15,7 +15,6 @@ SubShader { CGPROGRAM #pragma surface surf Lambert -#pragma exclude_renderers d3d11_9x sampler2D _MainTex; sampler2D _BumpMap; diff --git a/DefaultResourcesExtra/Reflect-Glossy.shader b/DefaultResourcesExtra/Reflect-Glossy.shader index 362654a..98fc75b 100644 --- a/DefaultResourcesExtra/Reflect-Glossy.shader +++ b/DefaultResourcesExtra/Reflect-Glossy.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Reflective/Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} _Cube ("Reflection Cubemap", Cube) = "_Skybox" {} diff --git a/DefaultResourcesExtra/Reflect-ParallaxSpec.shader b/DefaultResourcesExtra/Reflect-ParallaxSpec.shader index 362ed26..af18bb1 100644 --- a/DefaultResourcesExtra/Reflect-ParallaxSpec.shader +++ b/DefaultResourcesExtra/Reflect-ParallaxSpec.shader @@ -4,7 +4,7 @@ Shader "Legacy Shaders/Reflective/Parallax Specular" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1) - _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.01, 1)) = 0.078125 _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5) _Parallax ("Height", Range (0.005, 0.08)) = 0.02 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" { } diff --git a/DefaultResourcesExtra/TerrainShaders/Splats/Specular-AddPass.shader b/DefaultResourcesExtra/TerrainShaders/Splats/Specular-AddPass.shader index 2a64b23..adff332 100644 --- a/DefaultResourcesExtra/TerrainShaders/Splats/Specular-AddPass.shader +++ b/DefaultResourcesExtra/TerrainShaders/Splats/Specular-AddPass.shader @@ -3,7 +3,7 @@ Shader "Hidden/TerrainEngine/Splatmap/Specular-AddPass" { Properties { _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 // set by terrain engine [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {} diff --git a/DefaultResourcesExtra/TerrainShaders/Splats/Specular-Base.shader b/DefaultResourcesExtra/TerrainShaders/Splats/Specular-Base.shader index 4cd0d01..a933aef 100644 --- a/DefaultResourcesExtra/TerrainShaders/Splats/Specular-Base.shader +++ b/DefaultResourcesExtra/TerrainShaders/Splats/Specular-Base.shader @@ -3,7 +3,7 @@ Shader "Hidden/TerrainEngine/Splatmap/Specular-Base" { Properties { _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {} // used in fallback on old cards diff --git a/DefaultResourcesExtra/TerrainShaders/Splats/Specular-FirstPass.shader b/DefaultResourcesExtra/TerrainShaders/Splats/Specular-FirstPass.shader index 347c049..462074c 100644 --- a/DefaultResourcesExtra/TerrainShaders/Splats/Specular-FirstPass.shader +++ b/DefaultResourcesExtra/TerrainShaders/Splats/Specular-FirstPass.shader @@ -3,7 +3,7 @@ Shader "Nature/Terrain/Specular" { Properties { _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1) - _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 + [PowerSlider(5.0)] _Shininess ("Shininess", Range (0.03, 1)) = 0.078125 // set by terrain engine [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {} diff --git a/DefaultResourcesExtra/TerrainShaders/Trees/CameraFacingBillboardTree.shader b/DefaultResourcesExtra/TerrainShaders/Trees/CameraFacingBillboardTree.shader index 8b36723..7d19cd8 100644 --- a/DefaultResourcesExtra/TerrainShaders/Trees/CameraFacingBillboardTree.shader +++ b/DefaultResourcesExtra/TerrainShaders/Trees/CameraFacingBillboardTree.shader @@ -4,8 +4,9 @@ Shader "Hidden/TerrainEngine/CameraFacingBillboardTree" { Properties{ _MainTex("Base (RGB) Alpha (A)", 2D) = "white" {} _NormalTex("Base (RGB) Alpha (A)", 2D) = "white" {} + _TranslucencyViewDependency("View dependency", Range(0,1)) = 0.7 + _TranslucencyColor("Translucency Color", Color) = (0.73,0.85,0.41,1) } - SubShader{ Tags { "IgnoreProjector" = "True" "RenderType" = "TreeBillboard" } @@ -21,7 +22,9 @@ Shader "Hidden/TerrainEngine/CameraFacingBillboardTree" { #pragma multi_compile_fog #include "UnityCG.cginc" #include "UnityBuiltin3xTreeLibrary.cginc" - +#if SHADER_API_D3D11 || SHADER_API_GLCORE +#define ALBEDO_NORMAL_LIGHTING 1 +#endif struct v2f { float4 pos : SV_POSITION; fixed4 color : COLOR0; @@ -82,10 +85,15 @@ Shader "Hidden/TerrainEngine/CameraFacingBillboardTree" { return o; } - half3 CalcTreeLighting(half3 viewDir, half3 lightColor, half3 lightDir, half3 normal) + half3 CalcTreeLighting(half3 viewDir, half3 lightColor, half3 lightDir, half3 albedo, half3 normal, half backContribScale) { - half nl = saturate(dot(lightDir, normal)); - return nl * lightColor; + half backContrib = saturate(dot(viewDir, -lightDir)); + half ndotl = dot(lightDir, normal); + backContrib = lerp(saturate(-ndotl), backContrib, _TranslucencyViewDependency) * backContribScale; + half3 translucencyColor = backContrib * _TranslucencyColor; + const half diffuseWrap = 0.8; + ndotl = saturate(ndotl * diffuseWrap + (1 - diffuseWrap)); + return albedo * (translucencyColor + ndotl) * lightColor; } sampler2D _MainTex; @@ -94,18 +102,19 @@ Shader "Hidden/TerrainEngine/CameraFacingBillboardTree" { fixed4 frag(v2f input) : SV_Target { fixed4 col = tex2D(_MainTex, input.uv.xy); + col.rgb *= input.color.rgb; #if defined(ALBEDO_NORMAL_LIGHTING) - fixed4 normal = tex2D(_NormalTex, input.uv.xy); - fixed specular = normal.a * 128.0; - normal = (normal - 0.5) * 2; + half3 normal = tex2D(_NormalTex, input.uv.xy).xyz; + normal = normalize(normal); half3 albedo = col.rgb; - half3 light = UNITY_LIGHTMODEL_AMBIENT; - light += CalcTreeLighting(input.viewDir, _TerrainTreeLightColors[0].rgb, _TerrainTreeLightDirections[0], normal); - light += CalcTreeLighting(input.viewDir, _TerrainTreeLightColors[1].rgb, _TerrainTreeLightDirections[1], normal); - light += CalcTreeLighting(input.viewDir, _TerrainTreeLightColors[2].rgb, _TerrainTreeLightDirections[2], normal); - col.rgb = albedo * light; + half3 light = UNITY_LIGHTMODEL_AMBIENT * albedo; + const half backContribScale = 0.2; + + light += CalcTreeLighting(input.viewDir, _TerrainTreeLightColors[0].rgb, _TerrainTreeLightDirections[0], albedo, normal, backContribScale); + light += CalcTreeLighting(input.viewDir, _TerrainTreeLightColors[1].rgb, _TerrainTreeLightDirections[1], albedo, normal, backContribScale); + light += CalcTreeLighting(input.viewDir, _TerrainTreeLightColors[2].rgb, _TerrainTreeLightDirections[2], albedo, normal, backContribScale); + col.rgb = light; #endif - col.rgb *= input.color.rgb; float coverage = ComputeAlphaCoverage(input.screenPos, input.uv.z); col.a *= coverage; clip(col.a - _TreeBillboardCameraFront.w); diff --git a/DefaultResourcesExtra/UI/UI-Lit-Bumped.shader b/DefaultResourcesExtra/UI/UI-Lit-Bumped.shader index f982589..56710ec 100644 --- a/DefaultResourcesExtra/UI/UI-Lit-Bumped.shader +++ b/DefaultResourcesExtra/UI/UI-Lit-Bumped.shader @@ -8,7 +8,7 @@ Shader "UI/Lit/Bumped" _Specular ("Specular Color", Color) = (0,0,0,0) _MainTex ("Diffuse (RGB), Alpha (A)", 2D) = "white" {} [NoScaleOffset] _MainBump ("Diffuse Bump Map", 2D) = "bump" {} - _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 + [PowerSlider(5.0)] _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 _StencilComp ("Stencil Comparison", Float) = 8 _Stencil ("Stencil ID", Float) = 0 diff --git a/DefaultResourcesExtra/UI/UI-Lit-Detail.shader b/DefaultResourcesExtra/UI/UI-Lit-Detail.shader index 0088b6a..3ce5fed 100644 --- a/DefaultResourcesExtra/UI/UI-Lit-Detail.shader +++ b/DefaultResourcesExtra/UI/UI-Lit-Detail.shader @@ -11,7 +11,7 @@ Shader "UI/Lit/Detail" _DetailTex ("Detail (RGB)", 2D) = "white" {} _DetailBump ("Detail Bump Map", 2D) = "bump" {} _Strength ("Detail Strength", Range(0.0, 1.0)) = 0.2 - _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 + [PowerSlider(5.0)] _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 _StencilComp ("Stencil Comparison", Float) = 8 _Stencil ("Stencil ID", Float) = 0 diff --git a/DefaultResourcesExtra/UI/UI-Lit-Refraction.shader b/DefaultResourcesExtra/UI/UI-Lit-Refraction.shader index 8e614bc..de56225 100644 --- a/DefaultResourcesExtra/UI/UI-Lit-Refraction.shader +++ b/DefaultResourcesExtra/UI/UI-Lit-Refraction.shader @@ -9,7 +9,7 @@ Shader "UI/Lit/Refraction" _MainTex ("Diffuse (RGB), Alpha (A)", 2D) = "white" {} _MainBump ("Diffuse Bump Map", 2D) = "bump" {} _Mask ("Mask (Specularity, Shininess, Refraction)", 2D) = "black" {} - _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 + [PowerSlider(5.0)] _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 _Focus ("Focus", Range(-100.0, 100.0)) = -100.0 _StencilComp ("Stencil Comparison", Float) = 8 diff --git a/DefaultResourcesExtra/UI/UI-Lit-RefractionDetail.shader b/DefaultResourcesExtra/UI/UI-Lit-RefractionDetail.shader index bee4661..f1a9b94 100644 --- a/DefaultResourcesExtra/UI/UI-Lit-RefractionDetail.shader +++ b/DefaultResourcesExtra/UI/UI-Lit-RefractionDetail.shader @@ -12,7 +12,7 @@ Shader "UI/Lit/Refraction Detail" _DetailTex ("Detail (RGB)", 2D) = "white" {} _DetailBump ("Detail Bump Map", 2D) = "bump" {} _DetailMask ("Detail Mask (Spec, Shin, Ref)", 2D) = "white" {} - _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 + [PowerSlider(5.0)] _Shininess ("Shininess", Range(0.01, 1.0)) = 0.2 _Focus ("Focus", Range(-100.0, 100.0)) = -100.0 _StencilComp ("Stencil Comparison", Float) = 8 diff --git a/Editor/StandardParticlesShaderGUI.cs b/Editor/StandardParticlesShaderGUI.cs index 6ca8d2d..87b7c2d 100644 --- a/Editor/StandardParticlesShaderGUI.cs +++ b/Editor/StandardParticlesShaderGUI.cs @@ -530,10 +530,13 @@ void DoVertexStreamsArea(Material material) { foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial) { - if (useGPUInstancing && renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.supportsMeshInstancing) - renderer.SetActiveVertexStreams(instancedStreams); - else - renderer.SetActiveVertexStreams(streams); + if (renderer != null) + { + if (useGPUInstancing && renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.supportsMeshInstancing) + renderer.SetActiveVertexStreams(instancedStreams); + else + renderer.SetActiveVertexStreams(streams); + } } } @@ -542,16 +545,19 @@ void DoVertexStreamsArea(Material material) List rendererStreams = new List(); foreach (ParticleSystemRenderer renderer in m_RenderersUsingThisMaterial) { - renderer.GetActiveVertexStreams(rendererStreams); + if (renderer != null) + { + renderer.GetActiveVertexStreams(rendererStreams); - bool streamsValid; - if (useGPUInstancing && renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.supportsMeshInstancing) - streamsValid = rendererStreams.SequenceEqual(instancedStreams); - else - streamsValid = rendererStreams.SequenceEqual(streams); + bool streamsValid; + if (useGPUInstancing && renderer.renderMode == ParticleSystemRenderMode.Mesh && renderer.supportsMeshInstancing) + streamsValid = rendererStreams.SequenceEqual(instancedStreams); + else + streamsValid = rendererStreams.SequenceEqual(streams); - if (!streamsValid) - Warnings += " " + renderer.name + "\n"; + if (!streamsValid) + Warnings += " " + renderer.name + "\n"; + } } if (Warnings != "") { diff --git a/README.md b/README.md index e4bacfd..81bf7c5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Unity Built in Shaders -Current repository version: 2018.1.0f3 +Current repository version: 2018.2.10f1 An unofficial repo for Unity Built-in Shaders.