Compress baked PNGs and tighten XPbr shadows with URP quality tweaks.
Add png_compress to the model pipeline and update TownSquare lighting plus MaleExplorer/plaza textures. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,10 @@ Shader "Test/XPbr"
|
||||
_Metallic("Metallic", Range(0.0, 1.0)) = 0.8
|
||||
_Roughness("Roughness", Range(0.0, 1.0)) = 0.6
|
||||
_AO("AO", Range(0.0, 1.0)) = 1.0
|
||||
|
||||
[HideInInspector][NoScaleOffset]unity_Lightmaps("unity_Lightmaps", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_LightmapsInd("unity_LightmapsInd", 2DArray) = "" {}
|
||||
[HideInInspector][NoScaleOffset]unity_ShadowMasks("unity_ShadowMasks", 2DArray) = "" {}
|
||||
}
|
||||
|
||||
SubShader
|
||||
@@ -33,13 +37,16 @@ Shader "Test/XPbr"
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||
|
||||
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
|
||||
#pragma multi_compile _ SHADOWS_SHADOWMASK
|
||||
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
|
||||
#pragma multi_compile _ LIGHTMAP_ON
|
||||
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
|
||||
|
||||
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
#pragma vertex vert
|
||||
@@ -155,18 +162,13 @@ Shader "Test/XPbr"
|
||||
ColorMask 0
|
||||
|
||||
HLSLPROGRAM
|
||||
// Required to compile gles 2.0 with standard srp library
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
// -------------------------------------
|
||||
// Material Keywords
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
|
||||
//--------------------------------------
|
||||
// GPU Instancing
|
||||
#pragma multi_compile_instancing
|
||||
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
@@ -175,6 +177,7 @@ Shader "Test/XPbr"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
||||
|
||||
float3 _LightDirection;
|
||||
float3 _LightPosition;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
@@ -185,13 +188,18 @@ Shader "Test/XPbr"
|
||||
|
||||
float3 positionWS = TransformObjectToWorld(input.positionOS.xyz);
|
||||
float3 normalWS = TransformObjectToWorldNormal(input.normalOS);
|
||||
#if defined(_CASTING_PUNCTUAL_LIGHT_SHADOW)
|
||||
float3 lightDirectionWS = normalize(_LightPosition - positionWS);
|
||||
#else
|
||||
float3 lightDirectionWS = _LightDirection;
|
||||
#endif
|
||||
|
||||
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, _LightDirection));
|
||||
float4 positionCS = TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS));
|
||||
|
||||
#if UNITY_REVERSED_Z
|
||||
positionCS.z = min(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
|
||||
positionCS.z = min(positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
||||
#else
|
||||
positionCS.z = max(positionCS.z, positionCS.w * UNITY_NEAR_CLIP_VALUE);
|
||||
positionCS.z = max(positionCS.z, UNITY_NEAR_CLIP_VALUE);
|
||||
#endif
|
||||
|
||||
output.positionCS = positionCS;
|
||||
@@ -210,6 +218,136 @@ Shader "Test/XPbr"
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "DepthOnly"
|
||||
Tags{ "LightMode" = "DepthOnly" }
|
||||
|
||||
ZWrite On
|
||||
ColorMask R
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma prefer_hlslcc gles
|
||||
#pragma exclude_renderers d3d11_9x
|
||||
#pragma target 2.0
|
||||
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma multi_compile_instancing
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "XPbr_Base.hlsl"
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output = (Varyings)0;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = TRANSFORM_TEX(input.texcoord, _MainTex);
|
||||
return output;
|
||||
}
|
||||
|
||||
half frag(Varyings input) : SV_TARGET
|
||||
{
|
||||
#if defined(_ALPHATEST_ON)
|
||||
half alpha = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).a;
|
||||
clip(alpha - _Cutoff);
|
||||
#endif
|
||||
return input.positionCS.z;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Meta"
|
||||
Tags{ "LightMode" = "Meta" }
|
||||
|
||||
Cull Off
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma target 2.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma shader_feature_local_fragment _ALPHATEST_ON
|
||||
#pragma shader_feature EDITOR_VISUALIZATION
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/MetaInput.hlsl"
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _MainTex_ST;
|
||||
half4 _BaseColor;
|
||||
half _Cutoff;
|
||||
half _Metallic;
|
||||
half _Roughness;
|
||||
half _AO;
|
||||
CBUFFER_END
|
||||
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_MixTex); SAMPLER(sampler_MixTex);
|
||||
|
||||
struct MetaAttributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float3 normalOS : NORMAL;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct MetaVaryings
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
float2 VizUV : TEXCOORD1;
|
||||
float4 LightCoord : TEXCOORD2;
|
||||
#endif
|
||||
};
|
||||
|
||||
MetaVaryings vert(MetaAttributes input)
|
||||
{
|
||||
MetaVaryings output = (MetaVaryings)0;
|
||||
output.positionCS = UnityMetaVertexPosition(input.positionOS.xyz, input.uv1, input.uv2);
|
||||
output.uv = TRANSFORM_TEX(input.uv0, _MainTex);
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
UnityEditorVizData(input.positionOS.xyz, input.uv0, input.uv1, input.uv2, output.VizUV, output.LightCoord);
|
||||
#endif
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(MetaVaryings input) : SV_Target
|
||||
{
|
||||
half4 albedoAlpha = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||
#if defined(_ALPHATEST_ON)
|
||||
clip(albedoAlpha.a - _Cutoff);
|
||||
#endif
|
||||
half4 mixTex = SAMPLE_TEXTURE2D(_MixTex, sampler_MixTex, input.uv);
|
||||
half3 albedo = albedoAlpha.rgb * _BaseColor.rgb;
|
||||
half metallic = saturate(mixTex.b * _Metallic);
|
||||
half smoothness = 1.0 - saturate(mixTex.a * _Roughness);
|
||||
half alpha = 1.0;
|
||||
|
||||
BRDFData brdfData;
|
||||
InitializeBRDFData(albedo, metallic, half3(0.0, 0.0, 0.0), smoothness, alpha, brdfData);
|
||||
|
||||
MetaInput metaInput;
|
||||
metaInput.Albedo = brdfData.diffuse + brdfData.specular * brdfData.roughness * 0.5;
|
||||
metaInput.Emission = half3(0.0, 0.0, 0.0);
|
||||
#ifdef EDITOR_VISUALIZATION
|
||||
metaInput.VizUV = input.VizUV;
|
||||
metaInput.LightCoord = input.LightCoord;
|
||||
#endif
|
||||
return UnityMetaFragment(metaInput);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack Off
|
||||
|
||||
Reference in New Issue
Block a user