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:
udx
2026-09-28 16:25:38 +08:00
co-authored by Cursor
parent 9793d8581d
commit 79369e4473
39 changed files with 383 additions and 32 deletions
+5 -4
View File
@@ -310,8 +310,9 @@ public static class BuildTownSquare
var light = lightGo.AddComponent<Light>();
light.type = LightType.Directional;
light.color = new Color(1f, 0.96f, 0.88f);
light.intensity = 1.05f;
light.intensity = 1.15f;
light.shadows = LightShadows.Soft;
light.shadowStrength = 1f;
lightGo.transform.rotation = Quaternion.Euler(50f, -30f, 0f);
var camGo = new GameObject("Main Camera");
@@ -330,9 +331,9 @@ public static class BuildTownSquare
PrefabUtility.InstantiatePrefab(plaza);
RenderSettings.ambientMode = AmbientMode.Trilight;
RenderSettings.ambientSkyColor = new Color(0.55f, 0.7f, 0.85f);
RenderSettings.ambientEquatorColor = new Color(0.5f, 0.52f, 0.48f);
RenderSettings.ambientGroundColor = new Color(0.35f, 0.32f, 0.28f);
RenderSettings.ambientSkyColor = new Color(0.32f, 0.40f, 0.50f);
RenderSettings.ambientEquatorColor = new Color(0.24f, 0.26f, 0.24f);
RenderSettings.ambientGroundColor = new Color(0.16f, 0.15f, 0.13f);
EditorSceneManager.SaveScene(scene, ScenePath);
return ScenePath;
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 MiB

After

Width:  |  Height:  |  Size: 5.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 MiB

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 MiB

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

@@ -20,9 +20,9 @@ RenderSettings:
m_FogDensity: 0.01
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: 0.55, g: 0.7, b: 0.85, a: 1}
m_AmbientEquatorColor: {r: 0.5, g: 0.52, b: 0.48, a: 1}
m_AmbientGroundColor: {r: 0.35, g: 0.32, b: 0.28, a: 1}
m_AmbientSkyColor: {r: 0.32, g: 0.4, b: 0.5, a: 1}
m_AmbientEquatorColor: {r: 0.24, g: 0.26, b: 0.24, a: 1}
m_AmbientGroundColor: {r: 0.16, g: 0.15, b: 0.13, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 1
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
@@ -281,6 +281,7 @@ GameObject:
m_Component:
- component: {fileID: 2073245442}
- component: {fileID: 2073245441}
- component: {fileID: 2073245443}
m_Layer: 0
m_Name: Directional Light
m_TagString: Untagged
@@ -300,7 +301,7 @@ Light:
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.96, b: 0.88, a: 1}
m_Intensity: 1.05
m_Intensity: 1.15
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
@@ -365,6 +366,29 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2073245443
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2073245440}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Version: 3
m_UsePipelineSettings: 1
m_AdditionalLightsShadowResolutionTier: 2
m_LightLayerMask: 1
m_RenderingLayers: 1
m_CustomShadowLayers: 0
m_ShadowLayerMask: 1
m_ShadowRenderingLayers: 1
m_LightCookieSize: {x: 1, y: 1}
m_LightCookieOffset: {x: 0, y: 0}
m_SoftShadowQuality: 0
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 858 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 942 KiB

After

Width:  |  Height:  |  Size: 727 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 911 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 994 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

@@ -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
@@ -121,11 +121,10 @@ void InitializeInputData(Varyings input, half3 normalTS, out InputData inputData
inputData.bakedGI = SAMPLE_GI(input.staticLightmapUV, input.vertexSH, inputData.normalWS);
#else
inputData.bakedGI = SampleSH(inputData.normalWS);
#endif
// 仅在运行时全局环境光开启后才覆盖(Game.cs 设置);否则保留场景自身 SH/光照贴图,
// 避免编辑器预览比 URP Lit 亮(旧写法无条件覆盖成硬编码的高强度三色环境光)
// 仅覆盖动态物体的探针环境光。光照贴图(含烘焙阴影/间接光)必须保留。
if (_XRuntimeAmbientEnabled > 0.5h)
inputData.bakedGI = SampleXRuntimeAmbient(inputData.normalWS);
#endif
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(input.positionCS);
inputData.shadowMask = SAMPLE_SHADOWMASK(input.staticLightmapUV);
@@ -34,7 +34,7 @@ MonoBehaviour:
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 0
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 1024
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 2
@@ -45,7 +45,7 @@ MonoBehaviour:
m_AdditionalLightsShadowResolutionTierHigh: 1024
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 10
m_ShadowDistance: 150
m_ShadowCascadeCount: 1
m_Cascade2Split: 0.16666667
m_Cascade3Split: {x: 0.25800002, y: 0.5776}
@@ -34,8 +34,8 @@ MonoBehaviour:
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 0
m_MainLightShadowmapResolution: 512
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 1024
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0
@@ -45,7 +45,7 @@ MonoBehaviour:
m_AdditionalLightsShadowResolutionTierHigh: 1024
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 15
m_ShadowDistance: 150
m_ShadowCascadeCount: 1
m_Cascade2Split: 0.16666667
m_Cascade3Split: {x: 0.25800002, y: 0.5776}
@@ -35,7 +35,7 @@ MonoBehaviour:
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 1024
m_MainLightShadowmapResolution: 2048
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0
@@ -45,7 +45,7 @@ MonoBehaviour:
m_AdditionalLightsShadowResolutionTierHigh: 1024
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 15
m_ShadowDistance: 150
m_ShadowCascadeCount: 2
m_Cascade2Split: 0.26666668
m_Cascade3Split: {x: 0.25800002, y: 0.5776}
@@ -45,7 +45,7 @@ MonoBehaviour:
m_AdditionalLightsShadowResolutionTierHigh: 1024
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 30
m_ShadowDistance: 150
m_ShadowCascadeCount: 2
m_Cascade2Split: 0.2
m_Cascade3Split: {x: 0.10000001, y: 0.3}