mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-27 18:08:09 +08:00
Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
faad8c4d63 | ||
|
|
59ee409e6b | ||
|
|
49d50b863b | ||
|
|
b743505d54 | ||
|
|
ba018bb752 | ||
|
|
3c21e1cfcc | ||
|
|
ef7d798cc6 | ||
|
|
e757685a90 | ||
|
|
3886661036 | ||
|
|
fc1bde9da9 | ||
|
|
f42d04c2bb | ||
|
|
729fa33101 | ||
|
|
e309660c5c | ||
|
|
8c0d95a071 |
No files matched your search
@@ -0,0 +1,20 @@
|
|||||||
|
# Continuous integration
|
||||||
|
|
||||||
|
GitHub Actions builds PAL3 and PAL3A with the Unity version in
|
||||||
|
`ProjectSettings/ProjectVersion.txt`. Each variant covers Android, iOS,
|
||||||
|
macOS, Linux, and 32-bit/64-bit Windows. The workflows run on pushes and pull
|
||||||
|
requests, and successful desktop/Android builds upload artifacts.
|
||||||
|
|
||||||
|
Codacy is not part of this repository's CI. Its repository webhook is disabled;
|
||||||
|
there is no Codacy workflow or Codacy-required branch protection check. Re-enabling
|
||||||
|
that external integration would resume its checks independently of these workflows.
|
||||||
|
|
||||||
|
Keep the committed project configured for PAL3. PAL3A workflows switch their own
|
||||||
|
checkout before building. Public builds reject imported private VFX and legacy Toon assets;
|
||||||
|
do not add them or original game data to CI inputs.
|
||||||
|
|
||||||
|
When investigating a failure, inspect the failed job's Unity/build logs first.
|
||||||
|
Retry an isolated runner or network failure after checking the log; fix reproducible
|
||||||
|
source/build problems without bypassing the build checks. A successful CI build
|
||||||
|
checks compilation and packaging, and does not replace device or game-data runtime
|
||||||
|
validation.
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Assemblies;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -154,7 +155,7 @@ namespace IngameDebugConsole
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if UNITY_EDITOR || !NETFX_CORE
|
#if UNITY_EDITOR || !NETFX_CORE
|
||||||
foreach( Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() )
|
foreach( Assembly assembly in CurrentAssemblies.GetLoadedAssemblies() )
|
||||||
#else
|
#else
|
||||||
foreach( Assembly assembly in new Assembly[] { typeof( DebugLogConsole ).Assembly } ) // On UWP, at least search this plugin's Assembly for console methods
|
foreach( Assembly assembly in new Assembly[] { typeof( DebugLogConsole ).Assembly } ) // On UWP, at least search this plugin's Assembly for console methods
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -487,9 +487,6 @@ namespace IngameDebugConsole
|
|||||||
ShowLogWindow();
|
ShowLogWindow();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// On new Input System, scroll sensitivity is much higher than legacy Input system
|
|
||||||
logItemsScrollRect.scrollSensitivity *= 0.25f;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -859,13 +859,6 @@ namespace SimpleFileBrowser
|
|||||||
|
|
||||||
if( !showResizeCursor )
|
if( !showResizeCursor )
|
||||||
Destroy( resizeCursorHandler );
|
Destroy( resizeCursorHandler );
|
||||||
|
|
||||||
#if ENABLE_INPUT_SYSTEM && !ENABLE_LEGACY_INPUT_MANAGER
|
|
||||||
// On new Input System, scroll sensitivity is much higher than legacy Input system
|
|
||||||
filesScrollRect.scrollSensitivity *= 0.25f;
|
|
||||||
quickLinksContainer.GetComponentInParent<ScrollRect>().scrollSensitivity *= 0.25f;
|
|
||||||
filtersDropdownContainer.GetComponent<ScrollRect>().scrollSensitivity *= 0.25f;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRectTransformDimensionsChange()
|
private void OnRectTransformDimensionsChange()
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3a9b453b46274425981a83d68df6473f
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,798 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &-9130214687075653806
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: e021b4c809a781e468c2988c016ebbea, type: 3}
|
||||||
|
m_Name: ColorLookup
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ColorLookup
|
||||||
|
active: 1
|
||||||
|
texture:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {fileID: 0}
|
||||||
|
dimension: 1
|
||||||
|
contribution:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &-7817018176999065160
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 06437c1ff663d574d9447842ba0a72e4, type: 3}
|
||||||
|
m_Name: ScreenSpaceLensFlare
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ScreenSpaceLensFlare
|
||||||
|
active: 1
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
tintColor:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
bloomMip:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
firstFlareIntensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
secondaryFlareIntensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
warpedFlareIntensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
warpedFlareScale:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1}
|
||||||
|
samples:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
sampleDimmer:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.5
|
||||||
|
vignetteEffect:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
startingPosition:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1.25
|
||||||
|
scale:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1.5
|
||||||
|
streaksIntensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
streaksLength:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.5
|
||||||
|
streaksOrientation:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
streaksThreshold:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.25
|
||||||
|
resolution:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 4
|
||||||
|
chromaticAbberationIntensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.5
|
||||||
|
--- !u!114 &-7524763356354129735
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 558a8e2b6826cf840aae193990ba9f2e, type: 3}
|
||||||
|
m_Name: ShadowsMidtonesHighlights
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ShadowsMidtonesHighlights
|
||||||
|
active: 1
|
||||||
|
shadows:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1, z: 1, w: 0}
|
||||||
|
midtones:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1, z: 1, w: 0}
|
||||||
|
highlights:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1, z: 1, w: 0}
|
||||||
|
shadowsStart:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
shadowsEnd:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.3
|
||||||
|
highlightsStart:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.55
|
||||||
|
highlightsEnd:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
--- !u!114 &-7318447834972133286
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c01700fd266d6914ababb731e09af2eb, type: 3}
|
||||||
|
m_Name: DepthOfField
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.DepthOfField
|
||||||
|
active: 1
|
||||||
|
mode:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
gaussianStart:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 10
|
||||||
|
gaussianEnd:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 30
|
||||||
|
gaussianMaxRadius:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
highQualitySampling:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
focusDistance:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 10
|
||||||
|
aperture:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 5.6
|
||||||
|
focalLength:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 50
|
||||||
|
bladeCount:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 5
|
||||||
|
bladeCurvature:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
bladeRotation:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &-5971228661365037280
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 221518ef91623a7438a71fef23660601, type: 3}
|
||||||
|
m_Name: WhiteBalance
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.WhiteBalance
|
||||||
|
active: 1
|
||||||
|
temperature:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
tint:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &-5807738211224766849
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
|
||||||
|
m_Name: Bloom
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom
|
||||||
|
active: 1
|
||||||
|
skipIterations:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
threshold:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.9
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
scatter:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.7
|
||||||
|
clamp:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 65472
|
||||||
|
tint:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
highQualityFiltering:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
filter:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
downscale:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
maxIterations:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 6
|
||||||
|
dirtTexture:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {fileID: 0}
|
||||||
|
dimension: 1
|
||||||
|
dirtIntensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &-3309307926141130900
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3}
|
||||||
|
m_Name: ColorAdjustments
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ColorAdjustments
|
||||||
|
active: 1
|
||||||
|
postExposure:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
contrast:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
colorFilter:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
hueShift:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
saturation:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &-3033684091244297705
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 5485954d14dfb9a4c8ead8edb0ded5b1, type: 3}
|
||||||
|
m_Name: LiftGammaGain
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.LiftGammaGain
|
||||||
|
active: 1
|
||||||
|
lift:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1, z: 1, w: 0}
|
||||||
|
gamma:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1, z: 1, w: 0}
|
||||||
|
gain:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 1, y: 1, z: 1, w: 0}
|
||||||
|
--- !u!114 &-2693817965025424784
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c5e1dc532bcb41949b58bc4f2abfbb7e, type: 3}
|
||||||
|
m_Name: LensDistortion
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.LensDistortion
|
||||||
|
active: 1
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
xMultiplier:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
yMultiplier:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
center:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 0.5, y: 0.5}
|
||||||
|
scale:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
--- !u!114 &-2240148774783229831
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fb60a22f311433c4c962b888d1393f88, type: 3}
|
||||||
|
m_Name: PaniniProjection
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.PaniniProjection
|
||||||
|
active: 1
|
||||||
|
distance:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
cropToFit:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
--- !u!114 &-1722524011614745028
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3eb4b772797da9440885e8bd939e9560, type: 3}
|
||||||
|
m_Name: ColorCurves
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ColorCurves
|
||||||
|
active: 1
|
||||||
|
master:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 2
|
||||||
|
m_Loop: 0
|
||||||
|
m_ZeroValue: 0
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 1
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
red:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 2
|
||||||
|
m_Loop: 0
|
||||||
|
m_ZeroValue: 0
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 1
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
green:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 2
|
||||||
|
m_Loop: 0
|
||||||
|
m_ZeroValue: 0
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 1
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
blue:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 2
|
||||||
|
m_Loop: 0
|
||||||
|
m_ZeroValue: 0
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve:
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 0
|
||||||
|
value: 0
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
time: 1
|
||||||
|
value: 1
|
||||||
|
inSlope: 1
|
||||||
|
outSlope: 1
|
||||||
|
tangentMode: 0
|
||||||
|
weightedMode: 0
|
||||||
|
inWeight: 0
|
||||||
|
outWeight: 0
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
hueVsHue:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 0
|
||||||
|
m_Loop: 1
|
||||||
|
m_ZeroValue: 0.5
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve: []
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
hueVsSat:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 0
|
||||||
|
m_Loop: 1
|
||||||
|
m_ZeroValue: 0.5
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve: []
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
satVsSat:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 0
|
||||||
|
m_Loop: 0
|
||||||
|
m_ZeroValue: 0.5
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve: []
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
lumVsSat:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value:
|
||||||
|
<length>k__BackingField: 0
|
||||||
|
m_Loop: 0
|
||||||
|
m_ZeroValue: 0.5
|
||||||
|
m_Range: 1
|
||||||
|
m_Curve:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Curve: []
|
||||||
|
m_PreInfinity: 2
|
||||||
|
m_PostInfinity: 2
|
||||||
|
m_RotationOrder: 4
|
||||||
|
--- !u!114 &-383874240308919227
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ccf1aba9553839d41ae37dd52e9ebcce, type: 3}
|
||||||
|
m_Name: MotionBlur
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.MotionBlur
|
||||||
|
active: 1
|
||||||
|
mode:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
quality:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
clamp:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.05
|
||||||
|
--- !u!114 &-355272577634162072
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 70afe9e12c7a7ed47911bb608a23a8ff, type: 3}
|
||||||
|
m_Name: SplitToning
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.SplitToning
|
||||||
|
active: 1
|
||||||
|
shadows:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
highlights:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
|
balance:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
|
||||||
|
m_Name: DefaultVolumeProfile
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile
|
||||||
|
components:
|
||||||
|
- {fileID: -5807738211224766849}
|
||||||
|
- {fileID: -1722524011614745028}
|
||||||
|
- {fileID: -7318447834972133286}
|
||||||
|
- {fileID: 2578353125976525908}
|
||||||
|
- {fileID: -2240148774783229831}
|
||||||
|
- {fileID: -7817018176999065160}
|
||||||
|
- {fileID: 355823587882295533}
|
||||||
|
- {fileID: -383874240308919227}
|
||||||
|
- {fileID: 7634164242146030439}
|
||||||
|
- {fileID: 2142330103019606968}
|
||||||
|
- {fileID: -355272577634162072}
|
||||||
|
- {fileID: -3309307926141130900}
|
||||||
|
- {fileID: -2693817965025424784}
|
||||||
|
- {fileID: -9130214687075653806}
|
||||||
|
- {fileID: -3033684091244297705}
|
||||||
|
- {fileID: -5971228661365037280}
|
||||||
|
- {fileID: 1479729400236365617}
|
||||||
|
- {fileID: -7524763356354129735}
|
||||||
|
- {fileID: 8344855468588184016}
|
||||||
|
--- !u!114 &355823587882295533
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3}
|
||||||
|
m_Name: Tonemapping
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Tonemapping
|
||||||
|
active: 1
|
||||||
|
mode:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
neutralHDRRangeReductionMode:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 2
|
||||||
|
acesPreset:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 3
|
||||||
|
hueShiftAmount:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
detectPaperWhite:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
paperWhite:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 300
|
||||||
|
detectBrightnessLimits:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
minNits:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.005
|
||||||
|
maxNits:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1000
|
||||||
|
--- !u!114 &1479729400236365617
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 81180773991d8724ab7f2d216912b564, type: 3}
|
||||||
|
m_Name: ChromaticAberration
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ChromaticAberration
|
||||||
|
active: 1
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &2142330103019606968
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: cdfbdbb87d3286943a057f7791b43141, type: 3}
|
||||||
|
m_Name: ChannelMixer
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ChannelMixer
|
||||||
|
active: 1
|
||||||
|
redOutRedIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 100
|
||||||
|
redOutGreenIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
redOutBlueIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
greenOutRedIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
greenOutGreenIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 100
|
||||||
|
greenOutBlueIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
blueOutRedIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
blueOutGreenIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
blueOutBlueIn:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 100
|
||||||
|
--- !u!114 &2578353125976525908
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 29fa0085f50d5e54f8144f766051a691, type: 3}
|
||||||
|
m_Name: FilmGrain
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.FilmGrain
|
||||||
|
active: 1
|
||||||
|
type:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
response:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.8
|
||||||
|
texture:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {fileID: 0}
|
||||||
|
--- !u!114 &7634164242146030439
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 899c54efeace73346a0a16faa3afe726, type: 3}
|
||||||
|
m_Name: Vignette
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Vignette
|
||||||
|
active: 1
|
||||||
|
color:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {r: 0, g: 0, b: 0, a: 1}
|
||||||
|
center:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 0.5, y: 0.5}
|
||||||
|
intensity:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
smoothness:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.2
|
||||||
|
rounded:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
--- !u!114 &8344855468588184016
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 3
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 6bd486065ce11414fa40e631affc4900, type: 3}
|
||||||
|
m_Name: ProbeVolumesOptions
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.ProbeVolumesOptions
|
||||||
|
active: 1
|
||||||
|
normalBias:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.05
|
||||||
|
viewBias:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.1
|
||||||
|
scaleBiasWithMinProbeDistance:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0
|
||||||
|
samplingNoise:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.1
|
||||||
|
animateSamplingNoise:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
leakReductionMode:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 2
|
||||||
|
minValidDotProductValue:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 0.1
|
||||||
|
occlusionOnlyReflectionNormalization:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
intensityMultiplier:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
skyOcclusionIntensityMultiplier:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: 1
|
||||||
|
worldOffset:
|
||||||
|
m_OverrideState: 1
|
||||||
|
m_Value: {x: 0, y: 0, z: 0}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 580f5421befb34b3bab2e8645d38d6b6
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
|
||||||
|
m_Name: Pal3 Forward+ Renderer
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalRendererData
|
||||||
|
debugShaders:
|
||||||
|
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3}
|
||||||
|
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
|
||||||
|
probeVolumeSamplingDebugComputeShader: {fileID: 7200000, guid: 53626a513ea68ce47b59dc1299fe3959, type: 3}
|
||||||
|
probeVolumeResources:
|
||||||
|
probeVolumeDebugShader: {fileID: 0}
|
||||||
|
probeVolumeFragmentationDebugShader: {fileID: 0}
|
||||||
|
probeVolumeOffsetDebugShader: {fileID: 0}
|
||||||
|
probeVolumeSamplingDebugShader: {fileID: 0}
|
||||||
|
probeSamplingDebugMesh: {fileID: 0}
|
||||||
|
probeSamplingDebugTexture: {fileID: 0}
|
||||||
|
probeVolumeBlendStatesCS: {fileID: 0}
|
||||||
|
m_RendererFeatures:
|
||||||
|
- {fileID: 6015277420500135746}
|
||||||
|
- {fileID: 7317615400953120047}
|
||||||
|
m_RendererFeatureMap: 42af5692f18e7a532f05bdd06f648d65
|
||||||
|
xrSystemData: {fileID: 0}
|
||||||
|
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||||
|
m_AssetVersion: 3
|
||||||
|
m_PrepassLayerMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_OpaqueLayerMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_TransparentLayerMask:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_DefaultStencilState:
|
||||||
|
overrideStencilState: 0
|
||||||
|
stencilReference: 0
|
||||||
|
stencilCompareFunction: 8
|
||||||
|
passOperation: 2
|
||||||
|
failOperation: 0
|
||||||
|
zFailOperation: 0
|
||||||
|
m_ShadowTransparentReceive: 1
|
||||||
|
m_RenderingMode: 2
|
||||||
|
m_DepthPrimingMode: 0
|
||||||
|
m_CopyDepthMode: 1
|
||||||
|
m_DepthAttachmentFormat: 0
|
||||||
|
m_DepthTextureFormat: 0
|
||||||
|
m_AccurateGbufferNormals: 0
|
||||||
|
m_IntermediateTextureMode: 0
|
||||||
|
m_TileOnlyMode: 0
|
||||||
|
--- !u!114 &6015277420500135746
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4d674bdfa579425487f9e1b03d25758e, type: 3}
|
||||||
|
m_Name: Pal3 Screen Effects
|
||||||
|
m_EditorClassIdentifier: Pal3.Game::Pal3.Game.Rendering.ScreenEffects.Pal3ScreenEffectsFeature
|
||||||
|
m_Active: 1
|
||||||
|
distortionShader: {fileID: 4800000, guid: 0b8bcccc572f924448668c94cfa547b4, type: 3}
|
||||||
|
snowShader: {fileID: 4800000, guid: 310e70fe34ae470e9e0521e3fbb649d0, type: 3}
|
||||||
|
--- !u!114 &7317615400953120047
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 8375d96629014bce9e8f3ecf7aad6a08, type: 3}
|
||||||
|
m_Name: Toon Contact Shadows
|
||||||
|
m_EditorClassIdentifier: Pal3.Game::Pal3.Game.Rendering.Toon.ToonAmbientOcclusionFeature
|
||||||
|
m_Active: 1
|
||||||
|
m_Settings:
|
||||||
|
AOMethod: 0
|
||||||
|
Downsample: 1
|
||||||
|
AfterOpaque: 0
|
||||||
|
Source: 1
|
||||||
|
NormalSamples: 2
|
||||||
|
Intensity: 0.95
|
||||||
|
DirectLightingStrength: 0
|
||||||
|
Radius: 0.32
|
||||||
|
Samples: 1
|
||||||
|
BlurQuality: 0
|
||||||
|
Falloff: 60
|
||||||
|
SampleCount: -1
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c20ae1cdbb0ac4acb80371ee4652c8ba
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
|
||||||
|
m_Name: Pal3 URP
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset
|
||||||
|
k_AssetVersion: 13
|
||||||
|
k_AssetPreviousVersion: 13
|
||||||
|
m_RendererType: 1
|
||||||
|
m_RendererData: {fileID: 0}
|
||||||
|
m_RendererDataList:
|
||||||
|
- {fileID: 11400000, guid: c20ae1cdbb0ac4acb80371ee4652c8ba, type: 2}
|
||||||
|
m_DefaultRendererIndex: 0
|
||||||
|
m_RequireDepthTexture: 0
|
||||||
|
m_RequireOpaqueTexture: 0
|
||||||
|
m_OpaqueDownsampling: 1
|
||||||
|
m_SupportsTerrainHoles: 1
|
||||||
|
m_SupportsHDR: 1
|
||||||
|
m_HDRColorBufferPrecision: 0
|
||||||
|
m_MSAA: 1
|
||||||
|
m_RenderScale: 1
|
||||||
|
m_UpscalingFilter: 0
|
||||||
|
m_FsrOverrideSharpness: 0
|
||||||
|
m_FsrSharpness: 0.92
|
||||||
|
m_EnableLODCrossFade: 1
|
||||||
|
m_LODCrossFadeDitheringType: 1
|
||||||
|
m_ShEvalMode: 0
|
||||||
|
m_LightProbeSystem: 0
|
||||||
|
m_ProbeVolumeMemoryBudget: 1024
|
||||||
|
m_ProbeVolumeBlendingMemoryBudget: 256
|
||||||
|
m_SupportProbeVolumeGPUStreaming: 0
|
||||||
|
m_SupportProbeVolumeDiskStreaming: 0
|
||||||
|
m_SupportProbeVolumeScenarios: 0
|
||||||
|
m_SupportProbeVolumeScenarioBlending: 0
|
||||||
|
m_ProbeVolumeSHBands: 1
|
||||||
|
m_MainLightRenderingMode: 1
|
||||||
|
m_MainLightShadowsSupported: 1
|
||||||
|
m_MainLightShadowmapResolution: 2048
|
||||||
|
m_AdditionalLightsRenderingMode: 1
|
||||||
|
m_AdditionalLightsPerObjectLimit: 2
|
||||||
|
m_AdditionalLightShadowsSupported: 1
|
||||||
|
m_AdditionalLightsShadowmapResolution: 1024
|
||||||
|
m_AdditionalLightsShadowResolutionTierLow: 256
|
||||||
|
m_AdditionalLightsShadowResolutionTierMedium: 512
|
||||||
|
m_AdditionalLightsShadowResolutionTierHigh: 1024
|
||||||
|
m_ReflectionProbeBlending: 0
|
||||||
|
m_ReflectionProbeBoxProjection: 0
|
||||||
|
m_ReflectionProbeAtlas: 1
|
||||||
|
m_ShadowDistance: 85
|
||||||
|
m_ShadowCascadeCount: 2
|
||||||
|
m_Cascade2Split: 0.62
|
||||||
|
m_Cascade3Split: {x: 0.1, y: 0.3}
|
||||||
|
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
|
||||||
|
m_CascadeBorder: 0.2
|
||||||
|
m_ShadowDepthBias: 1
|
||||||
|
m_ShadowNormalBias: 1
|
||||||
|
m_AnyShadowsSupported: 1
|
||||||
|
m_SoftShadowsSupported: 1
|
||||||
|
m_ConservativeEnclosingSphere: 1
|
||||||
|
m_NumIterationsEnclosingSphere: 64
|
||||||
|
m_SoftShadowQuality: 1
|
||||||
|
m_AdditionalLightsCookieResolution: 2048
|
||||||
|
m_AdditionalLightsCookieFormat: 3
|
||||||
|
m_UseSRPBatcher: 1
|
||||||
|
m_SupportsDynamicBatching: 0
|
||||||
|
m_MixedLightingSupported: 1
|
||||||
|
m_SupportsLightCookies: 1
|
||||||
|
m_SupportsLightLayers: 0
|
||||||
|
m_StoreActionsOptimization: 0
|
||||||
|
m_UseAdaptivePerformance: 1
|
||||||
|
m_ColorGradingMode: 0
|
||||||
|
m_ColorGradingLutSize: 32
|
||||||
|
m_AllowPostProcessAlphaOutput: 0
|
||||||
|
m_UseFastSRGBLinearConversion: 0
|
||||||
|
m_SupportDataDrivenLensFlare: 1
|
||||||
|
m_SupportScreenSpaceLensFlare: 1
|
||||||
|
m_GPUResidentDrawerMode: 0
|
||||||
|
m_SmallMeshScreenPercentage: 0
|
||||||
|
m_ShadowSmallMeshScreenPercentages: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_GPUResidentDrawerEnableOcclusionCullingInCameras: 0
|
||||||
|
m_ShadowType: 1
|
||||||
|
m_LocalShadowsSupported: 0
|
||||||
|
m_LocalShadowsAtlasResolution: 256
|
||||||
|
m_MaxPixelLights: 0
|
||||||
|
m_ShadowAtlasResolution: 256
|
||||||
|
m_VolumeFrameworkUpdateMode: 0
|
||||||
|
m_VolumeProfile: {fileID: 0}
|
||||||
|
apvScenesData:
|
||||||
|
obsoleteSceneBounds:
|
||||||
|
m_Keys: []
|
||||||
|
m_Values: []
|
||||||
|
obsoleteHasProbeVolumes:
|
||||||
|
m_Keys: []
|
||||||
|
m_Values:
|
||||||
|
m_PrefilteringModeMainLightShadows: 1
|
||||||
|
m_PrefilteringModeAdditionalLight: 4
|
||||||
|
m_PrefilteringModeAdditionalLightShadows: 1
|
||||||
|
m_PrefilterXRKeywords: 0
|
||||||
|
m_PrefilteringModeForwardPlus: 1
|
||||||
|
m_PrefilteringModeDeferredRendering: 1
|
||||||
|
m_PrefilteringModeScreenSpaceOcclusion: 1
|
||||||
|
m_PrefilteringModeScreenSpaceReflection: 1
|
||||||
|
m_PrefilterWriteSmoothness: 1
|
||||||
|
m_PrefilterDebugKeywords: 0
|
||||||
|
m_PrefilterWriteRenderingLayers: 0
|
||||||
|
m_PrefilterHDROutput: 0
|
||||||
|
m_PrefilterAlphaOutput: 0
|
||||||
|
m_PrefilterSSAODepthNormals: 0
|
||||||
|
m_PrefilterSSAOSourceDepthLow: 0
|
||||||
|
m_PrefilterSSAOSourceDepthMedium: 0
|
||||||
|
m_PrefilterSSAOSourceDepthHigh: 0
|
||||||
|
m_PrefilterSSAOInterleaved: 0
|
||||||
|
m_PrefilterSSAOBlueNoise: 0
|
||||||
|
m_PrefilterSSAOSampleCountLow: 0
|
||||||
|
m_PrefilterSSAOSampleCountMedium: 0
|
||||||
|
m_PrefilterSSAOSampleCountHigh: 0
|
||||||
|
m_PrefilterDBufferMRT1: 0
|
||||||
|
m_PrefilterDBufferMRT2: 0
|
||||||
|
m_PrefilterDBufferMRT3: 0
|
||||||
|
m_PrefilterSoftShadowsQualityLow: 0
|
||||||
|
m_PrefilterSoftShadowsQualityMedium: 0
|
||||||
|
m_PrefilterSoftShadowsQualityHigh: 0
|
||||||
|
m_PrefilterSoftShadows: 0
|
||||||
|
m_PrefilterScreenCoord: 0
|
||||||
|
m_PrefilterScreenSpaceIrradiance: 0
|
||||||
|
m_PrefilterNativeRenderPass: 0
|
||||||
|
m_PrefilterUseLegacyLightmaps: 0
|
||||||
|
m_PrefilterBicubicLightmapSampling: 0
|
||||||
|
m_PrefilterReflectionProbeRotation: 0
|
||||||
|
m_PrefilterReflectionProbeBlending: 0
|
||||||
|
m_PrefilterReflectionProbeBoxProjection: 0
|
||||||
|
m_PrefilterReflectionProbeAtlas: 0
|
||||||
|
m_PrefilterPointSamplingUpsampling: 0
|
||||||
|
m_Light2DPrefilteringMode: 0
|
||||||
|
m_Light2DKeptVariantCombos: []
|
||||||
|
m_ShaderVariantLogLevel: 0
|
||||||
|
m_ShadowCascades: 0
|
||||||
|
m_Textures:
|
||||||
|
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
|
||||||
|
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 895616fcdb17845859539e6c06adacb2
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5bf027559c874e4a8e859473daf66566
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+7
-5
@@ -17,15 +17,16 @@ Shader "Pal3/PostEffectDistortion"
|
|||||||
}
|
}
|
||||||
|
|
||||||
HLSLINCLUDE
|
HLSLINCLUDE
|
||||||
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
|
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||||
|
|
||||||
float _TimeScale;
|
float _TimeScale;
|
||||||
float _XFactor;
|
float _XFactor;
|
||||||
float _YFactor;
|
float _YFactor;
|
||||||
|
|
||||||
float4 Frag(VaryingsDefault i) : SV_Target
|
float4 Frag(Varyings i) : SV_Target
|
||||||
{
|
{
|
||||||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||||
float2 uv = i.texcoord;
|
float2 uv = i.texcoord;
|
||||||
const float time = _Time.y;
|
const float time = _Time.y;
|
||||||
|
|
||||||
@@ -35,18 +36,19 @@ Shader "Pal3/PostEffectDistortion"
|
|||||||
uv.x += sin((uv.y+uv.x) * _XFactor + time * _TimeScale) / (180.0 + (_TimeScale * sin(time)));
|
uv.x += sin((uv.y+uv.x) * _XFactor + time * _TimeScale) / (180.0 + (_TimeScale * sin(time)));
|
||||||
uv.y += cos((uv.y+uv.x) * _YFactor + time * _TimeScale) / (200.0 + (_TimeScale * sin(time)));
|
uv.y += cos((uv.y+uv.x) * _YFactor + time * _TimeScale) / (200.0 + (_TimeScale * sin(time)));
|
||||||
|
|
||||||
float4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,uv);
|
float4 col = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp,uv);
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
ENDHLSL
|
ENDHLSL
|
||||||
|
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" }
|
||||||
Cull Off ZWrite Off ZTest Always
|
Cull Off ZWrite Off ZTest Always
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex VertDefault
|
#pragma vertex Vert
|
||||||
#pragma fragment Frag
|
#pragma fragment Frag
|
||||||
ENDHLSL
|
ENDHLSL
|
||||||
}
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,107 @@
|
|||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||||
|
// See LICENSE file in the project root for license information.
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// Based on cician's shader from https://forum.unity3d.com/threads/simple-optimized-blur-shader.185327/#post-1267642
|
||||||
|
// Based on RoundedCorners.shader from https://github.com/kirevdokimov/Unity-UI-Rounded-Corners
|
||||||
|
// with some modifications
|
||||||
|
|
||||||
|
Shader "Pal3/RoundedFrostedGlass"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_BlurAmount ("Blur", Range(0, 30)) = 1
|
||||||
|
_Transparency ("Transparency", Range(0, 1)) = 1
|
||||||
|
[HideInInspector] _MainTex ("Masking Texture", 2D) = "white" {}
|
||||||
|
_AdditiveColor ("Additive Tint color", Color) = (0, 0, 0, 0)
|
||||||
|
_MultiplyColor ("Multiply Tint color", Color) = (1, 1, 1, 1)
|
||||||
|
_WidthHeightRadius ("WidthHeightRadius", Vector) = (0, 0, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" "RenderType" = "Transparent" }
|
||||||
|
Cull Off
|
||||||
|
ZTest [unity_GUIZTestMode]
|
||||||
|
ZWrite Off
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma vertex Vert
|
||||||
|
#pragma fragment Frag
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
|
TEXTURE2D(_MainTex);
|
||||||
|
SAMPLER(sampler_MainTex);
|
||||||
|
TEXTURE2D(_Pal3SceneColor);
|
||||||
|
|
||||||
|
CBUFFER_START(UnityPerMaterial)
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
float4 _WidthHeightRadius;
|
||||||
|
half4 _AdditiveColor;
|
||||||
|
half4 _MultiplyColor;
|
||||||
|
float _BlurAmount;
|
||||||
|
float _Transparency;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
|
struct Attributes
|
||||||
|
{
|
||||||
|
float4 positionOS : POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
half4 color : COLOR;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Varyings
|
||||||
|
{
|
||||||
|
float4 positionCS : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float4 screenPosition : TEXCOORD1;
|
||||||
|
half alpha : TEXCOORD2;
|
||||||
|
};
|
||||||
|
|
||||||
|
Varyings Vert(Attributes input)
|
||||||
|
{
|
||||||
|
Varyings output;
|
||||||
|
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||||
|
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||||
|
output.screenPosition = output.positionCS;
|
||||||
|
output.alpha = input.color.a;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 Frag(Varyings input) : SV_Target
|
||||||
|
{
|
||||||
|
float2 size = _WidthHeightRadius.xy;
|
||||||
|
float radius = _WidthHeightRadius.z * 0.5;
|
||||||
|
float2 edge = abs((input.uv - 0.5) * size) - (size * 0.5 - radius);
|
||||||
|
float distanceToRect = length(max(edge, 0)) + min(max(edge.x, edge.y), 0) - radius;
|
||||||
|
float edgeWidth = max(fwidth(distanceToRect), 0.001);
|
||||||
|
float roundedAlpha = 1.0 - smoothstep(-edgeWidth, edgeWidth, distanceToRect);
|
||||||
|
half mask = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).a;
|
||||||
|
|
||||||
|
// The URP color copy uses Unity's bottom-left texture orientation.
|
||||||
|
float2 uv = input.screenPosition.xy / input.screenPosition.w * 0.5 + 0.5;
|
||||||
|
float2 pixelSize = abs(float2(ddx(uv.x), ddy(uv.y)));
|
||||||
|
float2 delta = pixelSize * (_BlurAmount * 1.2);
|
||||||
|
half3 blurred = 0;
|
||||||
|
[unroll] for (int y = -1; y <= 1; y++)
|
||||||
|
{
|
||||||
|
[unroll] for (int x = -1; x <= 1; x++)
|
||||||
|
{
|
||||||
|
// Bilinear taps approximate a separable five-tap Gaussian.
|
||||||
|
half weightX = x == 0 ? 0.375 : 0.3125;
|
||||||
|
half weightY = y == 0 ? 0.375 : 0.3125;
|
||||||
|
blurred += SAMPLE_TEXTURE2D(_Pal3SceneColor, sampler_LinearClamp,
|
||||||
|
uv + float2(x, y) * delta).rgb * (weightX * weightY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return half4(blurred * _MultiplyColor.rgb + _AdditiveColor.rgb,
|
||||||
|
mask * roundedAlpha * _Transparency * input.alpha);
|
||||||
|
}
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
+7
-5
@@ -13,8 +13,8 @@ Shader "Pal3/Snow"
|
|||||||
}
|
}
|
||||||
|
|
||||||
HLSLINCLUDE
|
HLSLINCLUDE
|
||||||
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
|
#include "Packages/com.unity.render-pipelines.core/Runtime/Utilities/Blit.hlsl"
|
||||||
|
|
||||||
#define vec2 float2
|
#define vec2 float2
|
||||||
#define vec3 float3
|
#define vec3 float3
|
||||||
@@ -123,8 +123,9 @@ Shader "Pal3/Snow"
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 Frag(VaryingsDefault i) : SV_Target
|
float4 Frag(Varyings i) : SV_Target
|
||||||
{
|
{
|
||||||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
|
||||||
float2 uv = i.texcoord;
|
float2 uv = i.texcoord;
|
||||||
float2 originUV = uv;
|
float2 originUV = uv;
|
||||||
const float time = _Time.y;
|
const float time = _Time.y;
|
||||||
@@ -166,18 +167,19 @@ Shader "Pal3/Snow"
|
|||||||
float Snowout=N5+N4+N3+N2+N1;
|
float Snowout=N5+N4+N3+N2+N1;
|
||||||
|
|
||||||
float4 snowColor = vec4(Snowout*0.9, Snowout, Snowout*1.1, 1.0);
|
float4 snowColor = vec4(Snowout*0.9, Snowout, Snowout*1.1, 1.0);
|
||||||
float4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex,originUV);
|
float4 col = SAMPLE_TEXTURE2D_X(_BlitTexture, sampler_LinearClamp, originUV);
|
||||||
return col + snowColor;
|
return col + snowColor;
|
||||||
}
|
}
|
||||||
ENDHLSL
|
ENDHLSL
|
||||||
|
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" }
|
||||||
Cull Off ZWrite Off ZTest Always
|
Cull Off ZWrite Off ZTest Always
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex VertDefault
|
#pragma vertex Vert
|
||||||
#pragma fragment Frag
|
#pragma fragment Frag
|
||||||
ENDHLSL
|
ENDHLSL
|
||||||
}
|
}
|
||||||
File renamed without changes.
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9533b8de7e25413c95e416f6c0204c2f
|
||||||
|
folderAsset: yes
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
#include "Pal3ToonInput.hlsl"
|
||||||
|
|
||||||
|
struct ToonDepthVaryings
|
||||||
|
{
|
||||||
|
float4 positionCS : SV_POSITION;
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
#endif
|
||||||
|
#if defined(PAL3_TOON_DEPTH_NORMALS)
|
||||||
|
half3 normalWS : TEXCOORD1;
|
||||||
|
#endif
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
ToonDepthVaryings ToonDepthVertex(ToonAttributes input)
|
||||||
|
{
|
||||||
|
ToonDepthVaryings output;
|
||||||
|
UNITY_SETUP_INSTANCE_ID(input);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||||
|
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||||
|
#if defined(PAL3_TOON_DEPTH_NORMALS)
|
||||||
|
output.normalWS = TransformObjectToWorldNormal(input.normalOS);
|
||||||
|
#endif
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||||
|
#endif
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PAL3_TOON_DEPTH_NORMALS)
|
||||||
|
half4 ToonDepthFragment(ToonDepthVaryings input) : SV_Target
|
||||||
|
#else
|
||||||
|
half ToonDepthFragment(ToonDepthVaryings input) : SV_Target
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
clip(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).a - _Threshold);
|
||||||
|
#endif
|
||||||
|
#if defined(PAL3_TOON_DEPTH_NORMALS)
|
||||||
|
float3 normalWS = SafeNormalize(input.normalWS);
|
||||||
|
#if defined(_GBUFFER_NORMALS_OCT)
|
||||||
|
float2 oct = saturate(PackNormalOctQuadEncode(normalWS) * 0.5 + 0.5);
|
||||||
|
return half4(PackFloat2To888(oct), 0);
|
||||||
|
#else
|
||||||
|
return half4(normalWS, 0);
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
return input.positionCS.z;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 96ecd7906a864113b94c845336992986
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
#include "Pal3ToonInput.hlsl"
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
|
||||||
|
|
||||||
|
float _Pal3ToonCharacterLighting;
|
||||||
|
float _Pal3ToonNightFireBoost;
|
||||||
|
float4 _Pal3ToonSceneLighting;
|
||||||
|
float4 _Pal3ToonEffectStrengths;
|
||||||
|
|
||||||
|
struct ToonVaryings
|
||||||
|
{
|
||||||
|
float4 positionCS : SV_POSITION;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float2 lightmapUV : TEXCOORD1;
|
||||||
|
float3 positionWS : TEXCOORD2;
|
||||||
|
half3 normalWS : TEXCOORD3;
|
||||||
|
float fogFactor : TEXCOORD4;
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
};
|
||||||
|
|
||||||
|
ToonVaryings ToonVertex(ToonAttributes input)
|
||||||
|
{
|
||||||
|
ToonVaryings output;
|
||||||
|
UNITY_SETUP_INSTANCE_ID(input);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||||
|
output.positionWS = TransformObjectToWorld(input.positionOS.xyz);
|
||||||
|
output.positionCS = TransformWorldToHClip(output.positionWS);
|
||||||
|
output.normalWS = TransformObjectToWorldNormal(input.normalOS);
|
||||||
|
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||||
|
output.lightmapUV = TRANSFORM_TEX(input.lightmapUV, _ShadowTex);
|
||||||
|
output.fogFactor = ComputeFogFactor(output.positionCS.z);
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(_ADDITIONAL_LIGHTS)
|
||||||
|
float3 ShadeToonFill(uint lightIndex, float3 positionWS, half3 normalWS)
|
||||||
|
{
|
||||||
|
Light light;
|
||||||
|
#if defined(_ADDITIONAL_LIGHT_SHADOWS)
|
||||||
|
if (_ReceiveShadows > 0.5)
|
||||||
|
light = GetAdditionalLight(lightIndex, positionWS, half4(1, 1, 1, 1));
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
light = GetAdditionalLight(lightIndex, positionWS);
|
||||||
|
half weight = smoothstep(-0.16, 0.54, dot(normalWS, light.direction));
|
||||||
|
return light.color * (weight * light.distanceAttenuation * light.shadowAttenuation);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 ShadeToon(half3 albedo, half3 baked, float4 positionCS, float3 positionWS, half3 normalWS)
|
||||||
|
{
|
||||||
|
Light key = GetMainLight();
|
||||||
|
#if defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||||
|
if (_ReceiveShadows > 0.5)
|
||||||
|
key.shadowAttenuation = MainLightRealtimeShadow(TransformWorldToShadowCoord(positionWS));
|
||||||
|
key.shadowAttenuation = lerp(key.shadowAttenuation, 1.0, GetMainLightShadowFade(positionWS));
|
||||||
|
#endif
|
||||||
|
half3 keyColor = key.color * key.distanceAttenuation;
|
||||||
|
if (max(max(keyColor.r, keyColor.g), keyColor.b) <= 0.001)
|
||||||
|
return albedo * baked;
|
||||||
|
|
||||||
|
half diffuse = dot(normalWS, key.direction);
|
||||||
|
// Two narrow transitions give three value bands with softened edges.
|
||||||
|
half bands = 0.19 * smoothstep(-0.18, -0.06, diffuse) + 0.38 * smoothstep(0.34, 0.46, diffuse);
|
||||||
|
half3 viewDir = GetWorldSpaceNormalizeViewDir(positionWS);
|
||||||
|
half rim = smoothstep(0.67, 0.87, 1.0 - saturate(dot(normalWS, viewDir)));
|
||||||
|
rim *= 0.14 * smoothstep(0.03, 0.45, diffuse);
|
||||||
|
half night = _Pal3ToonSceneLighting.x;
|
||||||
|
half indoors = _Pal3ToonSceneLighting.y;
|
||||||
|
half contrast = _Pal3ToonSceneLighting.z;
|
||||||
|
half visibility = lerp(lerp(0.22, 0.10, contrast), 1.0, key.shadowAttenuation);
|
||||||
|
half3 ambient = lerp(half3(0.58, 0.59, 0.63), half3(0.29, 0.32, 0.46), night);
|
||||||
|
half3 dayAmbient = lerp(half3(0.46, 0.48, 0.53), half3(0.40, 0.39, 0.39), indoors);
|
||||||
|
half3 nightAmbient = lerp(half3(0.22, 0.27, 0.41), half3(0.20, 0.235, 0.33), indoors);
|
||||||
|
ambient = lerp(ambient, lerp(dayAmbient, nightAmbient, night), contrast);
|
||||||
|
UNITY_BRANCH
|
||||||
|
if (_IsCharacter > 0.5 && _Pal3ToonCharacterLighting > 0.0)
|
||||||
|
{
|
||||||
|
// Retain facial readability while allowing the body and cast shadows to have contrast.
|
||||||
|
half fillStrength = _Pal3ToonCharacterLighting;
|
||||||
|
half3 characterAmbient = lerp(half3(0.72, 0.73, 0.77), half3(0.50, 0.52, 0.64), night);
|
||||||
|
ambient = lerp(ambient, characterAmbient, fillStrength);
|
||||||
|
half characterBands = 0.17 * smoothstep(-0.39, -0.19, diffuse) + 0.26 * smoothstep(0.26, 0.42, diffuse);
|
||||||
|
bands = lerp(bands, characterBands, fillStrength);
|
||||||
|
visibility = lerp(visibility, lerp(0.40, 1.0, key.shadowAttenuation), fillStrength);
|
||||||
|
}
|
||||||
|
half3 direct = keyColor * ((bands + rim) * visibility);
|
||||||
|
|
||||||
|
#if defined(_ADDITIONAL_LIGHTS)
|
||||||
|
float3 fill = 0;
|
||||||
|
#if USE_CLUSTER_LIGHT_LOOP
|
||||||
|
InputData inputData = (InputData)0;
|
||||||
|
inputData.positionWS = positionWS;
|
||||||
|
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(positionCS);
|
||||||
|
|
||||||
|
// URP stores additional directional lights outside the punctual light clusters.
|
||||||
|
[loop] for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); ++lightIndex)
|
||||||
|
{
|
||||||
|
CLUSTER_LIGHT_LOOP_SUBTRACTIVE_LIGHT_CHECK
|
||||||
|
fill += ShadeToonFill(lightIndex, positionWS, normalWS);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
uint lightCount = GetAdditionalLightsCount();
|
||||||
|
LIGHT_LOOP_BEGIN(lightCount)
|
||||||
|
fill += ShadeToonFill(lightIndex, positionWS, normalWS);
|
||||||
|
LIGHT_LOOP_END
|
||||||
|
float3 scaledFill = fill * lerp(0.34, 0.42, night * contrast);
|
||||||
|
if (_Pal3ToonNightFireBoost > 0.5)
|
||||||
|
{
|
||||||
|
// Limit the fill without clipping its red and green channels separately.
|
||||||
|
float peak = max(max(scaledFill.r, scaledFill.g), scaledFill.b);
|
||||||
|
direct += scaledFill * (0.90 / (0.90 + peak));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
direct += min(scaledFill, 0.45);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half occlusion = 1.0;
|
||||||
|
#if !defined(PAL3_TOON_TRANSPARENT) && !defined(PAL3_TOON_WATER)
|
||||||
|
UNITY_BRANCH
|
||||||
|
if (_Pal3ToonEffectStrengths.x > 0.0)
|
||||||
|
{
|
||||||
|
// The per-camera switch also controls the SSAO pass. Sampling directly avoids
|
||||||
|
// depending on URP retaining an SSAO-off shader variant for runtime toggles.
|
||||||
|
half sampledAO = saturate(SampleAmbientOcclusion(GetNormalizedScreenSpaceUV(positionCS)));
|
||||||
|
half strength = _Pal3ToonEffectStrengths.x;
|
||||||
|
occlusion = lerp(1.0, sampledAO, min(strength, 1.0));
|
||||||
|
occlusion = lerp(occlusion, sampledAO * sampledAO, saturate(strength - 1.0));
|
||||||
|
// Prevent strong AO from obscuring small facial features.
|
||||||
|
occlusion = lerp(occlusion, lerp(1.0, occlusion, 0.70), _IsCharacter * _Pal3ToonCharacterLighting);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 bakedVisibility = lerp(1.0, saturate(baked), _Pal3ToonEffectStrengths.y);
|
||||||
|
// Static occlusion shapes ambient lighting; direct candle light can still brighten dark corners.
|
||||||
|
half3 lighting = ambient * bakedVisibility * occlusion;
|
||||||
|
lighting += direct * lerp(1.0, bakedVisibility, 0.55) * lerp(1.0, occlusion, 0.15);
|
||||||
|
return albedo * lighting;
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 ToonFragment(ToonVaryings input) : SV_Target
|
||||||
|
{
|
||||||
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
|
||||||
|
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
clip(color.a - _Threshold);
|
||||||
|
#elif defined(PAL3_TOON_TRANSPARENT)
|
||||||
|
if (color.a >= _Threshold || (color.a <= 0.0 && _Threshold <= 1.0))
|
||||||
|
discard;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
half3 baked = 1.0;
|
||||||
|
if (_HasShadowTex > 0.5)
|
||||||
|
baked = SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.lightmapUV).rgb * _LightmapScale;
|
||||||
|
|
||||||
|
color *= _TintColor;
|
||||||
|
#if defined(PAL3_TOON_WATER)
|
||||||
|
// The first frame defines opacity for the full water animation.
|
||||||
|
color.a = _Alpha;
|
||||||
|
#endif
|
||||||
|
#if defined(PAL3_TOON_TRANSPARENT)
|
||||||
|
if (_ReceiveLighting < 0.5)
|
||||||
|
color.rgb *= baked;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
color.rgb = ShadeToon(color.rgb, baked, input.positionCS, input.positionWS, SafeNormalize(input.normalWS));
|
||||||
|
|
||||||
|
color.rgb = MixFog(color.rgb, input.fogFactor);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7acecdde760249099a8143bb40d37f00
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
#ifndef PAL3_TOON_INPUT_INCLUDED
|
||||||
|
#define PAL3_TOON_INPUT_INCLUDED
|
||||||
|
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
|
TEXTURE2D(_MainTex);
|
||||||
|
SAMPLER(sampler_MainTex);
|
||||||
|
TEXTURE2D(_ShadowTex);
|
||||||
|
SAMPLER(sampler_ShadowTex);
|
||||||
|
|
||||||
|
CBUFFER_START(UnityPerMaterial)
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
float4 _ShadowTex_ST;
|
||||||
|
half4 _TintColor;
|
||||||
|
float _Threshold;
|
||||||
|
float _HasShadowTex;
|
||||||
|
float _LightmapScale;
|
||||||
|
float _ReceiveLighting;
|
||||||
|
float _ReceiveShadows;
|
||||||
|
float _IsCharacter;
|
||||||
|
#if defined(PAL3_TOON_WATER)
|
||||||
|
float _Alpha;
|
||||||
|
#endif
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
|
struct ToonAttributes
|
||||||
|
{
|
||||||
|
float4 positionOS : POSITION;
|
||||||
|
float3 normalOS : NORMAL;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
float2 lightmapUV : TEXCOORD1;
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3bee6608024749edbf4c7da92644306f
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
#include "Pal3ToonInput.hlsl"
|
||||||
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
||||||
|
|
||||||
|
float3 _LightDirection;
|
||||||
|
float3 _LightPosition;
|
||||||
|
|
||||||
|
struct ToonShadowVaryings
|
||||||
|
{
|
||||||
|
float4 positionCS : SV_POSITION;
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
ToonShadowVaryings ToonShadowVertex(ToonAttributes input)
|
||||||
|
{
|
||||||
|
ToonShadowVaryings output;
|
||||||
|
UNITY_SETUP_INSTANCE_ID(input);
|
||||||
|
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
|
||||||
|
output.positionCS = ApplyShadowClamping(TransformWorldToHClip(ApplyShadowBias(positionWS, normalWS, lightDirectionWS)));
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||||
|
#endif
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
half4 ToonShadowFragment(ToonShadowVaryings input) : SV_Target
|
||||||
|
{
|
||||||
|
#if defined(PAL3_TOON_CUTOUT)
|
||||||
|
clip(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv).a - _Threshold);
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b0fa0b9b56f240acb66be2dbbcaf61a2
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9971a1796d9c4269808917bc978c7b96
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
Shader "Pal3/ToonCutout"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
|
_TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||||
|
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||||
|
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||||
|
_LightmapScale ("Baked Light Scale", Float) = 1.666667
|
||||||
|
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||||
|
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||||
|
_Threshold ("Alpha Cutoff", Float) = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "ToonForward"
|
||||||
|
Tags { "LightMode" = "UniversalForward" }
|
||||||
|
ZWrite On
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonVertex
|
||||||
|
#pragma fragment ToonFragment
|
||||||
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHTS
|
||||||
|
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||||
|
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||||
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
#define PAL3_TOON_CUTOUT
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonForward.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DepthOnly"
|
||||||
|
Tags { "LightMode" = "DepthOnly" }
|
||||||
|
ZWrite On
|
||||||
|
ColorMask R
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonDepthVertex
|
||||||
|
#pragma fragment ToonDepthFragment
|
||||||
|
#define PAL3_TOON_CUTOUT
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonDepth.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DepthNormals"
|
||||||
|
Tags { "LightMode" = "DepthNormals" }
|
||||||
|
ZWrite On
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonDepthVertex
|
||||||
|
#pragma fragment ToonDepthFragment
|
||||||
|
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||||
|
#define PAL3_TOON_DEPTH_NORMALS
|
||||||
|
#define PAL3_TOON_CUTOUT
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonDepth.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
ZWrite On
|
||||||
|
ZTest LEqual
|
||||||
|
ColorMask 0
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonShadowVertex
|
||||||
|
#pragma fragment ToonShadowFragment
|
||||||
|
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||||
|
#define PAL3_TOON_CUTOUT
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonShadow.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e57ba5c6fe0b42a98d2f373c67cc1e38
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
Shader "Pal3/ToonOpaque"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
|
_TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||||
|
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||||
|
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||||
|
_LightmapScale ("Baked Light Scale", Float) = 1.666667
|
||||||
|
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||||
|
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "ToonForward"
|
||||||
|
Tags { "LightMode" = "UniversalForward" }
|
||||||
|
ZWrite On
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonVertex
|
||||||
|
#pragma fragment ToonFragment
|
||||||
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHTS
|
||||||
|
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||||
|
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||||
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonForward.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DepthOnly"
|
||||||
|
Tags { "LightMode" = "DepthOnly" }
|
||||||
|
ZWrite On
|
||||||
|
ColorMask R
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonDepthVertex
|
||||||
|
#pragma fragment ToonDepthFragment
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonDepth.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "DepthNormals"
|
||||||
|
Tags { "LightMode" = "DepthNormals" }
|
||||||
|
ZWrite On
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonDepthVertex
|
||||||
|
#pragma fragment ToonDepthFragment
|
||||||
|
#pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT
|
||||||
|
#define PAL3_TOON_DEPTH_NORMALS
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonDepth.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "ShadowCaster"
|
||||||
|
Tags { "LightMode" = "ShadowCaster" }
|
||||||
|
ZWrite On
|
||||||
|
ZTest LEqual
|
||||||
|
ColorMask 0
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonShadowVertex
|
||||||
|
#pragma fragment ToonShadowFragment
|
||||||
|
#pragma multi_compile_vertex _ _CASTING_PUNCTUAL_LIGHT_SHADOW
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonShadow.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bc6ca31ba7ce4c028c2f9d135a8f81f6
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
Shader "Pal3/ToonTransparent"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
|
_TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||||
|
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||||
|
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||||
|
_LightmapScale ("Baked Light Scale", Float) = 1.666667
|
||||||
|
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||||
|
[HideInInspector] _IsCharacter ("Character", Float) = 0
|
||||||
|
_Threshold ("Alpha Cutoff", Float) = 1
|
||||||
|
_ReceiveLighting ("Receive Lighting", Float) = 1
|
||||||
|
[Enum(UnityEngine.Rendering.BlendMode)] _BlendSrcFactor ("Source Blend Factor", Int) = 5
|
||||||
|
[Enum(UnityEngine.Rendering.BlendMode)] _BlendDstFactor ("Destination Blend Factor", Int) = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" }
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "ToonForward"
|
||||||
|
Tags { "LightMode" = "UniversalForward" }
|
||||||
|
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||||
|
ZWrite Off
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonVertex
|
||||||
|
#pragma fragment ToonFragment
|
||||||
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHTS
|
||||||
|
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||||
|
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||||
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
#define PAL3_TOON_TRANSPARENT
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonForward.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 89695d596cab416a803088a5ce370c10
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
Shader "Pal3/ToonWater"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
_MainTex ("Texture", 2D) = "white" {}
|
||||||
|
_ShadowTex ("Baked Shadow", 2D) = "white" {}
|
||||||
|
_HasShadowTex ("Has Baked Shadow", Float) = 0
|
||||||
|
_LightmapScale ("Baked Light Scale", Float) = 1.428571
|
||||||
|
_Alpha ("Opacity", Range(0, 1)) = 0.5
|
||||||
|
_ReceiveShadows ("Receive Shadows", Float) = 1
|
||||||
|
[HideInInspector] _TintColor ("Tint Color", Color) = (1, 1, 1, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent-1" }
|
||||||
|
|
||||||
|
Pass
|
||||||
|
{
|
||||||
|
Name "ToonForward"
|
||||||
|
Tags { "LightMode" = "UniversalForward" }
|
||||||
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
ZWrite Off
|
||||||
|
|
||||||
|
HLSLPROGRAM
|
||||||
|
#pragma target 3.0
|
||||||
|
#pragma vertex ToonVertex
|
||||||
|
#pragma fragment ToonFragment
|
||||||
|
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHTS
|
||||||
|
#pragma multi_compile _ _CLUSTER_LIGHT_LOOP
|
||||||
|
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
|
||||||
|
#pragma multi_compile_fragment _ _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH
|
||||||
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
#define PAL3_TOON_WATER
|
||||||
|
#include "Assets/Rendering/Toon/Pal3ToonForward.hlsl"
|
||||||
|
ENDHLSL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bfe8e4c75f54fd5b64a93adc46ef6fc
|
||||||
@@ -0,0 +1,467 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2ec995e51a6e251468d2a3fd8a686257, type: 3}
|
||||||
|
m_Name: UniversalRenderPipelineGlobalSettings
|
||||||
|
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalRenderPipelineGlobalSettings
|
||||||
|
m_ShaderStrippingSetting:
|
||||||
|
m_Version: 0
|
||||||
|
m_ExportShaderVariants: 1
|
||||||
|
m_ShaderVariantLogLevel: 0
|
||||||
|
m_StripRuntimeDebugShaders: 1
|
||||||
|
m_URPShaderStrippingSetting:
|
||||||
|
m_Version: 0
|
||||||
|
m_StripUnusedPostProcessingVariantsAndResources: 0
|
||||||
|
m_StripUnusedVariants: 1
|
||||||
|
m_StripScreenCoordOverrideVariants: 1
|
||||||
|
m_Strip2DUnusedVariants: 0
|
||||||
|
m_ShaderVariantLogLevel: 0
|
||||||
|
m_ExportShaderVariants: 1
|
||||||
|
m_StripDebugVariants: 1
|
||||||
|
m_StripUnusedPostProcessingVariants: 0
|
||||||
|
m_StripUnusedVariants: 1
|
||||||
|
m_StripScreenCoordOverrideVariants: 1
|
||||||
|
supportRuntimeDebugDisplay: 0
|
||||||
|
m_Settings:
|
||||||
|
m_SettingsList:
|
||||||
|
m_List:
|
||||||
|
- rid: 4672219873250902016
|
||||||
|
- rid: 4672219873250902017
|
||||||
|
- rid: 4672219873250902018
|
||||||
|
- rid: 4672219873250902019
|
||||||
|
- rid: 4672219873250902020
|
||||||
|
- rid: 4672219873250902021
|
||||||
|
- rid: 4672219873250902022
|
||||||
|
- rid: 4672219873250902023
|
||||||
|
- rid: 4672219873250902024
|
||||||
|
- rid: 4672219873250902025
|
||||||
|
- rid: 4672219873250902026
|
||||||
|
- rid: 4672219873250902027
|
||||||
|
- rid: 4672219873250902028
|
||||||
|
- rid: 4672219873250902029
|
||||||
|
- rid: 4672219873250902030
|
||||||
|
- rid: 4672219873250902031
|
||||||
|
- rid: 4672219873250902032
|
||||||
|
- rid: 4672219873250902033
|
||||||
|
- rid: 4672219873250902034
|
||||||
|
- rid: 4672219873250902035
|
||||||
|
- rid: 4672219873250902036
|
||||||
|
- rid: 4672219873250902037
|
||||||
|
- rid: 4672219873250902038
|
||||||
|
- rid: 4672219873250902039
|
||||||
|
- rid: 4672219873250902040
|
||||||
|
- rid: 4672219873250902041
|
||||||
|
- rid: 4672219873250902042
|
||||||
|
- rid: 4672219873250902043
|
||||||
|
- rid: 4672219873250902044
|
||||||
|
- rid: 4672219873250902045
|
||||||
|
- rid: 4672219873250902046
|
||||||
|
- rid: 4672219873250902047
|
||||||
|
- rid: 4672219873250902048
|
||||||
|
- rid: 4672219873250902049
|
||||||
|
- rid: 4672219873250902050
|
||||||
|
- rid: 4672219873250902051
|
||||||
|
- rid: 4672219873250902052
|
||||||
|
- rid: 4672219873250902053
|
||||||
|
m_RuntimeSettings:
|
||||||
|
m_List: []
|
||||||
|
m_AssetVersion: 11
|
||||||
|
m_ObsoleteDefaultVolumeProfile: {fileID: 0}
|
||||||
|
m_RenderingLayerNames:
|
||||||
|
- Default
|
||||||
|
m_ValidRenderingLayers: 0
|
||||||
|
lightLayerName0:
|
||||||
|
lightLayerName1:
|
||||||
|
lightLayerName2:
|
||||||
|
lightLayerName3:
|
||||||
|
lightLayerName4:
|
||||||
|
lightLayerName5:
|
||||||
|
lightLayerName6:
|
||||||
|
lightLayerName7:
|
||||||
|
apvScenesData:
|
||||||
|
obsoleteSceneBounds:
|
||||||
|
m_Keys: []
|
||||||
|
m_Values: []
|
||||||
|
obsoleteHasProbeVolumes:
|
||||||
|
m_Keys: []
|
||||||
|
m_Values:
|
||||||
|
references:
|
||||||
|
version: 2
|
||||||
|
RefIds:
|
||||||
|
- rid: 4672219873250902016
|
||||||
|
type: {class: WorldRenderPipelineResources, ns: UnityEngine.PathTracing.Core, asm: Unity.PathTracing.Runtime}
|
||||||
|
data:
|
||||||
|
_version: 3
|
||||||
|
_blitCubemap: {fileID: 7200000, guid: 5a992812cb320d146a66cc600200cce7, type: 3}
|
||||||
|
_blitGrayScaleCookie: {fileID: 7200000, guid: 557fa399e33bf7647bda5697c5c158df, type: 3}
|
||||||
|
_setAlphaChannelShader: {fileID: 7200000, guid: 5efaea0e81c66334aa9d062d6573e6fd, type: 3}
|
||||||
|
_environmentImportanceSamplingBuild: {fileID: 7200000, guid: 5bb2534d2411d344cbc54f880232640f, type: 3}
|
||||||
|
_skyBoxMesh: {fileID: 4300000, guid: 0529e6c5f6dea8c4a8c2835ed7de57cb, type: 2}
|
||||||
|
_sixFaceSkyBoxMesh: {fileID: 4300000, guid: a80925ceebd011741b42509226cefc74, type: 2}
|
||||||
|
_buildLightGridShader: {fileID: 7200000, guid: 16e47c1641bd0104e92b624601457bb0, type: 3}
|
||||||
|
_solidColorShader: {fileID: 4800000, guid: 3765a7ac691541038de4d587b94ae768, type: 3}
|
||||||
|
- rid: 4672219873250902017
|
||||||
|
type: {class: RayTracingRenderPipelineResources, ns: UnityEngine.Rendering.UnifiedRayTracing, asm: Unity.UnifiedRayTracing.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
m_GeometryPoolKernels: {fileID: 7200000, guid: 98e3d58cae7210c4786f67f504c9e899, type: 3}
|
||||||
|
m_CopyBuffer: {fileID: 7200000, guid: 1b95b5dcf48d1914c9e1e7405c7660e3, type: 3}
|
||||||
|
m_CopyPositions: {fileID: 7200000, guid: 1ad53a96b58d3c3488dde4f14db1aaeb, type: 3}
|
||||||
|
m_BitHistogram: {fileID: 7200000, guid: 8670f7ce4b60cef43bed36148aa1b0a2, type: 3}
|
||||||
|
m_BlockReducePart: {fileID: 7200000, guid: 4e034cc8ea2635c4e9f063e5ddc7ea7a, type: 3}
|
||||||
|
m_BlockScan: {fileID: 7200000, guid: 4d6d5de35fa45ef4a92119397a045cc9, type: 3}
|
||||||
|
m_BuildHlbvh: {fileID: 7200000, guid: 2d70cd6be91bd7843a39a54b51c15b13, type: 3}
|
||||||
|
m_RestructureBvh: {fileID: 7200000, guid: 56641cb88dcb31a4398a4997ef7a7a8c, type: 3}
|
||||||
|
m_Scatter: {fileID: 7200000, guid: a2eaeefdac4637a44b734e85b7be9186, type: 3}
|
||||||
|
- rid: 4672219873250902018
|
||||||
|
type: {class: ScreenSpaceReflectionPersistentResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Shader: {fileID: 4800000, guid: 7b3e6785f5f6b634794df3a85a2a35da, type: 3}
|
||||||
|
m_BlitShader: {fileID: 4800000, guid: 815c625bb9d4fe240a4ccf42ca3899cb, type: 3}
|
||||||
|
m_Version: 0
|
||||||
|
- rid: 4672219873250902019
|
||||||
|
type: {class: UniversalRenderPipelineDebugShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_DebugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7, type: 3}
|
||||||
|
m_HdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
|
||||||
|
m_ProbeVolumeSamplingDebugComputeShader: {fileID: 7200000, guid: 53626a513ea68ce47b59dc1299fe3959, type: 3}
|
||||||
|
- rid: 4672219873250902020
|
||||||
|
type: {class: OnTilePostProcessResource, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_UberPostShader: {fileID: 4800000, guid: fe4f13c1004a07d4ea1e30bfd0326d9e, type: 3}
|
||||||
|
- rid: 4672219873250902021
|
||||||
|
type: {class: UniversalRenderPipelineRuntimeShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_FallbackErrorShader: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
|
||||||
|
m_BlitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
|
||||||
|
m_CoreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
|
||||||
|
m_CoreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b, type: 3}
|
||||||
|
m_UIBackdropFilterCompositePS: {fileID: 4800000, guid: 8b3d1e6f4c5a4d219a72f8e1c0b3d4a7, type: 3}
|
||||||
|
m_SamplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
|
||||||
|
m_TerrainDetailLit: {fileID: 0}
|
||||||
|
m_TerrainDetailGrassBillboard: {fileID: 0}
|
||||||
|
m_TerrainDetailGrass: {fileID: 0}
|
||||||
|
- rid: 4672219873250902022
|
||||||
|
type: {class: PostProcessData/ShaderResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
stopNanPS: {fileID: 4800000, guid: 1121bb4e615ca3c48b214e79e841e823, type: 3}
|
||||||
|
subpixelMorphologicalAntialiasingPS: {fileID: 4800000, guid: 63eaba0ebfb82cc43bde059b4a8c65f6, type: 3}
|
||||||
|
gaussianDepthOfFieldPS: {fileID: 4800000, guid: 5e7134d6e63e0bc47a1dd2669cedb379, type: 3}
|
||||||
|
bokehDepthOfFieldPS: {fileID: 4800000, guid: 2aed67ad60045d54ba3a00c91e2d2631, type: 3}
|
||||||
|
cameraMotionBlurPS: {fileID: 4800000, guid: 1edcd131364091c46a17cbff0b1de97a, type: 3}
|
||||||
|
paniniProjectionPS: {fileID: 4800000, guid: a15b78cf8ca26ca4fb2090293153c62c, type: 3}
|
||||||
|
lutBuilderLdrPS: {fileID: 4800000, guid: 65df88701913c224d95fc554db28381a, type: 3}
|
||||||
|
lutBuilderHdrPS: {fileID: 4800000, guid: ec9fec698a3456d4fb18cf8bacb7a2bc, type: 3}
|
||||||
|
bloomPS: {fileID: 4800000, guid: 5f1864addb451f54bae8c86d230f736e, type: 3}
|
||||||
|
temporalAntialiasingPS: {fileID: 4800000, guid: 9c70c1a35ff15f340b38ea84842358bf, type: 3}
|
||||||
|
LensFlareDataDrivenPS: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92, type: 3}
|
||||||
|
LensFlareScreenSpacePS: {fileID: 4800000, guid: 701880fecb344ea4c9cd0db3407ab287, type: 3}
|
||||||
|
scalingSetupPS: {fileID: 4800000, guid: e8ee25143a34b8c4388709ea947055d1, type: 3}
|
||||||
|
easuPS: {fileID: 4800000, guid: 562b7ae4f629f144aa97780546fce7c6, type: 3}
|
||||||
|
uberPostPS: {fileID: 4800000, guid: e7857e9d0c934dc4f83f270f8447b006, type: 3}
|
||||||
|
finalPostPassPS: {fileID: 4800000, guid: c49e63ed1bbcb334780a3bd19dfed403, type: 3}
|
||||||
|
m_ShaderResourcesVersion: 0
|
||||||
|
- rid: 4672219873250902023
|
||||||
|
type: {class: URPDefaultVolumeProfileSettings, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_VolumeProfile: {fileID: 11400000, guid: 580f5421befb34b3bab2e8645d38d6b6, type: 2}
|
||||||
|
- rid: 4672219873250902024
|
||||||
|
type: {class: URPShaderStrippingSetting, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_StripUnusedPostProcessingVariantsAndResources: 0
|
||||||
|
m_StripUnusedVariants: 1
|
||||||
|
m_StripScreenCoordOverrideVariants: 1
|
||||||
|
m_Strip2DUnusedVariants: 0
|
||||||
|
- rid: 4672219873250902025
|
||||||
|
type: {class: ScreenSpaceAmbientOcclusionBlueNoiseResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_BlueNoise256Textures:
|
||||||
|
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 4b7b083e6b6734e8bb2838b0b50a0bc8, type: 3}
|
||||||
|
- {fileID: 2800000, guid: c06cc21c692f94f5fb5206247191eeee, type: 3}
|
||||||
|
- {fileID: 2800000, guid: cb76dd40fa7654f9587f6a344f125c9a, type: 3}
|
||||||
|
- {fileID: 2800000, guid: e32226222ff144b24bf3a5a451de54bc, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
|
||||||
|
m_Version: 0
|
||||||
|
- rid: 4672219873250902026
|
||||||
|
type: {class: URPTerrainShaderSetting, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_IncludeTerrainShaders: 1
|
||||||
|
- rid: 4672219873250902027
|
||||||
|
type: {class: Renderer2DResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_LightShader: {fileID: 4800000, guid: 3f6c848ca3d7bca4bbe846546ac701a1, type: 3}
|
||||||
|
m_RenderingLayerMaskShader: {fileID: 4800000, guid: 9ac9bae9f40d7dc4a80dbf809b9544aa, type: 3}
|
||||||
|
m_ProjectedShadowShader: {fileID: 4800000, guid: ce09d4a80b88c5a4eb9768fab4f1ee00, type: 3}
|
||||||
|
m_SpriteShadowShader: {fileID: 4800000, guid: 44fc62292b65ab04eabcf310e799ccf6, type: 3}
|
||||||
|
m_SpriteUnshadowShader: {fileID: 4800000, guid: de02b375720b5c445afe83cd483bedf3, type: 3}
|
||||||
|
m_GeometryShadowShader: {fileID: 4800000, guid: 19349a0f9a7ed4c48a27445bcf92e5e1, type: 3}
|
||||||
|
m_GeometryUnshadowShader: {fileID: 4800000, guid: 77774d9009bb81447b048c907d4c6273, type: 3}
|
||||||
|
m_CopyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
|
||||||
|
m_DefaultLitMaterial: {fileID: 2100000, guid: a97c105638bdf8b4a8650670310a4cd3, type: 2}
|
||||||
|
m_DefaultUnlitMaterial: {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2}
|
||||||
|
m_DefaultMaskMaterial: {fileID: 2100000, guid: 15d0c3709176029428a0da2f8cecf0b5, type: 2}
|
||||||
|
m_DefaultMesh2DLitMaterial: {fileID: 2100000, guid: 9452ae1262a74094f8a68013fbcd1834, type: 2}
|
||||||
|
- rid: 4672219873250902028
|
||||||
|
type: {class: UniversalRenderPipelineEditorAssets, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_DefaultSettingsVolumeProfile: {fileID: 11400000, guid: eda47df5b85f4f249abf7abd73db2cb2, type: 2}
|
||||||
|
- rid: 4672219873250902029
|
||||||
|
type: {class: MipGenRenderPipelineRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_ColorPyramidPS: {fileID: 4800000, guid: 63b92baba208e314c8fdebe52ca0cc34, type: 3}
|
||||||
|
m_ColorPyramidCS: {fileID: 7200000, guid: 28969cfddd9ef3f4e94b971690146a4f, type: 3}
|
||||||
|
m_DepthPyramidCS: {fileID: 7200000, guid: 90a204702cd44e54cac7ed4fc6e5d86b, type: 3}
|
||||||
|
- rid: 4672219873250902030
|
||||||
|
type: {class: UniversalRenderPipelineEditorMaterials, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_DefaultMaterial: {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||||
|
m_SimpleLitMaterial: {fileID: 2100000, guid: 6a1143ee683302f4aa628c052723efc1, type: 2}
|
||||||
|
m_DefaultParticleMaterial: {fileID: 2100000, guid: e823cd5b5d27c0f4b8256e7c12ee3e6d, type: 2}
|
||||||
|
m_DefaultLineMaterial: {fileID: 2100000, guid: e823cd5b5d27c0f4b8256e7c12ee3e6d, type: 2}
|
||||||
|
m_DefaultTerrainMaterial: {fileID: 2100000, guid: 594ea882c5a793440b60ff72d896021e, type: 2}
|
||||||
|
m_DefaultDecalMaterial: {fileID: 2100000, guid: 31d0dcc6f2dd4e4408d18036a2c93862, type: 2}
|
||||||
|
m_DefaultSpriteMaterial: {fileID: 2100000, guid: 9dfc825aed78fcd4ba02077103263b40, type: 2}
|
||||||
|
- rid: 4672219873250902031
|
||||||
|
type: {class: UniversalRenderPipelineRuntimeTextures, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
m_BlueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
|
||||||
|
m_BayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
|
||||||
|
m_DebugFontTex: {fileID: 2800000, guid: 26a413214480ef144b2915d6ff4d0beb, type: 3}
|
||||||
|
- rid: 4672219873250902032
|
||||||
|
type: {class: RenderGraphSettings, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
- rid: 4672219873250902033
|
||||||
|
type: {class: UniversalRenderPipelineRuntimeTerrainShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_TerrainDetailLit: {fileID: 4800000, guid: f6783ab646d374f94b199774402a5144, type: 3}
|
||||||
|
m_TerrainDetailGrassBillboard: {fileID: 4800000, guid: 29868e73b638e48ca99a19ea58c48d90, type: 3}
|
||||||
|
m_TerrainDetailGrass: {fileID: 4800000, guid: e507fdfead5ca47e8b9a768b51c291a1, type: 3}
|
||||||
|
- rid: 4672219873250902034
|
||||||
|
type: {class: UniversalRenderPipelineEditorShaders, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_AutodeskInteractive: {fileID: 4800000, guid: 0e9d5a909a1f7e84882a534d0d11e49f, type: 3}
|
||||||
|
m_AutodeskInteractiveTransparent: {fileID: 4800000, guid: 5c81372d981403744adbdda4433c9c11, type: 3}
|
||||||
|
m_AutodeskInteractiveMasked: {fileID: 4800000, guid: 80aa867ac363ac043847b06ad71604cd, type: 3}
|
||||||
|
m_DefaultSpeedTree7Shader: {fileID: 4800000, guid: 0f4122b9a743b744abe2fb6a0a88868b, type: 3}
|
||||||
|
m_DefaultSpeedTree8Shader: {fileID: -6465566751694194690, guid: 9920c1f1781549a46ba081a2a15a16ec, type: 3}
|
||||||
|
m_DefaultSpeedTree9Shader: {fileID: -6465566751694194690, guid: cbd3e1cc4ae141c42a30e33b4d666a61, type: 3}
|
||||||
|
- rid: 4672219873250902035
|
||||||
|
type: {class: ScreenSpaceAmbientOcclusionCoreResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_RasterizationShader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
|
||||||
|
m_Version: 0
|
||||||
|
- rid: 4672219873250902036
|
||||||
|
type: {class: UniversalRendererResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_CopyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
|
||||||
|
m_CameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf, type: 3}
|
||||||
|
m_StencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
|
||||||
|
m_ClusterDeferred: {fileID: 4800000, guid: 222cce62363a44a380c36bf03b392608, type: 3}
|
||||||
|
m_StencilDitherMaskSeedPS: {fileID: 4800000, guid: 8c3ee818f2efa514c889881ccb2e95a2, type: 3}
|
||||||
|
m_DBufferClear: {fileID: 4800000, guid: f056d8bd2a1c7e44e9729144b4c70395, type: 3}
|
||||||
|
- rid: 4672219873250902037
|
||||||
|
type: {class: UniversalRenderPipelineFilmGrainResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_Textures:
|
||||||
|
- {fileID: 2800000, guid: 654c582f7f8a5a14dbd7d119cbde215d, type: 3}
|
||||||
|
- {fileID: 2800000, guid: dd77ffd079630404e879388999033049, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 1097e90e1306e26439701489f391a6c0, type: 3}
|
||||||
|
- {fileID: 2800000, guid: f0b67500f7fad3b4c9f2b13e8f41ba6e, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 9930fb4528622b34687b00bbe6883de7, type: 3}
|
||||||
|
- {fileID: 2800000, guid: bd9e8c758250ef449a4b4bfaad7a2133, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 510a2f57334933e4a8dbabe4c30204e4, type: 3}
|
||||||
|
- {fileID: 2800000, guid: b4db8180660810945bf8d55ab44352ad, type: 3}
|
||||||
|
- {fileID: 2800000, guid: fd2fd78b392986e42a12df2177d3b89c, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 5cdee82a77d13994f83b8fdabed7c301, type: 3}
|
||||||
|
m_Version: 0
|
||||||
|
- rid: 4672219873250902038
|
||||||
|
type: {class: UniversalRenderPipelineRuntimeXRResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
m_xrOcclusionMeshPS: {fileID: 4800000, guid: 4431b1f1f743fbf4eb310a967890cbea, type: 3}
|
||||||
|
m_xrMirrorViewPS: {fileID: 4800000, guid: d5a307c014552314b9f560906d708772, type: 3}
|
||||||
|
m_xrMotionVector: {fileID: 4800000, guid: f89aac1e4f84468418fe30e611dff395, type: 3}
|
||||||
|
- rid: 4672219873250902039
|
||||||
|
type: {class: PostProcessData/TextureResources, ns: UnityEngine.Rendering.Universal, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
blueNoise16LTex:
|
||||||
|
- {fileID: 2800000, guid: 81200413a40918d4d8702e94db29911c, type: 3}
|
||||||
|
- {fileID: 2800000, guid: d50c5e07c9911a74982bddf7f3075e7b, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 1134690bf9216164dbc75050e35b7900, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 7ce2118f74614a94aa8a0cdf2e6062c3, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 2ca97df9d1801e84a8a8f2c53cb744f0, type: 3}
|
||||||
|
- {fileID: 2800000, guid: e63eef8f54aa9dc4da9a5ac094b503b5, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 39451254daebd6d40b52899c1f1c0c1b, type: 3}
|
||||||
|
- {fileID: 2800000, guid: c94ad916058dff743b0f1c969ddbe660, type: 3}
|
||||||
|
- {fileID: 2800000, guid: ed5ea7ce59ca8ec4f9f14bf470a30f35, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 071e954febf155243a6c81e48f452644, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 96aaab9cc247d0b4c98132159688c1af, type: 3}
|
||||||
|
- {fileID: 2800000, guid: fc3fa8f108657e14486697c9a84ccfc5, type: 3}
|
||||||
|
- {fileID: 2800000, guid: bfed3e498947fcb4890b7f40f54d85b9, type: 3}
|
||||||
|
- {fileID: 2800000, guid: d512512f4af60a442ab3458489412954, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 47a45908f6db0cb44a0d5e961143afec, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 4dcc0502f8586f941b5c4a66717205e8, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 9d92991794bb5864c8085468b97aa067, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 14381521ff11cb74abe3fe65401c23be, type: 3}
|
||||||
|
- {fileID: 2800000, guid: d36f0fe53425e08499a2333cf423634c, type: 3}
|
||||||
|
- {fileID: 2800000, guid: d4044ea2490d63b43aa1765f8efbf8a9, type: 3}
|
||||||
|
- {fileID: 2800000, guid: c9bd74624d8070f429e3f46d161f9204, type: 3}
|
||||||
|
- {fileID: 2800000, guid: d5c9b274310e5524ebe32a4e4da3df1f, type: 3}
|
||||||
|
- {fileID: 2800000, guid: f69770e54f2823f43badf77916acad83, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 10b6c6d22e73dea46a8ab36b6eebd629, type: 3}
|
||||||
|
- {fileID: 2800000, guid: a2ec5cbf5a9b64345ad3fab0912ddf7b, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 1c3c6d69a645b804fa232004b96b7ad3, type: 3}
|
||||||
|
- {fileID: 2800000, guid: d18a24d7b4ed50f4387993566d9d3ae2, type: 3}
|
||||||
|
- {fileID: 2800000, guid: c989e1ed85cf7154caa922fec53e6af6, type: 3}
|
||||||
|
- {fileID: 2800000, guid: ff47e5a0f105eb34883b973e51f4db62, type: 3}
|
||||||
|
- {fileID: 2800000, guid: fa042edbfc40fbd4bad0ab9d505b1223, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 896d9004736809c4fb5973b7c12eb8b9, type: 3}
|
||||||
|
- {fileID: 2800000, guid: 179f794063d2a66478e6e726f84a65bc, type: 3}
|
||||||
|
filmGrainTex: []
|
||||||
|
smaaAreaTex: {fileID: 2800000, guid: d1f1048909d55cd4fa1126ab998f617e, type: 3}
|
||||||
|
smaaSearchTex: {fileID: 2800000, guid: 51eee22c2a633ef4aada830eed57c3fd, type: 3}
|
||||||
|
m_TexturesResourcesVersion: 0
|
||||||
|
- rid: 4672219873250902040
|
||||||
|
type: {class: URPReflectionProbeSettings, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Universal.Runtime}
|
||||||
|
data:
|
||||||
|
version: 1
|
||||||
|
useReflectionProbeRotation: 1
|
||||||
|
- rid: 4672219873250902041
|
||||||
|
type: {class: GPUResidentDrawerResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.GPUDriven.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_InstanceDataBufferCopyKernels: {fileID: 7200000, guid: f984aeb540ded8b4fbb8a2047ab5b2e2, type: 3}
|
||||||
|
m_InstanceDataBufferUploadKernels: {fileID: 7200000, guid: 53864816eb00f2343b60e1a2c5a262ef, type: 3}
|
||||||
|
m_TransformUpdaterKernels: {fileID: 7200000, guid: 2a567b9b2733f8d47a700c3c85bed75b, type: 3}
|
||||||
|
m_WindDataUpdaterKernels: {fileID: 7200000, guid: fde76746e4fd0ed418c224f6b4084114, type: 3}
|
||||||
|
m_OccluderDepthPyramidKernels: {fileID: 7200000, guid: 08b2b5fb307b0d249860612774a987da, type: 3}
|
||||||
|
m_InstanceOcclusionCullingKernels: {fileID: 7200000, guid: f6d223acabc2f974795a5a7864b50e6c, type: 3}
|
||||||
|
m_OcclusionCullingDebugKernels: {fileID: 7200000, guid: b23e766bcf50ca4438ef186b174557df, type: 3}
|
||||||
|
m_DebugOcclusionTestPS: {fileID: 4800000, guid: d3f0849180c2d0944bc71060693df100, type: 3}
|
||||||
|
m_DebugOccluderPS: {fileID: 4800000, guid: b3c92426a88625841ab15ca6a7917248, type: 3}
|
||||||
|
- rid: 4672219873250902042
|
||||||
|
type: {class: ShaderStrippingSetting, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_ExportShaderVariants: 1
|
||||||
|
m_ShaderVariantLogLevel: 0
|
||||||
|
m_StripRuntimeDebugShaders: 1
|
||||||
|
- rid: 4672219873250902043
|
||||||
|
type: {class: ProbeVolumeGlobalSettings, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
m_ProbeVolumeDisableStreamingAssets: 0
|
||||||
|
- rid: 4672219873250902044
|
||||||
|
type: {class: ProbeVolumeDebugResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
probeVolumeDebugShader: {fileID: 4800000, guid: 3b21275fd12d65f49babb5286f040f2d, type: 3}
|
||||||
|
probeVolumeFragmentationDebugShader: {fileID: 4800000, guid: 3a80877c579b9144ebdcc6d923bca303, type: 3}
|
||||||
|
probeVolumeSamplingDebugShader: {fileID: 4800000, guid: bf54e6528c79a224e96346799064c393, type: 3}
|
||||||
|
probeVolumeOffsetDebugShader: {fileID: 4800000, guid: db8bd7436dc2c5f4c92655307d198381, type: 3}
|
||||||
|
probeSamplingDebugMesh: {fileID: -3555484719484374845, guid: 20be25aac4e22ee49a7db76fb3df6de2, type: 3}
|
||||||
|
numbersDisplayTex: {fileID: 2800000, guid: 73fe53b428c5b3440b7e87ee830b608a, type: 3}
|
||||||
|
- rid: 4672219873250902045
|
||||||
|
type: {class: IncludeAdditionalRPAssets, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_version: 0
|
||||||
|
m_IncludeReferencedInScenes: 0
|
||||||
|
m_IncludeAssetsByLabel: 0
|
||||||
|
m_LabelToInclude:
|
||||||
|
- rid: 4672219873250902046
|
||||||
|
type: {class: RenderingDebuggerRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_version: 0
|
||||||
|
m_PanelSettings: {fileID: 11400000, guid: fa69697be3070b04a893666f5947f18c, type: 2}
|
||||||
|
m_StyleSheets:
|
||||||
|
- {fileID: 7433441132597879392, guid: 0ff99fd36f66f1a41bcc1d3c90e0922a, type: 3}
|
||||||
|
- {fileID: 7433441132597879392, guid: 3a8aa4d508da46d4dace18b280f064aa, type: 3}
|
||||||
|
m_VisualTreeAsset: {fileID: 9197481963319205126, guid: b647ceb1e15264943b9b439971e71110, type: 3}
|
||||||
|
- rid: 4672219873250902047
|
||||||
|
type: {class: RenderGraphUtilsResources, ns: UnityEngine.Rendering.RenderGraphModule.Util, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 0
|
||||||
|
m_CoreCopyPS: {fileID: 4800000, guid: 12dc59547ea167a4ab435097dd0f9add, type: 3}
|
||||||
|
- rid: 4672219873250902048
|
||||||
|
type: {class: RenderGraphGlobalSettings, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_version: 0
|
||||||
|
m_EnableCompilationCaching: 1
|
||||||
|
m_EnableValidityChecks: 1
|
||||||
|
- rid: 4672219873250902049
|
||||||
|
type: {class: VrsRenderPipelineRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_TextureComputeShader: {fileID: 7200000, guid: cacb30de6c40c7444bbc78cb0a81fd2a, type: 3}
|
||||||
|
m_VisualizationShader: {fileID: 4800000, guid: 620b55b8040a88d468e94abe55bed5ba, type: 3}
|
||||||
|
m_VisualizationLookupTable:
|
||||||
|
m_Data:
|
||||||
|
- {r: 0.785, g: 0.23, b: 0.2, a: 1}
|
||||||
|
- {r: 1, g: 0.8, b: 0.8, a: 1}
|
||||||
|
- {r: 0.4, g: 0.2, b: 0.2, a: 1}
|
||||||
|
- {r: 0.51, g: 0.8, b: 0.6, a: 1}
|
||||||
|
- {r: 0.6, g: 0.8, b: 1, a: 1}
|
||||||
|
- {r: 0.2, g: 0.4, b: 0.6, a: 1}
|
||||||
|
- {r: 0.8, g: 1, b: 0.8, a: 1}
|
||||||
|
- {r: 0.2, g: 0.4, b: 0.2, a: 1}
|
||||||
|
- {r: 0.125, g: 0.22, b: 0.36, a: 1}
|
||||||
|
m_ConversionLookupTable:
|
||||||
|
m_Data:
|
||||||
|
- {r: 0.785, g: 0.23, b: 0.2, a: 1}
|
||||||
|
- {r: 1, g: 0.8, b: 0.8, a: 1}
|
||||||
|
- {r: 0.4, g: 0.2, b: 0.2, a: 1}
|
||||||
|
- {r: 0.51, g: 0.8, b: 0.6, a: 1}
|
||||||
|
- {r: 0.6, g: 0.8, b: 1, a: 1}
|
||||||
|
- {r: 0.2, g: 0.4, b: 0.6, a: 1}
|
||||||
|
- {r: 0.8, g: 1, b: 0.8, a: 1}
|
||||||
|
- {r: 0.2, g: 0.4, b: 0.2, a: 1}
|
||||||
|
- {r: 0.125, g: 0.22, b: 0.36, a: 1}
|
||||||
|
- rid: 4672219873250902050
|
||||||
|
type: {class: LightmapSamplingSettings, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
m_UseBicubicLightmapSampling: 0
|
||||||
|
- rid: 4672219873250902051
|
||||||
|
type: {class: ProbeVolumeRuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
probeVolumeBlendStatesCS: {fileID: 7200000, guid: a3f7b8c99de28a94684cb1daebeccf5d, type: 3}
|
||||||
|
probeVolumeUploadDataCS: {fileID: 7200000, guid: 0951de5992461754fa73650732c4954c, type: 3}
|
||||||
|
probeVolumeUploadDataL2CS: {fileID: 7200000, guid: 6196f34ed825db14b81fb3eb0ea8d931, type: 3}
|
||||||
|
- rid: 4672219873250902052
|
||||||
|
type: {class: STP/RuntimeResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_setupCS: {fileID: 7200000, guid: 33be2e9a5506b2843bdb2bdff9cad5e1, type: 3}
|
||||||
|
m_preTaaCS: {fileID: 7200000, guid: a679dba8ec4d9ce45884a270b0e22dda, type: 3}
|
||||||
|
m_taaCS: {fileID: 7200000, guid: 3923900e2b41b5e47bc25bfdcbcdc9e6, type: 3}
|
||||||
|
- rid: 4672219873250902053
|
||||||
|
type: {class: ProbeVolumeBakingResources, ns: UnityEngine.Rendering, asm: Unity.RenderPipelines.Core.Runtime}
|
||||||
|
data:
|
||||||
|
m_Version: 1
|
||||||
|
dilationShader: {fileID: 7200000, guid: 6bb382f7de370af41b775f54182e491d, type: 3}
|
||||||
|
subdivideSceneCS: {fileID: 7200000, guid: bb86f1f0af829fd45b2ebddda1245c22, type: 3}
|
||||||
|
voxelizeSceneShader: {fileID: 4800000, guid: c8b6a681c7b4e2e4785ffab093907f9e, type: 3}
|
||||||
|
traceVirtualOffsetCS: {fileID: -6772857160820960102, guid: ff2cbab5da58bf04d82c5f34037ed123, type: 3}
|
||||||
|
traceVirtualOffsetRT: {fileID: -5126288278712620388, guid: ff2cbab5da58bf04d82c5f34037ed123, type: 3}
|
||||||
|
skyOcclusionCS: {fileID: -6772857160820960102, guid: 5a2a534753fbdb44e96c3c78b5a6999d, type: 3}
|
||||||
|
skyOcclusionRT: {fileID: -5126288278712620388, guid: 5a2a534753fbdb44e96c3c78b5a6999d, type: 3}
|
||||||
|
renderingLayerCS: {fileID: -6772857160820960102, guid: 94a070d33e408384bafc1dea4a565df9, type: 3}
|
||||||
|
renderingLayerRT: {fileID: -5126288278712620388, guid: 94a070d33e408384bafc1dea4a565df9, type: 3}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a67b5f1a0a2d042b7ab35bfde91ca6e3
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -166,7 +166,6 @@ GameObject:
|
|||||||
- component: {fileID: 311849592}
|
- component: {fileID: 311849592}
|
||||||
- component: {fileID: 311849591}
|
- component: {fileID: 311849591}
|
||||||
- component: {fileID: 311849595}
|
- component: {fileID: 311849595}
|
||||||
- component: {fileID: 7927220425085558669}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GameCamera
|
m_Name: GameCamera
|
||||||
m_TagString: MainCamera
|
m_TagString: MainCamera
|
||||||
@@ -345,70 +344,6 @@ AudioSource:
|
|||||||
m_PreInfinity: 2
|
m_PreInfinity: 2
|
||||||
m_PostInfinity: 2
|
m_PostInfinity: 2
|
||||||
m_RotationOrder: 4
|
m_RotationOrder: 4
|
||||||
--- !u!114 &7927220425085558669
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 311849590}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 948f4100a11a5c24981795d21301da5c, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
volumeTrigger: {fileID: 311849593}
|
|
||||||
volumeLayer:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 136
|
|
||||||
stopNaNPropagation: 0
|
|
||||||
finalBlitToCameraTarget: 0
|
|
||||||
antialiasingMode: 0
|
|
||||||
temporalAntialiasing:
|
|
||||||
jitterSpread: 0.75
|
|
||||||
sharpness: 0.25
|
|
||||||
stationaryBlending: 0.95
|
|
||||||
motionBlending: 0.85
|
|
||||||
subpixelMorphologicalAntialiasing:
|
|
||||||
quality: 2
|
|
||||||
fastApproximateAntialiasing:
|
|
||||||
fastMode: 1
|
|
||||||
keepAlpha: 0
|
|
||||||
fog:
|
|
||||||
enabled: 1
|
|
||||||
excludeSkybox: 1
|
|
||||||
debugLayer:
|
|
||||||
lightMeter:
|
|
||||||
width: 512
|
|
||||||
height: 256
|
|
||||||
showCurves: 1
|
|
||||||
histogram:
|
|
||||||
width: 512
|
|
||||||
height: 256
|
|
||||||
channel: 3
|
|
||||||
waveform:
|
|
||||||
exposure: 0.12
|
|
||||||
height: 256
|
|
||||||
vectorscope:
|
|
||||||
size: 256
|
|
||||||
exposure: 0.12
|
|
||||||
overlaySettings:
|
|
||||||
linearDepth: 0
|
|
||||||
motionColorIntensity: 4
|
|
||||||
motionGridSize: 64
|
|
||||||
colorBlindnessType: 0
|
|
||||||
colorBlindnessStrength: 1
|
|
||||||
m_Resources: {fileID: 11400000, guid: d82512f9c8e5d4a4d938b575d47f88d4, type: 2}
|
|
||||||
m_ShowToolkit: 0
|
|
||||||
m_ShowCustomSorter: 0
|
|
||||||
breakBeforeColorGrading: 0
|
|
||||||
m_BeforeTransparentBundles: []
|
|
||||||
m_BeforeStackBundles: []
|
|
||||||
m_AfterStackBundles:
|
|
||||||
- assemblyQualifiedName: Pal3.Game.Effect.PostProcessing.Distortion, Pal3.Game,
|
|
||||||
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
|
||||||
- assemblyQualifiedName: Pal3.Game.Effect.PostProcessing.Snow, Pal3.Game, Version=0.0.0.0,
|
|
||||||
Culture=neutral, PublicKeyToken=null
|
|
||||||
--- !u!1 &547426358569454562
|
--- !u!1 &547426358569454562
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1734,11 +1669,11 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
|
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
blurAmount: 4
|
blurAmount: 5
|
||||||
transparency: 1
|
transparency: 1
|
||||||
cornerRadius: 40
|
cornerRadius: 40
|
||||||
additiveTintColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
additiveTintColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||||
multiplyTintColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
multiplyTintColor: {r: 0.4, g: 0.4, b: 0.4, a: 1}
|
||||||
image: {fileID: 6514349001384511054}
|
image: {fileID: 6514349001384511054}
|
||||||
--- !u!1 &2165102651006652904
|
--- !u!1 &2165102651006652904
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -2061,11 +1996,11 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
|
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
blurAmount: 3
|
blurAmount: 4
|
||||||
transparency: 1
|
transparency: 1
|
||||||
cornerRadius: 35
|
cornerRadius: 35
|
||||||
additiveTintColor: {r: 0.039215688, g: 0.039215688, b: 0.039215688, a: 1}
|
additiveTintColor: {r: 0.03, g: 0.03, b: 0.03, a: 1}
|
||||||
multiplyTintColor: {r: 0.54901963, g: 0.54901963, b: 0.54901963, a: 1}
|
multiplyTintColor: {r: 0.46, g: 0.46, b: 0.46, a: 1}
|
||||||
image: {fileID: 3596785283706710040}
|
image: {fileID: 3596785283706710040}
|
||||||
--- !u!1 &2430233534765130901
|
--- !u!1 &2430233534765130901
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -3149,55 +3084,6 @@ RectTransform:
|
|||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 0, y: 220}
|
m_SizeDelta: {x: 0, y: 220}
|
||||||
m_Pivot: {x: 0.5, y: 0}
|
m_Pivot: {x: 0.5, y: 0}
|
||||||
--- !u!1 &4227195284865171261
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 5491488055271105370}
|
|
||||||
- component: {fileID: 8346885185333560231}
|
|
||||||
m_Layer: 3
|
|
||||||
m_Name: PostProcessVolume
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &5491488055271105370
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4227195284865171261}
|
|
||||||
serializedVersion: 2
|
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_ConstrainProportionsScale: 0
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 8627381932629902483}
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!114 &8346885185333560231
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 4227195284865171261}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 8b9a305e18de0c04dbd257a21cd47087, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
sharedProfile: {fileID: 11400000, guid: ff7231d545273e045a612dccba8a02ad, type: 2}
|
|
||||||
isGlobal: 1
|
|
||||||
blendDistance: 0
|
|
||||||
weight: 1
|
|
||||||
priority: 0
|
|
||||||
--- !u!1 &4647852684174260219
|
--- !u!1 &4647852684174260219
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -3767,11 +3653,11 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
|
m_Script: {fileID: 11500000, guid: 47aa715050ab45e09496c366d4e11600, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
blurAmount: 3
|
blurAmount: 4
|
||||||
transparency: 1
|
transparency: 1
|
||||||
cornerRadius: 20
|
cornerRadius: 20
|
||||||
additiveTintColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
additiveTintColor: {r: 0.16, g: 0.16, b: 0.16, a: 1}
|
||||||
multiplyTintColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
multiplyTintColor: {r: 0.7, g: 0.7, b: 0.7, a: 1}
|
||||||
image: {fileID: 4638320210657625687}
|
image: {fileID: 4638320210657625687}
|
||||||
--- !u!1 &6400366477307100862
|
--- !u!1 &6400366477307100862
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -4964,7 +4850,6 @@ Transform:
|
|||||||
- {fileID: 4424067051843665300}
|
- {fileID: 4424067051843665300}
|
||||||
- {fileID: 20216136}
|
- {fileID: 20216136}
|
||||||
- {fileID: 9166793672834059380}
|
- {fileID: 9166793672834059380}
|
||||||
- {fileID: 5491488055271105370}
|
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!114 &8627381932629902480
|
--- !u!114 &8627381932629902480
|
||||||
@@ -5014,8 +4899,7 @@ MonoBehaviour:
|
|||||||
multiFunctionButton: {fileID: 416810473558055248}
|
multiFunctionButton: {fileID: 416810473558055248}
|
||||||
mainMenuButton: {fileID: 7186792160907318265}
|
mainMenuButton: {fileID: 7186792160907318265}
|
||||||
eventSystem: {fileID: 20216138}
|
eventSystem: {fileID: 20216138}
|
||||||
postProcessVolume: {fileID: 8346885185333560231}
|
postProcessProfile: {fileID: 11400000, guid: ff7231d545273e045a612dccba8a02ad, type: 2}
|
||||||
postProcessLayer: {fileID: 7927220425085558669}
|
|
||||||
logoCanvas: {fileID: 6400366477307100862}
|
logoCanvas: {fileID: 6400366477307100862}
|
||||||
logoImage: {fileID: 5537344167455247235}
|
logoImage: {fileID: 5537344167455247235}
|
||||||
--- !u!114 &887733067292281693
|
--- !u!114 &887733067292281693
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Shader "Pal3/Dev"
|
|||||||
|
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
||||||
LOD 100
|
LOD 100
|
||||||
|
|
||||||
ZWrite Off
|
ZWrite Off
|
||||||
@@ -20,13 +20,14 @@ Shader "Pal3/Dev"
|
|||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
CGPROGRAM
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||||
|
HLSLPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
#pragma target 2.0
|
#pragma target 2.0
|
||||||
#pragma multi_compile_fog
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
struct appdata_t {
|
struct appdata_t {
|
||||||
float4 vertex : POSITION;
|
float4 vertex : POSITION;
|
||||||
@@ -37,32 +38,36 @@ Shader "Pal3/Dev"
|
|||||||
struct v2f {
|
struct v2f {
|
||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
float2 texcoord : TEXCOORD0;
|
float2 texcoord : TEXCOORD0;
|
||||||
UNITY_FOG_COORDS(7)
|
float fogFactor : TEXCOORD7;
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
TEXTURE2D(_MainTex);
|
||||||
float4 _MainTex_ST;
|
SAMPLER(sampler_MainTex);
|
||||||
|
|
||||||
|
CBUFFER_START(UnityPerMaterial)
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
v2f vert (appdata_t v)
|
v2f vert (appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||||
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||||
UNITY_TRANSFER_FOG(o,o.vertex);
|
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
half4 frag (v2f i) : SV_Target
|
half4 frag (v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
half4 col = tex2D(_MainTex, i.texcoord);
|
half4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
|
||||||
col.a = 0.5;
|
col.a = 0.5;
|
||||||
UNITY_APPLY_FOG(i.fogCoord, col);
|
col.rgb = MixFog(col.rgb, i.fogFactor);
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,27 +12,25 @@ Shader "Pal3/Opaque"
|
|||||||
|
|
||||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
_LightmapScale("Lightmap Scale", Float) = 1.666667
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Lighting Off
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
|
||||||
|
|
||||||
Tags { "QUEUE" = "Geometry" }
|
|
||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
Tags{ "Qeueue" = "Geometry" }
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||||
Blend Off
|
Blend Off
|
||||||
ZWrite On
|
ZWrite On
|
||||||
|
|
||||||
CGPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
#pragma target 2.0
|
#pragma target 2.0
|
||||||
#pragma multi_compile_fog
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
@@ -47,43 +45,47 @@ Shader "Pal3/Opaque"
|
|||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
float2 texcoord0 : TEXCOORD0;
|
float2 texcoord0 : TEXCOORD0;
|
||||||
float2 texcoord1 : TEXCOORD1;
|
float2 texcoord1 : TEXCOORD1;
|
||||||
UNITY_FOG_COORDS(7)
|
float fogFactor : TEXCOORD7;
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
TEXTURE2D(_MainTex);
|
||||||
float4 _MainTex_ST;
|
SAMPLER(sampler_MainTex);
|
||||||
float4 _TintColor;
|
TEXTURE2D(_ShadowTex);
|
||||||
|
SAMPLER(sampler_ShadowTex);
|
||||||
|
|
||||||
float _HasShadowTex;
|
CBUFFER_START(UnityPerMaterial)
|
||||||
sampler2D _ShadowTex;
|
float4 _MainTex_ST;
|
||||||
float4 _ShadowTex_ST;
|
float4 _TintColor;
|
||||||
float _Exposure;
|
float _HasShadowTex;
|
||||||
|
float4 _ShadowTex_ST;
|
||||||
|
float _LightmapScale;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
v2f vert(appdata_t v)
|
v2f vert(appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
half4 frag(v2f i) : SV_Target
|
half4 frag(v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
half4 color = tex2D(_MainTex, i.texcoord0);
|
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||||
if(_HasShadowTex > 0.5f)
|
if(_HasShadowTex > 0.5f)
|
||||||
{
|
{
|
||||||
color *= tex2D(_ShadowTex, i.texcoord1) / (1 - _Exposure);
|
color.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb * _LightmapScale;
|
||||||
}
|
}
|
||||||
color *= _TintColor;
|
color *= _TintColor;
|
||||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
color.rgb = MixFog(color.rgb, i.fogFactor);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,246 +0,0 @@
|
|||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
||||||
// See LICENSE file in the project root for license information.
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
// Based on cician's shader from https://forum.unity3d.com/threads/simple-optimized-blur-shader.185327/#post-1267642
|
|
||||||
// Based on RoundedCorners.shader from https://github.com/kirevdokimov/Unity-UI-Rounded-Corners
|
|
||||||
// with some modifications
|
|
||||||
|
|
||||||
Shader "Pal3/RoundedFrostedGlass"
|
|
||||||
{
|
|
||||||
Properties
|
|
||||||
{
|
|
||||||
_BlurAmount ("Blur", Range(0, 30)) = 1
|
|
||||||
_Transparency ("Transparency", Range(0, 1)) = 1
|
|
||||||
[HideInInspector] _MainTex ("Masking Texture", 2D) = "white" {}
|
|
||||||
_AdditiveColor ("Additive Tint color", Color) = (0, 0, 0, 0)
|
|
||||||
_MultiplyColor ("Multiply Tint color", Color) = (1, 1, 1, 1)
|
|
||||||
_WidthHeightRadius ("WidthHeightRadius", Vector) = (0, 0, 0, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
Category
|
|
||||||
{
|
|
||||||
// We must be transparent, so other objects are drawn before this one.
|
|
||||||
Tags { "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
|
|
||||||
|
|
||||||
SubShader
|
|
||||||
{
|
|
||||||
Cull Off
|
|
||||||
Lighting Off
|
|
||||||
ZTest [unity_GUIZTestMode]
|
|
||||||
ZWrite Off
|
|
||||||
Blend SrcAlpha OneMinusSrcAlpha
|
|
||||||
|
|
||||||
// Horizontal blur
|
|
||||||
GrabPass
|
|
||||||
{
|
|
||||||
"_HBlur"
|
|
||||||
}
|
|
||||||
|
|
||||||
Pass
|
|
||||||
{
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma vertex vert
|
|
||||||
#pragma fragment frag
|
|
||||||
#pragma fragmentoption ARB_precision_hint_fastest
|
|
||||||
#include "UnityCG.cginc"
|
|
||||||
|
|
||||||
struct appdata_t {
|
|
||||||
float4 vertex : POSITION;
|
|
||||||
float2 texcoord : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct v2f {
|
|
||||||
float4 vertex : POSITION;
|
|
||||||
float4 uvgrab : TEXCOORD0;
|
|
||||||
float2 uvmain : TEXCOORD1;
|
|
||||||
};
|
|
||||||
|
|
||||||
sampler2D _MainTex;
|
|
||||||
float4 _MainTex_ST;
|
|
||||||
|
|
||||||
v2f vert (appdata_t v)
|
|
||||||
{
|
|
||||||
v2f o;
|
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
||||||
|
|
||||||
#if UNITY_UV_STARTS_AT_TOP
|
|
||||||
float scale = -1.0;
|
|
||||||
#else
|
|
||||||
float scale = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
|
|
||||||
o.uvgrab.zw = o.vertex.zw;
|
|
||||||
|
|
||||||
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float roundedRectangle(float2 samplePosition, float absoluteRound, float2 halfSize){
|
|
||||||
halfSize = halfSize - absoluteRound;
|
|
||||||
float2 distanceToEdge = abs(samplePosition) - halfSize;
|
|
||||||
const float outsideDistance = length(max(distanceToEdge, 0));
|
|
||||||
const float insideDistance = min(max(distanceToEdge.x, distanceToEdge.y), 0);
|
|
||||||
return outsideDistance + insideDistance - absoluteRound;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float calcAlpha(float2 samplePosition, float2 size, float radius){
|
|
||||||
const float2 samplePositionTranslated = (samplePosition - .5) * size;
|
|
||||||
const float distToRect = roundedRectangle(samplePositionTranslated, radius * .5, size * .5);
|
|
||||||
const float distanceChange = fwidth(distToRect) * 0.5;
|
|
||||||
return smoothstep(distanceChange, -distanceChange, distToRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fixed4 mixAlpha(fixed4 mainTexColor, fixed4 color, float sdfAlpha){
|
|
||||||
fixed4 col = mainTexColor * color;
|
|
||||||
col.a = min(col.a, sdfAlpha);
|
|
||||||
return col;
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler2D _HBlur;
|
|
||||||
float4 _HBlur_TexelSize;
|
|
||||||
float _BlurAmount;
|
|
||||||
float _Transparency;
|
|
||||||
float4 _AdditiveColor;
|
|
||||||
float4 _MultiplyColor;
|
|
||||||
float4 _WidthHeightRadius;
|
|
||||||
|
|
||||||
half4 frag(v2f i) : COLOR
|
|
||||||
{
|
|
||||||
const float alpha = calcAlpha(i.uvmain, _WidthHeightRadius.xy, _WidthHeightRadius.z);
|
|
||||||
half4 cutoffColor = mixAlpha(tex2D(_MainTex, i.uvmain), _AdditiveColor, alpha);
|
|
||||||
clip(cutoffColor.a - 0.001);
|
|
||||||
|
|
||||||
half4 sum = half4(0,0,0,0);
|
|
||||||
|
|
||||||
#define GRABPIXEL(weight, kernelx) tex2Dproj( _HBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x + _HBlur_TexelSize.x * kernelx * _BlurAmount, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
|
|
||||||
|
|
||||||
sum += GRABPIXEL(0.05, -4.0);
|
|
||||||
sum += GRABPIXEL(0.09, -3.0);
|
|
||||||
sum += GRABPIXEL(0.12, -2.0);
|
|
||||||
sum += GRABPIXEL(0.15, -1.0);
|
|
||||||
sum += GRABPIXEL(0.18, 0.0);
|
|
||||||
sum += GRABPIXEL(0.15, +1.0);
|
|
||||||
sum += GRABPIXEL(0.12, +2.0);
|
|
||||||
sum += GRABPIXEL(0.09, +3.0);
|
|
||||||
sum += GRABPIXEL(0.05, +4.0);
|
|
||||||
|
|
||||||
|
|
||||||
half4 result = half4(sum.r * _MultiplyColor.r + _AdditiveColor.r,
|
|
||||||
sum.g * _MultiplyColor.g + _AdditiveColor.g,
|
|
||||||
sum.b * _MultiplyColor.b + _AdditiveColor.b,
|
|
||||||
tex2D(_MainTex, i.uvmain).a);
|
|
||||||
result.a *= _Transparency;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
|
|
||||||
// Vertical blur
|
|
||||||
GrabPass
|
|
||||||
{
|
|
||||||
"_VBlur"
|
|
||||||
}
|
|
||||||
|
|
||||||
Pass
|
|
||||||
{
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma vertex vert
|
|
||||||
#pragma fragment frag
|
|
||||||
#pragma fragmentoption ARB_precision_hint_fastest
|
|
||||||
#include "UnityCG.cginc"
|
|
||||||
|
|
||||||
struct appdata_t {
|
|
||||||
float4 vertex : POSITION;
|
|
||||||
float2 texcoord: TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct v2f {
|
|
||||||
float4 vertex : POSITION;
|
|
||||||
float4 uvgrab : TEXCOORD0;
|
|
||||||
float2 uvmain : TEXCOORD1;
|
|
||||||
};
|
|
||||||
|
|
||||||
sampler2D _MainTex;
|
|
||||||
float4 _MainTex_ST;
|
|
||||||
|
|
||||||
v2f vert(appdata_t v) {
|
|
||||||
v2f o;
|
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
||||||
|
|
||||||
#if UNITY_UV_STARTS_AT_TOP
|
|
||||||
const float scale = -1.0;
|
|
||||||
#else
|
|
||||||
const float scale = 1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
|
|
||||||
o.uvgrab.zw = o.vertex.zw;
|
|
||||||
|
|
||||||
o.uvmain = TRANSFORM_TEX(v.texcoord, _MainTex);
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float roundedRectangle(float2 samplePosition, float absoluteRound, float2 halfSize){
|
|
||||||
halfSize = halfSize - absoluteRound;
|
|
||||||
float2 distanceToEdge = abs(samplePosition) - halfSize;
|
|
||||||
const float outsideDistance = length(max(distanceToEdge, 0));
|
|
||||||
const float insideDistance = min(max(distanceToEdge.x, distanceToEdge.y), 0);
|
|
||||||
return outsideDistance + insideDistance - absoluteRound;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline float calcAlpha(float2 samplePosition, float2 size, float radius){
|
|
||||||
const float2 samplePositionTranslated = (samplePosition - .5) * size;
|
|
||||||
const float distToRect = roundedRectangle(samplePositionTranslated, radius * .5, size * .5);
|
|
||||||
const float distanceChange = fwidth(distToRect) * 0.5;
|
|
||||||
return smoothstep(distanceChange, -distanceChange, distToRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline fixed4 mixAlpha(fixed4 mainTexColor, fixed4 color, float sdfAlpha){
|
|
||||||
fixed4 col = mainTexColor * color;
|
|
||||||
col.a = min(col.a, sdfAlpha);
|
|
||||||
return col;
|
|
||||||
}
|
|
||||||
|
|
||||||
sampler2D _VBlur;
|
|
||||||
float4 _VBlur_TexelSize;
|
|
||||||
float _BlurAmount;
|
|
||||||
float _Transparency;
|
|
||||||
float4 _AdditiveColor;
|
|
||||||
float4 _MultiplyColor;
|
|
||||||
float4 _WidthHeightRadius;
|
|
||||||
|
|
||||||
half4 frag(v2f i) : COLOR
|
|
||||||
{
|
|
||||||
const float alpha = calcAlpha(i.uvmain, _WidthHeightRadius.xy, _WidthHeightRadius.z);
|
|
||||||
half4 cutoffColor = mixAlpha(tex2D(_MainTex, i.uvmain), _AdditiveColor, alpha);
|
|
||||||
clip(cutoffColor.a - 0.001);
|
|
||||||
|
|
||||||
half4 sum = half4(0,0,0,0);
|
|
||||||
|
|
||||||
#define GRABPIXEL(weight, kernely) tex2Dproj( _VBlur, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _VBlur_TexelSize.y * kernely * _BlurAmount, i.uvgrab.z, i.uvgrab.w))) * weight
|
|
||||||
|
|
||||||
sum += GRABPIXEL(0.05, -4.0);
|
|
||||||
sum += GRABPIXEL(0.09, -3.0);
|
|
||||||
sum += GRABPIXEL(0.12, -2.0);
|
|
||||||
sum += GRABPIXEL(0.15, -1.0);
|
|
||||||
sum += GRABPIXEL(0.18, 0.0);
|
|
||||||
sum += GRABPIXEL(0.15, +1.0);
|
|
||||||
sum += GRABPIXEL(0.12, +2.0);
|
|
||||||
sum += GRABPIXEL(0.09, +3.0);
|
|
||||||
sum += GRABPIXEL(0.05, +4.0);
|
|
||||||
|
|
||||||
half4 result = half4(sum.r * _MultiplyColor.r + _AdditiveColor.r,
|
|
||||||
sum.g * _MultiplyColor.g + _AdditiveColor.g,
|
|
||||||
sum.b * _MultiplyColor.b + _AdditiveColor.b,
|
|
||||||
tex2D(_MainTex, i.uvmain).a);
|
|
||||||
result.a *= _Transparency;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,19 +11,20 @@ Shader "Pal3/Sprite"
|
|||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Tags { "Queue" = "Transparent" }
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" }
|
||||||
LOD 100
|
LOD 100
|
||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||||
Blend SrcAlpha One
|
Blend SrcAlpha One
|
||||||
ZWrite Off
|
ZWrite Off
|
||||||
|
|
||||||
CGPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
struct appdata
|
struct appdata
|
||||||
{
|
{
|
||||||
@@ -37,24 +38,28 @@ Shader "Pal3/Sprite"
|
|||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
TEXTURE2D(_MainTex);
|
||||||
float4 _MainTex_ST;
|
SAMPLER(sampler_MainTex);
|
||||||
|
|
||||||
|
CBUFFER_START(UnityPerMaterial)
|
||||||
|
float4 _MainTex_ST;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
v2f vert (appdata v)
|
v2f vert (appdata v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
fixed4 frag (v2f i) : SV_Target
|
half4 frag (v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
fixed4 col = tex2D(_MainTex, i.uv);
|
half4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uv);
|
||||||
col.a = 1.0f; // force alpha to 1 to avoid transparency
|
col.a = 1.0f; // force alpha to 1 to avoid transparency
|
||||||
return col;
|
return col;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ Shader "Pal3/Transparent"
|
|||||||
|
|
||||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
_LightmapScale("Lightmap Scale", Float) = 1.666667
|
||||||
|
|
||||||
[Enum(UnityEngine.Rendering.BlendMode)]
|
[Enum(UnityEngine.Rendering.BlendMode)]
|
||||||
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
|
_BlendSrcFactor("Source Blend Factor", int) = 5 // BlendMode.SrcAlpha as Default
|
||||||
@@ -23,23 +23,22 @@ Shader "Pal3/Transparent"
|
|||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Lighting Off
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" }
|
||||||
|
|
||||||
Tags { "Queue" = "Transparent" }
|
|
||||||
|
|
||||||
// Pass 2 ,transparent part
|
// Pass 2 ,transparent part
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||||
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||||
ZWrite Off
|
ZWrite Off
|
||||||
|
|
||||||
CGPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
#pragma target 2.0
|
#pragma target 2.0
|
||||||
#pragma multi_compile_fog
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
@@ -54,52 +53,53 @@ Shader "Pal3/Transparent"
|
|||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
float2 texcoord0 : TEXCOORD0;
|
float2 texcoord0 : TEXCOORD0;
|
||||||
float2 texcoord1 : TEXCOORD1;
|
float2 texcoord1 : TEXCOORD1;
|
||||||
UNITY_FOG_COORDS(7)
|
float fogFactor : TEXCOORD7;
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
TEXTURE2D(_MainTex);
|
||||||
float4 _MainTex_ST;
|
SAMPLER(sampler_MainTex);
|
||||||
float _Threshold;
|
TEXTURE2D(_ShadowTex);
|
||||||
|
SAMPLER(sampler_ShadowTex);
|
||||||
|
|
||||||
float _HasShadowTex;
|
CBUFFER_START(UnityPerMaterial)
|
||||||
sampler2D _ShadowTex;
|
float4 _MainTex_ST;
|
||||||
float4 _ShadowTex_ST;
|
float _Threshold;
|
||||||
float _Exposure;
|
float _HasShadowTex;
|
||||||
|
float4 _ShadowTex_ST;
|
||||||
float4 _TintColor;
|
float _LightmapScale;
|
||||||
|
float4 _TintColor;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
v2f vert(appdata_t v)
|
v2f vert(appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
half4 frag(v2f i) : SV_Target
|
half4 frag(v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
half4 color = tex2D(_MainTex, i.texcoord0);
|
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||||
const float alpha = color.a;
|
if (color.a >= _Threshold || (color.a <= 0.0 && _Threshold <= 1.0))
|
||||||
if(color.a >= _Threshold)
|
|
||||||
{
|
{
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_HasShadowTex > 0.5f)
|
if(_HasShadowTex > 0.5f)
|
||||||
{
|
{
|
||||||
color *= tex2D(_ShadowTex, i.texcoord1) / (1 - _Exposure);
|
color.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb * _LightmapScale;
|
||||||
color.a = alpha;
|
|
||||||
}
|
}
|
||||||
color *= _TintColor;
|
color *= _TintColor;
|
||||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
color.rgb = MixFog(color.rgb, i.fogFactor);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,27 +13,26 @@ Shader "Pal3/TransparentOpaquePart"
|
|||||||
|
|
||||||
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
_HasShadowTex ("Has Shadow Texture", Range(0, 1)) = 0.0
|
||||||
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
_ShadowTex ("Shadow Texture", 2D) = "white" {}
|
||||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.4
|
_LightmapScale("Lightmap Scale", Float) = 1.666667
|
||||||
}
|
}
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Lighting Off
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
|
||||||
|
|
||||||
Tags { "Qeueue" = "Geometry" }
|
|
||||||
|
|
||||||
// pass 1 , opaque part
|
// pass 1 , opaque part
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||||
Blend Off
|
Blend Off
|
||||||
ZWrite On
|
ZWrite On
|
||||||
|
|
||||||
CGPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
#pragma target 2.0
|
#pragma target 2.0
|
||||||
#pragma multi_compile_fog
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
@@ -48,47 +47,50 @@ Shader "Pal3/TransparentOpaquePart"
|
|||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
float2 texcoord0 : TEXCOORD0;
|
float2 texcoord0 : TEXCOORD0;
|
||||||
float2 texcoord1 : TEXCOORD1;
|
float2 texcoord1 : TEXCOORD1;
|
||||||
UNITY_FOG_COORDS(7)
|
float fogFactor : TEXCOORD7;
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
TEXTURE2D(_MainTex);
|
||||||
float4 _MainTex_ST;
|
SAMPLER(sampler_MainTex);
|
||||||
float _Threshold;
|
TEXTURE2D(_ShadowTex);
|
||||||
|
SAMPLER(sampler_ShadowTex);
|
||||||
|
|
||||||
float _HasShadowTex;
|
CBUFFER_START(UnityPerMaterial)
|
||||||
sampler2D _ShadowTex;
|
float4 _MainTex_ST;
|
||||||
float4 _ShadowTex_ST;
|
float _Threshold;
|
||||||
float _Exposure;
|
float _HasShadowTex;
|
||||||
|
float4 _ShadowTex_ST;
|
||||||
float4 _TintColor;
|
float _LightmapScale;
|
||||||
|
float4 _TintColor;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
v2f vert(appdata_t v)
|
v2f vert(appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
half4 frag(v2f i) : SV_Target
|
half4 frag(v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
half4 color = tex2D(_MainTex, i.texcoord0);
|
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||||
clip(color.a - _Threshold);
|
clip(color.a - _Threshold);
|
||||||
|
|
||||||
if(_HasShadowTex > 0.5f)
|
if(_HasShadowTex > 0.5f)
|
||||||
{
|
{
|
||||||
color *= tex2D(_ShadowTex, i.texcoord1) / (1 - _Exposure);
|
color.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb * _LightmapScale;
|
||||||
}
|
}
|
||||||
color *= _TintColor;
|
color *= _TintColor;
|
||||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
color.rgb = MixFog(color.rgb, i.fogFactor);
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ Shader "Pal3/Water"
|
|||||||
// alpha value
|
// alpha value
|
||||||
_Alpha ("Alpha",Range(0, 1)) = 0.5
|
_Alpha ("Alpha",Range(0, 1)) = 0.5
|
||||||
|
|
||||||
_Exposure("Exposure Amount", Range(0.1, 1.0)) = 0.3
|
_LightmapScale("Lightmap Scale", Float) = 1.428571
|
||||||
|
|
||||||
// pre baked shadow texture
|
// pre baked shadow texture
|
||||||
_ShadowTex ("Shadow texture", 2D) = "white" {}
|
_ShadowTex ("Shadow texture", 2D) = "white" {}
|
||||||
@@ -28,22 +28,21 @@ Shader "Pal3/Water"
|
|||||||
|
|
||||||
SubShader
|
SubShader
|
||||||
{
|
{
|
||||||
Lighting Off
|
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent-1" } // -1 to fix sorting order issue with semi-transparent trees etc.
|
||||||
|
|
||||||
Tags { "QUEUE" = "Transparent-1" } // -1 to fix sorting order issue with semi-transparent trees etc.
|
|
||||||
|
|
||||||
Pass
|
Pass
|
||||||
{
|
{
|
||||||
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
||||||
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
Blend [_BlendSrcFactor] [_BlendDstFactor]
|
||||||
ZWrite Off
|
ZWrite Off
|
||||||
|
|
||||||
CGPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma vertex vert
|
#pragma vertex vert
|
||||||
#pragma fragment frag
|
#pragma fragment frag
|
||||||
#pragma target 2.0
|
#pragma target 2.0
|
||||||
#pragma multi_compile_fog
|
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"
|
||||||
|
|
||||||
#include "UnityCG.cginc"
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||||
|
|
||||||
struct appdata_t
|
struct appdata_t
|
||||||
{
|
{
|
||||||
@@ -58,42 +57,48 @@ Shader "Pal3/Water"
|
|||||||
float4 vertex : SV_POSITION;
|
float4 vertex : SV_POSITION;
|
||||||
float2 texcoord0 : TEXCOORD0;
|
float2 texcoord0 : TEXCOORD0;
|
||||||
float2 texcoord1 : TEXCOORD1;
|
float2 texcoord1 : TEXCOORD1;
|
||||||
UNITY_FOG_COORDS(7)
|
float fogFactor : TEXCOORD7;
|
||||||
UNITY_VERTEX_OUTPUT_STEREO
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
};
|
};
|
||||||
|
|
||||||
sampler2D _MainTex;
|
TEXTURE2D(_MainTex);
|
||||||
float4 _MainTex_ST;
|
SAMPLER(sampler_MainTex);
|
||||||
|
TEXTURE2D(_ShadowTex);
|
||||||
|
SAMPLER(sampler_ShadowTex);
|
||||||
|
|
||||||
float _Alpha;
|
CBUFFER_START(UnityPerMaterial)
|
||||||
float _Exposure;
|
float4 _MainTex_ST;
|
||||||
|
float _Alpha;
|
||||||
float _HasShadowTex;
|
float _LightmapScale;
|
||||||
sampler2D _ShadowTex;
|
float _HasShadowTex;
|
||||||
float4 _ShadowTex_ST;
|
float4 _ShadowTex_ST;
|
||||||
|
CBUFFER_END
|
||||||
|
|
||||||
v2f vert(appdata_t v)
|
v2f vert(appdata_t v)
|
||||||
{
|
{
|
||||||
v2f o;
|
v2f o;
|
||||||
UNITY_SETUP_INSTANCE_ID(v);
|
UNITY_SETUP_INSTANCE_ID(v);
|
||||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
o.vertex = TransformObjectToHClip(v.vertex.xyz);
|
||||||
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
o.texcoord0 = TRANSFORM_TEX(v.texcoord0, _MainTex);
|
||||||
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
o.texcoord1 = TRANSFORM_TEX(v.texcoord1, _ShadowTex);
|
||||||
UNITY_TRANSFER_FOG(o, o.vertex);
|
o.fogFactor = ComputeFogFactor(o.vertex.z);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
half4 frag(v2f i) : SV_Target
|
half4 frag(v2f i) : SV_Target
|
||||||
{
|
{
|
||||||
const half4 color = tex2D(_MainTex, i.texcoord0);
|
half4 mixedColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord0);
|
||||||
const half4 colorShadow = tex2D(_ShadowTex, i.texcoord1);
|
if (_HasShadowTex > 0.5)
|
||||||
half4 mixedColor = color * colorShadow / (1 - _Exposure);
|
{
|
||||||
mixedColor.a = _Alpha; // use global alpha
|
mixedColor.rgb *= SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, i.texcoord1).rgb;
|
||||||
UNITY_APPLY_FOG(i.fogCoord, mixedColor);
|
}
|
||||||
|
mixedColor.rgb *= _LightmapScale;
|
||||||
|
mixedColor.a = _Alpha;
|
||||||
|
mixedColor.rgb = MixFog(mixedColor.rgb, i.fogFactor);
|
||||||
return mixedColor;
|
return mixedColor;
|
||||||
}
|
}
|
||||||
ENDCG
|
ENDHLSL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||||
|
// See LICENSE file in the project root for license information.
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Editor
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEditor.Build;
|
||||||
|
using UnityEditor.Build.Reporting;
|
||||||
|
|
||||||
|
internal sealed class PrivateAssetBuildGuard : IPreprocessBuildWithReport
|
||||||
|
{
|
||||||
|
private const string PrivateBuildVariable = "PAL3_ALLOW_PRIVATE_ASSETS";
|
||||||
|
private const string StoryVfxPath = "/Resources/Prefabs/VFX/";
|
||||||
|
private const string HovlStudioPath = "/Hovl Studio/";
|
||||||
|
private const string RealToonPath = "/RealToon/";
|
||||||
|
private const string LegacyToonMaterialsPath = "Assets/Resources/Materials/";
|
||||||
|
private const string Pal3VfxReadme = "Assets/Resources/Prefabs/VFX/PAL3/README.txt";
|
||||||
|
private const string Pal3AVfxReadme = "Assets/Resources/Prefabs/VFX/PAL3A/README.txt";
|
||||||
|
|
||||||
|
internal static bool PrivateBuildEnabled =>
|
||||||
|
Environment.GetEnvironmentVariable(PrivateBuildVariable) == "1" &&
|
||||||
|
string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CI")) &&
|
||||||
|
string.IsNullOrEmpty(Environment.GetEnvironmentVariable("GITHUB_ACTIONS"));
|
||||||
|
|
||||||
|
public int callbackOrder => int.MaxValue;
|
||||||
|
|
||||||
|
public void OnPreprocessBuild(BuildReport report) => Validate();
|
||||||
|
|
||||||
|
internal static void Validate()
|
||||||
|
{
|
||||||
|
if (PrivateBuildEnabled) return;
|
||||||
|
|
||||||
|
string privateAsset = AssetDatabase.GetAllAssetPaths().FirstOrDefault(IsPrivateAsset);
|
||||||
|
if (privateAsset == null) return;
|
||||||
|
|
||||||
|
throw new BuildFailedException(
|
||||||
|
$"Local optional VFX or legacy Toon assets are installed ({privateAsset}). " +
|
||||||
|
"Use a clean checkout for public builds. " +
|
||||||
|
$"For a private local build, launch Unity with {PrivateBuildVariable}=1.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPrivateAsset(string assetPath)
|
||||||
|
{
|
||||||
|
if (assetPath.IndexOf(HovlStudioPath, StringComparison.OrdinalIgnoreCase) < 0 &&
|
||||||
|
assetPath.IndexOf(RealToonPath, StringComparison.OrdinalIgnoreCase) < 0 &&
|
||||||
|
!assetPath.StartsWith(LegacyToonMaterialsPath, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
assetPath.IndexOf(StoryVfxPath, StringComparison.OrdinalIgnoreCase) < 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !assetPath.Equals(Pal3VfxReadme, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!assetPath.Equals(Pal3AVfxReadme, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!AssetDatabase.IsValidFolder(assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ac41b9b3ac5641d98126273f7efb452f
|
||||||
@@ -131,13 +131,16 @@ namespace Editor
|
|||||||
|
|
||||||
private static void BuildGame(Pal3BuildTarget buildTarget)
|
private static void BuildGame(Pal3BuildTarget buildTarget)
|
||||||
{
|
{
|
||||||
|
PrivateAssetBuildGuard.Validate();
|
||||||
|
|
||||||
BuildTargetGroup targetGroupBeforeBuild = EditorUserBuildSettings.selectedBuildTargetGroup;
|
BuildTargetGroup targetGroupBeforeBuild = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||||
BuildTarget targetBeforeBuild = EditorUserBuildSettings.activeBuildTarget;
|
BuildTarget targetBeforeBuild = EditorUserBuildSettings.activeBuildTarget;
|
||||||
|
|
||||||
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
|
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game", "", "");
|
||||||
if (string.IsNullOrWhiteSpace(buildOutputPath)) return;
|
if (string.IsNullOrWhiteSpace(buildOutputPath)) return;
|
||||||
|
|
||||||
buildOutputPath += $"{DirSeparator}{PlayerSettings.bundleVersion}{DirSeparator}";
|
string versionFolder = GetVersionFolderName(PrivateAssetBuildGuard.PrivateBuildEnabled);
|
||||||
|
buildOutputPath += $"{DirSeparator}{versionFolder}{DirSeparator}";
|
||||||
|
|
||||||
var buildConfigurations = new[]
|
var buildConfigurations = new[]
|
||||||
{
|
{
|
||||||
@@ -268,16 +271,30 @@ namespace Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string GetVersionFolderName(bool privateBuild)
|
||||||
|
{
|
||||||
|
return PlayerSettings.bundleVersion + (privateBuild ? "-Private" : "");
|
||||||
|
}
|
||||||
|
|
||||||
private static void ZipReleaseFiles()
|
private static void ZipReleaseFiles()
|
||||||
{
|
{
|
||||||
|
string versionFolder = GetVersionFolderName(PrivateAssetBuildGuard.PrivateBuildEnabled);
|
||||||
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game",
|
string buildOutputPath = EditorUtility.SaveFolderPanel("Choose Location of Built Game",
|
||||||
$"{PlayerSettings.bundleVersion}", $"{PlayerSettings.bundleVersion}");
|
versionFolder, versionFolder);
|
||||||
if (string.IsNullOrWhiteSpace(buildOutputPath)) return;
|
if (string.IsNullOrWhiteSpace(buildOutputPath)) return;
|
||||||
|
ZipReleaseFiles(buildOutputPath);
|
||||||
|
}
|
||||||
|
|
||||||
if (!buildOutputPath.EndsWith($"{PlayerSettings.bundleVersion}"))
|
private static void ZipReleaseFiles(string buildOutputPath)
|
||||||
|
{
|
||||||
|
string selectedFolder = Path.GetFileName(buildOutputPath.TrimEnd(
|
||||||
|
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar));
|
||||||
|
bool privateBuild = selectedFolder == GetVersionFolderName(true);
|
||||||
|
if (!privateBuild && selectedFolder != GetVersionFolderName(false))
|
||||||
{
|
{
|
||||||
Debug.LogError($"Invalid build output path: {buildOutputPath}. " +
|
Debug.LogError($"Invalid build output path: {buildOutputPath}. " +
|
||||||
$"Please choose the current release build folder \"{PlayerSettings.bundleVersion}\"");
|
$"Please choose the current release build folder \"{GetVersionFolderName(false)}\" " +
|
||||||
|
$"or \"{GetVersionFolderName(true)}\".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +313,7 @@ namespace Editor
|
|||||||
foreach ((string folderPath, Pal3BuildTarget target) in buildTargets)
|
foreach ((string folderPath, Pal3BuildTarget target) in buildTargets)
|
||||||
{
|
{
|
||||||
string fullPath = $"{buildOutputPath}{DirSeparator}{folderPath}";
|
string fullPath = $"{buildOutputPath}{DirSeparator}{folderPath}";
|
||||||
string zipFileName = $"{GameConstants.AppName}_v{PlayerSettings.bundleVersion}_{target.ToString()}.zip";
|
string zipFileName = $"{GameConstants.AppName}_v{GetVersionFolderName(privateBuild)}_{target.ToString()}.zip";
|
||||||
string zipFilePath = $"{releaseDirPath}{DirSeparator}{zipFileName}";
|
string zipFilePath = $"{releaseDirPath}{DirSeparator}{zipFileName}";
|
||||||
|
|
||||||
if (File.Exists(fullPath) || Directory.Exists(fullPath))
|
if (File.Exists(fullPath) || Directory.Exists(fullPath))
|
||||||
|
|||||||
@@ -0,0 +1,99 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
namespace Editor
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Keeps normal Save Project operations from persisting temporary MSAA and shadow budgets.
|
||||||
|
/// SaveAssetIfDirty bypasses OnWillSaveAssets and is outside this safeguard.
|
||||||
|
/// </summary>
|
||||||
|
[InitializeOnLoad]
|
||||||
|
internal sealed class RuntimePipelineAssetSaveGuard : AssetModificationProcessor
|
||||||
|
{
|
||||||
|
private const string SnapshotKey = "Pal3.RuntimePipelineAssetSaveGuard.v1";
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
private sealed class Snapshot
|
||||||
|
{
|
||||||
|
public string Guid;
|
||||||
|
public int Msaa;
|
||||||
|
public int ShadowAtlas;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RuntimePipelineAssetSaveGuard()
|
||||||
|
{
|
||||||
|
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||||
|
EditorApplication.delayCall += () =>
|
||||||
|
{
|
||||||
|
if (!EditorApplication.isPlayingOrWillChangePlaymode) RestoreAndClear();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Snapshot ReadSnapshot()
|
||||||
|
{
|
||||||
|
string json = SessionState.GetString(SnapshotKey, "");
|
||||||
|
return string.IsNullOrEmpty(json) ? null : JsonUtility.FromJson<Snapshot>(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnPlayModeStateChanged(PlayModeStateChange state)
|
||||||
|
{
|
||||||
|
if (state == PlayModeStateChange.ExitingEditMode)
|
||||||
|
{
|
||||||
|
SessionState.EraseString(SnapshotKey);
|
||||||
|
var pipeline = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||||
|
string guid = pipeline != null ? AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(pipeline)) : "";
|
||||||
|
if (string.IsNullOrEmpty(guid)) return;
|
||||||
|
SessionState.SetString(SnapshotKey, JsonUtility.ToJson(new Snapshot
|
||||||
|
{
|
||||||
|
Guid = guid,
|
||||||
|
Msaa = pipeline.msaaSampleCount,
|
||||||
|
ShadowAtlas = pipeline.additionalLightsShadowmapResolution,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
else if (state == PlayModeStateChange.ExitingPlayMode)
|
||||||
|
{
|
||||||
|
Restore();
|
||||||
|
}
|
||||||
|
else if (state == PlayModeStateChange.EnteredEditMode)
|
||||||
|
{
|
||||||
|
RestoreAndClear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Restore()
|
||||||
|
{
|
||||||
|
Snapshot snapshot = ReadSnapshot();
|
||||||
|
if (snapshot == null) return;
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(snapshot.Guid);
|
||||||
|
if (string.IsNullOrEmpty(path)) return;
|
||||||
|
var pipeline = AssetDatabase.LoadAssetAtPath<UniversalRenderPipelineAsset>(path);
|
||||||
|
if (pipeline == null) return;
|
||||||
|
pipeline.msaaSampleCount = snapshot.Msaa;
|
||||||
|
pipeline.additionalLightsShadowmapResolution = snapshot.ShadowAtlas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RestoreAndClear()
|
||||||
|
{
|
||||||
|
Restore();
|
||||||
|
SessionState.EraseString(SnapshotKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string[] OnWillSaveAssets(string[] paths)
|
||||||
|
{
|
||||||
|
Snapshot snapshot = ReadSnapshot();
|
||||||
|
if (!EditorApplication.isPlayingOrWillChangePlaymode && snapshot == null) return paths;
|
||||||
|
|
||||||
|
string originalPath = snapshot != null ? AssetDatabase.GUIDToAssetPath(snapshot.Guid) : "";
|
||||||
|
// When this script is first imported during Play, there may be no pre-Play snapshot.
|
||||||
|
var pipeline = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||||
|
string currentPath = pipeline != null ? AssetDatabase.GetAssetPath(pipeline) : "";
|
||||||
|
return paths.Where(path => path != originalPath && path != currentPath).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a13814d6afa0483d9a3a8b433ffaf97f
|
||||||
@@ -10,6 +10,7 @@ namespace Editor.SourceGenerator.Base
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
public static class Utility
|
public static class Utility
|
||||||
{
|
{
|
||||||
@@ -45,9 +46,7 @@ namespace Editor.SourceGenerator.Base
|
|||||||
|
|
||||||
public static IEnumerable<Type> GetTypesOfInterface(Type interfaceType)
|
public static IEnumerable<Type> GetTypesOfInterface(Type interfaceType)
|
||||||
{
|
{
|
||||||
return AppDomain.CurrentDomain.GetAssemblies()
|
return TypeCache.GetTypesDerivedFrom(interfaceType).Where(type => type.IsClass);
|
||||||
.SelectMany(assembly => assembly.GetTypes())
|
|
||||||
.Where(t => t.IsClass && t.GetInterfaces().Contains(interfaceType));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@
|
|||||||
namespace Engine.Core.Implementation
|
namespace Engine.Core.Implementation
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using Abstraction;
|
using Abstraction;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -25,11 +24,6 @@ namespace Engine.Core.Implementation
|
|||||||
get { return _gameEntity ??= new GameEntity(base.gameObject); }
|
get { return _gameEntity ??= new GameEntity(base.gameObject); }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected new void StartCoroutine(IEnumerator coroutine)
|
|
||||||
{
|
|
||||||
base.StartCoroutine(coroutine);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected virtual void OnEnableGameEntity() {}
|
protected virtual void OnEnableGameEntity() {}
|
||||||
|
|
||||||
protected virtual void OnDisableGameEntity() {}
|
protected virtual void OnDisableGameEntity() {}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace Engine.Renderer
|
|||||||
using Core.Implementation;
|
using Core.Implementation;
|
||||||
using Extensions;
|
using Extensions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
public sealed class StaticMeshRenderer : GameEntityScript, IDisposable
|
public sealed class StaticMeshRenderer : GameEntityScript, IDisposable
|
||||||
{
|
{
|
||||||
@@ -33,10 +34,8 @@ namespace Engine.Renderer
|
|||||||
{
|
{
|
||||||
Dispose();
|
Dispose();
|
||||||
|
|
||||||
_materials = materials;
|
|
||||||
_meshRenderer = GameEntity.AddComponent<MeshRenderer>();
|
_meshRenderer = GameEntity.AddComponent<MeshRenderer>();
|
||||||
_meshRenderer.sharedMaterials = materials.Select(material => material.NativeObject as Material).ToArray();
|
SetMaterials(materials);
|
||||||
_meshRenderer.receiveShadows = _receiveShadows;
|
|
||||||
|
|
||||||
_meshFilter = GameEntity.AddComponent<MeshFilter>();
|
_meshFilter = GameEntity.AddComponent<MeshFilter>();
|
||||||
|
|
||||||
@@ -83,16 +82,28 @@ namespace Engine.Renderer
|
|||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _receiveShadows = true; // Default to receive shadows
|
private static readonly int ReceiveShadowsId = Shader.PropertyToID("_ReceiveShadows");
|
||||||
public bool ReceiveShadows
|
private bool _shadowsDisabled;
|
||||||
|
|
||||||
|
public void SetMaterials(IMaterial[] materials)
|
||||||
{
|
{
|
||||||
get => _receiveShadows;
|
_meshRenderer.sharedMaterials = materials.Select(material => material.NativeObject as Material).ToArray();
|
||||||
set
|
_materials = materials;
|
||||||
|
if (_shadowsDisabled) DisableShadows();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableShadows()
|
||||||
|
{
|
||||||
|
_shadowsDisabled = true;
|
||||||
|
if (_meshRenderer == null) return;
|
||||||
|
|
||||||
|
_meshRenderer.receiveShadows = false;
|
||||||
|
_meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
|
||||||
|
foreach (IMaterial material in _materials)
|
||||||
{
|
{
|
||||||
_receiveShadows = value;
|
if (material.NativeObject is Material unityMaterial && unityMaterial.HasProperty(ReceiveShadowsId))
|
||||||
if (_meshRenderer != null)
|
|
||||||
{
|
{
|
||||||
_meshRenderer.receiveShadows = value;
|
unityMaterial.SetFloat(ReceiveShadowsId, 0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,11 +125,6 @@ namespace Engine.Renderer
|
|||||||
return _meshFilter.sharedMesh.bounds;
|
return _meshFilter.sharedMesh.bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMaterial[] GetMaterials()
|
|
||||||
{
|
|
||||||
return _materials;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_meshFilter != null)
|
if (_meshFilter != null)
|
||||||
@@ -130,6 +136,7 @@ namespace Engine.Renderer
|
|||||||
|
|
||||||
if (_meshRenderer != null)
|
if (_meshRenderer != null)
|
||||||
{
|
{
|
||||||
|
_meshRenderer.enabled = false;
|
||||||
_meshRenderer.Destroy();
|
_meshRenderer.Destroy();
|
||||||
_meshRenderer = null;
|
_meshRenderer = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
namespace Engine.UI
|
namespace Engine.UI
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
using Extensions;
|
using Extensions;
|
||||||
using Logging;
|
using Logging;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -21,6 +22,7 @@ namespace Engine.UI
|
|||||||
private static readonly int AdditiveColorPropertyId = Shader.PropertyToID("_AdditiveColor");
|
private static readonly int AdditiveColorPropertyId = Shader.PropertyToID("_AdditiveColor");
|
||||||
private static readonly int MultiplyColorPropertyId = Shader.PropertyToID("_MultiplyColor");
|
private static readonly int MultiplyColorPropertyId = Shader.PropertyToID("_MultiplyColor");
|
||||||
|
|
||||||
|
private static readonly HashSet<RoundedFrostedGlassImage> EnabledPanels = new();
|
||||||
private static Shader _shader;
|
private static Shader _shader;
|
||||||
|
|
||||||
[SerializeField] public float blurAmount = 1f;
|
[SerializeField] public float blurAmount = 1f;
|
||||||
@@ -33,6 +35,29 @@ namespace Engine.UI
|
|||||||
|
|
||||||
[HideInInspector, SerializeField] private MaskableGraphic image;
|
[HideInInspector, SerializeField] private MaskableGraphic image;
|
||||||
|
|
||||||
|
public static bool HasVisibleOverlay(int targetDisplay)
|
||||||
|
{
|
||||||
|
foreach (var panel in EnabledPanels)
|
||||||
|
{
|
||||||
|
var graphic = panel.image;
|
||||||
|
if (graphic == null || !graphic.isActiveAndEnabled || graphic.color.a <= 0f ||
|
||||||
|
graphic.canvasRenderer.GetInheritedAlpha() <= 0f)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Canvas canvas = graphic.canvas;
|
||||||
|
if (canvas != null && canvas.isActiveAndEnabled &&
|
||||||
|
canvas.rootCanvas.renderMode == RenderMode.ScreenSpaceOverlay &&
|
||||||
|
canvas.rootCanvas.targetDisplay == targetDisplay)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetMaterialBlurAmount(float newBlurAmount)
|
public void SetMaterialBlurAmount(float newBlurAmount)
|
||||||
{
|
{
|
||||||
if (_material == null) return;
|
if (_material == null) return;
|
||||||
@@ -55,6 +80,12 @@ namespace Engine.UI
|
|||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
|
EnabledPanels.Add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
EnabledPanels.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Engine.Utilities
|
|||||||
{
|
{
|
||||||
if (_instance != null) return _instance;
|
if (_instance != null) return _instance;
|
||||||
|
|
||||||
_instance = (T)FindFirstObjectByType(typeof(T));
|
_instance = FindAnyObjectByType<T>();
|
||||||
|
|
||||||
if (_instance != null) return _instance;
|
if (_instance != null) return _instance;
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ namespace Pal3.Core.Command
|
|||||||
private bool _isInitialized = false;
|
private bool _isInitialized = false;
|
||||||
private readonly Dictionary<Type, PropertyInfo[]> _sceCommandToActorIdPropertiesCache = new();
|
private readonly Dictionary<Type, PropertyInfo[]> _sceCommandToActorIdPropertiesCache = new();
|
||||||
|
|
||||||
public void Init()
|
public void Init(IEnumerable<Assembly> commandAssemblies)
|
||||||
{
|
{
|
||||||
if (_isInitialized) return;
|
if (_isInitialized) return;
|
||||||
|
|
||||||
IEnumerable<Type> commandTypes = AppDomain.CurrentDomain.GetAssemblies()
|
IEnumerable<Type> commandTypes = commandAssemblies
|
||||||
.SelectMany(assembly => assembly.GetTypes())
|
.SelectMany(assembly => assembly.GetTypes())
|
||||||
.Where(t => t.IsClass && t.GetInterfaces().Contains(typeof(ICommand)));
|
.Where(t => t.IsClass && t.GetInterfaces().Contains(typeof(ICommand)));
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace Pal3.Core.DataReader.Dxt
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
a = (byte) ((*(src + (alphaIndex-1) / 2) & 0xF0) | ((*(src + (alphaIndex-1) / 2) & 0xF0) << 4));
|
a = (byte) ((*(src + (alphaIndex-1) / 2) & 0xF0) | ((*(src + (alphaIndex-1) / 2) & 0xF0) >> 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
alphaIndex++;
|
alphaIndex++;
|
||||||
|
|||||||
@@ -96,17 +96,20 @@ namespace Pal3.Core.DataReader.Gdb
|
|||||||
public string ModelId; // 战斗角色模型ID
|
public string ModelId; // 战斗角色模型ID
|
||||||
public string IconId; // 战斗角色图标ID
|
public string IconId; // 战斗角色图标ID
|
||||||
|
|
||||||
// 角色基础五灵属性值
|
// 角色基础五灵属性值(由 GDB 文件读取)
|
||||||
public Dictionary<ElementType, int> ElementAttributeValues;
|
[field: System.NonSerialized]
|
||||||
|
public Dictionary<ElementType, int> ElementAttributeValues { get; set; }
|
||||||
|
|
||||||
public string Name; // 战斗角色名称
|
public string Name; // 战斗角色名称
|
||||||
public int Level; // 战斗角色等级
|
public int Level; // 战斗角色等级
|
||||||
|
|
||||||
// 角色基础属性值
|
// 角色基础属性值
|
||||||
public Dictionary<ActorAttributeType, int> AttributeValues;
|
[field: System.NonSerialized]
|
||||||
|
public Dictionary<ActorAttributeType, int> AttributeValues { get; set; }
|
||||||
|
|
||||||
// 战斗状态影响类型
|
// 战斗状态影响类型
|
||||||
public Dictionary<ActorCombatStateType, CombatStateImpactType> CombatStateImpactTypes;
|
[field: System.NonSerialized]
|
||||||
|
public Dictionary<ActorCombatStateType, CombatStateImpactType> CombatStateImpactTypes { get; set; }
|
||||||
|
|
||||||
public int MaxRound; // 指定最大回合数 (保存或者初始化的时候用,数据库文件里均为-1,主角为0)
|
public int MaxRound; // 指定最大回合数 (保存或者初始化的时候用,数据库文件里均为-1,主角为0)
|
||||||
public int SpecialActionId; // 特殊动作ID
|
public int SpecialActionId; // 特殊动作ID
|
||||||
|
|||||||
@@ -61,8 +61,9 @@ namespace Pal3.Core.DataReader.Mv3
|
|||||||
public GameBoxVector3 GameBoxBoundsMin;
|
public GameBoxVector3 GameBoxBoundsMin;
|
||||||
public GameBoxVector3 GameBoxBoundsMax;
|
public GameBoxVector3 GameBoxBoundsMax;
|
||||||
public Mv3Attribute[] Attributes;
|
public Mv3Attribute[] Attributes;
|
||||||
public GameBoxVector3[] GameBoxNormals;
|
|
||||||
public int[] GameBoxTriangles;
|
public int[] GameBoxTriangles;
|
||||||
|
public int[] NormalIndices;
|
||||||
|
public int NormalCount;
|
||||||
public GameBoxVector2[] Uvs;
|
public GameBoxVector2[] Uvs;
|
||||||
public Mv3AnimationKeyFrame[] KeyFrames;
|
public Mv3AnimationKeyFrame[] KeyFrames;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
namespace Pal3.Core.DataReader.Mv3
|
namespace Pal3.Core.DataReader.Mv3
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Primitives;
|
using Primitives;
|
||||||
@@ -148,44 +149,61 @@ namespace Pal3.Core.DataReader.Mv3
|
|||||||
Mv3VertFrame[] vertFrames,
|
Mv3VertFrame[] vertFrames,
|
||||||
GameBoxVector2[] texCoords)
|
GameBoxVector2[] texCoords)
|
||||||
{
|
{
|
||||||
int numberOfTriangles = attributes[0].IndexBuffers.Length * 3;
|
Mv3IndexBuffer[] faces = attributes[0].IndexBuffers;
|
||||||
int[] triangles = new int[numberOfTriangles];
|
int[] triangles = new int[faces.Length * 3];
|
||||||
GameBoxVector2[] uvs = new GameBoxVector2[numberOfTriangles];
|
int positionCount = vertFrames[0].Vertices.Length;
|
||||||
|
var sourceCorners = new int[triangles.Length];
|
||||||
int totalVerticesPerKeyFrame = attributes[0].IndexBuffers.Length * 3;
|
for (int i = 0; i < faces.Length; i++)
|
||||||
GameBoxVector3[][] keyFrameVertices = new GameBoxVector3[vertFrames.Length][];
|
|
||||||
for (int i = 0; i < vertFrames.Length; i++)
|
|
||||||
{
|
{
|
||||||
keyFrameVertices[i] = new GameBoxVector3[totalVerticesPerKeyFrame];
|
ushort[] corners = faces[i].TriangleIndex;
|
||||||
|
sourceCorners[i * 3] = corners[0];
|
||||||
|
sourceCorners[i * 3 + 1] = corners[1];
|
||||||
|
sourceCorners[i * 3 + 2] = corners[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
int triangleIndex = 0;
|
int[] vertexRepresentatives = GetVertexRepresentatives(vertFrames, positionCount);
|
||||||
|
var (normalCorners, normalCount) = CoreUtility.GetNormalIndices(sourceCorners, positionCount, vertexRepresentatives);
|
||||||
|
var renderVertexByCorner = new Dictionary<(int normalIndex, ushort uv), int>();
|
||||||
|
var normalIndices = new List<int>();
|
||||||
|
var positionIndices = new List<int>();
|
||||||
|
var uvs = new List<GameBoxVector2>();
|
||||||
|
|
||||||
foreach (Mv3IndexBuffer indexBuffer in attributes[0].IndexBuffers)
|
// Share render vertices across matching corners while keeping UV seams and back faces distinct.
|
||||||
|
int corner = 0;
|
||||||
|
foreach (Mv3IndexBuffer face in faces)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < 3; j++)
|
for (int j = 0; j < 3; j++)
|
||||||
{
|
{
|
||||||
for (int k = 0; k < vertFrames.Length; k++)
|
int normalIndex = normalCorners[corner];
|
||||||
|
var key = (normalIndex, uv: face.TexCoordIndex[j]);
|
||||||
|
if (!renderVertexByCorner.TryGetValue(key, out int renderVertex))
|
||||||
{
|
{
|
||||||
Mv3VertFrame frame = vertFrames[k];
|
renderVertex = normalIndices.Count;
|
||||||
Mv3Vert vertex = frame.Vertices[indexBuffer.TriangleIndex[j]];
|
renderVertexByCorner.Add(key, renderVertex);
|
||||||
|
normalIndices.Add(normalIndex);
|
||||||
keyFrameVertices[k][triangleIndex] = new GameBoxVector3(vertex.X, vertex.Y, vertex.Z);
|
positionIndices.Add(face.TriangleIndex[j]);
|
||||||
|
uvs.Add(texCoords[key.uv]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uvs[triangleIndex] = texCoords[indexBuffer.TexCoordIndex[j]];
|
triangles[corner++] = renderVertex;
|
||||||
triangles[triangleIndex] = triangleIndex;
|
|
||||||
triangleIndex++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Mv3AnimationKeyFrame[] animationKeyFrames = new Mv3AnimationKeyFrame[vertFrames.Length];
|
Mv3AnimationKeyFrame[] animationKeyFrames = new Mv3AnimationKeyFrame[vertFrames.Length];
|
||||||
for (int i = 0; i < animationKeyFrames.Length; i++)
|
for (int i = 0; i < animationKeyFrames.Length; i++)
|
||||||
{
|
{
|
||||||
animationKeyFrames[i] = new Mv3AnimationKeyFrame()
|
Mv3VertFrame frame = vertFrames[i];
|
||||||
|
var vertices = new GameBoxVector3[normalIndices.Count];
|
||||||
|
for (int j = 0; j < vertices.Length; j++)
|
||||||
{
|
{
|
||||||
GameBoxTick = vertFrames[i].GameBoxTick,
|
Mv3Vert vertex = frame.Vertices[positionIndices[j]];
|
||||||
GameBoxVertices = keyFrameVertices[i],
|
vertices[j] = new GameBoxVector3(vertex.X, vertex.Y, vertex.Z);
|
||||||
|
}
|
||||||
|
|
||||||
|
animationKeyFrames[i] = new Mv3AnimationKeyFrame
|
||||||
|
{
|
||||||
|
GameBoxTick = frame.GameBoxTick,
|
||||||
|
GameBoxVertices = vertices,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,12 +214,57 @@ namespace Pal3.Core.DataReader.Mv3
|
|||||||
GameBoxBoundsMax = gameBoxBoundsMax,
|
GameBoxBoundsMax = gameBoxBoundsMax,
|
||||||
Attributes = attributes,
|
Attributes = attributes,
|
||||||
GameBoxTriangles = triangles,
|
GameBoxTriangles = triangles,
|
||||||
Uvs = uvs,
|
NormalIndices = normalIndices.ToArray(),
|
||||||
GameBoxNormals = CoreUtility.CalculateNormals(animationKeyFrames[0].GameBoxVertices, triangles),
|
NormalCount = normalCount,
|
||||||
|
Uvs = uvs.ToArray(),
|
||||||
KeyFrames = animationKeyFrames,
|
KeyFrames = animationKeyFrames,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int[] GetVertexRepresentatives(Mv3VertFrame[] frames, int vertexCount)
|
||||||
|
{
|
||||||
|
var verticesByTrajectory = new Dictionary<int, int>(vertexCount, new VertexTrajectoryComparer(frames));
|
||||||
|
var vertexRepresentatives = new int[vertexCount];
|
||||||
|
for (int vertex = 0; vertex < vertexCount; vertex++)
|
||||||
|
{
|
||||||
|
vertexRepresentatives[vertex] = verticesByTrajectory.TryAdd(vertex, vertex)
|
||||||
|
? vertex
|
||||||
|
: verticesByTrajectory[vertex];
|
||||||
|
}
|
||||||
|
return verticesByTrajectory.Count < vertexCount ? vertexRepresentatives : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class VertexTrajectoryComparer : IEqualityComparer<int>
|
||||||
|
{
|
||||||
|
private readonly Mv3VertFrame[] _frames;
|
||||||
|
|
||||||
|
public VertexTrajectoryComparer(Mv3VertFrame[] frames) => _frames = frames;
|
||||||
|
|
||||||
|
public bool Equals(int a, int b)
|
||||||
|
{
|
||||||
|
foreach (Mv3VertFrame frame in _frames)
|
||||||
|
{
|
||||||
|
Mv3Vert first = frame.Vertices[a];
|
||||||
|
Mv3Vert second = frame.Vertices[b];
|
||||||
|
if (first.X != second.X || first.Y != second.Y || first.Z != second.Z) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(int index)
|
||||||
|
{
|
||||||
|
var hash = new HashCode();
|
||||||
|
foreach (Mv3VertFrame frame in _frames)
|
||||||
|
{
|
||||||
|
Mv3Vert vertex = frame.Vertices[index];
|
||||||
|
hash.Add(vertex.X);
|
||||||
|
hash.Add(vertex.Y);
|
||||||
|
hash.Add(vertex.Z);
|
||||||
|
}
|
||||||
|
return hash.ToHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Mv3TagNode ReadTagNode(IBinaryReader reader, int codepage)
|
private static Mv3TagNode ReadTagNode(IBinaryReader reader, int codepage)
|
||||||
{
|
{
|
||||||
string nodeName = reader.ReadString(64, codepage);
|
string nodeName = reader.ReadString(64, codepage);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace Pal3.Core.Primitives
|
|||||||
{
|
{
|
||||||
Opaque, // opaque
|
Opaque, // opaque
|
||||||
AlphaBlend, // src.alpha, 1-src.alpha, +
|
AlphaBlend, // src.alpha, 1-src.alpha, +
|
||||||
InvertColorBlend, // srcAlpha, One , +
|
InvertColorBlend, // One, OneMinusSrcColor
|
||||||
AdditiveBlend, //
|
AdditiveBlend, // One, One
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
namespace Pal3.Core.Utilities
|
namespace Pal3.Core.Utilities
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -55,6 +56,155 @@ namespace Pal3.Core.Utilities
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static (int[] indices, int count) GetNormalIndices(int[] corners, int sourceVertexCount,
|
||||||
|
int[] vertexRepresentatives = null)
|
||||||
|
{
|
||||||
|
// Match faces by deformation identity while keeping normals indexed by source vertex.
|
||||||
|
int[] faceCorners = corners;
|
||||||
|
if (vertexRepresentatives != null)
|
||||||
|
{
|
||||||
|
faceCorners = new int[corners.Length];
|
||||||
|
for (int i = 0; i + 2 < corners.Length; i += 3)
|
||||||
|
{
|
||||||
|
int a = vertexRepresentatives[corners[i]];
|
||||||
|
int b = vertexRepresentatives[corners[i + 1]];
|
||||||
|
int c = vertexRepresentatives[corners[i + 2]];
|
||||||
|
// Preserve exact-index matching for collapsed faces.
|
||||||
|
bool collapsed = a == b || b == c || a == c;
|
||||||
|
faceCorners[i] = collapsed ? corners[i] : a;
|
||||||
|
faceCorners[i + 1] = collapsed ? corners[i + 1] : b;
|
||||||
|
faceCorners[i + 2] = collapsed ? corners[i + 2] : c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int faceCount = corners.Length / 3;
|
||||||
|
var firstFaces = new Dictionary<(int, int, int), int>();
|
||||||
|
var matchingFaces = new int[faceCount];
|
||||||
|
bool[] pairedFaces = null;
|
||||||
|
for (int face = 0; face < faceCount; face++)
|
||||||
|
{
|
||||||
|
int a = faceCorners[face * 3];
|
||||||
|
int b = faceCorners[face * 3 + 1];
|
||||||
|
int c = faceCorners[face * 3 + 2];
|
||||||
|
if (a == b || b == c || a == c) continue;
|
||||||
|
|
||||||
|
// Rotate to the smallest corner without changing the winding.
|
||||||
|
if (b < a && b < c) (a, b, c) = (b, c, a);
|
||||||
|
else if (c < a && c < b) (a, b, c) = (c, a, b);
|
||||||
|
if (firstFaces.TryGetValue((a, c, b), out int opposite))
|
||||||
|
{
|
||||||
|
pairedFaces ??= new bool[faceCount];
|
||||||
|
pairedFaces[opposite] = true;
|
||||||
|
matchingFaces[face] = -(opposite + 1);
|
||||||
|
}
|
||||||
|
else if (firstFaces.TryGetValue((a, b, c), out int same))
|
||||||
|
{
|
||||||
|
matchingFaces[face] = same + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstFaces.Add((a, b, c), face);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pairedFaces == null) return (corners, sourceVertexCount);
|
||||||
|
|
||||||
|
sbyte[] sides = OrientPairedFaces(faceCorners, firstFaces.Values, pairedFaces);
|
||||||
|
var backFaces = new bool[faceCount];
|
||||||
|
var frontVertices = new bool[sourceVertexCount];
|
||||||
|
for (int face = 0; face < faceCount; face++)
|
||||||
|
{
|
||||||
|
int match = matchingFaces[face];
|
||||||
|
int first = match == 0 ? face : Math.Abs(match) - 1;
|
||||||
|
if (pairedFaces[first] && (sides[first] < 0) != (match < 0))
|
||||||
|
{
|
||||||
|
backFaces[face] = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int corner = face * 3;
|
||||||
|
frontVertices[corners[corner]] = true;
|
||||||
|
frontVertices[corners[corner + 1]] = true;
|
||||||
|
frontVertices[corners[corner + 2]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A source vertex that already belongs to only one side keeps its normal group.
|
||||||
|
int[] normalIndices = null;
|
||||||
|
for (int face = 0; face < faceCount; face++)
|
||||||
|
{
|
||||||
|
if (!backFaces[face]) continue;
|
||||||
|
int corner = face * 3;
|
||||||
|
for (int i = corner; i < corner + 3; i++)
|
||||||
|
{
|
||||||
|
if (!frontVertices[corners[i]]) continue;
|
||||||
|
normalIndices ??= (int[])corners.Clone();
|
||||||
|
normalIndices[i] += sourceVertexCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return normalIndices == null ? (corners, sourceVertexCount) : (normalIndices, sourceVertexCount * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static sbyte[] OrientPairedFaces(int[] corners, IEnumerable<int> firstFaces, bool[] pairedFaces)
|
||||||
|
{
|
||||||
|
var edges = new Dictionary<(int, int), (int first, int second, bool firstAscending, bool secondAscending)>();
|
||||||
|
foreach (int face in firstFaces)
|
||||||
|
{
|
||||||
|
for (int edge = 0; edge < 3; edge++)
|
||||||
|
{
|
||||||
|
var (key, ascending) = GetEdge(face, edge);
|
||||||
|
if (!edges.TryGetValue(key, out var adjacent))
|
||||||
|
edges.Add(key, (face, -1, ascending, false));
|
||||||
|
else if (adjacent.second == -1)
|
||||||
|
edges[key] = (adjacent.first, face, adjacent.firstAscending, ascending);
|
||||||
|
else
|
||||||
|
edges[key] = (adjacent.first, -2, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var sides = new sbyte[pairedFaces.Length];
|
||||||
|
var pending = new Stack<int>();
|
||||||
|
// Prefer the orientation of any adjoining single-sided surface.
|
||||||
|
foreach (int face in firstFaces)
|
||||||
|
{
|
||||||
|
if (!pairedFaces[face]) Walk(face);
|
||||||
|
}
|
||||||
|
foreach (int face in firstFaces)
|
||||||
|
{
|
||||||
|
if (sides[face] == 0) Walk(face);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sides;
|
||||||
|
|
||||||
|
void Walk(int seed)
|
||||||
|
{
|
||||||
|
sides[seed] = 1;
|
||||||
|
pending.Push(seed);
|
||||||
|
while (pending.TryPop(out int face))
|
||||||
|
{
|
||||||
|
for (int edge = 0; edge < 3; edge++)
|
||||||
|
{
|
||||||
|
var (key, _) = GetEdge(face, edge);
|
||||||
|
var (first, second, firstAscending, secondAscending) = edges[key];
|
||||||
|
if (second < 0) continue; // Border or non-manifold edge.
|
||||||
|
int neighbor = face == first ? second : first;
|
||||||
|
if (!pairedFaces[neighbor] || sides[neighbor] != 0) continue;
|
||||||
|
|
||||||
|
// Adjacent faces on the same side traverse a shared edge in opposite directions.
|
||||||
|
sides[neighbor] = firstAscending == secondAscending ? (sbyte)-sides[face] : sides[face];
|
||||||
|
pending.Push(neighbor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
((int, int) key, bool ascending) GetEdge(int face, int edge)
|
||||||
|
{
|
||||||
|
int from = corners[face * 3 + edge];
|
||||||
|
int to = corners[face * 3 + (edge + 1) % 3];
|
||||||
|
return from < to ? ((from, to), true) : ((to, from), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static GameBoxVector3[] CalculateNormals(GameBoxVector3[] vertices, int[] triangles)
|
public static GameBoxVector3[] CalculateNormals(GameBoxVector3[] vertices, int[] triangles)
|
||||||
{
|
{
|
||||||
GameBoxVector3[] normals = new GameBoxVector3[vertices.Length];
|
GameBoxVector3[] normals = new GameBoxVector3[vertices.Length];
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace Pal3.Game.Data
|
|||||||
using Core.DataReader.Mv3;
|
using Core.DataReader.Mv3;
|
||||||
using Core.FileSystem;
|
using Core.FileSystem;
|
||||||
using Core.Utilities;
|
using Core.Utilities;
|
||||||
|
using Effect;
|
||||||
using Engine.Core.Abstraction;
|
using Engine.Core.Abstraction;
|
||||||
using Engine.Core.Implementation;
|
using Engine.Core.Implementation;
|
||||||
using Engine.DataLoader;
|
using Engine.DataLoader;
|
||||||
@@ -42,8 +43,7 @@ namespace Pal3.Game.Data
|
|||||||
/// Also manages the lifecycle of the resource it provides.
|
/// Also manages the lifecycle of the resource it provides.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class GameResourceProvider : IDisposable,
|
public sealed class GameResourceProvider : IDisposable,
|
||||||
ICommandExecutor<ScenePreLoadingNotification>,
|
ICommandExecutor<ScenePreLoadingNotification>
|
||||||
ICommandExecutor<SettingChangedNotification>
|
|
||||||
{
|
{
|
||||||
private const string CACHE_FOLDER_NAME = "CacheData";
|
private const string CACHE_FOLDER_NAME = "CacheData";
|
||||||
private const string MV3_ACTOR_CONFIG_HEADER = ";#MV3#";
|
private const string MV3_ACTOR_CONFIG_HEADER = ";#MV3#";
|
||||||
@@ -53,8 +53,7 @@ namespace Pal3.Game.Data
|
|||||||
private readonly ICpkFileSystem _fileSystem;
|
private readonly ICpkFileSystem _fileSystem;
|
||||||
private readonly ITextureLoaderFactory _textureLoaderFactory;
|
private readonly ITextureLoaderFactory _textureLoaderFactory;
|
||||||
private readonly ITextureFactory _textureFactory;
|
private readonly ITextureFactory _textureFactory;
|
||||||
private readonly IMaterialManager _unlitMaterialManager;
|
private readonly IMaterialManager _materialManager;
|
||||||
private readonly IMaterialManager _litMaterialManager;
|
|
||||||
private readonly GameSettings _gameSettings;
|
private readonly GameSettings _gameSettings;
|
||||||
|
|
||||||
private readonly GdbFile _gameDatabase;
|
private readonly GdbFile _gameDatabase;
|
||||||
@@ -63,28 +62,28 @@ namespace Pal3.Game.Data
|
|||||||
|
|
||||||
private readonly Dictionary<string, ISprite> _spriteCache = new ();
|
private readonly Dictionary<string, ISprite> _spriteCache = new ();
|
||||||
private readonly Dictionary<string, AudioClip> _audioClipCache = new ();
|
private readonly Dictionary<string, AudioClip> _audioClipCache = new ();
|
||||||
private readonly Dictionary<int, UnityEngine.Object> _vfxEffectPrefabCache = new ();
|
|
||||||
|
|
||||||
private readonly Dictionary<Type, Dictionary<string, object>> _gameResourceFileCache = new ();
|
private readonly Dictionary<Type, Dictionary<string, object>> _gameResourceFileCache = new ();
|
||||||
|
|
||||||
private readonly int _codepage;
|
private readonly int _codepage;
|
||||||
|
|
||||||
|
internal OptionalVfxPlayer OptionalVfx { get; }
|
||||||
|
|
||||||
public GameResourceProvider(ICpkFileSystem fileSystem,
|
public GameResourceProvider(ICpkFileSystem fileSystem,
|
||||||
ITextureLoaderFactory textureLoaderFactory,
|
ITextureLoaderFactory textureLoaderFactory,
|
||||||
ITextureFactory textureFactory,
|
ITextureFactory textureFactory,
|
||||||
IMaterialManager unlitMaterialManager,
|
IMaterialManager materialManager,
|
||||||
IMaterialManager litMaterialManager,
|
|
||||||
GameSettings gameSettings)
|
GameSettings gameSettings)
|
||||||
{
|
{
|
||||||
_fileSystem = Requires.IsNotNull(fileSystem, nameof(fileSystem));
|
_fileSystem = Requires.IsNotNull(fileSystem, nameof(fileSystem));
|
||||||
_textureLoaderFactory = Requires.IsNotNull(textureLoaderFactory, nameof(textureLoaderFactory));
|
_textureLoaderFactory = Requires.IsNotNull(textureLoaderFactory, nameof(textureLoaderFactory));
|
||||||
_textureFactory = Requires.IsNotNull(textureFactory, nameof(textureFactory));
|
_textureFactory = Requires.IsNotNull(textureFactory, nameof(textureFactory));
|
||||||
_unlitMaterialManager = Requires.IsNotNull(unlitMaterialManager, nameof(unlitMaterialManager));
|
_materialManager = Requires.IsNotNull(materialManager, nameof(materialManager));
|
||||||
_litMaterialManager = litMaterialManager; // Lit materials are not required
|
|
||||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
||||||
|
|
||||||
_codepage = _gameSettings.Language == Language.SimplifiedChinese ? 936 : 950;
|
_codepage = _gameSettings.Language == Language.SimplifiedChinese ? 936 : 950;
|
||||||
_gameDatabase = GetGameDatabaseFile(); // Initialize game database file
|
_gameDatabase = GetGameDatabaseFile(); // Initialize game database file
|
||||||
|
OptionalVfx = new OptionalVfxPlayer(_gameSettings);
|
||||||
|
|
||||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||||
}
|
}
|
||||||
@@ -113,10 +112,9 @@ namespace Pal3.Game.Data
|
|||||||
}
|
}
|
||||||
_audioClipCache.Clear();
|
_audioClipCache.Clear();
|
||||||
|
|
||||||
_vfxEffectPrefabCache.Clear();
|
OptionalVfx.Dispose();
|
||||||
|
|
||||||
_unlitMaterialManager?.DeallocateMaterialPool();
|
_materialManager.Dispose();
|
||||||
_litMaterialManager?.DeallocateMaterialPool();
|
|
||||||
|
|
||||||
_gameResourceFileCache.Clear();
|
_gameResourceFileCache.Clear();
|
||||||
}
|
}
|
||||||
@@ -145,12 +143,7 @@ namespace Pal3.Game.Data
|
|||||||
return _shadowSprite;
|
return _shadowSprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMaterialManager GetMaterialManager()
|
public IMaterialManager GetMaterialManager() => _materialManager;
|
||||||
{
|
|
||||||
return !_gameSettings.IsOpenSourceVersion && _gameSettings.IsRealtimeLightingAndShadowsEnabled ?
|
|
||||||
_litMaterialManager :
|
|
||||||
_unlitMaterialManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITextureResourceProvider CreateTextureResourceProvider(string relativeDirectoryPath, bool useCache = true)
|
public ITextureResourceProvider CreateTextureResourceProvider(string relativeDirectoryPath, bool useCache = true)
|
||||||
{
|
{
|
||||||
@@ -525,55 +518,6 @@ namespace Pal3.Game.Data
|
|||||||
return Array.Empty<(ITexture2D, bool)>();
|
return Array.Empty<(ITexture2D, bool)>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetVfxPrefabPath(int effectGroupId)
|
|
||||||
{
|
|
||||||
return $"Prefabs/VFX/{GameConstants.AppName}/{effectGroupId}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public object GetVfxEffectPrefab(int effectGroupId)
|
|
||||||
{
|
|
||||||
if (_vfxEffectPrefabCache.TryGetValue(effectGroupId, out UnityEngine.Object vfxEffectPrefab))
|
|
||||||
{
|
|
||||||
return vfxEffectPrefab;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnityEngine.Object vfxPrefab = Resources.Load(GetVfxPrefabPath(effectGroupId));
|
|
||||||
|
|
||||||
if (vfxPrefab == null)
|
|
||||||
{
|
|
||||||
EngineLogger.LogWarning($"VFX prefab not found: {effectGroupId}");
|
|
||||||
}
|
|
||||||
|
|
||||||
_vfxEffectPrefabCache[effectGroupId] = vfxPrefab;
|
|
||||||
return vfxPrefab;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator PreLoadVfxEffectAsync(int effectGroupId)
|
|
||||||
{
|
|
||||||
if (_vfxEffectPrefabCache.ContainsKey(effectGroupId))
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceRequest request = Resources.LoadAsync(GetVfxPrefabPath(effectGroupId));
|
|
||||||
|
|
||||||
while (!request.isDone)
|
|
||||||
{
|
|
||||||
yield return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.asset == null)
|
|
||||||
{
|
|
||||||
EngineLogger.LogWarning($"VFX prefab not found: {effectGroupId}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EngineLogger.Log($"VFX prefab preloaded: {effectGroupId}");
|
|
||||||
}
|
|
||||||
|
|
||||||
_vfxEffectPrefabCache[effectGroupId] = request.asset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITexture2D GetCursorTexture()
|
public ITexture2D GetCursorTexture()
|
||||||
{
|
{
|
||||||
string cursorSpriteRelativePath = FileConstants.CursorSpriteFolderVirtualPath;
|
string cursorSpriteRelativePath = FileConstants.CursorSpriteFolderVirtualPath;
|
||||||
@@ -646,26 +590,8 @@ namespace Pal3.Game.Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all vfx prefabs in cache
|
OptionalVfx.ClearPrefabCache();
|
||||||
_vfxEffectPrefabCache.Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(SettingChangedNotification command)
|
|
||||||
{
|
|
||||||
// Need to deallocate and reallocate material pool when switching between lit and unlit materials
|
|
||||||
if (command.SettingName == nameof(_gameSettings.IsRealtimeLightingAndShadowsEnabled))
|
|
||||||
{
|
|
||||||
if (_gameSettings.IsRealtimeLightingAndShadowsEnabled)
|
|
||||||
{
|
|
||||||
_unlitMaterialManager?.DeallocateMaterialPool();
|
|
||||||
_litMaterialManager?.AllocateMaterialPool();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_litMaterialManager?.DeallocateMaterialPool();
|
|
||||||
_unlitMaterialManager?.AllocateMaterialPool();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,6 @@ namespace Pal3.Game.Dev
|
|||||||
using UnityEngine.EventSystems;
|
using UnityEngine.EventSystems;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.InputSystem.DualShock;
|
using UnityEngine.InputSystem.DualShock;
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public sealed class MainMenu : IDisposable,
|
public sealed class MainMenu : IDisposable,
|
||||||
@@ -346,74 +345,22 @@ namespace Pal3.Game.Dev
|
|||||||
{
|
{
|
||||||
SetupMenuLayout(isVertical: true);
|
SetupMenuLayout(isVertical: true);
|
||||||
|
|
||||||
const string lightingEnabledText = "实时光影:开启";
|
string GetRenderingStyleButtonText() => _gameSettings.ToonRendering
|
||||||
const string lightingDisabledText = "实时光影:关闭";
|
? "画风:卡通与实时光影"
|
||||||
const string ssaoEnabledText = "环境光遮蔽:开启";
|
: "画风:原版";
|
||||||
const string ssaoDisabledText = "环境光遮蔽:关闭";
|
CreateMenuButton(GetRenderingStyleButtonText(), buttonText => delegate
|
||||||
|
|
||||||
// Toon materials are not available in open source build.
|
|
||||||
// so lighting and shadow will not work, thus we remove the option.
|
|
||||||
if (!_gameSettings.IsOpenSourceVersion)
|
|
||||||
{
|
{
|
||||||
string GetLightAndShadowButtonText() => _gameSettings.IsRealtimeLightingAndShadowsEnabled ?
|
_gameSettings.ToonRendering = !_gameSettings.ToonRendering;
|
||||||
lightingEnabledText :
|
_gameSettings.SaveSettings();
|
||||||
lightingDisabledText;
|
buttonText.text = GetRenderingStyleButtonText();
|
||||||
CreateMenuButton(GetLightAndShadowButtonText(), buttonTextUGUI => delegate
|
Pal3.Instance.Execute(new UIDisplayNoteCommand("画风将在重启游戏后生效"));
|
||||||
{
|
});
|
||||||
// Do not allow toggling lighting and shadow if there are scripts running
|
|
||||||
// because it might cause unexpected behavior.
|
|
||||||
if (_scriptManager.GetNumberOfRunningScripts() > 0) return;
|
|
||||||
|
|
||||||
_gameSettings.IsRealtimeLightingAndShadowsEnabled = !_gameSettings.IsRealtimeLightingAndShadowsEnabled;
|
CreateMenuButton("画面与特效设置", _ => delegate
|
||||||
|
{
|
||||||
buttonTextUGUI.text = GetLightAndShadowButtonText();
|
DestroyAllMenuItems();
|
||||||
|
SetupVisualEffectButtons();
|
||||||
// Should turn off SSAO if realtime lighting and shadows is disabled
|
});
|
||||||
if (!_gameSettings.IsRealtimeLightingAndShadowsEnabled && _gameSettings.IsAmbientOcclusionEnabled)
|
|
||||||
{
|
|
||||||
_gameSettings.IsAmbientOcclusionEnabled = false;
|
|
||||||
_menuItems.FirstOrDefault(_ => _.GetComponentInChildren<TextMeshProUGUI>() is {text: ssaoEnabledText})!
|
|
||||||
.GetComponentInChildren<TextMeshProUGUI>().text = ssaoDisabledText;
|
|
||||||
Pal3.Instance.Execute(new UIDisplayNoteCommand("环境光遮蔽已关闭"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isInInitView)
|
|
||||||
{
|
|
||||||
ShowInitView(); // Reload init scene to apply changes
|
|
||||||
}
|
|
||||||
else // reload scene to apply changes
|
|
||||||
{
|
|
||||||
List<ICommand> commands = _saveManager.ConvertCurrentGameStateToCommands(SaveLevel.Full);
|
|
||||||
string saveFileContent = string.Join('\n', commands.Select(CommandExtensions.ToString).ToList());
|
|
||||||
ExecuteCommandsFromSaveFile(saveFileContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
Pal3.Instance.Execute(new UIDisplayNoteCommand("实时光影已" +
|
|
||||||
(_gameSettings.IsRealtimeLightingAndShadowsEnabled ? "开启(注意性能和耗电影响)" : "关闭") + ""));
|
|
||||||
});
|
|
||||||
|
|
||||||
// SSAO is not available on Android OpenGLES3
|
|
||||||
if (!(Application.platform == RuntimePlatform.Android &&
|
|
||||||
SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan))
|
|
||||||
{
|
|
||||||
string GetSSAOButtonText() => _gameSettings.IsAmbientOcclusionEnabled ? ssaoEnabledText : ssaoDisabledText;
|
|
||||||
CreateMenuButton(GetSSAOButtonText(), buttonTextUGUI => delegate
|
|
||||||
{
|
|
||||||
if (!_gameSettings.IsAmbientOcclusionEnabled && !_gameSettings.IsRealtimeLightingAndShadowsEnabled)
|
|
||||||
{
|
|
||||||
Pal3.Instance.Execute(new UIDisplayNoteCommand("请先开启实时光影,再开启环境光遮蔽"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_gameSettings.IsAmbientOcclusionEnabled = !_gameSettings.IsAmbientOcclusionEnabled;
|
|
||||||
|
|
||||||
buttonTextUGUI.text = GetSSAOButtonText();
|
|
||||||
|
|
||||||
Pal3.Instance.Execute(new UIDisplayNoteCommand("环境光遮蔽已" +
|
|
||||||
(_gameSettings.IsAmbientOcclusionEnabled ? "开启(注意性能和耗电影响)" : "关闭") + ""));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_STANDALONE
|
#if UNITY_STANDALONE
|
||||||
const string vsyncEnabledText = "垂直同步:开启";
|
const string vsyncEnabledText = "垂直同步:开启";
|
||||||
@@ -553,6 +500,47 @@ namespace Pal3.Game.Dev
|
|||||||
- _contentGridLayoutGroup.spacing.y);
|
- _contentGridLayoutGroup.spacing.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetupVisualEffectButtons()
|
||||||
|
{
|
||||||
|
SetupMenuLayout(isVertical: true);
|
||||||
|
AddOption("接触阴影", () => _gameSettings.ToonContactShadows,
|
||||||
|
value => _gameSettings.ToonContactShadows = value);
|
||||||
|
AddOption("角色光照", () => _gameSettings.ToonCharacterLighting,
|
||||||
|
value => _gameSettings.ToonCharacterLighting = value);
|
||||||
|
AddOption("增强夜景火光", () => _gameSettings.ToonNightFireBoost,
|
||||||
|
value => _gameSettings.ToonNightFireBoost = value);
|
||||||
|
AddOption("火光投影", () => _gameSettings.ToonFireShadows,
|
||||||
|
value => _gameSettings.ToonFireShadows = value);
|
||||||
|
AddOption("泛光", () => _gameSettings.BloomEnabled,
|
||||||
|
value => _gameSettings.BloomEnabled = value);
|
||||||
|
AddOption("可选剧情特效", () => _gameSettings.OptionalVfxEnabled,
|
||||||
|
value => _gameSettings.OptionalVfxEnabled = value);
|
||||||
|
|
||||||
|
CreateMenuButton("返回", _ => delegate
|
||||||
|
{
|
||||||
|
DestroyAllMenuItems();
|
||||||
|
SetupSettingButtons();
|
||||||
|
});
|
||||||
|
SetupButtonNavigations(isUpAndDown: true);
|
||||||
|
SelectFirstButtonForEventSystem();
|
||||||
|
|
||||||
|
UpdateRectTransformWidthAndHeight(_backgroundTransform,
|
||||||
|
_contentGridLayoutGroup.cellSize.x + _contentGridLayoutGroup.padding.horizontal,
|
||||||
|
_menuItems.Count * (_contentGridLayoutGroup.cellSize.y + _contentGridLayoutGroup.spacing.y)
|
||||||
|
+ _contentGridLayoutGroup.padding.vertical - _contentGridLayoutGroup.spacing.y);
|
||||||
|
|
||||||
|
void AddOption(string label, Func<bool> get, Action<bool> set)
|
||||||
|
{
|
||||||
|
string Text() => $"{label}:{(get() ? "开启" : "关闭")}";
|
||||||
|
CreateMenuButton(Text(), text => delegate
|
||||||
|
{
|
||||||
|
set(!get());
|
||||||
|
_gameSettings.SaveSettings();
|
||||||
|
text.text = Text();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SetupSaveMenuButtons()
|
private void SetupSaveMenuButtons()
|
||||||
{
|
{
|
||||||
SetupMenuLayout(isVertical: true);
|
SetupMenuLayout(isVertical: true);
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
namespace Pal3.Game.Effect
|
namespace Pal3.Game.Effect
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
using Data;
|
using Data;
|
||||||
using Engine.Core.Abstraction;
|
|
||||||
using Engine.Core.Implementation;
|
using Engine.Core.Implementation;
|
||||||
using Engine.Extensions;
|
using Engine.Extensions;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ namespace Pal3.Game.Effect
|
|||||||
|
|
||||||
private RotatingSpriteEffect _bridgeBaseEffect;
|
private RotatingSpriteEffect _bridgeBaseEffect;
|
||||||
private RotatingSpriteEffect _bridgeEffect;
|
private RotatingSpriteEffect _bridgeEffect;
|
||||||
private IGameEntity _effect;
|
private IDisposable _effect;
|
||||||
|
|
||||||
protected override void OnDisableGameEntity()
|
protected override void OnDisableGameEntity()
|
||||||
{
|
{
|
||||||
@@ -41,14 +41,6 @@ namespace Pal3.Game.Effect
|
|||||||
|
|
||||||
public void Init(GameResourceProvider resourceProvider, uint effectParameter)
|
public void Init(GameResourceProvider resourceProvider, uint effectParameter)
|
||||||
{
|
{
|
||||||
// object vfxPrefab = resourceProvider.GetVfxEffectPrefab((int)effectParameter);
|
|
||||||
//
|
|
||||||
// if (vfxPrefab != null)
|
|
||||||
// {
|
|
||||||
// _effect = PrefabFactory.Instantiate(vfxPrefab, Transform, worldPositionStays: false);
|
|
||||||
// _effect.Name = "VFX_" + effectParameter;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#if PAL3
|
#if PAL3
|
||||||
if (effectParameter == 465) // 蜀山太极桥特效
|
if (effectParameter == 465) // 蜀山太极桥特效
|
||||||
#elif PAL3A
|
#elif PAL3A
|
||||||
@@ -78,15 +70,12 @@ namespace Pal3.Game.Effect
|
|||||||
if (effectParameter == 344) // 重盘古元灵特效
|
if (effectParameter == 344) // 重盘古元灵特效
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
object vfxPrefab = resourceProvider.GetVfxEffectPrefab((int)effectParameter);
|
_effect = resourceProvider.OptionalVfx.Attach((int)effectParameter, GameEntity);
|
||||||
if (vfxPrefab != null)
|
|
||||||
{
|
|
||||||
_effect = GameEntityFactory.Create(name: $"VFX_{effectParameter}",
|
|
||||||
vfxPrefab, GameEntity, worldPositionStays: false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy() => Dispose();
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_bridgeBaseEffect != null)
|
if (_bridgeBaseEffect != null)
|
||||||
@@ -103,11 +92,8 @@ namespace Pal3.Game.Effect
|
|||||||
_bridgeEffect = null;
|
_bridgeEffect = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_effect != null)
|
_effect?.Dispose();
|
||||||
{
|
_effect = null;
|
||||||
_effect.Destroy();
|
|
||||||
_effect = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,6 @@ namespace Pal3.Game.Effect
|
|||||||
using Core.Primitives;
|
using Core.Primitives;
|
||||||
using Core.Utilities;
|
using Core.Utilities;
|
||||||
using Data;
|
using Data;
|
||||||
using Engine.Core.Abstraction;
|
|
||||||
using Engine.Core.Implementation;
|
|
||||||
using Engine.Extensions;
|
using Engine.Extensions;
|
||||||
using Scene;
|
using Scene;
|
||||||
|
|
||||||
@@ -32,7 +30,7 @@ namespace Pal3.Game.Effect
|
|||||||
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
|
ICommandExecutor<SceneLeavingCurrentSceneNotification>,
|
||||||
ICommandExecutor<ResetGameStateCommand>
|
ICommandExecutor<ResetGameStateCommand>
|
||||||
{
|
{
|
||||||
private readonly GameResourceProvider _resourceProvider;
|
private readonly OptionalVfxPlayer _optionalVfx;
|
||||||
private readonly SceneManager _sceneManager;
|
private readonly SceneManager _sceneManager;
|
||||||
private ICommand _effectPositionCommand;
|
private ICommand _effectPositionCommand;
|
||||||
|
|
||||||
@@ -42,10 +40,10 @@ namespace Pal3.Game.Effect
|
|||||||
public EffectManager(GameResourceProvider resourceProvider,
|
public EffectManager(GameResourceProvider resourceProvider,
|
||||||
SceneManager sceneManager)
|
SceneManager sceneManager)
|
||||||
{
|
{
|
||||||
_resourceProvider = Requires.IsNotNull(resourceProvider, nameof(resourceProvider));
|
_optionalVfx = Requires.IsNotNull(resourceProvider, nameof(resourceProvider)).OptionalVfx;
|
||||||
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
_sceneManager = Requires.IsNotNull(sceneManager, nameof(sceneManager));
|
||||||
|
|
||||||
_effectLinkerFile = _resourceProvider.GetGameResourceFile<EffectLinkerFile>(
|
_effectLinkerFile = resourceProvider.GetGameResourceFile<EffectLinkerFile>(
|
||||||
FileConstants.CombatDataFolderVirtualPath + EFFECT_LINKER_FILE_NAME);
|
FileConstants.CombatDataFolderVirtualPath + EFFECT_LINKER_FILE_NAME);
|
||||||
|
|
||||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||||
@@ -54,7 +52,7 @@ namespace Pal3.Game.Effect
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||||
_effectPositionCommand = null;
|
ClearSceneEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(EffectPreLoadCommand command)
|
public void Execute(EffectPreLoadCommand command)
|
||||||
@@ -64,7 +62,7 @@ namespace Pal3.Game.Effect
|
|||||||
// Even with a waiter, we need to make sure waiter's current execution mode is set
|
// Even with a waiter, we need to make sure waiter's current execution mode is set
|
||||||
// to synchronous otherwise the effect will be played before the pre-load is finished.
|
// to synchronous otherwise the effect will be played before the pre-load is finished.
|
||||||
#if PAL3
|
#if PAL3
|
||||||
Pal3.Instance.StartCoroutine(_resourceProvider.PreLoadVfxEffectAsync(command.EffectGroupId));
|
Pal3.Instance.StartCoroutine(_optionalVfx.PreloadAsync(command.EffectGroupId));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,33 +78,20 @@ namespace Pal3.Game.Effect
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Play VFX
|
if (_effectPositionCommand is EffectSetPositionCommand positionCommand)
|
||||||
object vfxPrefab = _resourceProvider.GetVfxEffectPrefab(command.EffectGroupId);
|
|
||||||
if (vfxPrefab != null)
|
|
||||||
{
|
{
|
||||||
IGameEntity parent = null;
|
Vector3 localPosition = new GameBoxVector3(
|
||||||
Vector3 localPosition = Vector3.zero;
|
positionCommand.GameBoxXPosition,
|
||||||
|
positionCommand.GameBoxYPosition,
|
||||||
|
positionCommand.GameBoxZPosition).ToUnityPosition();
|
||||||
|
|
||||||
if (_effectPositionCommand is EffectSetPositionCommand positionCommand &&
|
_optionalVfx.Play(command.EffectGroupId,
|
||||||
_sceneManager.GetSceneRootGameEntity() is {} sceneRootGameEntity)
|
_sceneManager.GetSceneRootGameEntity(), localPosition);
|
||||||
{
|
}
|
||||||
parent = sceneRootGameEntity;
|
else if (_effectPositionCommand is EffectAttachToActorCommand actorCommand)
|
||||||
localPosition = new GameBoxVector3(
|
{
|
||||||
positionCommand.GameBoxXPosition,
|
_optionalVfx.Play(command.EffectGroupId,
|
||||||
positionCommand.GameBoxYPosition,
|
currentScene.GetActorGameEntity(actorCommand.ActorId), Vector3.zero);
|
||||||
positionCommand.GameBoxZPosition).ToUnityPosition();
|
|
||||||
}
|
|
||||||
else if (_effectPositionCommand is EffectAttachToActorCommand actorCommand)
|
|
||||||
{
|
|
||||||
parent = currentScene.GetActorGameEntity(actorCommand.ActorId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent.IsNullOrDisposed())
|
|
||||||
{
|
|
||||||
IGameEntity effectEntity = GameEntityFactory.Create(name: $"VFX_{command.EffectGroupId}",
|
|
||||||
vfxPrefab, parent, worldPositionStays: false);
|
|
||||||
effectEntity.Transform.LocalPosition += localPosition;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play SFX if any
|
// Play SFX if any
|
||||||
@@ -159,8 +144,14 @@ namespace Pal3.Game.Effect
|
|||||||
|
|
||||||
public void Execute(EffectAttachToActorCommand command) => _effectPositionCommand = command;
|
public void Execute(EffectAttachToActorCommand command) => _effectPositionCommand = command;
|
||||||
|
|
||||||
public void Execute(SceneLeavingCurrentSceneNotification command) => _effectPositionCommand = null;
|
public void Execute(SceneLeavingCurrentSceneNotification command) => ClearSceneEffects();
|
||||||
|
|
||||||
public void Execute(ResetGameStateCommand command) => _effectPositionCommand = null;
|
public void Execute(ResetGameStateCommand command) => ClearSceneEffects();
|
||||||
|
|
||||||
|
private void ClearSceneEffects()
|
||||||
|
{
|
||||||
|
_effectPositionCommand = null;
|
||||||
|
_optionalVfx.ClearPlayedEffects();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,198 @@
|
|||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||||
|
// See LICENSE file in the project root for license information.
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Pal3.Game.Effect
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Constants;
|
||||||
|
using Engine.Core.Abstraction;
|
||||||
|
using Engine.Core.Implementation;
|
||||||
|
using Engine.Extensions;
|
||||||
|
using Engine.Logging;
|
||||||
|
using Settings;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
internal sealed class OptionalVfxPlayer : IDisposable
|
||||||
|
{
|
||||||
|
private readonly GameSettings _settings;
|
||||||
|
private readonly Dictionary<int, GameObject> _prefabs = new();
|
||||||
|
private readonly List<IGameEntity> _playedEffects = new();
|
||||||
|
private readonly List<PersistentEffect> _persistentEffects = new();
|
||||||
|
|
||||||
|
private int _prefabCacheGeneration;
|
||||||
|
private bool _disposed;
|
||||||
|
private bool IsEnabled => !_disposed && _settings.OptionalVfxEnabled;
|
||||||
|
|
||||||
|
internal OptionalVfxPlayer(GameSettings settings)
|
||||||
|
{
|
||||||
|
_settings = settings;
|
||||||
|
_settings.OnGameSettingsChanged += OnGameSettingsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetPrefabPath(int effectGroupId) => $"Prefabs/VFX/{GameConstants.AppName}/{effectGroupId}";
|
||||||
|
|
||||||
|
internal IEnumerator PreloadAsync(int effectGroupId)
|
||||||
|
{
|
||||||
|
if (!IsEnabled || _prefabs.ContainsKey(effectGroupId)) yield break;
|
||||||
|
|
||||||
|
int generation = _prefabCacheGeneration;
|
||||||
|
ResourceRequest request = Resources.LoadAsync<GameObject>(GetPrefabPath(effectGroupId));
|
||||||
|
yield return request;
|
||||||
|
|
||||||
|
if (IsEnabled && generation == _prefabCacheGeneration && !_prefabs.ContainsKey(effectGroupId))
|
||||||
|
{
|
||||||
|
CachePrefab(effectGroupId, request.asset as GameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CachePrefab(int effectGroupId, GameObject prefab)
|
||||||
|
{
|
||||||
|
_prefabs[effectGroupId] = prefab;
|
||||||
|
if (prefab == null)
|
||||||
|
{
|
||||||
|
EngineLogger.LogWarning($"VFX prefab not found: {effectGroupId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IGameEntity Create(int effectGroupId, IGameEntity parent)
|
||||||
|
{
|
||||||
|
if (!IsEnabled || parent.IsNullOrDisposed()) return null;
|
||||||
|
|
||||||
|
if (!_prefabs.TryGetValue(effectGroupId, out GameObject prefab))
|
||||||
|
{
|
||||||
|
prefab = Resources.Load<GameObject>(GetPrefabPath(effectGroupId));
|
||||||
|
CachePrefab(effectGroupId, prefab);
|
||||||
|
}
|
||||||
|
|
||||||
|
return prefab == null ? null :
|
||||||
|
GameEntityFactory.Create($"VFX_{effectGroupId}", prefab, parent, worldPositionStays: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void Play(int effectGroupId, IGameEntity parent, Vector3 localPosition)
|
||||||
|
{
|
||||||
|
if (Create(effectGroupId, parent) is not {} instance) return;
|
||||||
|
|
||||||
|
instance.Transform.LocalPosition += localPosition;
|
||||||
|
_playedEffects.RemoveAll(effect => effect.IsNativeObjectDisposed);
|
||||||
|
_playedEffects.Add(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IDisposable Attach(int effectGroupId, IGameEntity parent)
|
||||||
|
{
|
||||||
|
if (_disposed || parent.IsNullOrDisposed()) return null;
|
||||||
|
PruneDeadAttachments();
|
||||||
|
var effect = new PersistentEffect(this, effectGroupId, parent);
|
||||||
|
_persistentEffects.Add(effect);
|
||||||
|
effect.Refresh();
|
||||||
|
return effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnGameSettingsChanged(string propertyName)
|
||||||
|
{
|
||||||
|
if (propertyName != nameof(GameSettings.OptionalVfxEnabled)) return;
|
||||||
|
|
||||||
|
if (!IsEnabled) ClearPlayedEffects();
|
||||||
|
|
||||||
|
foreach (PersistentEffect effect in _persistentEffects.ToArray())
|
||||||
|
{
|
||||||
|
effect.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClearPlayedEffects()
|
||||||
|
{
|
||||||
|
foreach (IGameEntity effect in _playedEffects)
|
||||||
|
{
|
||||||
|
Stop(effect);
|
||||||
|
}
|
||||||
|
_playedEffects.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Stop(IGameEntity effect)
|
||||||
|
{
|
||||||
|
if (effect.IsNullOrDisposed()) return;
|
||||||
|
|
||||||
|
// Destroy is deferred to the end of the frame.
|
||||||
|
((GameObject)effect.NativeObject).SetActive(false);
|
||||||
|
effect.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PruneDeadAttachments()
|
||||||
|
{
|
||||||
|
for (int i = _persistentEffects.Count - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if (_persistentEffects[i].ParentIsDisposed) _persistentEffects[i].Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void ClearPrefabCache()
|
||||||
|
{
|
||||||
|
PruneDeadAttachments();
|
||||||
|
_prefabCacheGeneration++;
|
||||||
|
_prefabs.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_disposed = true;
|
||||||
|
_settings.OnGameSettingsChanged -= OnGameSettingsChanged;
|
||||||
|
ClearPlayedEffects();
|
||||||
|
|
||||||
|
foreach (PersistentEffect effect in _persistentEffects.ToArray())
|
||||||
|
{
|
||||||
|
effect.Dispose();
|
||||||
|
}
|
||||||
|
ClearPrefabCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class PersistentEffect : IDisposable
|
||||||
|
{
|
||||||
|
private readonly OptionalVfxPlayer _player;
|
||||||
|
private readonly int _effectGroupId;
|
||||||
|
private readonly IGameEntity _parent;
|
||||||
|
private IGameEntity _instance;
|
||||||
|
private bool _disposed;
|
||||||
|
|
||||||
|
internal PersistentEffect(OptionalVfxPlayer player, int effectGroupId, IGameEntity parent)
|
||||||
|
{
|
||||||
|
_player = player;
|
||||||
|
_effectGroupId = effectGroupId;
|
||||||
|
_parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal bool ParentIsDisposed => _parent.IsNullOrDisposed();
|
||||||
|
|
||||||
|
internal void Refresh()
|
||||||
|
{
|
||||||
|
if (_disposed) return;
|
||||||
|
if (ParentIsDisposed)
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_player.IsEnabled)
|
||||||
|
{
|
||||||
|
if (_instance.IsNullOrDisposed()) _instance = _player.Create(_effectGroupId, _parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Stop(_instance);
|
||||||
|
_instance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
_disposed = true;
|
||||||
|
_player._persistentEffects.Remove(this);
|
||||||
|
Stop(_instance);
|
||||||
|
_instance = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 476922aa1f964e19b6cc16895511908c
|
||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
namespace Pal3.Game.Effect
|
namespace Pal3.Game.Effect
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
using Data;
|
using Data;
|
||||||
using Engine.Core.Abstraction;
|
|
||||||
using Engine.Core.Implementation;
|
using Engine.Core.Implementation;
|
||||||
using Engine.Extensions;
|
using Engine.Extensions;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ namespace Pal3.Game.Effect
|
|||||||
private const int PORTAL_RAY_EFFECT_ID = 0;
|
private const int PORTAL_RAY_EFFECT_ID = 0;
|
||||||
|
|
||||||
private RotatingSpriteEffect _baseEffect;
|
private RotatingSpriteEffect _baseEffect;
|
||||||
private IGameEntity _rayEffect;
|
private IDisposable _rayEffect;
|
||||||
|
|
||||||
protected override void OnDisableGameEntity()
|
protected override void OnDisableGameEntity()
|
||||||
{
|
{
|
||||||
@@ -40,14 +40,11 @@ namespace Pal3.Game.Effect
|
|||||||
new Vector3(PORTAL_DEFAULT_SIZE, PORTAL_DEFAULT_SIZE, PORTAL_DEFAULT_SIZE),
|
new Vector3(PORTAL_DEFAULT_SIZE, PORTAL_DEFAULT_SIZE, PORTAL_DEFAULT_SIZE),
|
||||||
PORTAL_ANIMATION_ROTATION_SPEED);
|
PORTAL_ANIMATION_ROTATION_SPEED);
|
||||||
|
|
||||||
object rayEffectPrefab = resourceProvider.GetVfxEffectPrefab(PORTAL_RAY_EFFECT_ID);
|
_rayEffect = resourceProvider.OptionalVfx.Attach(PORTAL_RAY_EFFECT_ID, GameEntity);
|
||||||
if (rayEffectPrefab != null)
|
|
||||||
{
|
|
||||||
_rayEffect = GameEntityFactory.Create($"VFX_{PORTAL_RAY_EFFECT_ID}",
|
|
||||||
rayEffectPrefab, GameEntity, worldPositionStays: false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy() => Dispose();
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_baseEffect != null)
|
if (_baseEffect != null)
|
||||||
@@ -57,11 +54,8 @@ namespace Pal3.Game.Effect
|
|||||||
_baseEffect = null;
|
_baseEffect = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_rayEffect != null)
|
_rayEffect?.Dispose();
|
||||||
{
|
_rayEffect = null;
|
||||||
_rayEffect.Destroy();
|
|
||||||
_rayEffect = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
||||||
// See LICENSE file in the project root for license information.
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Pal3.Game.Effect.PostProcessing
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using Engine.Services;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering.PostProcessing;
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
[PostProcess(typeof(DistortionRenderer), PostProcessEvent.AfterStack, "Pal3/Distortion")]
|
|
||||||
public sealed class Distortion : PostProcessEffectSettings
|
|
||||||
{
|
|
||||||
[Range(0.1f, 30.0f), Tooltip("TimeScale")]
|
|
||||||
public FloatParameter timeScale = new() { value = 4.0f };
|
|
||||||
|
|
||||||
[Range(0.1f, 30.0f), Tooltip("X Factor")]
|
|
||||||
public FloatParameter xFactor = new() { value = 15.0f };
|
|
||||||
|
|
||||||
[Range(0.1f, 30.0f), Tooltip("Y Factor")]
|
|
||||||
public FloatParameter yFactor = new() { value = 10.0f };
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class DistortionRenderer : PostProcessEffectRenderer<Distortion>
|
|
||||||
{
|
|
||||||
private static readonly int TimeScalePropertyId = ShaderUtility.GetPropertyIdByName("_TimeScale");
|
|
||||||
private static readonly int XFactorPropertyId = ShaderUtility.GetPropertyIdByName("_XFactor");
|
|
||||||
private static readonly int YFactorPropertyId = ShaderUtility.GetPropertyIdByName("_YFactor");
|
|
||||||
|
|
||||||
private Shader _distortionShader;
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
_distortionShader = Shader.Find("Pal3/PostEffectDistortion");
|
|
||||||
base.Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Render(PostProcessRenderContext context)
|
|
||||||
{
|
|
||||||
PropertySheet sheet = context.propertySheets.Get(_distortionShader);
|
|
||||||
sheet.properties.SetFloat(TimeScalePropertyId, settings.timeScale);
|
|
||||||
sheet.properties.SetFloat(XFactorPropertyId, settings.xFactor);
|
|
||||||
sheet.properties.SetFloat(YFactorPropertyId, settings.yFactor);
|
|
||||||
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: bb4ad18ac69b12845a429aba13929a07
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -11,9 +11,11 @@ namespace Pal3.Game.Effect.PostProcessing
|
|||||||
using Core.Command;
|
using Core.Command;
|
||||||
using Core.Command.SceCommands;
|
using Core.Command.SceCommands;
|
||||||
using Core.Utilities;
|
using Core.Utilities;
|
||||||
using Engine.Utilities;
|
using Rendering.ScreenEffects;
|
||||||
using Settings;
|
using Settings;
|
||||||
using UnityEngine.Rendering.PostProcessing;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
public sealed class PostProcessManager : IDisposable,
|
public sealed class PostProcessManager : IDisposable,
|
||||||
ICommandExecutor<EffectSetScreenEffectCommand>,
|
ICommandExecutor<EffectSetScreenEffectCommand>,
|
||||||
@@ -23,101 +25,125 @@ namespace Pal3.Game.Effect.PostProcessing
|
|||||||
ICommandExecutor<ResetGameStateCommand>,
|
ICommandExecutor<ResetGameStateCommand>,
|
||||||
ICommandExecutor<SettingChangedNotification>
|
ICommandExecutor<SettingChangedNotification>
|
||||||
{
|
{
|
||||||
private readonly PostProcessVolume _postProcessVolume;
|
private readonly Camera _camera;
|
||||||
private readonly PostProcessLayer _postProcessLayer;
|
private readonly UniversalAdditionalCameraData _cameraData;
|
||||||
private readonly GameSettings _gameSettings;
|
private readonly GameSettings _settings;
|
||||||
|
private readonly VolumeFrameworkUpdateMode _originalVolumeUpdateMode;
|
||||||
|
private readonly VolumeStack _originalVolumeStack;
|
||||||
|
private readonly bool _originalPostProcessing;
|
||||||
|
private readonly bool _originalHdr;
|
||||||
|
private readonly Pal3ScreenEffects _screenEffects;
|
||||||
|
private readonly bool _originalScreenEffectsEnabled;
|
||||||
|
private readonly bool _originalDistortion;
|
||||||
|
private readonly bool _originalSnow;
|
||||||
private readonly Bloom _bloom;
|
private readonly Bloom _bloom;
|
||||||
private readonly AmbientOcclusion _ambientOcclusion;
|
private readonly ColorAdjustments _colorGrading;
|
||||||
private readonly ColorGrading _colorGrading;
|
|
||||||
private readonly Vignette _vignette;
|
private readonly Vignette _vignette;
|
||||||
private readonly Distortion _distortion;
|
private VolumeStack _volumeStack;
|
||||||
private readonly Snow _snow;
|
private bool _volumeDirty = true;
|
||||||
|
private bool _gradingEnabled;
|
||||||
private int _currentAppliedEffectMode = -1;
|
private int _currentAppliedEffectMode = -1;
|
||||||
|
private bool _disposed;
|
||||||
|
|
||||||
public PostProcessManager(PostProcessVolume volume,
|
public PostProcessManager(VolumeProfile profile, Camera camera, GameSettings settings)
|
||||||
PostProcessLayer postProcessLayer,
|
|
||||||
GameSettings gameSettings)
|
|
||||||
{
|
{
|
||||||
_postProcessVolume = Requires.IsNotNull(volume, nameof(volume));
|
_camera = camera;
|
||||||
_postProcessLayer = Requires.IsNotNull(postProcessLayer, nameof(postProcessLayer));
|
_settings = settings;
|
||||||
_gameSettings = Requires.IsNotNull(gameSettings, nameof(gameSettings));
|
_cameraData = camera.GetUniversalAdditionalCameraData();
|
||||||
|
_originalVolumeUpdateMode = camera.GetVolumeFrameworkUpdateMode();
|
||||||
_bloom = _postProcessVolume.profile.GetSetting<Bloom>();
|
_originalVolumeStack = _cameraData.volumeStack;
|
||||||
ToggleBloomBasedOnSetting();
|
_originalPostProcessing = _cameraData.renderPostProcessing;
|
||||||
|
_originalHdr = camera.allowHDR;
|
||||||
_ambientOcclusion = _postProcessVolume.profile.GetSetting<AmbientOcclusion>();
|
_screenEffects = camera.TryGetComponent(out Pal3ScreenEffects existingEffects)
|
||||||
ToggleAmbientOcclusionBasedOnSetting();
|
? existingEffects
|
||||||
|
: camera.gameObject.AddComponent<Pal3ScreenEffects>();
|
||||||
// These are effects that are controlled and used by the game scripts
|
_originalScreenEffectsEnabled = existingEffects != null && existingEffects.enabled;
|
||||||
{
|
_originalDistortion = _screenEffects.Distortion;
|
||||||
_colorGrading = _postProcessVolume.profile.GetSetting<ColorGrading>();
|
_originalSnow = _screenEffects.Snow;
|
||||||
_colorGrading.active = false;
|
_screenEffects.enabled = true;
|
||||||
|
profile.TryGet(out _bloom);
|
||||||
_vignette = _postProcessVolume.profile.GetSetting<Vignette>();
|
profile.TryGet(out _colorGrading);
|
||||||
_vignette.active = false;
|
profile.TryGet(out _vignette);
|
||||||
|
|
||||||
_distortion = _postProcessVolume.profile.GetSetting<Distortion>();
|
|
||||||
_distortion.active = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Snow effect is controlled by pre-configured scene list
|
|
||||||
_snow = _postProcessVolume.profile.GetSetting<Snow>();
|
|
||||||
_snow.active = false;
|
|
||||||
|
|
||||||
TogglePostProcessLayerWhenNeeded();
|
|
||||||
|
|
||||||
|
UpdateBloom();
|
||||||
|
RenderPipelineManager.beginCameraRendering += RefreshVolumeStack;
|
||||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleBloomBasedOnSetting()
|
private bool BloomEnabled => _bloom != null && _settings.BloomEnabled;
|
||||||
|
|
||||||
|
private void UpdateBloom()
|
||||||
{
|
{
|
||||||
if (_gameSettings.IsRealtimeLightingAndShadowsEnabled)
|
_camera.allowHDR = BloomEnabled;
|
||||||
{
|
_volumeDirty = true;
|
||||||
// Pointless when lighting is on
|
UpdateCameraPostProcessing();
|
||||||
_bloom.active = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Enable bloom for better VFX visual fidelity on desktop devices
|
|
||||||
_bloom.active = UnityEngineUtility.IsDesktopDevice();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleAmbientOcclusionBasedOnSetting()
|
public void Execute(SettingChangedNotification command)
|
||||||
{
|
{
|
||||||
if (_gameSettings.IsRealtimeLightingAndShadowsEnabled)
|
if (command.SettingName == nameof(GameSettings.BloomEnabled)) UpdateBloom();
|
||||||
{
|
|
||||||
_ambientOcclusion.active = _gameSettings.IsAmbientOcclusionEnabled;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Pointless when lighting is off
|
|
||||||
_ambientOcclusion.active = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TogglePostProcessLayerWhenNeeded()
|
private void UpdateCameraPostProcessing()
|
||||||
{
|
{
|
||||||
if (_bloom.active ||
|
_cameraData.renderPostProcessing = BloomEnabled || _gradingEnabled;
|
||||||
_ambientOcclusion.active ||
|
}
|
||||||
_colorGrading.active ||
|
|
||||||
_vignette.active ||
|
private void RefreshVolumeStack(ScriptableRenderContext context, Camera camera)
|
||||||
_distortion.active ||
|
{
|
||||||
_snow.active)
|
if (camera != _camera || (!_volumeDirty && _volumeStack?.isValid == true)) return;
|
||||||
|
|
||||||
|
// Rebuild from URP defaults only when settings change. A private stack avoids
|
||||||
|
// blending another camera's Volume even when both cameras share a profile.
|
||||||
|
var manager = VolumeManager.instance;
|
||||||
|
var previous = _volumeStack;
|
||||||
|
_volumeStack = manager.CreateStack();
|
||||||
|
_cameraData.volumeStack = _volumeStack;
|
||||||
|
camera.SetVolumeFrameworkUpdateMode(VolumeFrameworkUpdateMode.ViaScripting);
|
||||||
|
manager.Update(_volumeStack, null, 0);
|
||||||
|
|
||||||
|
if (BloomEnabled) _bloom.Override(_volumeStack.GetComponent<Bloom>(), 1f);
|
||||||
|
if (_gradingEnabled)
|
||||||
{
|
{
|
||||||
_postProcessLayer.enabled = true;
|
_colorGrading?.Override(_volumeStack.GetComponent<ColorAdjustments>(), 1f);
|
||||||
}
|
_vignette?.Override(_volumeStack.GetComponent<Vignette>(), 1f);
|
||||||
else
|
|
||||||
{
|
|
||||||
_postProcessLayer.enabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DestroyVolumeStack(previous);
|
||||||
|
_volumeDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DestroyVolumeStack(VolumeStack stack)
|
||||||
|
{
|
||||||
|
if (stack?.isValid != true) return;
|
||||||
|
var manager = VolumeManager.instance;
|
||||||
|
if (manager.stack == stack) manager.ResetMainStack();
|
||||||
|
manager.DestroyStack(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (_disposed) return;
|
||||||
|
_disposed = true;
|
||||||
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
||||||
|
RenderPipelineManager.beginCameraRendering -= RefreshVolumeStack;
|
||||||
|
if (_screenEffects != null)
|
||||||
|
{
|
||||||
|
_screenEffects.Distortion = _originalDistortion;
|
||||||
|
_screenEffects.Snow = _originalSnow;
|
||||||
|
_screenEffects.enabled = _originalScreenEffectsEnabled;
|
||||||
|
}
|
||||||
|
DestroyVolumeStack(_volumeStack);
|
||||||
|
if (_cameraData != null)
|
||||||
|
{
|
||||||
|
if (_volumeStack != null && _cameraData.volumeStack == _volumeStack)
|
||||||
|
{
|
||||||
|
_cameraData.volumeStack = _originalVolumeStack?.isValid == true ? _originalVolumeStack : null;
|
||||||
|
_camera.SetVolumeFrameworkUpdateMode(_originalVolumeUpdateMode);
|
||||||
|
}
|
||||||
|
_cameraData.renderPostProcessing = _originalPostProcessing;
|
||||||
|
}
|
||||||
|
if (_camera != null) _camera.allowHDR = _originalHdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetCurrentAppliedEffectMode()
|
public int GetCurrentAppliedEffectMode()
|
||||||
@@ -132,28 +158,33 @@ namespace Pal3.Game.Effect.PostProcessing
|
|||||||
// Disable all post-processing effects used by the game
|
// Disable all post-processing effects used by the game
|
||||||
case -1:
|
case -1:
|
||||||
{
|
{
|
||||||
_colorGrading.active = false;
|
SetColorGrading(false);
|
||||||
_vignette.active = false;
|
_screenEffects.Distortion = false;
|
||||||
_distortion.active = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Distortion effect
|
// Distortion effect
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
_distortion.active = true;
|
_screenEffects.Distortion = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Vintage + color filter effect
|
// Vintage + color filter effect
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
_colorGrading.active = true;
|
SetColorGrading(true);
|
||||||
_vignette.active = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentAppliedEffectMode = command.Mode;
|
_currentAppliedEffectMode = command.Mode;
|
||||||
TogglePostProcessLayerWhenNeeded();
|
UpdateCameraPostProcessing();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetColorGrading(bool enabled)
|
||||||
|
{
|
||||||
|
if (_gradingEnabled == enabled) return;
|
||||||
|
_gradingEnabled = enabled;
|
||||||
|
_volumeDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(ResetGameStateCommand command)
|
public void Execute(ResetGameStateCommand command)
|
||||||
@@ -161,17 +192,6 @@ namespace Pal3.Game.Effect.PostProcessing
|
|||||||
Execute(new EffectSetScreenEffectCommand(-1));
|
Execute(new EffectSetScreenEffectCommand(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(SettingChangedNotification command)
|
|
||||||
{
|
|
||||||
if (command.SettingName is nameof(GameSettings.IsRealtimeLightingAndShadowsEnabled)
|
|
||||||
or nameof(GameSettings.IsAmbientOcclusionEnabled))
|
|
||||||
{
|
|
||||||
ToggleBloomBasedOnSetting();
|
|
||||||
ToggleAmbientOcclusionBasedOnSetting();
|
|
||||||
TogglePostProcessLayerWhenNeeded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(EffectShowSnowCommand command)
|
public void Execute(EffectShowSnowCommand command)
|
||||||
{
|
{
|
||||||
// Ignoring this command since now we control the snow effect based
|
// Ignoring this command since now we control the snow effect based
|
||||||
@@ -184,8 +204,7 @@ namespace Pal3.Game.Effect.PostProcessing
|
|||||||
if (command.NewSceneInfo.Is("q15", "q15") ||
|
if (command.NewSceneInfo.Is("q15", "q15") ||
|
||||||
command.NewSceneInfo.IsCity("m22"))
|
command.NewSceneInfo.IsCity("m22"))
|
||||||
{
|
{
|
||||||
_snow.active = true;
|
_screenEffects.Snow = true;
|
||||||
TogglePostProcessLayerWhenNeeded();
|
|
||||||
}
|
}
|
||||||
#elif PAL3A
|
#elif PAL3A
|
||||||
if (command.NewSceneInfo.Is("q02", "hs") ||
|
if (command.NewSceneInfo.Is("q02", "hs") ||
|
||||||
@@ -193,16 +212,14 @@ namespace Pal3.Game.Effect.PostProcessing
|
|||||||
command.NewSceneInfo.Is("q02", "xs") ||
|
command.NewSceneInfo.Is("q02", "xs") ||
|
||||||
command.NewSceneInfo.Is("q02", "zs"))
|
command.NewSceneInfo.Is("q02", "zs"))
|
||||||
{
|
{
|
||||||
_snow.active = true;
|
_screenEffects.Snow = true;
|
||||||
TogglePostProcessLayerWhenNeeded();
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(SceneLeavingCurrentSceneNotification command)
|
public void Execute(SceneLeavingCurrentSceneNotification command)
|
||||||
{
|
{
|
||||||
_snow.active = false;
|
_screenEffects.Snow = false;
|
||||||
TogglePostProcessLayerWhenNeeded();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
||||||
// See LICENSE file in the project root for license information.
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Pal3.Game.Effect.PostProcessing
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using Engine.Services;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.Rendering.PostProcessing;
|
|
||||||
|
|
||||||
[Serializable]
|
|
||||||
[PostProcess(typeof(SnowEffectRenderer), PostProcessEvent.AfterStack, "Pal3/Snow")]
|
|
||||||
public sealed class Snow : PostProcessEffectSettings
|
|
||||||
{
|
|
||||||
[Range(0.1f, 5.0f), Tooltip("Snow falling speed [X axis]")]
|
|
||||||
public FloatParameter xSpeed = new() { value = 2.0f };
|
|
||||||
|
|
||||||
[Range(0.1f, 5.0f), Tooltip("Snow falling speed [Y axis]")]
|
|
||||||
public FloatParameter ySpeed = new() { value = 1.0f };
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class SnowEffectRenderer : PostProcessEffectRenderer<Snow>
|
|
||||||
{
|
|
||||||
private static readonly int XSpeedPropertyId = ShaderUtility.GetPropertyIdByName("_xSpeed");
|
|
||||||
private static readonly int YSpeedPropertyId = ShaderUtility.GetPropertyIdByName("_ySpeed");
|
|
||||||
|
|
||||||
private Shader _shader;
|
|
||||||
|
|
||||||
public override void Init()
|
|
||||||
{
|
|
||||||
_shader = Shader.Find("Pal3/Snow");
|
|
||||||
base.Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Render(PostProcessRenderContext context)
|
|
||||||
{
|
|
||||||
PropertySheet sheet = context.propertySheets.Get(_shader);
|
|
||||||
sheet.properties.SetFloat(XSpeedPropertyId, settings.xSpeed);
|
|
||||||
sheet.properties.SetFloat(YSpeedPropertyId, settings.ySpeed);
|
|
||||||
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: dcb7f03e990a4b3eb9988671f88cd793
|
|
||||||
timeCreated: 1693107849
|
|
||||||
@@ -33,6 +33,7 @@ namespace Pal3.Game
|
|||||||
using SimpleFileBrowser;
|
using SimpleFileBrowser;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Assemblies;
|
||||||
using Transform = UnityEngine.Transform;
|
using Transform = UnityEngine.Transform;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -44,31 +45,11 @@ namespace Pal3.Game
|
|||||||
[SerializeField] private GameObject startingComponent;
|
[SerializeField] private GameObject startingComponent;
|
||||||
[SerializeField] private TextMeshProUGUI loadingText;
|
[SerializeField] private TextMeshProUGUI loadingText;
|
||||||
|
|
||||||
// Optional materials that are used in the game but not open sourced
|
|
||||||
private Material _toonOpaqueMaterial;
|
|
||||||
private Material _toonTransparentMaterial;
|
|
||||||
|
|
||||||
private IEnumerator Start()
|
private IEnumerator Start()
|
||||||
{
|
{
|
||||||
loadingText.text = "正在加载游戏数据...";
|
loadingText.text = "正在加载游戏数据...";
|
||||||
yield return null; // Wait for next frame to make sure the text is updated
|
yield return null; // Wait for next frame to make sure the text is updated
|
||||||
|
|
||||||
ResourceRequest toonOpaqueMaterialLoadRequest = Resources.LoadAsync<Material>("Materials/ToonDefault");
|
|
||||||
yield return toonOpaqueMaterialLoadRequest;
|
|
||||||
|
|
||||||
if (toonOpaqueMaterialLoadRequest.asset != null)
|
|
||||||
{
|
|
||||||
_toonOpaqueMaterial = toonOpaqueMaterialLoadRequest.asset as Material;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceRequest toonTransparentMaterialLoadRequest = Resources.LoadAsync<Material>("Materials/ToonTransparent");
|
|
||||||
yield return toonTransparentMaterialLoadRequest;
|
|
||||||
|
|
||||||
if (toonTransparentMaterialLoadRequest.asset != null)
|
|
||||||
{
|
|
||||||
_toonTransparentMaterial = toonTransparentMaterialLoadRequest.asset as Material;
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return InitResourceAsync();
|
yield return InitResourceAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,14 +62,11 @@ namespace Pal3.Game
|
|||||||
crcHash.Init();
|
crcHash.Init();
|
||||||
ServiceLocator.Instance.Register<Crc32Hash>(crcHash);
|
ServiceLocator.Instance.Register<Crc32Hash>(crcHash);
|
||||||
|
|
||||||
// If toon materials are not present, it's an open source build
|
|
||||||
bool isOpenSourceVersion = _toonOpaqueMaterial == null || _toonTransparentMaterial == null;
|
|
||||||
|
|
||||||
// Init settings store
|
// Init settings store
|
||||||
ITransactionalKeyValueStore settingsStore = new PlayerPrefsStore();
|
ITransactionalKeyValueStore settingsStore = new PlayerPrefsStore();
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
GameSettings gameSettings = new (settingsStore, isOpenSourceVersion);
|
GameSettings gameSettings = new (settingsStore);
|
||||||
gameSettings.InitOrLoadSettings();
|
gameSettings.InitOrLoadSettings();
|
||||||
ServiceLocator.Instance.Register<GameSettings>(gameSettings);
|
ServiceLocator.Instance.Register<GameSettings>(gameSettings);
|
||||||
|
|
||||||
@@ -162,7 +140,8 @@ namespace Pal3.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create and register IFileReader<T> instances using reflection
|
// Create and register IFileReader<T> instances using reflection
|
||||||
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
Assembly[] loadedAssemblies = CurrentAssemblies.GetLoadedAssemblies().ToArray();
|
||||||
|
foreach (Assembly assembly in loadedAssemblies)
|
||||||
{
|
{
|
||||||
// Get all types that implement any version of IFileReader<>
|
// Get all types that implement any version of IFileReader<>
|
||||||
IEnumerable<Type> fileReaderTypes = assembly.GetTypes().Where(type =>
|
IEnumerable<Type> fileReaderTypes = assembly.GetTypes().Where(type =>
|
||||||
@@ -194,27 +173,8 @@ namespace Pal3.Game
|
|||||||
IMaterialFactory materialFactory = new UnityMaterialFactory();
|
IMaterialFactory materialFactory = new UnityMaterialFactory();
|
||||||
ServiceLocator.Instance.Register<IMaterialFactory>(materialFactory);
|
ServiceLocator.Instance.Register<IMaterialFactory>(materialFactory);
|
||||||
|
|
||||||
// Init material factories
|
// Select the material family for the lifetime of this session.
|
||||||
IMaterialManager unlitMaterialManager = new UnlitMaterialManager(materialFactory);
|
IMaterialManager materialManager = new GameMaterialManager(materialFactory, gameSettings.ToonRendering);
|
||||||
|
|
||||||
IMaterialManager litMaterialManager = null;
|
|
||||||
// Only create litMaterialFactory when toon materials are present
|
|
||||||
if (_toonOpaqueMaterial != null && _toonTransparentMaterial != null)
|
|
||||||
{
|
|
||||||
litMaterialManager = new LitMaterialManager(materialFactory,
|
|
||||||
new UnityMaterial(_toonOpaqueMaterial, isClone: false),
|
|
||||||
new UnityMaterial(_toonTransparentMaterial, isClone: false));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pre-allocate material pool, since it is very costly to create new materials at runtime
|
|
||||||
if (!isOpenSourceVersion && gameSettings.IsRealtimeLightingAndShadowsEnabled && litMaterialManager != null)
|
|
||||||
{
|
|
||||||
litMaterialManager.AllocateMaterialPool();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unlitMaterialManager.AllocateMaterialPool();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init command related services
|
// Init command related services
|
||||||
SceCommandTypeResolver sceCommandTypeResolver = new SceCommandTypeResolver();
|
SceCommandTypeResolver sceCommandTypeResolver = new SceCommandTypeResolver();
|
||||||
@@ -225,7 +185,7 @@ namespace Pal3.Game
|
|||||||
ServiceLocator.Instance.Register<ISceCommandParser>(sceCommandParser);
|
ServiceLocator.Instance.Register<ISceCommandParser>(sceCommandParser);
|
||||||
|
|
||||||
SceCommandPreprocessor sceCommandPreprocessor = new SceCommandPreprocessor();
|
SceCommandPreprocessor sceCommandPreprocessor = new SceCommandPreprocessor();
|
||||||
sceCommandPreprocessor.Init();
|
sceCommandPreprocessor.Init(loadedAssemblies);
|
||||||
ServiceLocator.Instance.Register<ISceCommandPreprocessor>(sceCommandPreprocessor);
|
ServiceLocator.Instance.Register<ISceCommandPreprocessor>(sceCommandPreprocessor);
|
||||||
|
|
||||||
// Init scene object factory
|
// Init scene object factory
|
||||||
@@ -237,8 +197,7 @@ namespace Pal3.Game
|
|||||||
GameResourceProvider resourceProvider = new GameResourceProvider(cpkFileSystem,
|
GameResourceProvider resourceProvider = new GameResourceProvider(cpkFileSystem,
|
||||||
textureLoaderFactory,
|
textureLoaderFactory,
|
||||||
textureFactory,
|
textureFactory,
|
||||||
unlitMaterialManager,
|
materialManager,
|
||||||
litMaterialManager,
|
|
||||||
gameSettings);
|
gameSettings);
|
||||||
ServiceLocator.Instance.Register(resourceProvider);
|
ServiceLocator.Instance.Register(resourceProvider);
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ namespace Pal3.Game.GameSystems.Combat.Scene
|
|||||||
using Engine.Core.Abstraction;
|
using Engine.Core.Abstraction;
|
||||||
using Engine.Core.Implementation;
|
using Engine.Core.Implementation;
|
||||||
using Engine.Extensions;
|
using Engine.Extensions;
|
||||||
|
using Engine.Services;
|
||||||
|
using Settings;
|
||||||
|
using Rendering.Toon;
|
||||||
using Rendering.Material;
|
using Rendering.Material;
|
||||||
using Rendering.Renderer;
|
using Rendering.Renderer;
|
||||||
|
|
||||||
@@ -29,10 +32,12 @@ namespace Pal3.Game.GameSystems.Combat.Scene
|
|||||||
private const string COMBAT_CONFIG_FILE_NAME = "combat.ini";
|
private const string COMBAT_CONFIG_FILE_NAME = "combat.ini";
|
||||||
|
|
||||||
private GameResourceProvider _resourceProvider;
|
private GameResourceProvider _resourceProvider;
|
||||||
|
private GameSettings _lightingSettings;
|
||||||
|
private UnityEngine.Light _keyLight;
|
||||||
private IMaterialManager _materialManager;
|
private IMaterialManager _materialManager;
|
||||||
|
|
||||||
private string _combatSceneName;
|
private string _combatSceneName;
|
||||||
private bool _isLightingEnabled;
|
private bool _usesToonRendering;
|
||||||
|
|
||||||
private IGameEntity _parent;
|
private IGameEntity _parent;
|
||||||
private IGameEntity _mesh;
|
private IGameEntity _mesh;
|
||||||
@@ -55,11 +60,19 @@ namespace Pal3.Game.GameSystems.Combat.Scene
|
|||||||
|
|
||||||
public void Load(IGameEntity parent,
|
public void Load(IGameEntity parent,
|
||||||
string combatSceneName,
|
string combatSceneName,
|
||||||
bool isLightingEnabled)
|
bool usesToonRendering)
|
||||||
{
|
{
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
_combatSceneName = combatSceneName;
|
_combatSceneName = combatSceneName;
|
||||||
_isLightingEnabled = isLightingEnabled;
|
_usesToonRendering = usesToonRendering;
|
||||||
|
if (usesToonRendering)
|
||||||
|
{
|
||||||
|
_lightingSettings = ServiceLocator.Instance.Get<GameSettings>();
|
||||||
|
_keyLight = ToonLighting.CreateKey(transform, Quaternion.Euler(58f, -30f, 0f),
|
||||||
|
new UnityEngine.Color(1f, 0.95f, 0.9f), 1f);
|
||||||
|
ToonLighting.ConfigureKeyShadows(_keyLight, _lightingSettings);
|
||||||
|
_lightingSettings.OnGameSettingsChanged += OnLightingSettingsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
string meshFileRelativeFolderPath = FileConstants.CombatSceneFolderVirtualPath + combatSceneName;
|
string meshFileRelativeFolderPath = FileConstants.CombatSceneFolderVirtualPath + combatSceneName;
|
||||||
|
|
||||||
@@ -72,6 +85,16 @@ namespace Pal3.Game.GameSystems.Combat.Scene
|
|||||||
RenderMesh(polFile, sceneTextureProvider);
|
RenderMesh(polFile, sceneTextureProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnLightingSettingsChanged(string propertyName)
|
||||||
|
{
|
||||||
|
if (_keyLight != null) ToonLighting.ConfigureKeyShadows(_keyLight, _lightingSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDisableGameEntity()
|
||||||
|
{
|
||||||
|
if (_lightingSettings != null) _lightingSettings.OnGameSettingsChanged -= OnLightingSettingsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void RenderMesh(PolFile polFile, ITextureResourceProvider textureProvider)
|
private void RenderMesh(PolFile polFile, ITextureResourceProvider textureProvider)
|
||||||
{
|
{
|
||||||
// Render mesh
|
// Render mesh
|
||||||
@@ -129,7 +152,7 @@ namespace Pal3.Game.GameSystems.Combat.Scene
|
|||||||
_resourceProvider,
|
_resourceProvider,
|
||||||
combatActor,
|
combatActor,
|
||||||
elementPosition,
|
elementPosition,
|
||||||
isDropShadowEnabled: !_isLightingEnabled);
|
isDropShadowEnabled: !_usesToonRendering);
|
||||||
combatActorGameEntity.SetParent(_parent, worldPositionStays: false);
|
combatActorGameEntity.SetParent(_parent, worldPositionStays: false);
|
||||||
|
|
||||||
Quaternion rotation;
|
Quaternion rotation;
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
"GUID:75cff0429b0fa4147a3d84da245baf0d",
|
"GUID:75cff0429b0fa4147a3d84da245baf0d",
|
||||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||||
"GUID:d60799ab2a985554ea1a39cd38695018",
|
"Unity.RenderPipelines.Core.Runtime",
|
||||||
|
"Unity.RenderPipelines.Universal.Runtime",
|
||||||
"GUID:3de88c88fbbb8f944b9210d496af9762",
|
"GUID:3de88c88fbbb8f944b9210d496af9762",
|
||||||
"GUID:c685d05731421f64287ad6d13be5af0e"
|
"GUID:c685d05731421f64287ad6d13be5af0e"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Pal3.Game
|
|||||||
using GameSystems.WorldMap;
|
using GameSystems.WorldMap;
|
||||||
using Input;
|
using Input;
|
||||||
using IngameDebugConsole;
|
using IngameDebugConsole;
|
||||||
|
using Rendering.Toon;
|
||||||
using Scene;
|
using Scene;
|
||||||
using Script;
|
using Script;
|
||||||
using Script.Patcher;
|
using Script.Patcher;
|
||||||
@@ -57,7 +58,7 @@ namespace Pal3.Game
|
|||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
using UnityEngine.InputSystem.Controls;
|
using UnityEngine.InputSystem.Controls;
|
||||||
using UnityEngine.InputSystem.LowLevel;
|
using UnityEngine.InputSystem.LowLevel;
|
||||||
using UnityEngine.Rendering.PostProcessing;
|
using UnityEngine.Rendering;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityEngine.Video;
|
using UnityEngine.Video;
|
||||||
using Video;
|
using Video;
|
||||||
@@ -129,9 +130,8 @@ namespace Pal3.Game
|
|||||||
// Event system
|
// Event system
|
||||||
[SerializeField] private EventSystem eventSystem;
|
[SerializeField] private EventSystem eventSystem;
|
||||||
|
|
||||||
// Post-process volume and layer
|
// Post-processing
|
||||||
[SerializeField] private PostProcessVolume postProcessVolume;
|
[SerializeField] private VolumeProfile postProcessProfile;
|
||||||
[SerializeField] private PostProcessLayer postProcessLayer;
|
|
||||||
|
|
||||||
// Game logo
|
// Game logo
|
||||||
[SerializeField] private GameObject logoCanvas;
|
[SerializeField] private GameObject logoCanvas;
|
||||||
@@ -198,7 +198,8 @@ namespace Pal3.Game
|
|||||||
private MazeSkipper _mazeSkipper;
|
private MazeSkipper _mazeSkipper;
|
||||||
private MainMenu _mainMenu;
|
private MainMenu _mainMenu;
|
||||||
|
|
||||||
private IEnumerable<object> _allDisposableServices;
|
private IDisposable[] _allDisposableServices;
|
||||||
|
private ToonCameraLighting _toonCameraLighting;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
@@ -211,6 +212,10 @@ namespace Pal3.Game
|
|||||||
_fileSystem = Requires.IsNotNull(ServiceLocator.Instance.Get<ICpkFileSystem>(), nameof(ICpkFileSystem));
|
_fileSystem = Requires.IsNotNull(ServiceLocator.Instance.Get<ICpkFileSystem>(), nameof(ICpkFileSystem));
|
||||||
_gameResourceProvider = Requires.IsNotNull(ServiceLocator.Instance.Get<GameResourceProvider>(), nameof(GameResourceProvider));
|
_gameResourceProvider = Requires.IsNotNull(ServiceLocator.Instance.Get<GameResourceProvider>(), nameof(GameResourceProvider));
|
||||||
_gameResourceProvider.UseTextureCache(_textureCache);
|
_gameResourceProvider.UseTextureCache(_textureCache);
|
||||||
|
if (_gameResourceProvider.GetMaterialManager().UsesToonRendering)
|
||||||
|
{
|
||||||
|
_toonCameraLighting = ToonCameraLighting.Attach(mainCamera, _gameSettings);
|
||||||
|
}
|
||||||
|
|
||||||
_commandPreprocessor = Requires.IsNotNull(ServiceLocator.Instance.Get<ISceCommandPreprocessor>(), nameof(ISceCommandPreprocessor));
|
_commandPreprocessor = Requires.IsNotNull(ServiceLocator.Instance.Get<ISceCommandPreprocessor>(), nameof(ISceCommandPreprocessor));
|
||||||
|
|
||||||
@@ -278,7 +283,6 @@ namespace Pal3.Game
|
|||||||
sceneObjectFactory,
|
sceneObjectFactory,
|
||||||
_sceneStateManager,
|
_sceneStateManager,
|
||||||
_scriptManager,
|
_scriptManager,
|
||||||
_gameSettings,
|
|
||||||
cameraEntity)
|
cameraEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -346,9 +350,7 @@ namespace Pal3.Game
|
|||||||
);
|
);
|
||||||
|
|
||||||
ServiceLocator.Instance.Register(_postProcessManager =
|
ServiceLocator.Instance.Register(_postProcessManager =
|
||||||
new PostProcessManager(postProcessVolume,
|
new PostProcessManager(postProcessProfile, mainCamera, _gameSettings)
|
||||||
postProcessLayer,
|
|
||||||
_gameSettings)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ServiceLocator.Instance.Register(_effectManager =
|
ServiceLocator.Instance.Register(_effectManager =
|
||||||
@@ -513,7 +515,7 @@ namespace Pal3.Game
|
|||||||
eventSystem)
|
eventSystem)
|
||||||
);
|
);
|
||||||
|
|
||||||
_allDisposableServices = ServiceLocator.Instance.GetAllRegisteredServices().Where(o => o is IDisposable);
|
_allDisposableServices = ServiceLocator.Instance.GetAllRegisteredServices().OfType<IDisposable>().Distinct().ToArray();
|
||||||
|
|
||||||
DebugLogManager.Instance.OnLogWindowShown += OnDebugWindowShown;
|
DebugLogManager.Instance.OnLogWindowShown += OnDebugWindowShown;
|
||||||
DebugLogManager.Instance.OnLogWindowHidden += OnDebugWindowHidden;
|
DebugLogManager.Instance.OnLogWindowHidden += OnDebugWindowHidden;
|
||||||
@@ -689,15 +691,39 @@ namespace Pal3.Game
|
|||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
_gameSettings.OnGameSettingsChanged -= OnGameSettingsChanged;
|
try
|
||||||
|
|
||||||
DebugLogManager.Instance.OnLogWindowShown -= OnDebugWindowShown;
|
|
||||||
DebugLogManager.Instance.OnLogWindowHidden -= OnDebugWindowHidden;
|
|
||||||
|
|
||||||
foreach (IDisposable service in _allDisposableServices)
|
|
||||||
{
|
{
|
||||||
EngineLogger.Log($"Disposing service: [{service.GetType().Name}]");
|
if (_toonCameraLighting != null) _toonCameraLighting.Detach();
|
||||||
service.Dispose();
|
if (_gameSettings != null) _gameSettings.OnGameSettingsChanged -= OnGameSettingsChanged;
|
||||||
|
|
||||||
|
var console = DebugLogManager.Instance;
|
||||||
|
if (console != null)
|
||||||
|
{
|
||||||
|
console.OnLogWindowShown -= OnDebugWindowShown;
|
||||||
|
console.OnLogWindowHidden -= OnDebugWindowHidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialization can fail before the normal service snapshot is created.
|
||||||
|
IDisposable[] services = _allDisposableServices ??
|
||||||
|
FindAnyObjectByType<ServiceLocator>(FindObjectsInactive.Include)?.GetAllRegisteredServices()
|
||||||
|
.OfType<IDisposable>().Distinct().ToArray() ?? Array.Empty<IDisposable>();
|
||||||
|
foreach (IDisposable service in services)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
EngineLogger.Log($"Disposing service: [{service.GetType().Name}]");
|
||||||
|
service.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Debug.LogException(exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// Pipeline overrides must be restored even if another cleanup step fails.
|
||||||
|
_renderingSettingsManager?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
EngineLogger.Log("Game exited");
|
EngineLogger.Log("Game exited");
|
||||||
|
|||||||
@@ -0,0 +1,211 @@
|
|||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
||||||
|
// See LICENSE file in the project root for license information.
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Pal3.Game.Rendering.Material
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Core.Primitives;
|
||||||
|
using Engine.Core.Abstraction;
|
||||||
|
using Engine.Services;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
using Color = Core.Primitives.Color;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Material factory for the original and toon rendering styles.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class GameMaterialManager : MaterialManagerBase, IMaterialManager
|
||||||
|
{
|
||||||
|
private const string OpaqueShaderName = "Pal3/Opaque";
|
||||||
|
private const string TransparentShaderName = "Pal3/Transparent";
|
||||||
|
private const string AlphaCutoutShaderName = "Pal3/TransparentOpaquePart";
|
||||||
|
private const string WaterShaderName = "Pal3/Water";
|
||||||
|
private const string ToonWaterShaderName = "Pal3/ToonWater";
|
||||||
|
private const string ToonOpaqueShaderName = "Pal3/ToonOpaque";
|
||||||
|
private const string ToonTransparentShaderName = "Pal3/ToonTransparent";
|
||||||
|
private const string ToonCutoutShaderName = "Pal3/ToonCutout";
|
||||||
|
|
||||||
|
// Water material uniforms
|
||||||
|
private static readonly int WaterAlphaPropId = ShaderUtility.GetPropertyIdByName("_Alpha");
|
||||||
|
|
||||||
|
// Material properties shared by the original and Toon shaders
|
||||||
|
private static readonly int BlendSrcFactorPropertyId = ShaderUtility.GetPropertyIdByName("_BlendSrcFactor");
|
||||||
|
private static readonly int BlendDstFactorPropertyId = ShaderUtility.GetPropertyIdByName("_BlendDstFactor");
|
||||||
|
private static readonly int TintColorPropertyId = ShaderUtility.GetPropertyIdByName("_TintColor");
|
||||||
|
private static readonly int TransparentThresholdPropertyId = ShaderUtility.GetPropertyIdByName("_Threshold");
|
||||||
|
private static readonly int HasBakedLightmapId = ShaderUtility.GetPropertyIdByName("_HasShadowTex");
|
||||||
|
private static readonly int LightmapScalePropertyId = ShaderUtility.GetPropertyIdByName("_LightmapScale");
|
||||||
|
private static readonly int ReceiveShadowsPropertyId = ShaderUtility.GetPropertyIdByName("_ReceiveShadows");
|
||||||
|
private static readonly int CharacterPropertyId = ShaderUtility.GetPropertyIdByName("_IsCharacter");
|
||||||
|
private static readonly int ReceiveLightingPropertyId = ShaderUtility.GetPropertyIdByName("_ReceiveLighting");
|
||||||
|
private static readonly int BakedLightmapId = ShaderUtility.GetPropertyIdByName("_ShadowTex");
|
||||||
|
|
||||||
|
private const float DefaultAlphaCutoff = 0.9f;
|
||||||
|
private const float PolAlphaCutoff = 245f / 255f;
|
||||||
|
private const float DisabledAlphaCutoff = 2f;
|
||||||
|
private const float DefaultLightmapScale = 1f / 0.6f;
|
||||||
|
private const float PolLightmapScale = 2f;
|
||||||
|
|
||||||
|
public bool UsesToonRendering { get; }
|
||||||
|
|
||||||
|
private readonly IMaterial _waterMaterial;
|
||||||
|
private readonly IMaterial _transparentMaterial;
|
||||||
|
private readonly IMaterial _alphaCutoutMaterial;
|
||||||
|
private readonly IMaterial _opaqueMaterial;
|
||||||
|
|
||||||
|
private const int WATER_MATERIAL_POOL_SIZE = 100;
|
||||||
|
private const int TRANSPARENT_MATERIAL_POOL_SIZE = 1500;
|
||||||
|
private const int ALPHA_CUTOUT_MATERIAL_POOL_SIZE = 1500;
|
||||||
|
private const int OPAQUE_MATERIAL_POOL_SIZE = 2000;
|
||||||
|
|
||||||
|
private readonly Stack<IMaterial> _waterMaterialPool = new();
|
||||||
|
private readonly Stack<IMaterial> _transparentMaterialPool = new();
|
||||||
|
private readonly Stack<IMaterial> _alphaCutoutMaterialPool = new();
|
||||||
|
private readonly Stack<IMaterial> _opaqueMaterialPool = new();
|
||||||
|
|
||||||
|
private bool _disposed;
|
||||||
|
|
||||||
|
public GameMaterialManager(IMaterialFactory materialFactory, bool usesToonRendering) : base(materialFactory)
|
||||||
|
{
|
||||||
|
UsesToonRendering = usesToonRendering;
|
||||||
|
_waterMaterial = MaterialFactory.CreateMaterial(usesToonRendering ? ToonWaterShaderName : WaterShaderName);
|
||||||
|
_transparentMaterial = MaterialFactory.CreateMaterial(usesToonRendering ? ToonTransparentShaderName : TransparentShaderName);
|
||||||
|
_alphaCutoutMaterial = MaterialFactory.CreateMaterial(usesToonRendering ? ToonCutoutShaderName : AlphaCutoutShaderName);
|
||||||
|
_opaqueMaterial = MaterialFactory.CreateMaterial(usesToonRendering ? ToonOpaqueShaderName : OpaqueShaderName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_disposed) return;
|
||||||
|
_disposed = true;
|
||||||
|
DisposePool(_waterMaterialPool);
|
||||||
|
DisposePool(_transparentMaterialPool);
|
||||||
|
DisposePool(_alphaCutoutMaterialPool);
|
||||||
|
DisposePool(_opaqueMaterialPool);
|
||||||
|
_waterMaterial.Destroy();
|
||||||
|
_transparentMaterial.Destroy();
|
||||||
|
_alphaCutoutMaterial.Destroy();
|
||||||
|
_opaqueMaterial.Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DisposePool(Stack<IMaterial> pool)
|
||||||
|
{
|
||||||
|
while (pool.TryPop(out IMaterial material))
|
||||||
|
{
|
||||||
|
material.Destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IMaterial[] CreateStandardMaterials(
|
||||||
|
RendererType rendererType,
|
||||||
|
(string name, ITexture2D texture) mainTexture,
|
||||||
|
(string name, ITexture2D texture) bakedLightmap,
|
||||||
|
Color tintColor,
|
||||||
|
GameBoxBlendFlag blendFlag)
|
||||||
|
{
|
||||||
|
float lightmapScale = rendererType == RendererType.Pol ? PolLightmapScale : DefaultLightmapScale;
|
||||||
|
switch (blendFlag)
|
||||||
|
{
|
||||||
|
case GameBoxBlendFlag.Opaque:
|
||||||
|
return new[] { CreateMeshMaterial(_opaqueMaterialPool, _opaqueMaterial) };
|
||||||
|
case GameBoxBlendFlag.AlphaBlend:
|
||||||
|
{
|
||||||
|
float cutoff = rendererType == RendererType.Pol ? PolAlphaCutoff : DefaultAlphaCutoff;
|
||||||
|
IMaterial depthWriting = CreateMeshMaterial(_alphaCutoutMaterialPool,
|
||||||
|
_alphaCutoutMaterial);
|
||||||
|
depthWriting.SetFloat(TransparentThresholdPropertyId, cutoff);
|
||||||
|
return new[] { depthWriting, CreateBlendedMaterial(cutoff, BlendMode.SrcAlpha, BlendMode.OneMinusSrcAlpha) };
|
||||||
|
}
|
||||||
|
case GameBoxBlendFlag.InvertColorBlend:
|
||||||
|
return new[] { CreateBlendedMaterial(DisabledAlphaCutoff, BlendMode.One, BlendMode.OneMinusSrcColor) };
|
||||||
|
case GameBoxBlendFlag.AdditiveBlend:
|
||||||
|
return new[] { CreateBlendedMaterial(DisabledAlphaCutoff, BlendMode.One, BlendMode.One) };
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(blendFlag), blendFlag, "Unknown mesh blend mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
IMaterial CreateMeshMaterial(Stack<IMaterial> pool, IMaterial template)
|
||||||
|
{
|
||||||
|
IMaterial material = RentMaterial(pool, template);
|
||||||
|
material.SetMainTexture(mainTexture.texture);
|
||||||
|
material.SetColor(TintColorPropertyId, tintColor);
|
||||||
|
material.SetFloat(LightmapScalePropertyId, lightmapScale);
|
||||||
|
SetBakedLightmap(material, bakedLightmap.texture);
|
||||||
|
if (UsesToonRendering)
|
||||||
|
{
|
||||||
|
material.SetFloat(ReceiveShadowsPropertyId, 1f);
|
||||||
|
material.SetFloat(CharacterPropertyId, rendererType is RendererType.Mv3 or RendererType.Msh ? 1f : 0f);
|
||||||
|
}
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
IMaterial CreateBlendedMaterial(float cutoff, BlendMode sourceBlend, BlendMode destinationBlend)
|
||||||
|
{
|
||||||
|
IMaterial material = CreateMeshMaterial(_transparentMaterialPool, _transparentMaterial);
|
||||||
|
material.SetFloat(TransparentThresholdPropertyId, cutoff);
|
||||||
|
material.SetInt(BlendSrcFactorPropertyId, (int)sourceBlend);
|
||||||
|
material.SetInt(BlendDstFactorPropertyId, (int)destinationBlend);
|
||||||
|
if (UsesToonRendering)
|
||||||
|
{
|
||||||
|
// Additive and inverse-color meshes are emissive in the original assets.
|
||||||
|
material.SetFloat(ReceiveLightingPropertyId, sourceBlend == BlendMode.SrcAlpha ? 1f : 0f);
|
||||||
|
}
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IMaterial CreateWaterMaterial(
|
||||||
|
(string name, ITexture2D texture) mainTexture,
|
||||||
|
(string name, ITexture2D texture) bakedLightmap,
|
||||||
|
float opacity)
|
||||||
|
{
|
||||||
|
IMaterial material = RentMaterial(_waterMaterialPool, _waterMaterial);
|
||||||
|
material.SetMainTexture(mainTexture.texture);
|
||||||
|
material.SetFloat(WaterAlphaPropId, opacity);
|
||||||
|
if (UsesToonRendering) material.SetFloat(ReceiveShadowsPropertyId, 1f);
|
||||||
|
SetBakedLightmap(material, bakedLightmap.texture);
|
||||||
|
return material;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IMaterial RentMaterial(Stack<IMaterial> pool, IMaterial template)
|
||||||
|
{
|
||||||
|
return pool.TryPop(out IMaterial material) ? material : MaterialFactory.CreateMaterialFrom(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetBakedLightmap(IMaterial material, ITexture2D bakedLightmap)
|
||||||
|
{
|
||||||
|
material.SetFloat(HasBakedLightmapId, bakedLightmap == null ? 0f : 1f);
|
||||||
|
material.SetTexture(BakedLightmapId, bakedLightmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void ReturnToPool(IMaterial material)
|
||||||
|
{
|
||||||
|
if (material == null || material.IsNativeObjectDisposed) return;
|
||||||
|
|
||||||
|
(Stack<IMaterial> pool, int capacity) = material.ShaderName switch
|
||||||
|
{
|
||||||
|
WaterShaderName or ToonWaterShaderName => (_waterMaterialPool, WATER_MATERIAL_POOL_SIZE),
|
||||||
|
TransparentShaderName or ToonTransparentShaderName => (_transparentMaterialPool, TRANSPARENT_MATERIAL_POOL_SIZE),
|
||||||
|
AlphaCutoutShaderName or ToonCutoutShaderName => (_alphaCutoutMaterialPool,
|
||||||
|
ALPHA_CUTOUT_MATERIAL_POOL_SIZE),
|
||||||
|
OpaqueShaderName or ToonOpaqueShaderName => (_opaqueMaterialPool, OPAQUE_MATERIAL_POOL_SIZE),
|
||||||
|
_ => (null, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (pool == null) return;
|
||||||
|
if (_disposed || pool.Count >= capacity)
|
||||||
|
{
|
||||||
|
material.Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
material.SetMainTexture(null);
|
||||||
|
material.SetTexture(BakedLightmapId, null);
|
||||||
|
pool.Push(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -5,19 +5,14 @@
|
|||||||
|
|
||||||
namespace Pal3.Game.Rendering.Material
|
namespace Pal3.Game.Rendering.Material
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
using Core.Primitives;
|
using Core.Primitives;
|
||||||
using Engine.Core.Abstraction;
|
using Engine.Core.Abstraction;
|
||||||
using Color = Core.Primitives.Color;
|
using Color = Core.Primitives.Color;
|
||||||
|
|
||||||
public enum MaterialShaderType
|
public interface IMaterialManager : IDisposable
|
||||||
{
|
{
|
||||||
Unlit,
|
public bool UsesToonRendering { get; }
|
||||||
Lit,
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface IMaterialManager
|
|
||||||
{
|
|
||||||
public MaterialShaderType ShaderType { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a material for effect sprite without alpha channel.
|
/// Create a material for effect sprite without alpha channel.
|
||||||
@@ -37,14 +32,14 @@ namespace Pal3.Game.Rendering.Material
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rendererType">Renderer type</param>
|
/// <param name="rendererType">Renderer type</param>
|
||||||
/// <param name="mainTexture">Main texture</param>
|
/// <param name="mainTexture">Main texture</param>
|
||||||
/// <param name="shadowTexture">Shadow texture</param>
|
/// <param name="bakedLightmap">Baked lightmap</param>
|
||||||
/// <param name="tintColor">Tint color</param>
|
/// <param name="tintColor">Tint color</param>
|
||||||
/// <param name="blendFlag">Blend flag</param>
|
/// <param name="blendFlag">Blend flag</param>
|
||||||
/// <returns>Materials</returns>
|
/// <returns>Materials</returns>
|
||||||
public IMaterial[] CreateStandardMaterials(
|
public IMaterial[] CreateStandardMaterials(
|
||||||
RendererType rendererType,
|
RendererType rendererType,
|
||||||
(string name, ITexture2D texture) mainTexture,
|
(string name, ITexture2D texture) mainTexture,
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
(string name, ITexture2D texture) bakedLightmap,
|
||||||
Color tintColor,
|
Color tintColor,
|
||||||
GameBoxBlendFlag blendFlag);
|
GameBoxBlendFlag blendFlag);
|
||||||
|
|
||||||
@@ -52,15 +47,13 @@ namespace Pal3.Game.Rendering.Material
|
|||||||
/// Create material for water surface
|
/// Create material for water surface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mainTexture">Main texture</param>
|
/// <param name="mainTexture">Main texture</param>
|
||||||
/// <param name="shadowTexture">Shadow texture</param>
|
/// <param name="bakedLightmap">Baked lightmap</param>
|
||||||
/// <param name="opacity">Opacity</param>
|
/// <param name="opacity">Opacity</param>
|
||||||
/// <param name="blendFlag">Blend flag</param>
|
|
||||||
/// <returns>Material</returns>
|
/// <returns>Material</returns>
|
||||||
public IMaterial CreateWaterMaterial(
|
public IMaterial CreateWaterMaterial(
|
||||||
(string name, ITexture2D texture) mainTexture,
|
(string name, ITexture2D texture) mainTexture,
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
(string name, ITexture2D texture) bakedLightmap,
|
||||||
float opacity,
|
float opacity);
|
||||||
GameBoxBlendFlag blendFlag);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create material for sky box
|
/// Create material for sky box
|
||||||
@@ -80,26 +73,6 @@ namespace Pal3.Game.Rendering.Material
|
|||||||
ITexture2D upTex,
|
ITexture2D upTex,
|
||||||
ITexture2D downTex);
|
ITexture2D downTex);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update existing material with new texture.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="material">Material</param>
|
|
||||||
/// <param name="newMainTexture">New main texture</param>
|
|
||||||
/// <param name="blendFlag">Blend flag</param>
|
|
||||||
public void UpdateMaterial(IMaterial material,
|
|
||||||
ITexture2D newMainTexture,
|
|
||||||
GameBoxBlendFlag blendFlag);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Allocate a pool of materials.
|
|
||||||
/// </summary>
|
|
||||||
public void AllocateMaterialPool();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Deallocate the material pool.
|
|
||||||
/// </summary>
|
|
||||||
public void DeallocateMaterialPool();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return materials to the pool.
|
/// Return materials to the pool.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,315 +0,0 @@
|
|||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
||||||
// See LICENSE file in the project root for license information.
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Pal3.Game.Rendering.Material
|
|
||||||
{
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using Core.Primitives;
|
|
||||||
using Engine.Core.Abstraction;
|
|
||||||
using Engine.Logging;
|
|
||||||
using Engine.Services;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using Color = Core.Primitives.Color;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Lit material factory for generating materials
|
|
||||||
/// to be used when lighting and shadow are enabled
|
|
||||||
/// </summary>
|
|
||||||
public sealed class LitMaterialManager : MaterialManagerBase, IMaterialManager
|
|
||||||
{
|
|
||||||
// Toon material uniforms
|
|
||||||
private static readonly int BlendSrcFactorPropertyId = ShaderUtility.GetPropertyIdByName("_BlendSrcFactor");
|
|
||||||
private static readonly int BlendDstFactorPropertyId = ShaderUtility.GetPropertyIdByName("_BlendDstFactor");
|
|
||||||
private static readonly int CutoutPropertyId = ShaderUtility.GetPropertyIdByName("_Cutout");
|
|
||||||
private static readonly int LightIntensityPropertyId = ShaderUtility.GetPropertyIdByName("_LightIntensity");
|
|
||||||
private static readonly int OpacityPropertyId = ShaderUtility.GetPropertyIdByName("_Opacity");
|
|
||||||
private static readonly int EnvironmentalLightingIntensityPropertyId = ShaderUtility.GetPropertyIdByName("_EnvironmentalLightingIntensity");
|
|
||||||
|
|
||||||
private readonly IMaterial _toonOpaqueMaterial;
|
|
||||||
private readonly IMaterial _toonTransparentMaterial;
|
|
||||||
|
|
||||||
private const string OPAQUE_MATERIAL_SHADER_NAME = "RealToon/Version 5/Default/Default";
|
|
||||||
private const string TRANSPARENT_MATERIAL_SHADER_NAME = "RealToon/Version 5/Default/Fade Transparency";
|
|
||||||
|
|
||||||
private const int OPAQUE_MATERIAL_POOL_SIZE = 3500;
|
|
||||||
private const int TRANSPARENT_MATERIAL_POOL_SIZE = 500;
|
|
||||||
|
|
||||||
private readonly Stack<IMaterial> _opaqueMaterialPool = new (OPAQUE_MATERIAL_POOL_SIZE);
|
|
||||||
private readonly Stack<IMaterial> _transparentMaterialPool = new (TRANSPARENT_MATERIAL_POOL_SIZE);
|
|
||||||
|
|
||||||
private readonly float _opaqueMaterialCutoutPropertyDefaultValue;
|
|
||||||
private readonly float _opaqueMaterialLightIntensityPropertyDefaultValue;
|
|
||||||
private readonly float _opaqueMaterialEnvironmentalLightingIntensityPropertyDefaultValue;
|
|
||||||
|
|
||||||
private readonly int _transparentMaterialBlendSrcFactorPropertyDefaultValue;
|
|
||||||
private readonly int _transparentMaterialBlendDstFactorPropertyDefaultValue;
|
|
||||||
private readonly float _transparentMaterialOpacityPropertyDefaultValue;
|
|
||||||
private readonly float _transparentMaterialLightIntensityPropertyDefaultValue;
|
|
||||||
private readonly float _transparentMaterialEnvironmentalLightingIntensityPropertyDefaultValue;
|
|
||||||
|
|
||||||
private bool _isMaterialPoolAllocated = false;
|
|
||||||
|
|
||||||
public LitMaterialManager(
|
|
||||||
IMaterialFactory materialFactory,
|
|
||||||
IMaterial toonOpaqueMaterial,
|
|
||||||
IMaterial toonTransparentMaterial) : base (materialFactory)
|
|
||||||
{
|
|
||||||
_toonOpaqueMaterial = toonOpaqueMaterial;
|
|
||||||
_toonTransparentMaterial = toonTransparentMaterial;
|
|
||||||
|
|
||||||
_opaqueMaterialCutoutPropertyDefaultValue =
|
|
||||||
_toonOpaqueMaterial.GetFloat(CutoutPropertyId);
|
|
||||||
_opaqueMaterialLightIntensityPropertyDefaultValue =
|
|
||||||
_toonOpaqueMaterial.GetFloat(LightIntensityPropertyId);
|
|
||||||
_opaqueMaterialEnvironmentalLightingIntensityPropertyDefaultValue =
|
|
||||||
_toonOpaqueMaterial.GetFloat(EnvironmentalLightingIntensityPropertyId);
|
|
||||||
|
|
||||||
_transparentMaterialBlendSrcFactorPropertyDefaultValue =
|
|
||||||
_toonTransparentMaterial.GetInt(BlendSrcFactorPropertyId);
|
|
||||||
_transparentMaterialBlendDstFactorPropertyDefaultValue =
|
|
||||||
_toonTransparentMaterial.GetInt(BlendDstFactorPropertyId);
|
|
||||||
_transparentMaterialOpacityPropertyDefaultValue = _toonTransparentMaterial.GetFloat(OpacityPropertyId);
|
|
||||||
_transparentMaterialLightIntensityPropertyDefaultValue =
|
|
||||||
_toonTransparentMaterial.GetFloat(LightIntensityPropertyId);
|
|
||||||
_transparentMaterialEnvironmentalLightingIntensityPropertyDefaultValue =
|
|
||||||
_toonTransparentMaterial.GetFloat(EnvironmentalLightingIntensityPropertyId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AllocateMaterialPool()
|
|
||||||
{
|
|
||||||
if (_isMaterialPoolAllocated) return;
|
|
||||||
|
|
||||||
Stopwatch timer = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
for (int i = 0; i < OPAQUE_MATERIAL_POOL_SIZE; i++)
|
|
||||||
{
|
|
||||||
_opaqueMaterialPool.Push(MaterialFactory.CreateMaterialFrom(_toonOpaqueMaterial));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < TRANSPARENT_MATERIAL_POOL_SIZE; i++)
|
|
||||||
{
|
|
||||||
_transparentMaterialPool.Push(MaterialFactory.CreateMaterialFrom(_toonTransparentMaterial));
|
|
||||||
}
|
|
||||||
|
|
||||||
_isMaterialPoolAllocated = true;
|
|
||||||
|
|
||||||
EngineLogger.Log($"Material pool allocated in {timer.ElapsedMilliseconds} ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeallocateMaterialPool()
|
|
||||||
{
|
|
||||||
Stopwatch timer = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
while (_opaqueMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
_opaqueMaterialPool.Pop().Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_transparentMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
_transparentMaterialPool.Pop().Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
_isMaterialPoolAllocated = false;
|
|
||||||
|
|
||||||
EngineLogger.Log($"Material pool de-allocated in {timer.ElapsedMilliseconds} ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
public MaterialShaderType ShaderType => MaterialShaderType.Lit;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IMaterial[] CreateStandardMaterials(
|
|
||||||
RendererType rendererType,
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
Color tintColor,
|
|
||||||
GameBoxBlendFlag blendFlag)
|
|
||||||
{
|
|
||||||
IMaterial[] materials = null;
|
|
||||||
|
|
||||||
if (blendFlag is GameBoxBlendFlag.AlphaBlend or GameBoxBlendFlag.InvertColorBlend)
|
|
||||||
{
|
|
||||||
#if PAL3
|
|
||||||
// These are the texture/materials that have to be transparent in the game
|
|
||||||
// m23-3-05.tga => transparent doom like structure in PAL3 scene M23-3
|
|
||||||
// Q08QN10-05.tga => transparent coffin in PAL3 scene Q08-QN10
|
|
||||||
// m25-2-05.tga => transparent roof in PAL3 scene M25-2
|
|
||||||
// TODO: Add more if needed, by default we use opaque material
|
|
||||||
bool useTransparentMaterial = blendFlag == GameBoxBlendFlag.InvertColorBlend ||
|
|
||||||
mainTexture.name.Equals("m23-3-05.tga", StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
mainTexture.name.Equals("Q08QN10-05.tga", StringComparison.OrdinalIgnoreCase) ||
|
|
||||||
mainTexture.name.Equals("m25-2-05.tga", StringComparison.OrdinalIgnoreCase);
|
|
||||||
#elif PAL3A
|
|
||||||
bool useTransparentMaterial = blendFlag == GameBoxBlendFlag.InvertColorBlend;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For CVD renderer, we always use transparent material if blendFlag is
|
|
||||||
// InvertColorBlend or AlphaBlend
|
|
||||||
if (rendererType == RendererType.Cvd) useTransparentMaterial = true;
|
|
||||||
|
|
||||||
materials = new IMaterial[1];
|
|
||||||
materials[0] = useTransparentMaterial
|
|
||||||
? CreateBaseTransparentMaterial(mainTexture, shadowTexture)
|
|
||||||
: CreateBaseOpaqueMaterial(mainTexture, shadowTexture);
|
|
||||||
|
|
||||||
if (!useTransparentMaterial)
|
|
||||||
{
|
|
||||||
materials[0].SetFloat(CutoutPropertyId, 0.3f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blendFlag == GameBoxBlendFlag.InvertColorBlend)
|
|
||||||
{
|
|
||||||
materials[0].SetInt(BlendSrcFactorPropertyId, (int)BlendMode.SrcAlpha);
|
|
||||||
materials[0].SetInt(BlendDstFactorPropertyId, (int)BlendMode.One);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (blendFlag == GameBoxBlendFlag.Opaque)
|
|
||||||
{
|
|
||||||
materials = new IMaterial[1];
|
|
||||||
materials[0] = CreateBaseOpaqueMaterial(mainTexture, shadowTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (materials != null && rendererType == RendererType.Mv3)
|
|
||||||
{
|
|
||||||
// This is to make the shadow on actor lighter
|
|
||||||
materials[0].SetFloat(LightIntensityPropertyId, -0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateMaterial(IMaterial material, ITexture2D newMainTexture, GameBoxBlendFlag blendFlag)
|
|
||||||
{
|
|
||||||
if (newMainTexture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(newMainTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blendFlag is GameBoxBlendFlag.AlphaBlend or GameBoxBlendFlag.InvertColorBlend)
|
|
||||||
{
|
|
||||||
material.SetFloat(CutoutPropertyId, 0.3f);
|
|
||||||
}
|
|
||||||
else if (blendFlag == GameBoxBlendFlag.Opaque)
|
|
||||||
{
|
|
||||||
material.SetFloat(CutoutPropertyId, 0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IMaterial CreateWaterMaterial(
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
float opacity,
|
|
||||||
GameBoxBlendFlag blendFlag)
|
|
||||||
{
|
|
||||||
if (blendFlag == GameBoxBlendFlag.Opaque)
|
|
||||||
{
|
|
||||||
opacity = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a tweak to make the water surface look better
|
|
||||||
// when lit materials are used
|
|
||||||
opacity = opacity < 0.8f ? 0.8f : opacity;
|
|
||||||
|
|
||||||
// No need to use transparent material if alpha is close to 1
|
|
||||||
bool useTransparentMaterial = opacity < 0.9f;
|
|
||||||
|
|
||||||
if (useTransparentMaterial)
|
|
||||||
{
|
|
||||||
IMaterial material = CreateBaseTransparentMaterial(mainTexture, shadowTexture);
|
|
||||||
material.SetFloat(OpacityPropertyId, opacity);
|
|
||||||
material.SetFloat(EnvironmentalLightingIntensityPropertyId, 0.3f);
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IMaterial material = CreateBaseOpaqueMaterial(mainTexture, shadowTexture);
|
|
||||||
material.SetFloat(EnvironmentalLightingIntensityPropertyId, 0.5f);
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterial CreateBaseTransparentMaterial((string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture)
|
|
||||||
{
|
|
||||||
IMaterial material;
|
|
||||||
if (_transparentMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
material = _transparentMaterialPool.Pop();
|
|
||||||
// Reset material properties
|
|
||||||
material.SetInt(BlendSrcFactorPropertyId,
|
|
||||||
_transparentMaterialBlendSrcFactorPropertyDefaultValue);
|
|
||||||
material.SetInt(BlendDstFactorPropertyId,
|
|
||||||
_transparentMaterialBlendDstFactorPropertyDefaultValue);
|
|
||||||
material.SetFloat(OpacityPropertyId,
|
|
||||||
_transparentMaterialOpacityPropertyDefaultValue);
|
|
||||||
material.SetFloat(LightIntensityPropertyId,
|
|
||||||
_transparentMaterialLightIntensityPropertyDefaultValue);
|
|
||||||
material.SetFloat(EnvironmentalLightingIntensityPropertyId,
|
|
||||||
_transparentMaterialEnvironmentalLightingIntensityPropertyDefaultValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// In case we run out of transparent materials
|
|
||||||
material = MaterialFactory.CreateMaterialFrom(_toonTransparentMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mainTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(mainTexture.texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterial CreateBaseOpaqueMaterial((string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture)
|
|
||||||
{
|
|
||||||
IMaterial material;
|
|
||||||
if (_opaqueMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
material = _opaqueMaterialPool.Pop();
|
|
||||||
// Reset material properties
|
|
||||||
material.SetFloat(CutoutPropertyId,
|
|
||||||
_opaqueMaterialCutoutPropertyDefaultValue);
|
|
||||||
material.SetFloat(LightIntensityPropertyId,
|
|
||||||
_opaqueMaterialLightIntensityPropertyDefaultValue);
|
|
||||||
material.SetFloat(EnvironmentalLightingIntensityPropertyId,
|
|
||||||
_opaqueMaterialEnvironmentalLightingIntensityPropertyDefaultValue);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// In case we run out of opaque materials
|
|
||||||
material = MaterialFactory.CreateMaterialFrom(_toonOpaqueMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mainTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(mainTexture.texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ReturnToPool(IMaterial material)
|
|
||||||
{
|
|
||||||
switch (material.ShaderName)
|
|
||||||
{
|
|
||||||
case TRANSPARENT_MATERIAL_SHADER_NAME:
|
|
||||||
material.SetMainTexture(null);
|
|
||||||
_transparentMaterialPool.Push(material);
|
|
||||||
break;
|
|
||||||
case OPAQUE_MATERIAL_SHADER_NAME:
|
|
||||||
material.SetMainTexture(null);
|
|
||||||
_opaqueMaterialPool.Push(material);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 393e7c85fd6d4fdfb017eb2b9b57def3
|
|
||||||
timeCreated: 1666762795
|
|
||||||
@@ -1,367 +0,0 @@
|
|||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
||||||
// See LICENSE file in the project root for license information.
|
|
||||||
// ---------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace Pal3.Game.Rendering.Material
|
|
||||||
{
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using Core.Primitives;
|
|
||||||
using Engine.Core.Abstraction;
|
|
||||||
using Engine.Logging;
|
|
||||||
using Engine.Services;
|
|
||||||
using UnityEngine.Rendering;
|
|
||||||
using Color = Core.Primitives.Color;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Unlit material factory for generating materials that have similar
|
|
||||||
/// look and feel as the original game
|
|
||||||
/// </summary>
|
|
||||||
public sealed class UnlitMaterialManager : MaterialManagerBase, IMaterialManager
|
|
||||||
{
|
|
||||||
// Pal3 unlit shaders
|
|
||||||
private const string OPAQUE_SHADER_PATH = "Pal3/Opaque";
|
|
||||||
private const string TRANSPARENT_SHADER_PATH = "Pal3/Transparent";
|
|
||||||
private const string TRANSPARENT_OPAQUE_PART_SHADER_PATH = "Pal3/TransparentOpaquePart";
|
|
||||||
private const string WATER_SHADER_PATH = "Pal3/Water";
|
|
||||||
|
|
||||||
private const string OPAQUE_SHADER_NAME = "Pal3/Opaque";
|
|
||||||
private const string TRANSPARENT_SHADER_NAME = "Pal3/Transparent";
|
|
||||||
private const string TRANSPARENT_OPAQUE_PART_SHADER_NAME = "Pal3/TransparentOpaquePart";
|
|
||||||
private const string WATER_SHADER_NAME = "Pal3/Water";
|
|
||||||
|
|
||||||
// Water material uniforms
|
|
||||||
private static readonly int WaterAlphaPropId = ShaderUtility.GetPropertyIdByName("_Alpha");
|
|
||||||
private static readonly int WaterHasShadowTexPropId = ShaderUtility.GetPropertyIdByName("_HasShadowTex");
|
|
||||||
|
|
||||||
// Standard material uniforms for Pal3 unlit shaders
|
|
||||||
private static readonly int BlendSrcFactorPropertyId = ShaderUtility.GetPropertyIdByName("_BlendSrcFactor");
|
|
||||||
private static readonly int BlendDstFactorPropertyId = ShaderUtility.GetPropertyIdByName("_BlendDstFactor");
|
|
||||||
private static readonly int TintColorPropertyId = ShaderUtility.GetPropertyIdByName("_TintColor");
|
|
||||||
private static readonly int TransparentThresholdPropertyId = ShaderUtility.GetPropertyIdByName("_Threshold");
|
|
||||||
private static readonly int HasShadowTexturePropertyId = ShaderUtility.GetPropertyIdByName("_HasShadowTex");
|
|
||||||
private static readonly int ShadowTexturePropertyId = ShaderUtility.GetPropertyIdByName("_ShadowTex");
|
|
||||||
|
|
||||||
private const float DEFAULT_TRANSPARENT_THRESHOLD = 0.9f;
|
|
||||||
|
|
||||||
public MaterialShaderType ShaderType => MaterialShaderType.Unlit;
|
|
||||||
|
|
||||||
private readonly IMaterial _waterMaterial;
|
|
||||||
private readonly IMaterial _transparentMaterial;
|
|
||||||
private readonly IMaterial _transparentOpaquePartMaterial;
|
|
||||||
private readonly IMaterial _opaqueMaterial;
|
|
||||||
|
|
||||||
private const int WATER_MATERIAL_POOL_SIZE = 100;
|
|
||||||
private const int TRANSPARENT_MATERIAL_POOL_SIZE = 1500;
|
|
||||||
private const int TRANSPARENT_OPAQUE_PART_MATERIAL_POOL_SIZE = 1500;
|
|
||||||
private const int OPAQUE_MATERIAL_POOL_SIZE = 2000;
|
|
||||||
|
|
||||||
private readonly Stack<IMaterial> _waterMaterialPool = new (WATER_MATERIAL_POOL_SIZE);
|
|
||||||
private readonly Stack<IMaterial> _transparentMaterialPool = new (TRANSPARENT_MATERIAL_POOL_SIZE);
|
|
||||||
private readonly Stack<IMaterial> _transparentOpaquePartMaterialPool = new (TRANSPARENT_OPAQUE_PART_MATERIAL_POOL_SIZE);
|
|
||||||
private readonly Stack<IMaterial> _opaqueMaterialPool = new (OPAQUE_MATERIAL_POOL_SIZE);
|
|
||||||
|
|
||||||
private bool _isMaterialPoolAllocated = false;
|
|
||||||
|
|
||||||
public UnlitMaterialManager(IMaterialFactory materialFactory) : base(materialFactory)
|
|
||||||
{
|
|
||||||
_waterMaterial = MaterialFactory.CreateMaterial(WATER_SHADER_PATH);
|
|
||||||
_transparentMaterial = MaterialFactory.CreateMaterial(TRANSPARENT_SHADER_PATH);
|
|
||||||
_transparentOpaquePartMaterial = MaterialFactory.CreateMaterial(TRANSPARENT_OPAQUE_PART_SHADER_PATH);
|
|
||||||
_opaqueMaterial = MaterialFactory.CreateMaterial(OPAQUE_SHADER_PATH);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AllocateMaterialPool()
|
|
||||||
{
|
|
||||||
if (_isMaterialPoolAllocated) return;
|
|
||||||
|
|
||||||
Stopwatch timer = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
for (int i = 0; i < WATER_MATERIAL_POOL_SIZE; i++)
|
|
||||||
{
|
|
||||||
_waterMaterialPool.Push(MaterialFactory.CreateMaterialFrom(_waterMaterial));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < TRANSPARENT_MATERIAL_POOL_SIZE; i++)
|
|
||||||
{
|
|
||||||
_transparentMaterialPool.Push(MaterialFactory.CreateMaterialFrom(_transparentMaterial));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < TRANSPARENT_OPAQUE_PART_MATERIAL_POOL_SIZE; i++)
|
|
||||||
{
|
|
||||||
_transparentOpaquePartMaterialPool.Push(MaterialFactory.CreateMaterialFrom(_transparentOpaquePartMaterial));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < OPAQUE_MATERIAL_POOL_SIZE; i++)
|
|
||||||
{
|
|
||||||
_opaqueMaterialPool.Push(MaterialFactory.CreateMaterialFrom(_opaqueMaterial));
|
|
||||||
}
|
|
||||||
|
|
||||||
EngineLogger.Log($"Material pool allocated in {timer.ElapsedMilliseconds} ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeallocateMaterialPool()
|
|
||||||
{
|
|
||||||
Stopwatch timer = Stopwatch.StartNew();
|
|
||||||
|
|
||||||
while (_waterMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
_waterMaterialPool.Pop().Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_transparentMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
_transparentMaterialPool.Pop().Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_transparentOpaquePartMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
_transparentOpaquePartMaterialPool.Pop().Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (_opaqueMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
_opaqueMaterialPool.Pop().Destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
_isMaterialPoolAllocated = false;
|
|
||||||
|
|
||||||
EngineLogger.Log($"Material pool de-allocated in {timer.ElapsedMilliseconds} ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IMaterial[] CreateStandardMaterials(
|
|
||||||
RendererType rendererType,
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
Color tintColor,
|
|
||||||
GameBoxBlendFlag blendFlag)
|
|
||||||
{
|
|
||||||
IMaterial[] materials = null;
|
|
||||||
|
|
||||||
float transparentThreshold = DEFAULT_TRANSPARENT_THRESHOLD;
|
|
||||||
|
|
||||||
if (shadowTexture.texture == null && rendererType == RendererType.Pol)
|
|
||||||
{
|
|
||||||
transparentThreshold = 1.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blendFlag is GameBoxBlendFlag.AlphaBlend or GameBoxBlendFlag.InvertColorBlend)
|
|
||||||
{
|
|
||||||
materials = new IMaterial[2];
|
|
||||||
materials[0] = CreateTransparentOpaquePartMaterial(mainTexture,
|
|
||||||
shadowTexture,
|
|
||||||
tintColor,
|
|
||||||
transparentThreshold);
|
|
||||||
materials[1] = CreateTransparentMaterial(mainTexture,
|
|
||||||
shadowTexture,
|
|
||||||
tintColor,
|
|
||||||
transparentThreshold);
|
|
||||||
|
|
||||||
BlendMode srcFactor;
|
|
||||||
BlendMode destFactor;
|
|
||||||
|
|
||||||
if (blendFlag == GameBoxBlendFlag.InvertColorBlend)
|
|
||||||
{
|
|
||||||
srcFactor = BlendMode.SrcAlpha;
|
|
||||||
destFactor = BlendMode.One;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
srcFactor = BlendMode.SrcAlpha;
|
|
||||||
destFactor = BlendMode.OneMinusSrcAlpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
materials[1].SetInt(BlendSrcFactorPropertyId, (int)srcFactor);
|
|
||||||
materials[1].SetInt(BlendDstFactorPropertyId, (int)destFactor);
|
|
||||||
}
|
|
||||||
else if (blendFlag == GameBoxBlendFlag.Opaque)
|
|
||||||
{
|
|
||||||
materials = new IMaterial[1];
|
|
||||||
materials[0] = CreateOpaqueMaterial(mainTexture, shadowTexture, tintColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
return materials;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateMaterial(IMaterial material,
|
|
||||||
ITexture2D newMainTexture,
|
|
||||||
GameBoxBlendFlag blendFlag)
|
|
||||||
{
|
|
||||||
if (newMainTexture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(newMainTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blendFlag is GameBoxBlendFlag.AlphaBlend or GameBoxBlendFlag.InvertColorBlend)
|
|
||||||
{
|
|
||||||
material.SetFloat(TransparentThresholdPropertyId, DEFAULT_TRANSPARENT_THRESHOLD);
|
|
||||||
}
|
|
||||||
else if (blendFlag == GameBoxBlendFlag.Opaque)
|
|
||||||
{
|
|
||||||
material.SetFloat(TransparentThresholdPropertyId, 0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public IMaterial CreateWaterMaterial(
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
float opacity,
|
|
||||||
GameBoxBlendFlag blendFlag)
|
|
||||||
{
|
|
||||||
IMaterial material;
|
|
||||||
if (_waterMaterialPool.Count > 0)
|
|
||||||
{
|
|
||||||
material = _waterMaterialPool.Pop();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
material = MaterialFactory.CreateMaterialFrom(_waterMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mainTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(mainTexture.texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
material.SetFloat(WaterAlphaPropId, opacity);
|
|
||||||
|
|
||||||
if (shadowTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetFloat(WaterHasShadowTexPropId, 1.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, shadowTexture.texture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
material.SetFloat(WaterHasShadowTexPropId, 0.5f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
}
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterial CreateTransparentMaterial(
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
Color tintColor,
|
|
||||||
float transparentThreshold)
|
|
||||||
{
|
|
||||||
IMaterial material = _transparentMaterialPool.Count > 0 ?
|
|
||||||
_transparentMaterialPool.Pop() :
|
|
||||||
MaterialFactory.CreateMaterialFrom(_transparentMaterial);
|
|
||||||
|
|
||||||
if (mainTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(mainTexture.texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
material.SetColor(TintColorPropertyId, tintColor);
|
|
||||||
material.SetFloat(TransparentThresholdPropertyId, transparentThreshold);
|
|
||||||
|
|
||||||
if (shadowTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetFloat(HasShadowTexturePropertyId, 1.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, shadowTexture.texture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
material.SetFloat(HasShadowTexturePropertyId, 0.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterial CreateTransparentOpaquePartMaterial(
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
Color tintColor,
|
|
||||||
float transparentThreshold)
|
|
||||||
{
|
|
||||||
IMaterial material = _transparentOpaquePartMaterialPool.Count > 0 ?
|
|
||||||
_transparentOpaquePartMaterialPool.Pop() :
|
|
||||||
MaterialFactory.CreateMaterialFrom(_transparentOpaquePartMaterial);
|
|
||||||
|
|
||||||
if (mainTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(mainTexture.texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
material.SetColor(TintColorPropertyId, tintColor);
|
|
||||||
material.SetFloat(TransparentThresholdPropertyId, transparentThreshold);
|
|
||||||
|
|
||||||
if (shadowTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetFloat(HasShadowTexturePropertyId, 1.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, shadowTexture.texture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
material.SetFloat(HasShadowTexturePropertyId, 0.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IMaterial CreateOpaqueMaterial(
|
|
||||||
(string name, ITexture2D texture) mainTexture,
|
|
||||||
(string name, ITexture2D texture) shadowTexture,
|
|
||||||
Color tintColor)
|
|
||||||
{
|
|
||||||
IMaterial material = _opaqueMaterialPool.Count > 0 ?
|
|
||||||
_opaqueMaterialPool.Pop() :
|
|
||||||
MaterialFactory.CreateMaterialFrom(_opaqueMaterial);
|
|
||||||
|
|
||||||
if (mainTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetMainTexture(mainTexture.texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
material.SetColor(TintColorPropertyId, tintColor);
|
|
||||||
|
|
||||||
if (shadowTexture.texture != null)
|
|
||||||
{
|
|
||||||
material.SetFloat(HasShadowTexturePropertyId, 1.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, shadowTexture.texture);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
material.SetFloat(HasShadowTexturePropertyId, 0.0f);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return material;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void ReturnToPool(IMaterial material)
|
|
||||||
{
|
|
||||||
switch (material.ShaderName)
|
|
||||||
{
|
|
||||||
case WATER_SHADER_NAME:
|
|
||||||
material.SetMainTexture(null);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
_waterMaterialPool.Push(material);
|
|
||||||
break;
|
|
||||||
case TRANSPARENT_SHADER_NAME:
|
|
||||||
material.SetMainTexture(null);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
_transparentMaterialPool.Push(material);
|
|
||||||
break;
|
|
||||||
case TRANSPARENT_OPAQUE_PART_SHADER_NAME:
|
|
||||||
material.SetMainTexture(null);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
_transparentOpaquePartMaterialPool.Push(material);
|
|
||||||
break;
|
|
||||||
case OPAQUE_SHADER_NAME:
|
|
||||||
material.SetMainTexture(null);
|
|
||||||
material.SetTexture(ShadowTexturePropertyId, null);
|
|
||||||
_opaqueMaterialPool.Push(material);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -50,6 +50,74 @@ namespace Pal3.Game.Rendering
|
|||||||
TriangleBuffer = AllocateOrResize(TriangleBuffer, triangleBufferSize);
|
TriangleBuffer = AllocateOrResize(TriangleBuffer, triangleBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep lighting continuous where UVs split the same original vertex.
|
||||||
|
public void RebuildNormalsBySourceVertex(int[] sourceIndices, Vector3[] normals)
|
||||||
|
{
|
||||||
|
Array.Clear(normals, 0, normals.Length);
|
||||||
|
int[] triangles = TriangleBuffer;
|
||||||
|
Vector3[] vertices = VertexBuffer;
|
||||||
|
for (int i = 0; i < triangles.Length; i += 3)
|
||||||
|
{
|
||||||
|
int a = triangles[i];
|
||||||
|
int b = triangles[i + 1];
|
||||||
|
int c = triangles[i + 2];
|
||||||
|
Vector3 normal = Vector3.Cross(vertices[b] - vertices[a], vertices[c] - vertices[a]);
|
||||||
|
normals[sourceIndices[a]] += normal;
|
||||||
|
normals[sourceIndices[b]] += normal;
|
||||||
|
normals[sourceIndices[c]] += normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < normals.Length; i++)
|
||||||
|
{
|
||||||
|
normals[i] = NormalizeFaceNormal(normals[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Coincident surfaces can still cancel even after splitting reversed faces.
|
||||||
|
// Use the first valid incident face for any referenced vertex with no direction.
|
||||||
|
foreach (int index in sourceIndices)
|
||||||
|
{
|
||||||
|
if (normals[index] == Vector3.zero)
|
||||||
|
{
|
||||||
|
RestoreCancelledNormals(sourceIndices, normals);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < sourceIndices.Length; i++)
|
||||||
|
{
|
||||||
|
NormalBuffer[i] = normals[sourceIndices[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RestoreCancelledNormals(int[] sourceIndices, Vector3[] normals)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < TriangleBuffer.Length; i += 3)
|
||||||
|
{
|
||||||
|
int a = TriangleBuffer[i];
|
||||||
|
int b = TriangleBuffer[i + 1];
|
||||||
|
int c = TriangleBuffer[i + 2];
|
||||||
|
int first = sourceIndices[a];
|
||||||
|
int second = sourceIndices[b];
|
||||||
|
int third = sourceIndices[c];
|
||||||
|
bool firstMissing = normals[first] == Vector3.zero;
|
||||||
|
bool secondMissing = normals[second] == Vector3.zero;
|
||||||
|
bool thirdMissing = normals[third] == Vector3.zero;
|
||||||
|
if (!firstMissing && !secondMissing && !thirdMissing) continue;
|
||||||
|
|
||||||
|
Vector3 normal = NormalizeFaceNormal(Vector3.Cross(VertexBuffer[b] - VertexBuffer[a],
|
||||||
|
VertexBuffer[c] - VertexBuffer[a]));
|
||||||
|
if (firstMissing) normals[first] = normal;
|
||||||
|
if (secondMissing) normals[second] = normal;
|
||||||
|
if (thirdMissing) normals[third] = normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vector3 NormalizeFaceNormal(Vector3 normal)
|
||||||
|
{
|
||||||
|
float length = normal.magnitude;
|
||||||
|
return length > 1e-12f ? normal / length : Vector3.zero;
|
||||||
|
}
|
||||||
|
|
||||||
private static T[] AllocateOrResize<T>(T[] buffer, int size)
|
private static T[] AllocateOrResize<T>(T[] buffer, int size)
|
||||||
{
|
{
|
||||||
if (buffer == null)
|
if (buffer == null)
|
||||||
|
|||||||
@@ -5,12 +5,14 @@
|
|||||||
|
|
||||||
namespace Pal3.Game.Rendering
|
namespace Pal3.Game.Rendering
|
||||||
{
|
{
|
||||||
|
using Engine.Core.Abstraction;
|
||||||
using Engine.Renderer;
|
using Engine.Renderer;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public sealed class RenderMeshComponent
|
public sealed class RenderMeshComponent
|
||||||
{
|
{
|
||||||
public Mesh Mesh { get; set; }
|
public Mesh Mesh { get; set; }
|
||||||
|
public IMaterial[] Materials { get; set; }
|
||||||
public StaticMeshRenderer MeshRenderer { get; set; }
|
public StaticMeshRenderer MeshRenderer { get; set; }
|
||||||
public MeshDataBuffer MeshDataBuffer { get; set; }
|
public MeshDataBuffer MeshDataBuffer { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,20 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
public sealed class CvdModelRenderer : GameEntityScript, IDisposable
|
public sealed class CvdModelRenderer : GameEntityScript, IDisposable
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, ITexture2D> _textureCache = new ();
|
private readonly Dictionary<string, ITexture2D> _textureCache = new ();
|
||||||
private readonly List<(CvdGeometryNode, Dictionary<int, RenderMeshComponent>)> _renderers = new ();
|
private readonly List<CvdNodeRenderState> _renderers = new();
|
||||||
|
|
||||||
|
private sealed class CvdNodeRenderState
|
||||||
|
{
|
||||||
|
public readonly CvdGeometryNode Node;
|
||||||
|
public readonly List<(int index, RenderMeshComponent renderMesh)> Sections = new();
|
||||||
|
public (Matrix4x4 matrix, int frameIndex, float influence) Pose;
|
||||||
|
|
||||||
|
public CvdNodeRenderState(CvdGeometryNode node, (Matrix4x4 matrix, int frameIndex, float influence) pose)
|
||||||
|
{
|
||||||
|
Node = node;
|
||||||
|
Pose = pose;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Color _tintColor;
|
private Color _tintColor;
|
||||||
|
|
||||||
@@ -99,11 +112,9 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
bool boundsInitialized = false;
|
bool boundsInitialized = false;
|
||||||
Bounds bounds = new (Transform.Position, Vector3.one);
|
Bounds bounds = new (Transform.Position, Vector3.one);
|
||||||
|
|
||||||
foreach ((CvdGeometryNode node, Dictionary<int, RenderMeshComponent> meshComponents) in _renderers)
|
foreach (CvdNodeRenderState node in _renderers)
|
||||||
{
|
{
|
||||||
if (!node.IsGeometryNode) continue;
|
foreach (var (_, meshComponent) in node.Sections)
|
||||||
|
|
||||||
foreach (RenderMeshComponent meshComponent in meshComponents.Values)
|
|
||||||
{
|
{
|
||||||
Bounds rendererBounds = meshComponent.MeshRenderer.GetRendererBounds();
|
Bounds rendererBounds = meshComponent.MeshRenderer.GetRendererBounds();
|
||||||
if (!boundsInitialized)
|
if (!boundsInitialized)
|
||||||
@@ -126,11 +137,9 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
bool boundsInitialized = false;
|
bool boundsInitialized = false;
|
||||||
Bounds bounds = new (Vector3.zero, Vector3.one);
|
Bounds bounds = new (Vector3.zero, Vector3.one);
|
||||||
|
|
||||||
foreach ((CvdGeometryNode node, Dictionary<int, RenderMeshComponent> meshComponents) in _renderers)
|
foreach (CvdNodeRenderState node in _renderers)
|
||||||
{
|
{
|
||||||
if (!node.IsGeometryNode) continue;
|
foreach (var (_, meshComponent) in node.Sections)
|
||||||
|
|
||||||
foreach (RenderMeshComponent meshComponent in meshComponents.Values)
|
|
||||||
{
|
{
|
||||||
Bounds meshBounds = meshComponent.MeshRenderer.GetMeshBounds();
|
Bounds meshBounds = meshComponent.MeshRenderer.GetMeshBounds();
|
||||||
if (!boundsInitialized)
|
if (!boundsInitialized)
|
||||||
@@ -215,19 +224,9 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
if (node.IsGeometryNode)
|
if (node.IsGeometryNode)
|
||||||
{
|
{
|
||||||
(CvdGeometryNode node, Dictionary<int, RenderMeshComponent> meshComponents) nodeMeshes =
|
var nodeMeshes = new CvdNodeRenderState(node, SamplePose(node, initTime));
|
||||||
(node, new Dictionary<int, RenderMeshComponent>());
|
var (frameMatrix, frameIndex, influence) = nodeMeshes.Pose;
|
||||||
|
bool usesToon = _materialManager.UsesToonRendering;
|
||||||
int frameIndex = GetFrameIndex(node.Mesh.AnimationTimeKeys, initTime);
|
|
||||||
Matrix4x4 frameMatrix = GetFrameMatrix(initTime, node);
|
|
||||||
|
|
||||||
float influence = 0f;
|
|
||||||
if (initTime > float.Epsilon && frameIndex + 1 < node.Mesh.AnimationTimeKeys.Length)
|
|
||||||
{
|
|
||||||
influence = (initTime - node.Mesh.AnimationTimeKeys[frameIndex]) /
|
|
||||||
(node.Mesh.AnimationTimeKeys[frameIndex + 1] -
|
|
||||||
node.Mesh.AnimationTimeKeys[frameIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < node.Mesh.MeshSections.Length; i++)
|
for (int i = 0; i < node.Mesh.MeshSections.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -235,23 +234,14 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
string sectionHashKey = $"{meshName}_{i}";
|
string sectionHashKey = $"{meshName}_{i}";
|
||||||
|
|
||||||
MeshDataBuffer meshDataBuffer = new(meshSection.FrameVertices[frameIndex].Length,
|
|
||||||
meshSection.FrameVertices[frameIndex].Length,
|
|
||||||
meshSection.FrameVertices[frameIndex].Length,
|
|
||||||
meshSection.GameBoxTriangles.Length);
|
|
||||||
|
|
||||||
// Triangles are the same for all frames, so we can just copy them once.
|
|
||||||
meshSection.GameBoxTriangles.ToUnityTriangles(meshDataBuffer.TriangleBuffer);
|
|
||||||
|
|
||||||
UpdateMeshDataBuffer(ref meshDataBuffer,
|
|
||||||
meshSection,
|
|
||||||
frameIndex,
|
|
||||||
influence,
|
|
||||||
frameMatrix);
|
|
||||||
|
|
||||||
string textureName = meshSection.Material.TextureFileNames[0];
|
string textureName = meshSection.Material.TextureFileNames[0];
|
||||||
|
if (string.IsNullOrEmpty(textureName) || !textureCache.TryGetValue(textureName, out ITexture2D texture))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(textureName) || !textureCache.ContainsKey(textureName)) continue;
|
int vertexCount = meshSection.FrameVertices[frameIndex].Length;
|
||||||
|
MeshDataBuffer meshDataBuffer = new(vertexCount, 0, vertexCount, meshSection.GameBoxTriangles.Length);
|
||||||
|
meshSection.GameBoxTriangles.ToUnityTriangles(meshDataBuffer.TriangleBuffer);
|
||||||
|
UpdateMeshDataBuffer(meshDataBuffer, meshSection, frameIndex, influence, frameMatrix);
|
||||||
|
|
||||||
IGameEntity meshSectionEntity = GameEntityFactory.Create($"{sectionHashKey}",
|
IGameEntity meshSectionEntity = GameEntityFactory.Create($"{sectionHashKey}",
|
||||||
meshEntity, worldPositionStays: false);
|
meshEntity, worldPositionStays: false);
|
||||||
@@ -265,8 +255,8 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
IMaterial[] materials = _materialManager.CreateStandardMaterials(
|
IMaterial[] materials = _materialManager.CreateStandardMaterials(
|
||||||
RendererType.Cvd,
|
RendererType.Cvd,
|
||||||
mainTexture: (textureName, textureCache[textureName]),
|
mainTexture: (textureName, texture),
|
||||||
shadowTexture: default, // CVD models don't have shadow textures
|
bakedLightmap: default, // CVD models don't have shadow textures
|
||||||
tintColor: _tintColor,
|
tintColor: _tintColor,
|
||||||
blendFlag: meshSection.BlendFlag);
|
blendFlag: meshSection.BlendFlag);
|
||||||
|
|
||||||
@@ -274,22 +264,21 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
Mesh renderMesh = meshRenderer.Render(
|
Mesh renderMesh = meshRenderer.Render(
|
||||||
vertices: meshDataBuffer.VertexBuffer,
|
vertices: meshDataBuffer.VertexBuffer,
|
||||||
triangles: meshDataBuffer.TriangleBuffer,
|
triangles: meshDataBuffer.TriangleBuffer,
|
||||||
normals: meshDataBuffer.NormalBuffer,
|
normals: null,
|
||||||
mainTextureUvs: (channel: 0, uvs: meshDataBuffer.UvBuffer),
|
mainTextureUvs: (channel: 0, uvs: meshDataBuffer.UvBuffer),
|
||||||
secondaryTextureUvs: default, // CVD models don't have secondary texture
|
secondaryTextureUvs: default, // CVD models don't have secondary texture
|
||||||
materials: materials,
|
materials: materials,
|
||||||
isDynamic: true);
|
isDynamic: true);
|
||||||
|
|
||||||
renderMesh.RecalculateNormals();
|
if (usesToon) renderMesh.RecalculateNormals();
|
||||||
renderMesh.RecalculateTangents();
|
|
||||||
renderMesh.RecalculateBounds();
|
|
||||||
|
|
||||||
nodeMeshes.meshComponents[i] = new RenderMeshComponent
|
nodeMeshes.Sections.Add((i, new RenderMeshComponent
|
||||||
{
|
{
|
||||||
Mesh = renderMesh,
|
Mesh = renderMesh,
|
||||||
MeshRenderer = meshRenderer,
|
MeshRenderer = meshRenderer,
|
||||||
|
Materials = materials,
|
||||||
MeshDataBuffer = meshDataBuffer
|
MeshDataBuffer = meshDataBuffer
|
||||||
};
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderers.Add(nodeMeshes);
|
_renderers.Add(nodeMeshes);
|
||||||
@@ -306,11 +295,22 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMeshDataBuffer(ref MeshDataBuffer meshDataBuffer,
|
private (Matrix4x4 matrix, int frameIndex, float influence) SamplePose(CvdGeometryNode node, float time)
|
||||||
|
{
|
||||||
|
float[] times = node.Mesh.AnimationTimeKeys;
|
||||||
|
int frameIndex = GetFrameIndex(times, time);
|
||||||
|
float influence = time > float.Epsilon && frameIndex + 1 < times.Length
|
||||||
|
? (time - times[frameIndex]) / (times[frameIndex + 1] - times[frameIndex])
|
||||||
|
: 0f;
|
||||||
|
return (GetFrameMatrix(time, node), frameIndex, influence);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void UpdateMeshDataBuffer(MeshDataBuffer meshDataBuffer,
|
||||||
CvdMeshSection meshSection,
|
CvdMeshSection meshSection,
|
||||||
int frameIndex,
|
int frameIndex,
|
||||||
float influence,
|
float influence,
|
||||||
Matrix4x4 matrix)
|
Matrix4x4 matrix,
|
||||||
|
bool updateUvs = true)
|
||||||
{
|
{
|
||||||
CvdVertex[] frameVertices = meshSection.FrameVertices[frameIndex];
|
CvdVertex[] frameVertices = meshSection.FrameVertices[frameIndex];
|
||||||
|
|
||||||
@@ -320,22 +320,23 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
{
|
{
|
||||||
meshDataBuffer.VertexBuffer[i] = matrix.MultiplyPoint3x4(
|
meshDataBuffer.VertexBuffer[i] = matrix.MultiplyPoint3x4(
|
||||||
frameVertices[i].GameBoxPosition.CvdPositionToUnityPosition());
|
frameVertices[i].GameBoxPosition.CvdPositionToUnityPosition());
|
||||||
meshDataBuffer.UvBuffer[i] = frameVertices[i].Uv.ToUnityVector2();
|
if (updateUvs) meshDataBuffer.UvBuffer[i] = frameVertices[i].Uv.ToUnityVector2();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
CvdVertex[] toFrameVertices = meshSection.FrameVertices[frameIndex + 1];
|
||||||
for (int i = 0; i < frameVertices.Length; i++)
|
for (int i = 0; i < frameVertices.Length; i++)
|
||||||
{
|
{
|
||||||
CvdVertex[] toFrameVertices = meshSection.FrameVertices[frameIndex + 1];
|
|
||||||
Vector3 lerpPosition = Vector3.Lerp(
|
Vector3 lerpPosition = Vector3.Lerp(
|
||||||
frameVertices[i].GameBoxPosition.CvdPositionToUnityPosition(),
|
frameVertices[i].GameBoxPosition.CvdPositionToUnityPosition(),
|
||||||
toFrameVertices[i].GameBoxPosition.CvdPositionToUnityPosition(), influence);
|
toFrameVertices[i].GameBoxPosition.CvdPositionToUnityPosition(), influence);
|
||||||
meshDataBuffer.VertexBuffer[i] = matrix.MultiplyPoint3x4(lerpPosition);
|
meshDataBuffer.VertexBuffer[i] = matrix.MultiplyPoint3x4(lerpPosition);
|
||||||
Vector2 lerpUv = Vector2.Lerp(
|
if (updateUvs)
|
||||||
frameVertices[i].Uv.ToUnityVector2(),
|
{
|
||||||
toFrameVertices[i].Uv.ToUnityVector2(), influence);
|
meshDataBuffer.UvBuffer[i] = Vector2.Lerp(frameVertices[i].Uv.ToUnityVector2(),
|
||||||
meshDataBuffer.UvBuffer[i] = lerpUv;
|
toFrameVertices[i].Uv.ToUnityVector2(), influence);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,36 +344,33 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
private void UpdateMesh(float time)
|
private void UpdateMesh(float time)
|
||||||
{
|
{
|
||||||
_currentAnimationTime = time;
|
_currentAnimationTime = time;
|
||||||
|
if (_renderers.Count == 0) return;
|
||||||
|
|
||||||
foreach ((CvdGeometryNode node, Dictionary<int, RenderMeshComponent> renderMeshComponents) in _renderers)
|
bool usesToon = _materialManager.UsesToonRendering;
|
||||||
|
foreach (CvdNodeRenderState node in _renderers)
|
||||||
{
|
{
|
||||||
int frameIndex = GetFrameIndex(node.Mesh.AnimationTimeKeys, time);
|
var pose = SamplePose(node.Node, time);
|
||||||
Matrix4x4 frameMatrix = GetFrameMatrix(time, node);
|
var previous = node.Pose;
|
||||||
|
bool matrixChanged = !pose.matrix.Equals(previous.matrix);
|
||||||
|
bool vertexFrameChanged = pose.frameIndex != previous.frameIndex || pose.influence != previous.influence;
|
||||||
|
if (!matrixChanged && !vertexFrameChanged) continue;
|
||||||
|
node.Pose = pose;
|
||||||
|
|
||||||
float influence = 0f;
|
bool normalTransformChanged = usesToon &&
|
||||||
if (time > float.Epsilon && frameIndex + 1 < node.Mesh.AnimationTimeKeys.Length)
|
(!pose.matrix.GetColumn(0).Equals(previous.matrix.GetColumn(0)) ||
|
||||||
|
!pose.matrix.GetColumn(1).Equals(previous.matrix.GetColumn(1)) ||
|
||||||
|
!pose.matrix.GetColumn(2).Equals(previous.matrix.GetColumn(2)));
|
||||||
|
|
||||||
|
foreach (var (sectionIndex, renderMesh) in node.Sections)
|
||||||
{
|
{
|
||||||
influence = (time - node.Mesh.AnimationTimeKeys[frameIndex]) /
|
Mesh mesh = renderMesh.Mesh;
|
||||||
(node.Mesh.AnimationTimeKeys[frameIndex + 1] -
|
MeshDataBuffer buffer = renderMesh.MeshDataBuffer;
|
||||||
node.Mesh.AnimationTimeKeys[frameIndex]);
|
CvdMeshSection source = node.Node.Mesh.MeshSections[sectionIndex];
|
||||||
}
|
UpdateMeshDataBuffer(buffer, source, pose.frameIndex, pose.influence, pose.matrix, vertexFrameChanged);
|
||||||
|
mesh.SetVertices(buffer.VertexBuffer);
|
||||||
for (int i = 0; i < node.Mesh.MeshSections.Length; i++)
|
if (usesToon && (vertexFrameChanged || normalTransformChanged)) mesh.RecalculateNormals();
|
||||||
{
|
if (vertexFrameChanged) mesh.SetUVs(0, buffer.UvBuffer);
|
||||||
if (!renderMeshComponents.TryGetValue(i, out RenderMeshComponent renderMeshComponent)) continue;
|
mesh.RecalculateBounds();
|
||||||
|
|
||||||
CvdMeshSection meshSection = node.Mesh.MeshSections[i];
|
|
||||||
|
|
||||||
MeshDataBuffer meshDataBuffer = renderMeshComponent.MeshDataBuffer;
|
|
||||||
UpdateMeshDataBuffer(ref meshDataBuffer,
|
|
||||||
meshSection,
|
|
||||||
frameIndex,
|
|
||||||
influence,
|
|
||||||
frameMatrix);
|
|
||||||
|
|
||||||
renderMeshComponent.Mesh.SetVertices(meshDataBuffer.VertexBuffer);
|
|
||||||
renderMeshComponent.Mesh.SetUVs(0, meshDataBuffer.UvBuffer);
|
|
||||||
renderMeshComponent.Mesh.RecalculateBounds();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -591,12 +589,19 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
{
|
{
|
||||||
StopCurrentAnimation();
|
StopCurrentAnimation();
|
||||||
|
|
||||||
foreach (StaticMeshRenderer meshRenderer in GetComponentsInChildren<StaticMeshRenderer>())
|
foreach (CvdNodeRenderState node in _renderers)
|
||||||
{
|
{
|
||||||
_materialManager.ReturnToPool(meshRenderer.GetMaterials());
|
foreach (var (_, component) in node.Sections)
|
||||||
meshRenderer.Dispose();
|
{
|
||||||
meshRenderer.Destroy();
|
if (component.MeshRenderer != null)
|
||||||
|
{
|
||||||
|
component.MeshRenderer.Dispose();
|
||||||
|
component.MeshRenderer.Destroy();
|
||||||
|
}
|
||||||
|
_materialManager.ReturnToPool(component.Materials);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_renderers.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,7 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
private ITexture2D[] _textures;
|
private ITexture2D[] _textures;
|
||||||
private bool[] _textureHasAlphaChannel;
|
private bool[] _textureHasAlphaChannel;
|
||||||
private IMaterial[][] _materials;
|
private IMaterial[][] _materials;
|
||||||
|
private Vector3[][] _sourceNormals;
|
||||||
private string[] _animationName;
|
private string[] _animationName;
|
||||||
private uint[][] _frameTicks;
|
private uint[][] _frameTicks;
|
||||||
private IGameEntity[] _meshEntities;
|
private IGameEntity[] _meshEntities;
|
||||||
@@ -109,6 +110,11 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
_meshEntities = new IGameEntity[_meshCount];
|
_meshEntities = new IGameEntity[_meshCount];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_materialManager.UsesToonRendering && (_sourceNormals == null || _sourceNormals.Length != _meshCount))
|
||||||
|
{
|
||||||
|
_sourceNormals = new Vector3[_meshCount][];
|
||||||
|
}
|
||||||
|
|
||||||
// Same for tag nodes
|
// Same for tag nodes
|
||||||
if (_tagNodesInfo.Length > 0)
|
if (_tagNodesInfo.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -187,7 +193,7 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
_gbMaterials[index] = material;
|
_gbMaterials[index] = material;
|
||||||
_textures[index] = _textureProvider.GetTexture(textureName, out bool hasAlphaChannel);
|
_textures[index] = _textureProvider.GetTexture(textureName, out bool hasAlphaChannel);
|
||||||
_textureHasAlphaChannel[index]= hasAlphaChannel;
|
_textureHasAlphaChannel[index] = hasAlphaChannel;
|
||||||
_animationName[index] = mv3Mesh.Name;
|
_animationName[index] = mv3Mesh.Name;
|
||||||
|
|
||||||
Mv3AnimationKeyFrame[] keyFrames = mv3Mesh.KeyFrames;
|
Mv3AnimationKeyFrame[] keyFrames = mv3Mesh.KeyFrames;
|
||||||
@@ -217,57 +223,42 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
StaticMeshRenderer meshRenderer = _meshEntities[index].AddComponent<StaticMeshRenderer>();
|
StaticMeshRenderer meshRenderer = _meshEntities[index].AddComponent<StaticMeshRenderer>();
|
||||||
|
|
||||||
IMaterial[] materials = _materialManager.CreateStandardMaterials(
|
_materials[index] = CreateMaterials(textureName, _textures[index], hasAlphaChannel);
|
||||||
RendererType.Mv3,
|
|
||||||
mainTexture: (textureName, _textures[index]),
|
|
||||||
shadowTexture: default, // MV3 models don't have shadow textures
|
|
||||||
tintColor: _tintColor,
|
|
||||||
blendFlag: _textureHasAlphaChannel[index] ? GameBoxBlendFlag.AlphaBlend : GameBoxBlendFlag.Opaque);
|
|
||||||
|
|
||||||
_materials[index] = materials;
|
|
||||||
|
|
||||||
#if PAL3A
|
|
||||||
// Apply PAL3A texture scaling/tiling fix
|
|
||||||
string texturePath = _textureProvider.GetTexturePath(textureName);
|
|
||||||
if (Dev.TexturePatcher.TextureFileHasWrongTiling(texturePath))
|
|
||||||
{
|
|
||||||
_materials[index][0].SetMainTextureScale(1f, -1f);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_renderMeshComponents[index] ??= new RenderMeshComponent();
|
_renderMeshComponents[index] ??= new RenderMeshComponent();
|
||||||
_renderMeshComponents[index].MeshDataBuffer ??= new MeshDataBuffer();
|
_renderMeshComponents[index].MeshDataBuffer ??= new MeshDataBuffer();
|
||||||
|
|
||||||
_renderMeshComponents[index].MeshDataBuffer
|
MeshDataBuffer buffer = _renderMeshComponents[index].MeshDataBuffer;
|
||||||
.AllocateOrResizeBuffers(vertexBufferSize: mv3Mesh.KeyFrames[0].GameBoxVertices.Length,
|
bool usesToon = _materialManager.UsesToonRendering;
|
||||||
normalBufferSize: mv3Mesh.GameBoxNormals.Length,
|
int vertexCount = mv3Mesh.KeyFrames[0].GameBoxVertices.Length;
|
||||||
|
buffer.AllocateOrResizeBuffers(vertexBufferSize: vertexCount,
|
||||||
|
normalBufferSize: usesToon ? vertexCount : 0,
|
||||||
uvBufferSize: mv3Mesh.Uvs.Length,
|
uvBufferSize: mv3Mesh.Uvs.Length,
|
||||||
triangleBufferSize: mv3Mesh.GameBoxTriangles.Length);
|
triangleBufferSize: mv3Mesh.GameBoxTriangles.Length);
|
||||||
|
|
||||||
mv3Mesh.KeyFrames[0].GameBoxVertices.ToUnityPositions(
|
mv3Mesh.KeyFrames[0].GameBoxVertices.ToUnityPositions(
|
||||||
_renderMeshComponents[index].MeshDataBuffer.VertexBuffer,
|
buffer.VertexBuffer, UnityPrimitivesConvertor.GameBoxMv3UnitToUnityUnit);
|
||||||
UnityPrimitivesConvertor.GameBoxMv3UnitToUnityUnit);
|
mv3Mesh.GameBoxTriangles.ToUnityTriangles(buffer.TriangleBuffer);
|
||||||
|
mv3Mesh.Uvs.ToUnityVector2s(buffer.UvBuffer);
|
||||||
|
|
||||||
mv3Mesh.GameBoxTriangles.ToUnityTriangles(
|
if (usesToon)
|
||||||
_renderMeshComponents[index].MeshDataBuffer.TriangleBuffer);
|
{
|
||||||
|
if (_sourceNormals[index]?.Length != mv3Mesh.NormalCount)
|
||||||
mv3Mesh.GameBoxNormals.ToUnityNormals(
|
{
|
||||||
_renderMeshComponents[index].MeshDataBuffer.NormalBuffer);
|
_sourceNormals[index] = new Vector3[mv3Mesh.NormalCount];
|
||||||
|
}
|
||||||
mv3Mesh.Uvs.ToUnityVector2s(
|
buffer.RebuildNormalsBySourceVertex(mv3Mesh.NormalIndices, _sourceNormals[index]);
|
||||||
_renderMeshComponents[index].MeshDataBuffer.UvBuffer);
|
}
|
||||||
|
|
||||||
Mesh renderMesh = meshRenderer.Render(
|
Mesh renderMesh = meshRenderer.Render(
|
||||||
vertices: _renderMeshComponents[index].MeshDataBuffer.VertexBuffer,
|
vertices: buffer.VertexBuffer,
|
||||||
triangles: _renderMeshComponents[index].MeshDataBuffer.TriangleBuffer,
|
triangles: buffer.TriangleBuffer,
|
||||||
normals: _renderMeshComponents[index].MeshDataBuffer.NormalBuffer,
|
normals: usesToon ? buffer.NormalBuffer : null,
|
||||||
mainTextureUvs: (channel: 0, uvs: _renderMeshComponents[index].MeshDataBuffer.UvBuffer),
|
mainTextureUvs: (channel: 0, uvs: buffer.UvBuffer),
|
||||||
secondaryTextureUvs: default, // MV3 models don't have secondary texture
|
secondaryTextureUvs: default, // MV3 models don't have secondary texture
|
||||||
materials: _materials[index],
|
materials: _materials[index],
|
||||||
isDynamic: true);
|
isDynamic: true);
|
||||||
|
|
||||||
renderMesh.RecalculateTangents();
|
|
||||||
|
|
||||||
_renderMeshComponents[index].Mesh = renderMesh;
|
_renderMeshComponents[index].Mesh = renderMesh;
|
||||||
_renderMeshComponents[index].MeshRenderer = meshRenderer;
|
_renderMeshComponents[index].MeshRenderer = meshRenderer;
|
||||||
}
|
}
|
||||||
@@ -285,17 +276,70 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
StartCoroutine(PlayAnimationInternalAsync(loopCount, _animationCts.Token));
|
StartCoroutine(PlayAnimationInternalAsync(loopCount, _animationCts.Token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IMaterial[] CreateMaterials(string textureName, ITexture2D texture, bool hasAlphaChannel)
|
||||||
|
{
|
||||||
|
IMaterial[] materials = _materialManager.CreateStandardMaterials(
|
||||||
|
RendererType.Mv3,
|
||||||
|
mainTexture: (textureName, texture),
|
||||||
|
bakedLightmap: default,
|
||||||
|
tintColor: _tintColor,
|
||||||
|
blendFlag: hasAlphaChannel ? GameBoxBlendFlag.AlphaBlend : GameBoxBlendFlag.Opaque);
|
||||||
|
ApplyTextureScale(materials, textureName);
|
||||||
|
return materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ApplyTextureScale(IMaterial[] materials, string textureName)
|
||||||
|
{
|
||||||
|
#if PAL3A
|
||||||
|
string texturePath = _textureProvider.GetTexturePath(textureName);
|
||||||
|
float scaleY = Dev.TexturePatcher.TextureFileHasWrongTiling(texturePath) ? -1f : 1f;
|
||||||
|
foreach (IMaterial material in materials)
|
||||||
|
{
|
||||||
|
material.SetMainTextureScale(1f, scaleY);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public void ChangeTexture(string textureName)
|
public void ChangeTexture(string textureName)
|
||||||
{
|
{
|
||||||
|
if (!IsInitialized || _meshCount == 0) return;
|
||||||
if (!textureName.Contains(".")) textureName += MV3_MODEL_DEFAULT_TEXTURE_EXTENSION;
|
if (!textureName.Contains(".")) textureName += MV3_MODEL_DEFAULT_TEXTURE_EXTENSION;
|
||||||
|
|
||||||
_textures[0] = _textureProvider.GetTexture(textureName, out var hasAlphaChannel);
|
ITexture2D texture = _textureProvider.GetTexture(textureName, out bool hasAlphaChannel);
|
||||||
_textureHasAlphaChannel[0] = hasAlphaChannel;
|
if (texture == null) return;
|
||||||
|
|
||||||
// Change the texture for the first sub-mesh only
|
// ActorChangeTexture targets the first sub-mesh and all of its material passes.
|
||||||
_materialManager.UpdateMaterial(_materials[0][0], _textures[0], _textureHasAlphaChannel[0] ?
|
IMaterial[] materials = _materials[0];
|
||||||
GameBoxBlendFlag.AlphaBlend :
|
if (_textureHasAlphaChannel[0] != hasAlphaChannel)
|
||||||
GameBoxBlendFlag.Opaque);
|
{
|
||||||
|
IMaterial[] replacement = CreateMaterials(textureName, texture, hasAlphaChannel);
|
||||||
|
_renderMeshComponents[0].MeshRenderer.SetMaterials(replacement);
|
||||||
|
_materials[0] = replacement;
|
||||||
|
ReturnMaterials(materials);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (IMaterial material in materials)
|
||||||
|
{
|
||||||
|
material.SetMainTexture(texture);
|
||||||
|
}
|
||||||
|
ApplyTextureScale(materials, textureName);
|
||||||
|
}
|
||||||
|
|
||||||
|
_textures[0] = texture;
|
||||||
|
_textureHasAlphaChannel[0] = hasAlphaChannel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReturnMaterials(IMaterial[] materials)
|
||||||
|
{
|
||||||
|
#if PAL3A
|
||||||
|
foreach (IMaterial material in materials)
|
||||||
|
{
|
||||||
|
material.SetMainTextureScale(1f, 1f);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_materialManager.ReturnToPool(materials);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PauseAnimation()
|
public void PauseAnimation()
|
||||||
@@ -503,6 +547,11 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
}
|
}
|
||||||
|
|
||||||
meshComponent.Mesh.SetVertices(vertices);
|
meshComponent.Mesh.SetVertices(vertices);
|
||||||
|
if (_materialManager.UsesToonRendering)
|
||||||
|
{
|
||||||
|
meshComponent.MeshDataBuffer.RebuildNormalsBySourceVertex(_meshes[i].NormalIndices, _sourceNormals[i]);
|
||||||
|
meshComponent.Mesh.SetNormals(meshComponent.MeshDataBuffer.NormalBuffer);
|
||||||
|
}
|
||||||
meshComponent.Mesh.RecalculateBounds();
|
meshComponent.Mesh.RecalculateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -561,24 +610,21 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
{
|
{
|
||||||
foreach (RenderMeshComponent renderMeshComponent in _renderMeshComponents)
|
foreach (RenderMeshComponent renderMeshComponent in _renderMeshComponents)
|
||||||
{
|
{
|
||||||
IMaterial[] materials = renderMeshComponent.MeshRenderer.GetMaterials();
|
if (renderMeshComponent?.MeshRenderer == null) continue;
|
||||||
if (materials != null)
|
|
||||||
{
|
|
||||||
#if PAL3A
|
|
||||||
// Revert tiling fix before returning to pool
|
|
||||||
foreach (IMaterial material in materials)
|
|
||||||
{
|
|
||||||
material.SetMainTextureScale(1f, 1f);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
_materialManager.ReturnToPool(materials);
|
|
||||||
}
|
|
||||||
renderMeshComponent.Mesh.Destroy();
|
|
||||||
renderMeshComponent.MeshRenderer.Dispose();
|
renderMeshComponent.MeshRenderer.Dispose();
|
||||||
renderMeshComponent.MeshRenderer.Destroy();
|
renderMeshComponent.MeshRenderer.Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < _materials.Length; i++)
|
||||||
|
{
|
||||||
|
IMaterial[] materials = _materials[i];
|
||||||
|
if (materials == null) continue;
|
||||||
|
|
||||||
|
ReturnMaterials(materials);
|
||||||
|
_materials[i] = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (_meshEntities != null)
|
if (_meshEntities != null)
|
||||||
{
|
{
|
||||||
foreach (IGameEntity meshEntity in _meshEntities)
|
foreach (IGameEntity meshEntity in _meshEntities)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
|
||||||
using Core.DataReader.Pol;
|
using Core.DataReader.Pol;
|
||||||
using Core.Primitives;
|
using Core.Primitives;
|
||||||
using Dev.Presenters;
|
using Dev.Presenters;
|
||||||
@@ -37,14 +36,17 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
private ITextureResourceProvider _textureProvider;
|
private ITextureResourceProvider _textureProvider;
|
||||||
private ITextureFactory _textureFactory;
|
private ITextureFactory _textureFactory;
|
||||||
private IMaterialManager _materialManager;
|
private IMaterialManager _materialManager;
|
||||||
private Dictionary<string, ITexture2D> _textureCache = new ();
|
private Dictionary<string, ITexture2D> _textureCache;
|
||||||
|
private ITexture2D _whiteTexture;
|
||||||
|
private readonly List<StaticMeshRenderer> _meshRenderers = new();
|
||||||
|
// Materials share one tint and texture provider within this POL instance.
|
||||||
|
private readonly Dictionary<(string main, string lightmap, GameBoxBlendFlag blend), IMaterial[]> _meshMaterials = new();
|
||||||
|
|
||||||
private bool _isStaticObject;
|
private bool _isStaticObject;
|
||||||
private Color _tintColor;
|
private Color _tintColor;
|
||||||
private bool _isWaterSurfaceOpaque;
|
private bool _forceOpaqueWater;
|
||||||
private CancellationTokenSource _animationCts;
|
private List<(IMaterial[] materials, ITexture2D firstFrame)> _waterSurfaces;
|
||||||
|
private UnityEngine.Coroutine _waterAnimation;
|
||||||
private readonly int _mainTexturePropertyId = ShaderUtility.GetPropertyIdByName("_MainTex");
|
|
||||||
|
|
||||||
protected override void OnEnableGameEntity()
|
protected override void OnEnableGameEntity()
|
||||||
{
|
{
|
||||||
@@ -61,23 +63,23 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
IMaterialManager materialManager,
|
IMaterialManager materialManager,
|
||||||
bool isStaticObject,
|
bool isStaticObject,
|
||||||
Color? tintColor = default,
|
Color? tintColor = default,
|
||||||
bool isWaterSurfaceOpaque = default)
|
bool forceOpaqueWater = false)
|
||||||
{
|
{
|
||||||
_textureProvider = textureProvider;
|
_textureProvider = textureProvider;
|
||||||
_materialManager = materialManager;
|
_materialManager = materialManager;
|
||||||
_isStaticObject = isStaticObject;
|
_isStaticObject = isStaticObject;
|
||||||
_tintColor = tintColor ?? Color.White;
|
_tintColor = tintColor ?? Color.White;
|
||||||
_isWaterSurfaceOpaque = isWaterSurfaceOpaque;
|
_forceOpaqueWater = forceOpaqueWater;
|
||||||
_textureCache = BuildTextureCache(polFile, textureProvider);
|
_textureCache = BuildTextureCache(polFile, textureProvider);
|
||||||
|
|
||||||
_animationCts = new CancellationTokenSource();
|
|
||||||
|
|
||||||
for (int i = 0; i < polFile.Meshes.Length; i++)
|
for (int i = 0; i < polFile.Meshes.Length; i++)
|
||||||
{
|
{
|
||||||
RenderMeshInternal(
|
RenderMeshInternal(polFile.NodeDescriptions[i], polFile.Meshes[i]);
|
||||||
polFile.NodeDescriptions[i],
|
}
|
||||||
polFile.Meshes[i],
|
|
||||||
_animationCts.Token);
|
if (_waterSurfaces != null)
|
||||||
|
{
|
||||||
|
_waterAnimation = StartCoroutine(AnimateWaterTextures());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,33 +126,21 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
if (string.IsNullOrEmpty(textureName)) continue;
|
if (string.IsNullOrEmpty(textureName)) continue;
|
||||||
if (textureCache.ContainsKey(textureName)) continue;
|
if (textureCache.ContainsKey(textureName)) continue;
|
||||||
|
|
||||||
ITexture2D texture2D;
|
textureCache[textureName] = textureProvider.GetTexture(textureName);
|
||||||
|
|
||||||
if (_materialManager.ShaderType == MaterialShaderType.Lit)
|
|
||||||
{
|
|
||||||
// No need to load pre-baked shadow texture if
|
|
||||||
// material is lit material, since shadow texture
|
|
||||||
// will be generated by shader in runtime.
|
|
||||||
// Note: all shadow texture name starts with "^"
|
|
||||||
texture2D = textureName.StartsWith("^") ?
|
|
||||||
null : textureProvider.GetTexture(textureName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
texture2D = textureProvider.GetTexture(textureName);
|
|
||||||
}
|
|
||||||
|
|
||||||
textureCache[textureName] = texture2D;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return textureCache;
|
return textureCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RenderMeshInternal(PolGeometryNode meshNode,
|
private void RenderMeshInternal(PolGeometryNode meshNode, PolMesh mesh)
|
||||||
PolMesh mesh,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
{
|
||||||
|
Vector3[] positions = mesh.VertexInfo.GameBoxPositions.ToUnityPositions();
|
||||||
|
Vector3[] normals = _materialManager.UsesToonRendering ? mesh.VertexInfo.GameBoxNormals.ToUnityNormals() : null;
|
||||||
|
var uvs = new Vector2[mesh.VertexInfo.Uvs.Length][];
|
||||||
|
|
||||||
|
Vector2[] GetUvs(int index) => uvs[index] ??= mesh.VertexInfo.Uvs[index].ToUnityVector2s();
|
||||||
|
|
||||||
for (int i = 0; i < mesh.Textures.Length; i++)
|
for (int i = 0; i < mesh.Textures.Length; i++)
|
||||||
{
|
{
|
||||||
List<(string name, ITexture2D texture)> textures = new();
|
List<(string name, ITexture2D texture)> textures = new();
|
||||||
@@ -158,7 +148,7 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(textureName))
|
if (string.IsNullOrEmpty(textureName))
|
||||||
{
|
{
|
||||||
textures.Add((textureName, _textureFactory.CreateWhiteTexture()));
|
textures.Add((string.Empty, _whiteTexture ??= _textureFactory.CreateWhiteTexture()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,119 +175,116 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
StaticMeshRenderer meshRenderer = meshEntity.AddComponent<StaticMeshRenderer>();
|
StaticMeshRenderer meshRenderer = meshEntity.AddComponent<StaticMeshRenderer>();
|
||||||
|
_meshRenderers.Add(meshRenderer);
|
||||||
GameBoxBlendFlag blendFlag = mesh.Textures[i].BlendFlag;
|
GameBoxBlendFlag blendFlag = mesh.Textures[i].BlendFlag;
|
||||||
|
int mainTextureIndex = textures.Count == 1 ? 0 : 1;
|
||||||
|
int lightmapIndex = textures.Count == 1 ? -1 : 0;
|
||||||
|
var mainTexture = textures[mainTextureIndex];
|
||||||
|
var bakedLightmap = lightmapIndex >= 0 ? textures[lightmapIndex] : default;
|
||||||
|
|
||||||
IMaterial[] CreateMaterials(bool isWaterSurface, int mainTextureIndex, int shadowTextureIndex = -1)
|
IMaterial[] materials;
|
||||||
|
if (mainTexture.name.StartsWith(ANIMATED_WATER_TEXTURE_DEFAULT_NAME, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
IMaterial[] materials;
|
// Water mutates its main texture, so it owns a separate material.
|
||||||
float waterSurfaceOpacity = 1.0f;
|
materials = _forceOpaqueWater
|
||||||
|
? _materialManager.CreateStandardMaterials(
|
||||||
if (isWaterSurface)
|
RendererType.Pol, mainTexture, bakedLightmap, _tintColor, GameBoxBlendFlag.Opaque)
|
||||||
{
|
: new[]
|
||||||
materials = new IMaterial[1];
|
|
||||||
|
|
||||||
if (!_isWaterSurfaceOpaque)
|
|
||||||
{
|
{
|
||||||
waterSurfaceOpacity = textures[mainTextureIndex].texture.GetPixel(0, 0).a;
|
_materialManager.CreateWaterMaterial(
|
||||||
}
|
mainTexture, bakedLightmap, mainTexture.texture.GetPixel(0, 0).a),
|
||||||
else
|
};
|
||||||
{
|
(_waterSurfaces ??= new()).Add((materials, mainTexture.texture));
|
||||||
blendFlag = GameBoxBlendFlag.Opaque;
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
materials[0] = _materialManager.CreateWaterMaterial(
|
var key = (mainTexture.name, bakedLightmap.name, blendFlag);
|
||||||
mainTexture: textures[mainTextureIndex],
|
if (!_meshMaterials.TryGetValue(key, out materials))
|
||||||
shadowTexture: shadowTextureIndex >= 0 ? textures[shadowTextureIndex] : default,
|
|
||||||
opacity: waterSurfaceOpacity,
|
|
||||||
blendFlag);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
materials = _materialManager.CreateStandardMaterials(
|
materials = _materialManager.CreateStandardMaterials(
|
||||||
RendererType.Pol,
|
RendererType.Pol, mainTexture, bakedLightmap, _tintColor, blendFlag);
|
||||||
mainTexture: textures[mainTextureIndex],
|
_meshMaterials.Add(key, materials);
|
||||||
shadowTexture: shadowTextureIndex >= 0 ? textures[shadowTextureIndex] : default,
|
|
||||||
tintColor: _tintColor,
|
|
||||||
blendFlag);
|
|
||||||
}
|
}
|
||||||
return materials;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textures.Count >= 1)
|
meshRenderer.Render(
|
||||||
|
vertices: positions,
|
||||||
|
triangles: mesh.Textures[i].GameBoxTriangles.ToUnityTriangles(),
|
||||||
|
normals: normals,
|
||||||
|
mainTextureUvs: (channel: 0, uvs: GetUvs(mainTextureIndex)),
|
||||||
|
secondaryTextureUvs: (channel: 1, uvs: GetUvs(Math.Max(lightmapIndex, 0))),
|
||||||
|
materials: materials,
|
||||||
|
isDynamic: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerator AnimateWaterTextures()
|
||||||
|
{
|
||||||
|
var frames = new ITexture2D[ANIMATED_WATER_ANIMATION_FRAMES];
|
||||||
|
for (int i = 1; i < frames.Length; i++)
|
||||||
|
{
|
||||||
|
string name = ANIMATED_WATER_TEXTURE_DEFAULT_NAME_PREFIX +
|
||||||
|
$"{i + 1:00}" + ANIMATED_WATER_TEXTURE_DEFAULT_EXTENSION;
|
||||||
|
frames[i] = _textureCache.TryGetValue(name, out ITexture2D texture)
|
||||||
|
? texture
|
||||||
|
: _textureProvider.GetTexture(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
object delay = CoroutineYieldInstruction.WaitForSeconds(1 / ANIMATED_WATER_ANIMATION_FPS);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
foreach (var (materials, firstFrame) in _waterSurfaces)
|
||||||
{
|
{
|
||||||
int mainTextureIndex = textures.Count == 1 ? 0 : 1;
|
materials[0].SetMainTexture(firstFrame);
|
||||||
int shadowTextureIndex = textures.Count == 1 ? -1 : 0;
|
}
|
||||||
|
yield return delay;
|
||||||
|
|
||||||
bool isWaterSurface = textures[mainTextureIndex].name
|
for (int i = 1; i < frames.Length; i++)
|
||||||
.StartsWith(ANIMATED_WATER_TEXTURE_DEFAULT_NAME, StringComparison.OrdinalIgnoreCase);
|
{
|
||||||
|
ITexture2D frame = frames[i];
|
||||||
IMaterial[] materials = CreateMaterials(isWaterSurface, mainTextureIndex, shadowTextureIndex);
|
if (frame != null)
|
||||||
|
|
||||||
if (isWaterSurface)
|
|
||||||
{
|
{
|
||||||
StartWaterSurfaceAnimation(materials[0], textures[mainTextureIndex].texture, cancellationToken);
|
foreach (var (materials, _) in _waterSurfaces)
|
||||||
|
{
|
||||||
|
materials[0].SetMainTexture(frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = meshRenderer.Render(
|
yield return delay;
|
||||||
vertices: mesh.VertexInfo.GameBoxPositions.ToUnityPositions(),
|
|
||||||
triangles: mesh.Textures[i].GameBoxTriangles.ToUnityTriangles(),
|
|
||||||
normals: mesh.VertexInfo.GameBoxNormals.ToUnityNormals(),
|
|
||||||
mainTextureUvs: (channel: 0, uvs: mesh.VertexInfo.Uvs[mainTextureIndex].ToUnityVector2s()),
|
|
||||||
secondaryTextureUvs: (channel: 1, uvs: mesh.VertexInfo.Uvs[Math.Max(shadowTextureIndex, 0)].ToUnityVector2s()),
|
|
||||||
materials: materials,
|
|
||||||
isDynamic: false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator AnimateWaterTextureAsync(IMaterial material,
|
|
||||||
ITexture2D defaultTexture,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
List<ITexture2D> waterTextures = new() { defaultTexture };
|
|
||||||
|
|
||||||
for (int i = 2; i <= ANIMATED_WATER_ANIMATION_FRAMES; i++)
|
|
||||||
{
|
|
||||||
ITexture2D texture = _textureProvider.GetTexture(
|
|
||||||
ANIMATED_WATER_TEXTURE_DEFAULT_NAME_PREFIX +
|
|
||||||
$"{i:00}" +
|
|
||||||
ANIMATED_WATER_TEXTURE_DEFAULT_EXTENSION);
|
|
||||||
waterTextures.Add(texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
object waterAnimationDelay = CoroutineYieldInstruction.WaitForSeconds(1 / ANIMATED_WATER_ANIMATION_FPS);
|
|
||||||
|
|
||||||
while (!cancellationToken.IsCancellationRequested)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < ANIMATED_WATER_ANIMATION_FRAMES; i++)
|
|
||||||
{
|
|
||||||
if (cancellationToken.IsCancellationRequested) break;
|
|
||||||
material.SetTexture(_mainTexturePropertyId, waterTextures[i]);
|
|
||||||
yield return waterAnimationDelay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void StartWaterSurfaceAnimation(IMaterial material,
|
|
||||||
ITexture2D defaultTexture,
|
|
||||||
CancellationToken cancellationToken)
|
|
||||||
{
|
|
||||||
StartCoroutine(AnimateWaterTextureAsync(material, defaultTexture, cancellationToken));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (_animationCts is {IsCancellationRequested: false})
|
if (_waterAnimation != null)
|
||||||
{
|
{
|
||||||
_animationCts.Cancel();
|
StopCoroutine(_waterAnimation);
|
||||||
|
_waterAnimation = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (StaticMeshRenderer meshRenderer in GameEntity.GetComponentsInChildren<StaticMeshRenderer>())
|
foreach (StaticMeshRenderer meshRenderer in _meshRenderers)
|
||||||
{
|
{
|
||||||
_materialManager.ReturnToPool(meshRenderer.GetMaterials());
|
if (meshRenderer == null) continue;
|
||||||
meshRenderer.Dispose();
|
meshRenderer.Dispose();
|
||||||
meshRenderer.Destroy();
|
meshRenderer.Destroy();
|
||||||
}
|
}
|
||||||
|
_meshRenderers.Clear();
|
||||||
|
|
||||||
|
foreach (IMaterial[] materials in _meshMaterials.Values)
|
||||||
|
{
|
||||||
|
_materialManager.ReturnToPool(materials);
|
||||||
|
}
|
||||||
|
_meshMaterials.Clear();
|
||||||
|
|
||||||
|
if (_waterSurfaces != null)
|
||||||
|
{
|
||||||
|
foreach (var (materials, _) in _waterSurfaces)
|
||||||
|
{
|
||||||
|
_materialManager.ReturnToPool(materials);
|
||||||
|
}
|
||||||
|
_waterSurfaces = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
public Matrix4x4 BindPoseModelToBoneSpace { get; set; }
|
public Matrix4x4 BindPoseModelToBoneSpace { get; set; }
|
||||||
public Matrix4x4 CurrentPoseToModelMatrix { get; set; }
|
public Matrix4x4 CurrentPoseToModelMatrix { get; set; }
|
||||||
|
public Matrix4x4 SkinningMatrix { get; set; }
|
||||||
|
|
||||||
public MovBoneAnimationTrack? AnimationTrack { get; private set; }
|
public MovBoneAnimationTrack? AnimationTrack { get; private set; }
|
||||||
|
|
||||||
@@ -98,6 +99,9 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
private int[][] _indexBuffer;
|
private int[][] _indexBuffer;
|
||||||
private Vector3[][] _allVerticesBuffer;
|
private Vector3[][] _allVerticesBuffer;
|
||||||
|
private int[][] _normalIndices;
|
||||||
|
private Vector3[][] _bindNormals;
|
||||||
|
private Vector3[][] _posedNormals;
|
||||||
|
|
||||||
public bool IsInitialized { get; private set; }
|
public bool IsInitialized { get; private set; }
|
||||||
|
|
||||||
@@ -292,11 +296,17 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
|
|
||||||
private void UpdateSkinning()
|
private void UpdateSkinning()
|
||||||
{
|
{
|
||||||
|
foreach (Bone bone in _bones.Values)
|
||||||
|
{
|
||||||
|
bone.SkinningMatrix = bone.CurrentPoseToModelMatrix * bone.BindPoseModelToBoneSpace;
|
||||||
|
}
|
||||||
|
|
||||||
for (int subMeshIndex = 0; subMeshIndex < _renderMeshComponents.Length; subMeshIndex++)
|
for (int subMeshIndex = 0; subMeshIndex < _renderMeshComponents.Length; subMeshIndex++)
|
||||||
{
|
{
|
||||||
UpdateVerticesWithCurrentSkeleton(subMeshIndex);
|
UpdateVerticesWithCurrentSkeleton(subMeshIndex);
|
||||||
Mesh mesh = _renderMeshComponents[subMeshIndex].Mesh;
|
Mesh mesh = _renderMeshComponents[subMeshIndex].Mesh;
|
||||||
mesh.SetVertices(_renderMeshComponents[subMeshIndex].MeshDataBuffer.VertexBuffer);
|
mesh.SetVertices(_renderMeshComponents[subMeshIndex].MeshDataBuffer.VertexBuffer);
|
||||||
|
if (_bindNormals != null) mesh.SetNormals(_renderMeshComponents[subMeshIndex].MeshDataBuffer.NormalBuffer);
|
||||||
mesh.RecalculateBounds();
|
mesh.RecalculateBounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -343,6 +353,12 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
_meshEntities = new IGameEntity[_mshFile.SubMeshes.Length];
|
_meshEntities = new IGameEntity[_mshFile.SubMeshes.Length];
|
||||||
_indexBuffer = new int[_mshFile.SubMeshes.Length][];
|
_indexBuffer = new int[_mshFile.SubMeshes.Length][];
|
||||||
_allVerticesBuffer = new Vector3[_mshFile.SubMeshes.Length][];
|
_allVerticesBuffer = new Vector3[_mshFile.SubMeshes.Length][];
|
||||||
|
if (_materialManager.UsesToonRendering)
|
||||||
|
{
|
||||||
|
_normalIndices = new int[_mshFile.SubMeshes.Length][];
|
||||||
|
_bindNormals = new Vector3[_mshFile.SubMeshes.Length][];
|
||||||
|
_posedNormals = new Vector3[_mshFile.SubMeshes.Length][];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _mshFile.SubMeshes.Length; i++)
|
for (int i = 0; i < _mshFile.SubMeshes.Length; i++)
|
||||||
@@ -364,7 +380,7 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
renderMeshComponent.MeshDataBuffer ??= new MeshDataBuffer();
|
renderMeshComponent.MeshDataBuffer ??= new MeshDataBuffer();
|
||||||
renderMeshComponent.MeshDataBuffer.AllocateOrResizeBuffers(
|
renderMeshComponent.MeshDataBuffer.AllocateOrResizeBuffers(
|
||||||
vertexBufferSize: numOfIndices,
|
vertexBufferSize: numOfIndices,
|
||||||
normalBufferSize: 0, // Skeletal model does not have normals, we will recalculate them later
|
normalBufferSize: _bindNormals != null ? numOfIndices : 0,
|
||||||
uvBufferSize: numOfIndices,
|
uvBufferSize: numOfIndices,
|
||||||
triangleBufferSize: numOfIndices);
|
triangleBufferSize: numOfIndices);
|
||||||
|
|
||||||
@@ -401,10 +417,15 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
subMesh.Vertices[_indexBuffer[subMeshIndex][i]].GameBoxPosition.ToUnityPosition();
|
subMesh.Vertices[_indexBuffer[subMeshIndex][i]].GameBoxPosition.ToUnityPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_bindNormals != null)
|
||||||
|
{
|
||||||
|
BuildBindNormals(subMeshIndex, subMesh.Vertices, renderMeshComponent.MeshDataBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
IMaterial[] materials = _materialManager.CreateStandardMaterials(
|
IMaterial[] materials = _materialManager.CreateStandardMaterials(
|
||||||
RendererType.Msh,
|
RendererType.Msh,
|
||||||
mainTexture: _mainTexture,
|
mainTexture: _mainTexture,
|
||||||
shadowTexture: default,
|
bakedLightmap: default,
|
||||||
tintColor: _tintColor,
|
tintColor: _tintColor,
|
||||||
blendFlag: GameBoxBlendFlag.Opaque);
|
blendFlag: GameBoxBlendFlag.Opaque);
|
||||||
|
|
||||||
@@ -412,26 +433,57 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
Mesh renderMesh = meshRenderer.Render(
|
Mesh renderMesh = meshRenderer.Render(
|
||||||
vertices: renderMeshComponent.MeshDataBuffer.VertexBuffer,
|
vertices: renderMeshComponent.MeshDataBuffer.VertexBuffer,
|
||||||
triangles: renderMeshComponent.MeshDataBuffer.TriangleBuffer,
|
triangles: renderMeshComponent.MeshDataBuffer.TriangleBuffer,
|
||||||
normals: default,
|
normals: _bindNormals != null ? renderMeshComponent.MeshDataBuffer.NormalBuffer : null,
|
||||||
mainTextureUvs: (channel: 0, uvs: renderMeshComponent.MeshDataBuffer.UvBuffer),
|
mainTextureUvs: (channel: 0, uvs: renderMeshComponent.MeshDataBuffer.UvBuffer),
|
||||||
secondaryTextureUvs: default, // Skeletal model does not have secondary texture
|
secondaryTextureUvs: default, // Skeletal model does not have secondary texture
|
||||||
materials: materials,
|
materials: materials,
|
||||||
isDynamic: true);
|
isDynamic: true);
|
||||||
|
|
||||||
renderMesh.RecalculateNormals();
|
|
||||||
renderMesh.RecalculateTangents();
|
|
||||||
renderMesh.RecalculateBounds();
|
renderMesh.RecalculateBounds();
|
||||||
|
|
||||||
renderMeshComponent.Mesh = renderMesh;
|
renderMeshComponent.Mesh = renderMesh;
|
||||||
renderMeshComponent.MeshRenderer = meshRenderer;
|
renderMeshComponent.MeshRenderer = meshRenderer;
|
||||||
|
renderMeshComponent.Materials = materials;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BuildBindNormals(int subMeshIndex, PhyVertex[] vertices, MeshDataBuffer mesh)
|
||||||
|
{
|
||||||
|
var verticesByBinding = new Dictionary<(float x, float y, float z, byte bone), int>(vertices.Length);
|
||||||
|
var vertexRepresentatives = new int[vertices.Length];
|
||||||
|
for (int i = 0; i < vertices.Length; i++)
|
||||||
|
{
|
||||||
|
PhyVertex vertex = vertices[i];
|
||||||
|
GameBoxVector3 position = vertex.GameBoxPosition;
|
||||||
|
// The pose uses the first bone only, so coincident positions with different bones can separate.
|
||||||
|
var key = (position.X, position.Y, position.Z, vertex.BoneIds[0]);
|
||||||
|
if (!verticesByBinding.TryGetValue(key, out int first))
|
||||||
|
{
|
||||||
|
first = i;
|
||||||
|
verticesByBinding.Add(key, first);
|
||||||
|
}
|
||||||
|
vertexRepresentatives[i] = first;
|
||||||
|
}
|
||||||
|
|
||||||
|
var (indices, count) = CoreUtility.GetNormalIndices(_indexBuffer[subMeshIndex], vertices.Length, vertexRepresentatives);
|
||||||
|
var normals = new Vector3[count];
|
||||||
|
_normalIndices[subMeshIndex] = indices;
|
||||||
|
_bindNormals[subMeshIndex] = normals;
|
||||||
|
_posedNormals[subMeshIndex] = new Vector3[count];
|
||||||
|
|
||||||
|
mesh.RebuildNormalsBySourceVertex(indices, normals);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateVerticesWithCurrentSkeleton(int subMeshIndex)
|
private void UpdateVerticesWithCurrentSkeleton(int subMeshIndex)
|
||||||
{
|
{
|
||||||
MshMesh subMesh = _mshFile.SubMeshes[subMeshIndex];
|
MshMesh subMesh = _mshFile.SubMeshes[subMeshIndex];
|
||||||
Vector3[] allVertices = _allVerticesBuffer[subMeshIndex];
|
Vector3[] allVertices = _allVerticesBuffer[subMeshIndex];
|
||||||
|
Vector3[] bindNormals = _bindNormals?[subMeshIndex];
|
||||||
|
Vector3[] posedNormals = _posedNormals?[subMeshIndex];
|
||||||
|
int[] normalIndices = _normalIndices?[subMeshIndex];
|
||||||
|
int vertexCount = subMesh.Vertices.Length;
|
||||||
|
bool hasBackNormals = posedNormals?.Length > vertexCount;
|
||||||
|
|
||||||
for (int i = 0; i < subMesh.Vertices.Length; i++)
|
for (int i = 0; i < vertexCount; i++)
|
||||||
{
|
{
|
||||||
PhyVertex vert = subMesh.Vertices[i];
|
PhyVertex vert = subMesh.Vertices[i];
|
||||||
|
|
||||||
@@ -439,18 +491,30 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
Bone bone = _bones[boneId];
|
Bone bone = _bones[boneId];
|
||||||
|
|
||||||
Vector3 originalPosition = vert.GameBoxPosition.ToUnityPosition();
|
Vector3 originalPosition = vert.GameBoxPosition.ToUnityPosition();
|
||||||
Vector4 currentPosition = bone.CurrentPoseToModelMatrix * bone.BindPoseModelToBoneSpace *
|
Vector4 currentPosition = bone.SkinningMatrix *
|
||||||
new Vector4(originalPosition.x, originalPosition.y, originalPosition.z, 1.0f);
|
new Vector4(originalPosition.x, originalPosition.y, originalPosition.z, 1.0f);
|
||||||
|
|
||||||
allVertices[i].x = currentPosition.x / currentPosition.w;
|
allVertices[i].x = currentPosition.x / currentPosition.w;
|
||||||
allVertices[i].y = currentPosition.y / currentPosition.w;
|
allVertices[i].y = currentPosition.y / currentPosition.w;
|
||||||
allVertices[i].z = currentPosition.z / currentPosition.w;
|
allVertices[i].z = currentPosition.z / currentPosition.w;
|
||||||
|
if (posedNormals != null)
|
||||||
|
{
|
||||||
|
posedNormals[i] = bone.SkinningMatrix.MultiplyVector(bindNormals[i]);
|
||||||
|
if (hasBackNormals)
|
||||||
|
{
|
||||||
|
int backIndex = i + vertexCount;
|
||||||
|
posedNormals[backIndex] = bone.SkinningMatrix.MultiplyVector(bindNormals[backIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _indexBuffer[subMeshIndex].Length; i++)
|
var mesh = _renderMeshComponents[subMeshIndex].MeshDataBuffer;
|
||||||
|
int[] sourceIndices = _indexBuffer[subMeshIndex];
|
||||||
|
for (int i = 0; i < sourceIndices.Length; i++)
|
||||||
{
|
{
|
||||||
_renderMeshComponents[subMeshIndex].MeshDataBuffer.VertexBuffer[i] =
|
int sourceIndex = sourceIndices[i];
|
||||||
allVertices[_indexBuffer[subMeshIndex][i]];
|
mesh.VertexBuffer[i] = allVertices[sourceIndex];
|
||||||
|
if (posedNormals != null) mesh.NormalBuffer[i] = posedNormals[normalIndices[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,10 +558,14 @@ namespace Pal3.Game.Rendering.Renderer
|
|||||||
{
|
{
|
||||||
foreach (RenderMeshComponent renderMeshComponent in _renderMeshComponents)
|
foreach (RenderMeshComponent renderMeshComponent in _renderMeshComponents)
|
||||||
{
|
{
|
||||||
_materialManager.ReturnToPool(renderMeshComponent.MeshRenderer.GetMaterials());
|
if (renderMeshComponent == null) continue;
|
||||||
renderMeshComponent.Mesh.Destroy();
|
if (renderMeshComponent.MeshRenderer != null)
|
||||||
renderMeshComponent.MeshRenderer.Dispose();
|
{
|
||||||
renderMeshComponent.MeshRenderer.Destroy();
|
renderMeshComponent.MeshRenderer.Dispose();
|
||||||
|
renderMeshComponent.MeshRenderer.Destroy();
|
||||||
|
}
|
||||||
|
_materialManager.ReturnToPool(renderMeshComponent.Materials);
|
||||||
|
renderMeshComponent.Materials = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6d5e6481402e4ea1b271122f6474971a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// See LICENSE file in the project root for license information.
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Pal3.Game.Rendering.ScreenEffects
|
||||||
|
{
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
internal sealed class Pal3ScreenEffects : MonoBehaviour
|
||||||
|
{
|
||||||
|
public bool Distortion { get; set; }
|
||||||
|
public bool Snow { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dcdf4f99c9b245999e70f4792f43c77a
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
// See LICENSE file in the project root for license information.
|
||||||
|
// ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace Pal3.Game.Rendering.ScreenEffects
|
||||||
|
{
|
||||||
|
using Engine.UI;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
using UnityEngine.Rendering.RenderGraphModule;
|
||||||
|
using UnityEngine.Rendering.RenderGraphModule.Util;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
|
public sealed class Pal3ScreenEffectsFeature : ScriptableRendererFeature
|
||||||
|
{
|
||||||
|
[SerializeField] private Shader distortionShader;
|
||||||
|
[SerializeField] private Shader snowShader;
|
||||||
|
|
||||||
|
private Material _distortion;
|
||||||
|
private Material _snow;
|
||||||
|
private ScreenEffectsPass _pass;
|
||||||
|
|
||||||
|
public override void Create()
|
||||||
|
{
|
||||||
|
CoreUtils.Destroy(_distortion);
|
||||||
|
CoreUtils.Destroy(_snow);
|
||||||
|
_distortion = CoreUtils.CreateEngineMaterial(distortionShader);
|
||||||
|
_snow = CoreUtils.CreateEngineMaterial(snowShader);
|
||||||
|
_pass = new ScreenEffectsPass(_distortion, _snow)
|
||||||
|
{
|
||||||
|
renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing,
|
||||||
|
requiresIntermediateTexture = true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||||
|
{
|
||||||
|
var cameraData = renderingData.cameraData;
|
||||||
|
if (cameraData.camera.TryGetComponent(out Pal3ScreenEffects effects) && effects.isActiveAndEnabled &&
|
||||||
|
(effects.Distortion || effects.Snow ||
|
||||||
|
(cameraData.rendersOverlayUI && RoundedFrostedGlassImage.HasVisibleOverlay(cameraData.camera.targetDisplay))))
|
||||||
|
{
|
||||||
|
renderer.EnqueuePass(_pass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
CoreUtils.Destroy(_distortion);
|
||||||
|
CoreUtils.Destroy(_snow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private sealed class ScreenEffectsPass : ScriptableRenderPass
|
||||||
|
{
|
||||||
|
private static readonly int SceneColorId = Shader.PropertyToID("_Pal3SceneColor");
|
||||||
|
private readonly Material _distortion;
|
||||||
|
private readonly Material _snow;
|
||||||
|
|
||||||
|
public ScreenEffectsPass(Material distortion, Material snow)
|
||||||
|
{
|
||||||
|
_distortion = distortion;
|
||||||
|
_snow = snow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void RecordRenderGraph(RenderGraph graph, ContextContainer frameData)
|
||||||
|
{
|
||||||
|
UniversalResourceData resources = frameData.Get<UniversalResourceData>();
|
||||||
|
if (resources.isActiveTargetBackBuffer) return;
|
||||||
|
|
||||||
|
var cameraData = frameData.Get<UniversalCameraData>();
|
||||||
|
Pal3ScreenEffects effects = cameraData.camera.GetComponent<Pal3ScreenEffects>();
|
||||||
|
if (effects.Distortion)
|
||||||
|
{
|
||||||
|
resources.cameraColor = Apply(graph, resources.cameraColor, _distortion, "Pal3 Distortion");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (effects.Snow)
|
||||||
|
{
|
||||||
|
resources.cameraColor = Apply(graph, resources.cameraColor, _snow, "Pal3 Snow");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cameraData.rendersOverlayUI && RoundedFrostedGlassImage.HasVisibleOverlay(cameraData.camera.targetDisplay))
|
||||||
|
{
|
||||||
|
// The overlay canvas samples the finished scene, including transparent objects.
|
||||||
|
TextureHandle source = resources.cameraColor;
|
||||||
|
TextureDesc descriptor = source.GetDescriptor(graph);
|
||||||
|
descriptor.name = "Pal3 Frosted Glass Backdrop";
|
||||||
|
descriptor.sizeMode = TextureSizeMode.Explicit;
|
||||||
|
descriptor.width = Mathf.Max(1, cameraData.cameraTargetDescriptor.width / 2);
|
||||||
|
descriptor.height = Mathf.Max(1, cameraData.cameraTargetDescriptor.height / 2);
|
||||||
|
descriptor.msaaSamples = MSAASamples.None;
|
||||||
|
descriptor.bindTextureMS = false;
|
||||||
|
descriptor.clearBuffer = false;
|
||||||
|
TextureHandle copy = graph.CreateTexture(descriptor);
|
||||||
|
using var builder = graph.AddBlitPass(source, copy, Vector2.one, Vector2.zero,
|
||||||
|
filterMode: RenderGraphUtils.BlitFilterMode.ClampBilinear,
|
||||||
|
passName: descriptor.name, returnBuilder: true);
|
||||||
|
builder.SetGlobalTextureAfterPass(copy, SceneColorId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TextureHandle Apply(RenderGraph graph, TextureHandle source, Material material, string name)
|
||||||
|
{
|
||||||
|
TextureDesc descriptor = source.GetDescriptor(graph);
|
||||||
|
descriptor.name = name;
|
||||||
|
descriptor.msaaSamples = MSAASamples.None;
|
||||||
|
descriptor.clearBuffer = false;
|
||||||
|
TextureHandle destination = graph.CreateTexture(descriptor);
|
||||||
|
graph.AddBlitPass(new RenderGraphUtils.BlitMaterialParameters(source, destination, material, 0), name);
|
||||||
|
return destination;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4d674bdfa579425487f9e1b03d25758e
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 24f07b30a39d4240aa43a220a5b05e3c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// See LICENSE in the project root.
|
||||||
|
|
||||||
|
namespace Pal3.Game.Rendering.Toon
|
||||||
|
{
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering.Universal;
|
||||||
|
using Camera = UnityEngine.Camera;
|
||||||
|
|
||||||
|
public sealed class ToonAmbientOcclusionFeature : ScreenSpaceAmbientOcclusion
|
||||||
|
{
|
||||||
|
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||||
|
{
|
||||||
|
Camera camera = renderingData.cameraData.camera;
|
||||||
|
if (camera.cameraType == CameraType.Game &&
|
||||||
|
camera.TryGetComponent(out ToonCameraLighting lighting) &&
|
||||||
|
lighting.isActiveAndEnabled && lighting.ContactShadowsEnabled)
|
||||||
|
{
|
||||||
|
base.AddRenderPasses(renderer, ref renderingData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8375d96629014bce9e8f3ecf7aad6a08
|
||||||
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user