sync
This commit is contained in:
parent
7acb946c4e
commit
b5c85039fe
8
Assets/Editor.meta
Normal file
8
Assets/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba7d410439c4a1144bcdfbe00943fe50
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/Editor/SceneEffectEditor.cs
Normal file
117
Assets/Editor/SceneEffectEditor.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using Unity.Mathematics;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using static Codice.Client.Commands.WkTree.WorkspaceTreeNode;
|
||||
|
||||
namespace X.Rendering.Scene
|
||||
{
|
||||
[CustomEditor(typeof(SceneEffect))]
|
||||
public class SceneEffectEditorBase : Editor
|
||||
{
|
||||
ReorderableList lightList;
|
||||
Transform transform;
|
||||
int selectIndex = -1;
|
||||
|
||||
public override VisualElement CreateInspectorGUI()
|
||||
{
|
||||
transform = (target as MonoBehaviour).transform;
|
||||
lightList = new ReorderableList(serializedObject, serializedObject.FindProperty("capsuleLights"), true, true, true, true);
|
||||
lightList.onSelectCallback += (_) =>
|
||||
{
|
||||
Debug.Log($"{lightList.index}");
|
||||
selectIndex = lightList.index;
|
||||
};
|
||||
lightList.drawHeaderCallback = DrawHeader;
|
||||
|
||||
lightList.drawElementCallback = DrawListItems;
|
||||
return base.CreateInspectorGUI();
|
||||
}
|
||||
|
||||
private void DrawListItems(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
SerializedProperty element = lightList.serializedProperty.GetArrayElementAtIndex(index);
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y, 200, EditorGUIUtility.singleLineHeight), $"{element.vector4Value}");
|
||||
}
|
||||
|
||||
private void DrawHeader(Rect rect)
|
||||
{
|
||||
string name = "光照方向";
|
||||
EditorGUI.LabelField(rect, name);
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
//base.OnInspectorGUI();
|
||||
lightList.DoLayoutList();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public void OnSceneGUI()
|
||||
{
|
||||
if(selectIndex == -1 || selectIndex >= lightList.serializedProperty.arraySize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
SerializedProperty element = lightList.serializedProperty.GetArrayElementAtIndex(selectIndex);
|
||||
|
||||
var rot = new float4(element.vector4Value).xyz;
|
||||
|
||||
rot += DrawRotationHandle(element.vector4Value);
|
||||
element.vector4Value = new float4(rot, element.vector4Value.w);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
protected float3 DrawRotationHandle(Vector3 rotation)
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var newRot = Handles.PositionHandle(rotation, Quaternion.identity);
|
||||
EditorGUI.EndChangeCheck();
|
||||
Debug.Log((newRot - transform.position).normalized);
|
||||
Handles.ConeHandleCap(0, transform.position, Quaternion.EulerRotation(math.degrees((newRot-transform.position).normalized)), HandleUtility.GetHandleSize(transform.position), EventType.Repaint);
|
||||
|
||||
float3 delta;
|
||||
|
||||
if (newRot != rotation)
|
||||
{
|
||||
Undo.RecordObject(target, "Rotate Handle");
|
||||
|
||||
// Perform the handle move and update the serialized data
|
||||
delta = newRot - rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = float3.zero;
|
||||
}
|
||||
|
||||
return delta;
|
||||
}
|
||||
|
||||
private Vector3 CalculateTargetPosition()
|
||||
{
|
||||
Vector3 handlePosition;
|
||||
|
||||
//if (transform.parent != null)
|
||||
//{
|
||||
// handlePosition = transform.parent.TransformPoint(tweenPosition.TargetPosition);
|
||||
//}
|
||||
//else
|
||||
{
|
||||
handlePosition = transform.position;
|
||||
}
|
||||
|
||||
|
||||
return handlePosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[CustomEditor(typeof(CapsuleShadowAreaEffect))]
|
||||
public class MyClaCapsuleShadowAreaEffectsEditor : SceneEffectEditorBase
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Editor/SceneEffectEditor.cs.meta
Normal file
11
Assets/Editor/SceneEffectEditor.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c96feaf210eb8a4d9ccd1a0c098a66c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:yousandi.cn,2023:
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -42,7 +42,7 @@ Texture2D:
|
||||
m_ColorSpace: 1
|
||||
m_PlatformBlob:
|
||||
image data: 1024
|
||||
_typelessdata: fff4f4fffff4f4fffff4f5fffff5f5fffff5f5fffff6f6fffff6f6fffff6f7fffff7f7fffff7f7fffff8f8fffff8f8fffff8f9fffff9f9fffff9f9fffffafafffffafafffffafafffffbfbfffffbfbfffffcfcfffffcfcfffffcfcfffffdfdfffffdfdfffffefefffffefefffffefefffffffffffffefefffffafafffff7f7fffff3f4fffff0f0ffffededffffe9eaffffe6e6ffffe2e3ffffdfe0ffffdbddffffd8d9ffffd5d6ffffd1d3ffffcecfffffcaccffffc7c9ffffc3c5ffffc0c2ffffbdbfffffb9bbffffb6b8ffffb2b5ffffafb1ffffabaeffffa8abffffa5a7ffffa1a4ffff9ea1ffff9a9dffff979affff9397ffff9093ffff8d90ffff898dffff8689ffff8286ffff7f83ffff7c80ffff787cffff7579ffff7176ffff6e72ffff6a6fffff676cffff6468ffff6065ffff5d62ffff595effff565bffff5258ffff4f54ffff4c51ffff484effff454affff4147ffff3e44ffff3a40ffff373dffff343affff3036ffff2d33ffff2930fffe282dfffb342bfff7402afff34c29fff05827ffec6426ffe87024ffe57c23ffe18822ffdd9420ffd9a01fffd6ac1effd2b81cffcec41bffcbd019ffc7dc18ffc3e817ffc0f415ffbcff14ffc1f813ffc6f111ffcaea10ffcfe40effd4dd0dffd9d60cffddd00affe2c909ffe7c207ffebbb06fff0b505fff5ae03fff9a702fffea100ffffa106ffffa40fffffa817ffffab1fffffae27ffffb130ffffb438ffffb740ffffba48ffffbd51ffffc059ffffc461ffffc769ffffca72ffffcd7affffd082ffffd38affffd693ffffd99bffffdca3ffffe0acffffe3b4ffffe6bcffffe9c4ffffeccdffffefd5fffff2ddfffff5e5fffff8eefffffcf6fffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
_typelessdata: fff3f4fffff4f4fffff5f5fffff5f5fffff6f6fffff6f7fffff7f7fffff7f8fffff8f8fffff8f9fffff9f9fffffafafffffafafffffbfbfffffbfbfffffcfcfffffcfcfffffdfdfffffdfdfffffefefffffefefffffffffffffaf9fffff4f2ffffeeebffffe8e4ffffe2deffffdcd7ffffd6d0ffffd0c9ffffcac3ffffc4bcffffbeb5ffffb8aeffffb2a8ffffaca1ffffa59affff9f94ffff998dffff9286ffff8b80ffff8579ffff7e72ffff776bffff6f64ffff675dffff5f56ffff574fffff4e48ffff4440ffff3838ffff2a2fffff2a2cffff2d2bffff312affff342affff3729ffff3a28ffff3c27ffff3f25ffff4124ffff4423ffff4622ffff4921ffff4b1fffff4d1effff4f1cffff511bffff5319ffff5517ffff5715ffff5913ffff5b11ffff5d0effff5f0bffff6107ffff6203ffff6400ffff6700ffff6900ffff6c00ffff6f00ffff7100ffff7300ffff7600ffff7800ffff7b00ffff7d00ffff7f00ffff8200ffff8400ffff8600ffff8800ffff8b00ffff8d00ffff8f00ffff9100ffff9300ffff9600ffff9800ffff9a00ffff9c00ffff9e00fff99e24fff09d3effe79c4fffde9a5dffd59869ffcc9773ffc2957dffb99385ffb0908effa78e95ff9e8b9dff9588a4ff8c85aaff8382b1ff7a7eb7ff717bbdff6877c3ff5f72c9ff556ecfff4c69d4ff4363daff3a5ddfff3057e4ff274feaff1d47efff133df4ff0830f9ff011dfeff1a1cffff2d23ffff3b28ffff482cffff552fffff6031ffff6b33ffff7634ffff8135ffff8b35ffff9635ffffa034ffffab33ffffb530ffffc02dffffca28ffffd422ffffdf18ffffe906ffffeb17ffffec24ffffec2dffffed35ffffee3cffffee42ffffef47ffffef4dfffff052fffff157fffff15bfffff260fffff264fffff368fffff36cfffff470fffff574fffff577fffff67bfffff67ffffff682fffff786fffff789fffff88cfffff890fffff993fffff996fffff999fffffa9dfffffaa0fffffba3fffffba6fffffba9fffffcacfffffcaffffffcb2fffffcb5fffffdb8fffffdbbfffffdbefffffec1fffffec4fffffec7fffffecafffffecdfffffed0ffffffd3ffffffd6ffffffd9ffffffdbffffffdeffffffe1ffffffe4ffffffe7ffffffeaffffffedffffffeffffffff2fffffff5fffffff8fffffffbfffffffdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
m_StreamData:
|
||||
serializedVersion: 2
|
||||
offset: 0
|
||||
@ -121,29 +121,29 @@ MonoBehaviour:
|
||||
key0: {r: 1, g: 0.95495445, b: 0.9563196, a: 1}
|
||||
key1: {r: 1, g: 1, b: 1, a: 1}
|
||||
key2: {r: 1, g: 0.15043616, b: 0.17618251, a: 1}
|
||||
key3: {r: 0.73782194, g: 1, b: 0.07843137, a: 1}
|
||||
key4: {r: 1, g: 0.62319684, b: 0, a: 0}
|
||||
key5: {r: 1, g: 1, b: 1, a: 0}
|
||||
key6: {r: 0, g: 0, b: 0, a: 0}
|
||||
key7: {r: 0, g: 0, b: 0, a: 0}
|
||||
key3: {r: 1, g: 0.39124364, b: 0, a: 1}
|
||||
key4: {r: 1, g: 0.62319684, b: 0, a: 1}
|
||||
key5: {r: 0, g: 0.08670282, b: 1, a: 1}
|
||||
key6: {r: 0.91846347, g: 0.0141509175, b: 1, a: 1}
|
||||
key7: {r: 1, g: 1, b: 1, a: 1}
|
||||
ctime0: 0
|
||||
ctime1: 7325
|
||||
ctime2: 23516
|
||||
ctime3: 28142
|
||||
ctime4: 31804
|
||||
ctime5: 39707
|
||||
ctime6: 0
|
||||
ctime7: 0
|
||||
ctime1: 5397
|
||||
ctime2: 13107
|
||||
ctime3: 19661
|
||||
ctime4: 26214
|
||||
ctime5: 33346
|
||||
ctime6: 38165
|
||||
ctime7: 54163
|
||||
atime0: 0
|
||||
atime1: 65535
|
||||
atime2: 65535
|
||||
atime3: 65535
|
||||
atime4: 0
|
||||
atime5: 0
|
||||
atime6: 0
|
||||
atime7: 0
|
||||
m_Mode: 0
|
||||
atime4: 65535
|
||||
atime5: 65535
|
||||
atime6: 65535
|
||||
atime7: 65535
|
||||
m_Mode: 2
|
||||
m_ColorSpace: 0
|
||||
m_NumColorKeys: 6
|
||||
m_NumColorKeys: 8
|
||||
m_NumAlphaKeys: 2
|
||||
_texture: {fileID: -3624966030674371785}
|
||||
|
||||
@ -605,6 +605,111 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1818384483134930436, guid: a4af472c77a9e40688ae7566b93ab7c2, type: 3}
|
||||
m_PrefabInstance: {fileID: 53147597}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &67279638
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 67279642}
|
||||
- component: {fileID: 67279641}
|
||||
- component: {fileID: 67279640}
|
||||
- component: {fileID: 67279639}
|
||||
m_Layer: 0
|
||||
m_Name: Cube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!65 &67279639
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 67279638}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &67279640
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 67279638}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_AdditionalVertexStreams: {fileID: 0}
|
||||
--- !u!33 &67279641
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 67279638}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &67279642
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 67279638}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -1.85, y: 1.726, z: -0.544}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &68778458 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7048526022681675114, guid: a19b99df922571649a1da524e3bdc86d, type: 3}
|
||||
@ -1780,6 +1885,34 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 682257e84cca6e24a94c39ff38cd2a11, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &172178771 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 2060764356010685525, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &172178773
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 172178771}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.03
|
||||
m_Height: 0.6
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &185609164
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2166,6 +2299,34 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 1b6e8c43aaa108e449f1e8ffd5e8f941, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &195094436 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: -1657220678678262603, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &195094438
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 195094436}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.03
|
||||
m_Height: 0.6
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &195711565 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 3345604766945953572, guid: 1ae38a12a032db54a818dda18022abd8, type: 3}
|
||||
@ -4238,7 +4399,7 @@ Light:
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Type: 0
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
@ -4290,13 +4451,13 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 397543234}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0.5956593, y: -0.3627213, z: 0.6228372, w: -0.35453805}
|
||||
m_LocalRotation: {x: -0.7163729, y: -0.13805202, z: 0.15117739, w: -0.66700596}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1890990766}
|
||||
m_LocalEulerAnglesHint: {x: 119.05, y: -266.783, z: 1.1239929}
|
||||
m_LocalEulerAnglesHint: {x: 94.14, y: -333.302, z: 3.08}
|
||||
--- !u!114 &397543237
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4687,6 +4848,34 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 7048526022681675114, guid: a19b99df922571649a1da524e3bdc86d, type: 3}
|
||||
m_PrefabInstance: {fileID: 166933154}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &437220746 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7466937936192503876, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &437220748
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 437220746}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.05
|
||||
m_Height: 0.2
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &437836040 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 1328794821902915481, guid: 7313909bb567bec4684fdffe69460335, type: 3}
|
||||
@ -10243,6 +10432,34 @@ MeshFilter:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 951552774}
|
||||
m_Mesh: {fileID: 1451443487313757394, guid: a0569c31be8fc4039a33e3ca90eb0c35, type: 3}
|
||||
--- !u!1 &957418059 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: -566845295101373756, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &957418061
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 957418059}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.05
|
||||
m_Height: 0.2
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &972107860
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -11709,6 +11926,34 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 6453139181329048723, guid: 56c6273782b4f9445ace1d906ec66161, type: 3}
|
||||
m_PrefabInstance: {fileID: 1097078861}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1105308490 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 7232223533151985020, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &1105308492
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1105308490}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.2
|
||||
m_Height: 0.7
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1118218363
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -12434,7 +12679,7 @@ GameObject:
|
||||
- component: {fileID: 1175237765}
|
||||
- component: {fileID: 1175237767}
|
||||
- component: {fileID: 1175237766}
|
||||
m_Layer: 6
|
||||
m_Layer: 0
|
||||
m_Name: Terminal_MeshCollider
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
@ -13474,6 +13719,30 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 34748359}
|
||||
m_LocalEulerAnglesHint: {x: 17.323, y: -90.323, z: 0}
|
||||
--- !u!1 &1285058669 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 974238578668270704, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
m_PrefabInstance: {fileID: 1449963300}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &1285058677
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1285058669}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8dd3bb5b4676f694fb04529a5609cf30, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
move: {x: 0, y: 0}
|
||||
look: {x: 0, y: 0}
|
||||
jump: 0
|
||||
sprint: 0
|
||||
analogMovement: 0
|
||||
cursorLocked: 1
|
||||
cursorInputForLook: 1
|
||||
--- !u!1001 &1296334284
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -13913,7 +14182,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1317243097}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a8f562490b8d41b47a6b21e2f514d782, type: 3}
|
||||
m_Name:
|
||||
@ -13928,12 +14197,38 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1317243097}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 763668dd69af1b243b7b0bebcc85b814, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: e395308c14c05ac46b83581ae4e5f7a1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
injectionPoint: 0
|
||||
settings:
|
||||
shadowRemapSettings:
|
||||
Enable: 0
|
||||
ShadowRemapTex: {fileID: 11400000, guid: 14fe883388dd915438a4832c5ce4bbf3, type: 2}
|
||||
InjectionPoint: 0
|
||||
capsuleAOSettings:
|
||||
Enable: 1
|
||||
RenderPassEvent: 450
|
||||
EnableShadowOffset: 0
|
||||
CascadeShadowOffset: {x: 0, y: 0, z: 1}
|
||||
updateInterval: 1
|
||||
capsuleLights:
|
||||
- {fileID: 397543235}
|
||||
capsuleAOSetting:
|
||||
AmbientIntensity: 1.19
|
||||
ConeAngle: 9.99
|
||||
ShadowIntensity: 1.28
|
||||
ShadowSharpness: 9.6
|
||||
lightStartID: 0
|
||||
lightEndID: 1
|
||||
CapsuleLightsDir:
|
||||
- {x: 85.86, y: 206.69797, z: 183.08, w: 5}
|
||||
capsuleAOAreaSettings:
|
||||
- AmbientIntensity: 1.19
|
||||
ConeAngle: 9.99
|
||||
ShadowIntensity: 1.28
|
||||
ShadowSharpness: 9.6
|
||||
lightStartID: 0
|
||||
lightEndID: 1
|
||||
sceneAreaEffects: []
|
||||
--- !u!1 &1325026286
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -14373,6 +14668,34 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 1b6e8c43aaa108e449f1e8ffd5e8f941, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1356087217 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: -7599317778200196202, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &1356087219
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1356087217}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.05
|
||||
m_Height: 0.3
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1357497468
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 3
|
||||
@ -15256,6 +15579,95 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 6453139181329048723, guid: 56c6273782b4f9445ace1d906ec66161, type: 3}
|
||||
m_PrefabInstance: {fileID: 1447881387}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1001 &1449963300
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 974238578668270716, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_Actions
|
||||
value:
|
||||
objectReference: {fileID: -944628639613478452, guid: 3c64d762cbd7c974e9d171976c28ec92, type: 3}
|
||||
- target: {fileID: 974238578668270716, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_DefaultControlScheme
|
||||
value: Gamepad
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 2.4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -1.54
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2119775930974504096, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3128949090649374765, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5542111180780342640, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: orthographic size
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7888303496483045073, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8047161636021232021, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: NestedParentArmature_Unpack
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8508310942573128499, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_RenderShadows
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9035860660672068996, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
propertyPath: m_LightProbeUsage
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents:
|
||||
- {fileID: 3543048675319490572, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 974238578668270704, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
insertIndex: 5
|
||||
addedObject: {fileID: 1285058677}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: c708a3b79cd542b42bbfedb17e213bc1, type: 3}
|
||||
--- !u!1 &1474557447
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -15449,6 +15861,34 @@ Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 1818384483134930436, guid: a4af472c77a9e40688ae7566b93ab7c2, type: 3}
|
||||
m_PrefabInstance: {fileID: 1492267861}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1498080730 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: -9097415683120949092, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &1498080732
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1498080730}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.04
|
||||
m_Height: 0.42
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1509981466
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -16424,11 +16864,6 @@ Light:
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!1 &1558980086 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4916034631659228877, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
m_PrefabInstance: {fileID: 2760477044720773439}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!1 &1559356782
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -17978,6 +18413,128 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &1712672753
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 1.135
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 1.285
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: -0.376
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -7717857002672948729, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -3630044854370959492, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -2561486518339407288, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: 1011_Puqieer_Low
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1392142383157919723, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1392142383157919723, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0.7071068
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1392142383157919723, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: -0.000000066204116
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1392142383157919723, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0.000000066204116
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7056367068603321595, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 2018993466}
|
||||
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 2018993468}
|
||||
- targetCorrespondingSourceObject: {fileID: -1657220678678262603, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 195094438}
|
||||
- targetCorrespondingSourceObject: {fileID: -566845295101373756, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 957418061}
|
||||
- targetCorrespondingSourceObject: {fileID: -9097415683120949092, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1498080732}
|
||||
- targetCorrespondingSourceObject: {fileID: 7466937936192503876, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 437220748}
|
||||
- targetCorrespondingSourceObject: {fileID: 2060764356010685525, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 172178773}
|
||||
- targetCorrespondingSourceObject: {fileID: 6399656869896887276, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1998585705}
|
||||
- targetCorrespondingSourceObject: {fileID: 4776297332898178532, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1883685996}
|
||||
- targetCorrespondingSourceObject: {fileID: -7599317778200196202, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1356087219}
|
||||
- targetCorrespondingSourceObject: {fileID: 7232223533151985020, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 1105308492}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
--- !u!1001 &1716476717
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -20511,6 +21068,34 @@ MeshCollider:
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -2787663058213945146, guid: e06817da454743a4bac28c1f2c8e91ad, type: 3}
|
||||
--- !u!1 &1883685994 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4776297332898178532, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &1883685996
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1883685994}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.04
|
||||
m_Height: 0.6
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1884233521
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -21524,6 +22109,34 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: ac0b09e7857660247b1477e93731de29, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1998585703 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 6399656869896887276, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!136 &1998585705
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1998585703}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 0
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.05
|
||||
m_Height: 0.3
|
||||
m_Direction: 0
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1001 &1998898371
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -21702,6 +22315,62 @@ MeshFilter:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2014770767}
|
||||
m_Mesh: {fileID: 1451443487313757394, guid: a0569c31be8fc4039a33e3ca90eb0c35, type: 3}
|
||||
--- !u!1 &2018993465 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: ff6fc39872c79c549b982caef1fc013a, type: 3}
|
||||
m_PrefabInstance: {fileID: 1712672753}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!111 &2018993466
|
||||
Animation:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2018993465}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_Animation: {fileID: 7400000, guid: a7ed015f44284f94a97fa6cf73b2e0a2, type: 2}
|
||||
m_Animations:
|
||||
- {fileID: 7400000, guid: a7ed015f44284f94a97fa6cf73b2e0a2, type: 2}
|
||||
m_WrapMode: 0
|
||||
m_PlayAutomatically: 1
|
||||
m_AnimatePhysics: 0
|
||||
m_CullingType: 0
|
||||
--- !u!114 &2018993468
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2018993465}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 8428b639172492046a0d002d77fe376e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
capsuleAOSettingMask: 1
|
||||
boneSettings:
|
||||
- BoneName: forearm01
|
||||
Radius: 0.05
|
||||
Height: 0.2
|
||||
Direction: 0
|
||||
- BoneName: upperarm01
|
||||
Radius: 0.05
|
||||
Height: 0.2
|
||||
Direction: 0
|
||||
- BoneName: spine1
|
||||
Radius: 0.2
|
||||
Height: 0.7
|
||||
Direction: 0
|
||||
- BoneName: calf01
|
||||
Radius: 0.03
|
||||
Height: 0.6
|
||||
Direction: 0
|
||||
- BoneName: thigh01
|
||||
Radius: 0.04
|
||||
Height: 0.4
|
||||
Direction: 0
|
||||
capsuleTransforms: []
|
||||
--- !u!1 &2023108638
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -24870,7 +25539,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4916034631659228877, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6645380163368094409, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
@ -25003,10 +25672,7 @@ PrefabInstance:
|
||||
- targetCorrespondingSourceObject: {fileID: 7019485897165914674, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 867583717}
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 4916034631659228877, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 6556307556733515108}
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
--- !u!4 &3547149924374491350
|
||||
Transform:
|
||||
@ -26296,24 +26962,12 @@ MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 2760477044286518991, guid: 8e5bed6b8dcfed240a38affefd9c58f6, type: 3}
|
||||
m_PrefabInstance: {fileID: 2760477044720773439}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1558980086}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 567bc3eba414c614da47a095c9dde5d7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &6556307556733515108
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1558980086}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a62f35552be2a4a4e8e2683b7aea565b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &8509203744807723470
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -26338,3 +26992,6 @@ SceneRoots:
|
||||
- {fileID: 1317243099}
|
||||
- {fileID: 2023108639}
|
||||
- {fileID: 2760477044720773439}
|
||||
- {fileID: 1449963300}
|
||||
- {fileID: 67279642}
|
||||
- {fileID: 1712672753}
|
||||
|
||||
48
Assets/Scripts/CapsuleShadowAreaEffect.cs
Normal file
48
Assets/Scripts/CapsuleShadowAreaEffect.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace X.Rendering.Scene
|
||||
{
|
||||
[ExecuteAlways]
|
||||
[DefaultExecutionOrder(200)]
|
||||
public class CapsuleShadowAreaEffect : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
internal CapsuleShadowAreaSetting capsuleAOSetting = CapsuleShadowAreaSetting.GetDefault();
|
||||
[SerializeField, HideInInspector]
|
||||
internal Vector4[] capsuleLights;
|
||||
[SerializeField]
|
||||
internal Bounds Bounds;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Awake()
|
||||
{
|
||||
if(Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SceneEffect.Instance.AddSceneAreaEffect(this);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SceneEffect.Instance.RmSceneAreaEffect(this);
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SceneEffect.Instance.AreaEffectValidate();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/CapsuleShadowAreaEffect.cs.meta
Normal file
11
Assets/Scripts/CapsuleShadowAreaEffect.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 763668dd69af1b243b7b0bebcc85b814
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
140
Assets/Scripts/CapsuleShadowPass.cs
Normal file
140
Assets/Scripts/CapsuleShadowPass.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace X.Rendering.Scene
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Capsule
|
||||
{
|
||||
public Vector3 a, b;
|
||||
public float radius;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Character
|
||||
{
|
||||
public Vector3 position;
|
||||
public float radius;
|
||||
//public Vector4 lightDir; //xyz:lightDir, w:根据 lightColor 算个系数
|
||||
public int capsuleStartID, capsuleEndID;
|
||||
public uint capsuleAOSettingMask;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential), Serializable]
|
||||
public struct CapsuleShadowAreaSetting
|
||||
{
|
||||
public float AmbientIntensity;
|
||||
//[Range(1, 90)]
|
||||
public float ConeAngle;
|
||||
public float ShadowIntensity;
|
||||
public float ShadowSharpness;
|
||||
public int lightStartID, lightEndID;
|
||||
|
||||
public static CapsuleShadowAreaSetting GetDefault()
|
||||
{
|
||||
return new CapsuleShadowAreaSetting()
|
||||
{
|
||||
AmbientIntensity = 0.2f,
|
||||
ShadowIntensity = 0.4f,
|
||||
ShadowSharpness = 20,
|
||||
ConeAngle = 1
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
internal class CapsuleShadowPass : ScriptableRenderPass, IDisposable
|
||||
{
|
||||
[Serializable]
|
||||
public class CapsuleShadowSettings
|
||||
{
|
||||
public bool Enable = true;
|
||||
public RenderPassEvent RenderPassEvent = RenderPassEvent.BeforeRenderingTransparents;
|
||||
}
|
||||
|
||||
private CapsuleShadowSettings settings;
|
||||
private readonly SceneEffect sceneEffect;
|
||||
private GraphicsBuffer capsuleDataBuffer;
|
||||
private GraphicsBuffer characterDataBuffer;
|
||||
private GraphicsBuffer capsuleShadowDataBuffer;
|
||||
private ProfilingSampler profiler;
|
||||
private CommandBuffer commandBuffer;
|
||||
|
||||
public CapsuleShadowPass(CapsuleShadowSettings settings, SceneEffect sceneEffect)
|
||||
{
|
||||
this.settings = settings;
|
||||
this.sceneEffect = sceneEffect;
|
||||
profiler = new(nameof(CapsuleShadowPass));
|
||||
renderPassEvent = settings.RenderPassEvent;
|
||||
commandBuffer = CommandBufferPool.Get(nameof(CapsuleShadowPass) + sceneEffect.name);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
capsuleDataBuffer?.Dispose();
|
||||
capsuleDataBuffer = null;
|
||||
characterDataBuffer?.Dispose();
|
||||
characterDataBuffer = null;
|
||||
capsuleShadowDataBuffer?.Dispose();
|
||||
capsuleShadowDataBuffer = null;
|
||||
commandBuffer.Dispose();
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
ref var characterArray = ref sceneEffect.CharacterArray;
|
||||
ref var capsuleArray = ref sceneEffect.CapsuleArray;
|
||||
ref var capsuleAOSettingArray = ref sceneEffect.CapsuleAOSettingArray;
|
||||
if (!capsuleArray.IsCreated || !capsuleAOSettingArray.IsCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (capsuleDataBuffer == null || capsuleDataBuffer.count != capsuleArray.Length)
|
||||
{
|
||||
capsuleDataBuffer?.Release();
|
||||
capsuleDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, capsuleArray.Length, UnsafeUtility.SizeOf<Capsule>());
|
||||
}
|
||||
|
||||
if (characterDataBuffer == null || characterDataBuffer.count != characterArray.Length)
|
||||
{
|
||||
characterDataBuffer?.Release();
|
||||
characterDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, characterArray.Length, UnsafeUtility.SizeOf<Character>());
|
||||
}
|
||||
|
||||
if (capsuleShadowDataBuffer == null || capsuleShadowDataBuffer.count != capsuleAOSettingArray.Length)
|
||||
{
|
||||
capsuleShadowDataBuffer?.Release();
|
||||
capsuleShadowDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, capsuleAOSettingArray.Length, UnsafeUtility.SizeOf<CapsuleShadowAreaSetting>());
|
||||
}
|
||||
|
||||
capsuleDataBuffer.SetData(capsuleArray);
|
||||
characterDataBuffer.SetData(characterArray);
|
||||
|
||||
var cmd = commandBuffer;
|
||||
using var scp = new ProfilingScope(cmd, profiler);
|
||||
cmd.SetGlobalBuffer("_CapsuleData", capsuleDataBuffer);
|
||||
cmd.SetGlobalBuffer("_CharacterData", characterDataBuffer);
|
||||
|
||||
capsuleShadowDataBuffer.SetData(capsuleAOSettingArray);
|
||||
cmd.SetGlobalBuffer("_CapsuleShadowData", capsuleShadowDataBuffer);
|
||||
cmd.SetGlobalInt("_CapsuleShadowDataCount", capsuleAOSettingArray.Length);
|
||||
|
||||
cmd.SetGlobalInt("_CapsulesCount", capsuleArray.Length);
|
||||
cmd.SetGlobalInt("_CharactersCount", characterArray.Length);
|
||||
|
||||
cmd.SetGlobalInt("_CapsuleLightsCount", sceneEffect.CapsuleLightsDirCount);
|
||||
|
||||
if(sceneEffect.CapsuleLightsDirCount > 0)
|
||||
{
|
||||
cmd.SetGlobalVectorArray("_CapsuleLightsDir", sceneEffect.CapsuleLightsDir);
|
||||
}
|
||||
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/CapsuleShadowPass.cs.meta
Normal file
11
Assets/Scripts/CapsuleShadowPass.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27cffe4db78f52c4f8287abca46ef282
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,19 +1,18 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
using Object = UnityEngine.Object;
|
||||
using UnityEditor.Callbacks;
|
||||
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
#endif
|
||||
|
||||
namespace X.Rendering.Assets
|
||||
{
|
||||
public interface IGradientTextureForEditor
|
||||
{
|
||||
void CreateTexture();
|
||||
@ -478,3 +477,4 @@ public class ProjectIconsUtility
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1,70 +1,408 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Collections;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace X.Rendering.Scene
|
||||
{
|
||||
[ExecuteAlways]
|
||||
[DefaultExecutionOrder(100)]
|
||||
public class SceneEffect : MonoBehaviour
|
||||
{
|
||||
public RenderPassEvent injectionPoint = RenderPassEvent.BeforeRendering;
|
||||
|
||||
[Serializable]
|
||||
class Settings
|
||||
{
|
||||
public GradientTexture ShadowRemapTex;
|
||||
}
|
||||
const string MultiCapsuleShadowAndAO = "_MultiCapsule_Shadow_AO_ON";
|
||||
const string MultiCapsuleAO = "_MultiCapsule_AO_ON";
|
||||
[SerializeField]
|
||||
private Settings settings;
|
||||
SetupPass pass;
|
||||
private ShadowEdgeRemapSetupPass.ShadowEdgeRemapSettings shadowRemapSettings = new();
|
||||
ShadowEdgeRemapSetupPass shadowRemapPass;
|
||||
|
||||
[SerializeField]
|
||||
private CapsuleShadowPass.CapsuleShadowSettings capsuleAOSettings = new();
|
||||
CapsuleShadowPass capsuleAOPass;
|
||||
|
||||
[SerializeField]
|
||||
public bool EnableShadowOffset;
|
||||
[SerializeField]
|
||||
public Vector3 CascadeShadowOffset;
|
||||
|
||||
public int updateInterval = 1;
|
||||
|
||||
static SceneEffect instance;
|
||||
public static SceneEffect Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!instance)
|
||||
{
|
||||
instance = GameObject.FindObjectOfType<SceneEffect>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
private set
|
||||
{
|
||||
instance = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool active = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
pass = new(settings);
|
||||
pass.renderPassEvent = injectionPoint;
|
||||
RenderPipelineManager.beginCameraRendering += OnBeginCamera;
|
||||
SetEnable(true);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
RenderPipelineManager.beginCameraRendering -= OnBeginCamera;
|
||||
SetEnable(false);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Shader.DisableKeyword(MultiCapsuleAO);
|
||||
Shader.DisableKeyword(MultiCapsuleShadowAndAO);
|
||||
shadowRemapPass?.Dispose();
|
||||
capsuleAOPass?.Dispose();
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
protected void SetEnable(bool enable)
|
||||
{
|
||||
active = enable;
|
||||
if (enable)
|
||||
{
|
||||
shadowRemapPass ??= new(shadowRemapSettings, this);
|
||||
capsuleAOPass ??= new(capsuleAOSettings, this);
|
||||
RenderPipelineManager.beginCameraRendering += OnBeginCamera;
|
||||
UpdateRenderAssetsSettings();
|
||||
#if UNITY_EDITOR
|
||||
UpdateCapsuleLights();
|
||||
#endif
|
||||
ApplySerializeData();
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderPipelineManager.beginCameraRendering -= OnBeginCamera;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
internal void AddSceneAreaEffect(CapsuleShadowAreaEffect sceneAreaEffect)
|
||||
{
|
||||
sceneAreaEffects.Add(sceneAreaEffect);
|
||||
UpdateCapsuleLights();
|
||||
}
|
||||
|
||||
internal void RmSceneAreaEffect(CapsuleShadowAreaEffect sceneAreaEffect)
|
||||
{
|
||||
sceneAreaEffects.Remove(sceneAreaEffect);
|
||||
UpdateCapsuleLights();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
UpdateRenderAssetsSettings();
|
||||
UpdateCapsuleLights();
|
||||
}
|
||||
|
||||
internal void AreaEffectValidate()
|
||||
{
|
||||
UpdateCapsuleLights();
|
||||
}
|
||||
|
||||
private void UpdateCapsuleLights()
|
||||
{
|
||||
List<Vector4> lightDirs = new List<Vector4>();
|
||||
CapsuleLightsDir = new Vector4[32];
|
||||
capsuleAOAreaSettings.Clear();
|
||||
for (int i = 0; i < capsuleLights?.Length; i++)
|
||||
{
|
||||
var light = capsuleLights[i];
|
||||
|
||||
lightDirs.Add(new Vector4()
|
||||
{
|
||||
x = light.x,
|
||||
y = light.y,
|
||||
z = light.z,
|
||||
w = 1
|
||||
});
|
||||
|
||||
}
|
||||
capsuleAOSetting.lightStartID = 0;
|
||||
capsuleAOSetting.lightEndID = lightDirs.Count;
|
||||
capsuleAOAreaSettings.Add(capsuleAOSetting);
|
||||
|
||||
for (int i = 0; i < sceneAreaEffects.Count; i++)
|
||||
{
|
||||
var sceneAreaEffect = sceneAreaEffects[i];
|
||||
ref var aoSetting = ref sceneAreaEffect.capsuleAOSetting;
|
||||
aoSetting.lightStartID = lightDirs.Count;
|
||||
for (int j = 0; j < sceneAreaEffect.capsuleLights.Length; j++)
|
||||
{
|
||||
var light = sceneAreaEffect.capsuleLights[j];
|
||||
|
||||
|
||||
lightDirs.Add(new Vector4()
|
||||
{
|
||||
x = light.x,
|
||||
y = light.y,
|
||||
z = light.z,
|
||||
w = 1
|
||||
});
|
||||
}
|
||||
|
||||
aoSetting.lightEndID = lightDirs.Count - 1;
|
||||
capsuleAOAreaSettings.Add(aoSetting);
|
||||
}
|
||||
|
||||
CapsuleLightsDirCount = lightDirs.Count;
|
||||
for (int i = 0; i < CapsuleLightsDirCount; i++)
|
||||
{
|
||||
CapsuleLightsDir[i] = lightDirs[i];
|
||||
}
|
||||
|
||||
if(CapsuleAOSettingArray.IsCreated)
|
||||
{
|
||||
CapsuleAOSettingArray.Dispose();
|
||||
}
|
||||
|
||||
CapsuleAOSettingArray = new NativeArray<CapsuleShadowAreaSetting>(capsuleAOAreaSettings.Count, Allocator.Persistent);
|
||||
CapsuleAOSettingArray.CopyFrom(capsuleAOAreaSettings.ToArray());
|
||||
}
|
||||
#endif
|
||||
|
||||
private void ApplySerializeData()
|
||||
{
|
||||
if (CapsuleAOSettingArray.IsCreated)
|
||||
{
|
||||
CapsuleAOSettingArray.Dispose();
|
||||
}
|
||||
|
||||
CapsuleAOSettingArray = new NativeArray<CapsuleShadowAreaSetting>(capsuleAOAreaSettings.Count, Allocator.Persistent);
|
||||
CapsuleAOSettingArray.CopyFrom(capsuleAOAreaSettings.ToArray());
|
||||
|
||||
Shader.EnableKeyword(MultiCapsuleAO);
|
||||
if (CapsuleLightsDir.Length > 0)
|
||||
{
|
||||
Shader.EnableKeyword(MultiCapsuleShadowAndAO);
|
||||
}
|
||||
else
|
||||
{
|
||||
Shader.DisableKeyword(MultiCapsuleShadowAndAO);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateRenderAssetsSettings()
|
||||
{
|
||||
var asset = (GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset);
|
||||
asset.EnableShadowOffset = EnableShadowOffset;
|
||||
asset.cascadeShadowOffset = CascadeShadowOffset;
|
||||
}
|
||||
|
||||
private void OnBeginCamera(ScriptableRenderContext context, Camera cam)
|
||||
{
|
||||
if (pass == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cam.cameraType != CameraType.Game && cam.cameraType != CameraType.SceneView)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cam.GetUniversalAdditionalCameraData().scriptableRenderer.EnqueuePass(pass);
|
||||
var rdr = cam.GetUniversalAdditionalCameraData().scriptableRenderer;
|
||||
|
||||
if (shadowRemapSettings.Enable && shadowRemapSettings.ShadowRemapTex)
|
||||
{
|
||||
rdr.EnqueuePass(shadowRemapPass);
|
||||
}
|
||||
|
||||
private class SetupPass : ScriptableRenderPass
|
||||
if (capsuleAOSettings.Enable)
|
||||
{
|
||||
const string ShadowRemap = "_ShadowRemapON";
|
||||
private Settings settings;
|
||||
|
||||
public SetupPass(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
rdr.EnqueuePass(capsuleAOPass);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FrameCleanup(CommandBuffer cmd)
|
||||
private void Update()
|
||||
{
|
||||
cmd.DisableShaderKeyword(ShadowRemap);
|
||||
if (active && Time.frameCount % updateInterval == 0)
|
||||
{
|
||||
UpdateCapsuleShadow();
|
||||
}
|
||||
if(a && b)
|
||||
{
|
||||
|
||||
//CapsuleLightsDir[0] = new float4(/*(a.position - b.position).normalized*/a.rotation.eulerAngles, 1);
|
||||
//Debug.Log(a.rotation.eulerAngles);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
#region CapsuleAO
|
||||
[SerializeField]
|
||||
public Transform a;
|
||||
[SerializeField]
|
||||
public Transform b;
|
||||
[SerializeField ]//, HideInInspector]
|
||||
private Vector4[] capsuleLights;
|
||||
[SerializeField]
|
||||
private CapsuleShadowAreaSetting capsuleAOSetting = CapsuleShadowAreaSetting.GetDefault();
|
||||
[HideInInspector]
|
||||
public NativeArray<Character> CharacterArray;
|
||||
[HideInInspector]
|
||||
public NativeArray<Capsule> CapsuleArray;
|
||||
|
||||
[HideInInspector, SerializeField]
|
||||
public Vector4[] CapsuleLightsDir = new Vector4[32];
|
||||
[HideInInspector, SerializeField]
|
||||
public int CapsuleLightsDirCount = 0;
|
||||
[HideInInspector, SerializeField]
|
||||
List<CapsuleShadowAreaSetting> capsuleAOAreaSettings = new();
|
||||
|
||||
[HideInInspector]
|
||||
public NativeArray<CapsuleShadowAreaSetting> CapsuleAOSettingArray;
|
||||
[SerializeField]
|
||||
private List<CapsuleShadowAreaEffect> sceneAreaEffects = new List<CapsuleShadowAreaEffect>(2);
|
||||
|
||||
private List<SceneEffectCharacter> sceneEffectCharacters = new();
|
||||
private Dictionary<SceneEffectCharacter, CapsuleCollider[]> character2CapsuleCollider = new();
|
||||
private int capsuleColliderCount = 0;
|
||||
|
||||
public void AddSceneEffectCharacter(SceneEffectCharacter character)
|
||||
{
|
||||
var cmd = CommandBufferPool.Get("DissolveEffect");
|
||||
cmd.EnableShaderKeyword(ShadowRemap);
|
||||
cmd.SetGlobalTexture("_ShadowRemap", settings.ShadowRemapTex.GetTexture());
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
sceneEffectCharacters.Add(character);
|
||||
AddCapsuleAOCharacter(character);
|
||||
}
|
||||
|
||||
public void RmSceneEffectCharacter(SceneEffectCharacter character)
|
||||
{
|
||||
sceneEffectCharacters.Remove(character);
|
||||
RemoveCapsuleAOCharacter(character);
|
||||
}
|
||||
|
||||
private void AddCapsuleAOCharacter(SceneEffectCharacter character)
|
||||
{
|
||||
if (character2CapsuleCollider.ContainsKey(character))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var oldCapsuleArray = CapsuleArray;
|
||||
var oldCharacterArray = CharacterArray;
|
||||
|
||||
var capsules = character.GetComponentsInChildren<CapsuleCollider>(true);
|
||||
character2CapsuleCollider.Add(character, capsules);
|
||||
capsuleColliderCount += capsules.Length;
|
||||
CapsuleArray = new(capsuleColliderCount, Allocator.Persistent);
|
||||
CharacterArray = new(character2CapsuleCollider.Count, Allocator.Persistent);
|
||||
|
||||
if (oldCharacterArray.IsCreated)
|
||||
{
|
||||
oldCharacterArray.Dispose();
|
||||
oldCapsuleArray.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveCapsuleAOCharacter(SceneEffectCharacter character)
|
||||
{
|
||||
if(!character2CapsuleCollider.ContainsKey(character))
|
||||
{
|
||||
return;
|
||||
}
|
||||
capsuleColliderCount -= character2CapsuleCollider[character].Length;
|
||||
character2CapsuleCollider.Remove(character);
|
||||
var oldCapsuleArray = CapsuleArray;
|
||||
var oldCharacterArray = CharacterArray;
|
||||
|
||||
CapsuleArray = new(capsuleColliderCount, Allocator.Persistent);
|
||||
CharacterArray = new(character2CapsuleCollider.Count, Allocator.Persistent);
|
||||
|
||||
if (oldCharacterArray.IsCreated)
|
||||
{
|
||||
oldCharacterArray.Dispose();
|
||||
oldCapsuleArray.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCapsuleShadow()
|
||||
{
|
||||
if (!CapsuleArray.IsCreated || CapsuleArray.Length == 0)
|
||||
{
|
||||
capsuleAOSettings.Enable = false;
|
||||
return;
|
||||
}
|
||||
SceneEffectCharacter sceneEffectCharacter = null;
|
||||
|
||||
for (int j = 0; j < sceneEffectCharacters.Count; j++)
|
||||
{
|
||||
sceneEffectCharacter = sceneEffectCharacters[j];
|
||||
sceneEffectCharacter.capsuleAOSettingMask = 1;
|
||||
for (int i = 0; i < sceneAreaEffects.Count; i++)
|
||||
{
|
||||
var sceneAreaEffect = sceneAreaEffects[i];
|
||||
if (sceneAreaEffect.Bounds.Contains(sceneEffectCharacter.transform.position))
|
||||
{
|
||||
sceneEffectCharacter.capsuleAOSettingMask |= (uint)1 << i;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int capsuleArrayIndex = 0;
|
||||
int characterArrayIndex = 0;
|
||||
int startID = 0;
|
||||
sceneEffectCharacter = null;
|
||||
|
||||
foreach (var item in character2CapsuleCollider)
|
||||
{
|
||||
for (int i = 0; i < item.Value.Length; i++)
|
||||
{
|
||||
var capsule = item.Value[i];
|
||||
//capsule.direction
|
||||
Vector3 dir = Vector3.zero;
|
||||
switch (capsule.direction)
|
||||
{
|
||||
case 0:
|
||||
dir = new Vector3(capsule.height / 2 - capsule.radius, 0);
|
||||
break;
|
||||
case 1:
|
||||
dir = new Vector3(0, capsule.height / 2 - capsule.radius, 0);
|
||||
break;
|
||||
case 2:
|
||||
dir = new Vector3(0, 0, capsule.height / 2 - capsule.radius);
|
||||
break;
|
||||
}
|
||||
var a = capsule.center - dir;
|
||||
var b = capsule.center + dir;
|
||||
//var a = capsule.center - new Vector3(0, capsule.height / 2, 0);
|
||||
//var b = capsule.center + new Vector3(0, capsule.height / 2, 0);
|
||||
|
||||
a = capsule.transform.TransformPoint(a);
|
||||
b = capsule.transform.TransformPoint(b);
|
||||
CapsuleArray[capsuleArrayIndex++] = new()
|
||||
{
|
||||
a = a,
|
||||
b = b,
|
||||
radius = capsule.radius,
|
||||
};
|
||||
}
|
||||
|
||||
if (sceneEffectCharacter != item.Key)
|
||||
{
|
||||
sceneEffectCharacter = item.Key;
|
||||
CharacterArray[characterArrayIndex++] = new()
|
||||
{
|
||||
position = sceneEffectCharacter.transform.position,
|
||||
radius = sceneEffectCharacter.transform.lossyScale.x,
|
||||
capsuleAOSettingMask = sceneEffectCharacter.capsuleAOSettingMask,
|
||||
capsuleStartID = startID,
|
||||
capsuleEndID = capsuleArrayIndex,
|
||||
};
|
||||
|
||||
startID = capsuleArrayIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 763668dd69af1b243b7b0bebcc85b814
|
||||
guid: e395308c14c05ac46b83581ae4e5f7a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
127
Assets/Scripts/SceneEffectCharacter.cs
Normal file
127
Assets/Scripts/SceneEffectCharacter.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace X.Rendering.Scene
|
||||
{
|
||||
[ExecuteAlways]
|
||||
[DefaultExecutionOrder(200)]
|
||||
public class SceneEffectCharacter : MonoBehaviour
|
||||
{
|
||||
public uint capsuleAOSettingMask;
|
||||
|
||||
[Serializable]
|
||||
class BoneCapsuleSetting
|
||||
{
|
||||
public string BoneName;
|
||||
public float Radius;
|
||||
public float Height;
|
||||
public int Direction;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private BoneCapsuleSetting[] boneSettings = new BoneCapsuleSetting[]
|
||||
{
|
||||
new()
|
||||
{
|
||||
BoneName = "Forearm01".ToLowerInvariant(), // 前臂
|
||||
Radius =0.05f,
|
||||
Height = 0.2f,
|
||||
Direction = 0
|
||||
},
|
||||
new()
|
||||
{
|
||||
BoneName ="UpperArm01".ToLowerInvariant(), // 上臂
|
||||
Radius =0.05f,
|
||||
Height = 0.2f,
|
||||
Direction = 0
|
||||
},
|
||||
new()
|
||||
{
|
||||
BoneName ="Spine1".ToLowerInvariant(), // 脊柱
|
||||
Radius =0.15f,
|
||||
Height = 0.7f,
|
||||
Direction = 0
|
||||
},
|
||||
new()
|
||||
{
|
||||
BoneName = "Calf01".ToLowerInvariant(), // 小腿
|
||||
Radius =0.03f,
|
||||
Height = 0.6f,
|
||||
Direction = 0
|
||||
},
|
||||
new()
|
||||
{
|
||||
BoneName ="Thigh01".ToLowerInvariant(), // 大腿
|
||||
Radius =0.1f,
|
||||
Height = 0.4f,
|
||||
Direction = 0
|
||||
}
|
||||
};
|
||||
[SerializeField]
|
||||
private List<Transform> capsuleTransforms = new List<Transform>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
AddCapsule();
|
||||
#endif
|
||||
if (capsuleTransforms?.Count == 0)
|
||||
{
|
||||
AddCapsule();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddCapsule()
|
||||
{
|
||||
var nodes = this.GetComponentsInChildren<Transform>();
|
||||
foreach (var item in nodes)
|
||||
{
|
||||
if(item.childCount > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var goName = item.name.ToLowerInvariant();
|
||||
|
||||
for (int i = 0; i < boneSettings.Length; i++)
|
||||
{
|
||||
var boneSetting = boneSettings[i];
|
||||
if(goName.EndsWith(boneSetting.BoneName))
|
||||
{
|
||||
if (!item.TryGetComponent<CapsuleCollider>(out var capsuleCollider))
|
||||
{
|
||||
capsuleCollider = item.gameObject.AddComponent<CapsuleCollider>();
|
||||
}
|
||||
|
||||
capsuleCollider.enabled = false;
|
||||
capsuleCollider.direction = boneSetting.Direction;
|
||||
capsuleCollider.radius = boneSetting.Radius;
|
||||
capsuleCollider.height = boneSetting.Height;
|
||||
if(!capsuleTransforms.Contains(item))
|
||||
{
|
||||
capsuleTransforms.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
capsuleTransforms.Clear();
|
||||
AddCapsule();
|
||||
}
|
||||
#endif
|
||||
private void OnEnable()
|
||||
{
|
||||
SceneEffect.Instance?.AddSceneEffectCharacter(this);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SceneEffect.Instance?.RmSceneEffectCharacter(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/SceneEffectCharacter.cs.meta
Normal file
11
Assets/Scripts/SceneEffectCharacter.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8428b639172492046a0d002d77fe376e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Scripts/ShadowEdgeRemapSetupPass.cs
Normal file
48
Assets/Scripts/ShadowEdgeRemapSetupPass.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using X.Rendering.Assets;
|
||||
|
||||
namespace X.Rendering.Scene
|
||||
{
|
||||
internal class ShadowEdgeRemapSetupPass : ScriptableRenderPass, IDisposable
|
||||
{
|
||||
[Serializable]
|
||||
public class ShadowEdgeRemapSettings
|
||||
{
|
||||
public bool Enable = true;
|
||||
public GradientTexture ShadowRemapTex;
|
||||
public RenderPassEvent InjectionPoint = RenderPassEvent.BeforeRendering;
|
||||
}
|
||||
|
||||
const string ShadowRemap = "_ShadowRemapON";
|
||||
private ShadowEdgeRemapSettings settings;
|
||||
private CommandBuffer commandBuffer;
|
||||
|
||||
public ShadowEdgeRemapSetupPass(ShadowEdgeRemapSettings settings, SceneEffect sceneEffect)
|
||||
{
|
||||
this.settings = settings;
|
||||
renderPassEvent = settings.InjectionPoint;
|
||||
commandBuffer = CommandBufferPool.Get(nameof(ShadowEdgeRemapSetupPass) + sceneEffect.name);
|
||||
}
|
||||
|
||||
public override void FrameCleanup(CommandBuffer cmd)
|
||||
{
|
||||
cmd.DisableShaderKeyword(ShadowRemap);
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
var cmd = commandBuffer;
|
||||
cmd.EnableShaderKeyword(ShadowRemap);
|
||||
cmd.SetGlobalTexture("_ShadowRemap", settings.ShadowRemapTex.GetTexture());
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
commandBuffer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ShadowEdgeRemapSetupPass.cs.meta
Normal file
11
Assets/Scripts/ShadowEdgeRemapSetupPass.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16886929e1e754e499604a5d8bb90ca9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -127,26 +127,6 @@ MonoBehaviour:
|
||||
BlitMat: {fileID: 2100000, guid: b04591ed716b35e41857f554d491ef4b, type: 2}
|
||||
ComputeHistogramComputeShader: {fileID: 7200000, guid: b140e27dc74a1fb4d9ae30f8566b8919, type: 3}
|
||||
AutoExposureComputeShader: {fileID: 7200000, guid: 6febb5a945f3510429c58ed4a45c1846, type: 3}
|
||||
--- !u!114 &-5770411415856688072
|
||||
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: 1eadf15e5222b6546b5c84a97197f414, type: 3}
|
||||
m_Name: CapsuleAO
|
||||
m_EditorClassIdentifier:
|
||||
m_Active: 0
|
||||
settings:
|
||||
RenderPassEvent: 450
|
||||
AmbientIntensity: 1.44
|
||||
ShadowIntensity: 0.2
|
||||
ShadowSharpness: 0.9
|
||||
ConeAngle: 16.21
|
||||
CapsuleAOMat: {fileID: 2100000, guid: c90d40f0d9828744b916dbed0eed9db6, type: 2}
|
||||
--- !u!114 &-5418649131825517062
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -163,12 +143,12 @@ MonoBehaviour:
|
||||
settings:
|
||||
PlanarShadowMat: {fileID: 2100000, guid: ce6debd28bc41e144a6cf99005cf820e, type: 2}
|
||||
planarShadowColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
castPlaneOffset: -1
|
||||
castPlaneOffset: -0.98
|
||||
castPlaneNormal: {x: 0, y: 1, z: 0}
|
||||
shadowResolution: 256
|
||||
shadowResolution: 512
|
||||
softQuality: 32
|
||||
softScaleByDistance: 2.32
|
||||
softGradientDistance: 15
|
||||
softScaleByDistance: 2.4
|
||||
softGradientDistance: 7.45
|
||||
minSoft: 1
|
||||
--- !u!114 &-4454652084718109581
|
||||
MonoBehaviour:
|
||||
@ -377,8 +357,7 @@ MonoBehaviour:
|
||||
- {fileID: 5808157236138506604}
|
||||
- {fileID: -5418649131825517062}
|
||||
- {fileID: -7143664486661302651}
|
||||
- {fileID: -5770411415856688072}
|
||||
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222716523fbf3439fdb7a327b7bff4bdd446ac59dfa966ffa88ca6373cd5da9013d6cff55ca297e5e908a7b3653203b82383b2141bb05fbe69aec5704e48e2763e90bc6ff9f19caa7686c79a6bb3bb89a50faad0fe75217cdb485d6fa85ff9adc9c38d400e66361ebaf
|
||||
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222716523fbf3439fdb7a327b7bff4bdd446ac59dfa966ffa88ca6373cd5da9013d6cff55ca297e5e908a7b3653203b82383b2141bb05fbe69aec5704e48e2763e90bc6ff9f19caa7686c79a6bb3bb89a50faad0fe75217cdb485d6fa85ff9adc9c
|
||||
m_UseNativeRenderPass: 0
|
||||
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
|
||||
shaders:
|
||||
|
||||
Binary file not shown.
@ -0,0 +1,109 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3625ea8e472e0d04881284295b492f63
|
||||
ModelImporter:
|
||||
serializedVersion: 22200
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 2
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importPhysicalCameras: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
strictVertexDataChecks: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 1
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 1
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
importBlendShapeDeformPercent: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@ -0,0 +1,109 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9bbc1d92fe19fb4ea5a667af726294c
|
||||
ModelImporter:
|
||||
serializedVersion: 22200
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 0
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 1
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importPhysicalCameras: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
strictVertexDataChecks: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 1
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 1
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
importBlendShapeDeformPercent: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
332957
Assets/SharedAssets/ThirdPersonController/Character/Animations/B_Idle.anim
Normal file
332957
Assets/SharedAssets/ThirdPersonController/Character/Animations/B_Idle.anim
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7ed015f44284f94a97fa6cf73b2e0a2
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
326837
Assets/SharedAssets/ThirdPersonController/Character/Animations/B_Run.anim
Normal file
326837
Assets/SharedAssets/ThirdPersonController/Character/Animations/B_Run.anim
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54c3f897e87e2eb43996a6db26a97df4
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 7400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@ -0,0 +1,109 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff6fc39872c79c549b982caef1fc013a
|
||||
ModelImporter:
|
||||
serializedVersion: 22200
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
materials:
|
||||
materialImportMode: 0
|
||||
materialName: 0
|
||||
materialSearch: 1
|
||||
materialLocation: 1
|
||||
animations:
|
||||
legacyGenerateAnimations: 4
|
||||
bakeSimulation: 0
|
||||
resampleCurves: 1
|
||||
optimizeGameObjects: 0
|
||||
removeConstantScaleCurves: 0
|
||||
motionNodeName:
|
||||
rigImportErrors:
|
||||
rigImportWarnings:
|
||||
animationImportErrors:
|
||||
animationImportWarnings:
|
||||
animationRetargetingWarnings:
|
||||
animationDoRetargetingWarnings: 0
|
||||
importAnimatedCustomProperties: 0
|
||||
importConstraints: 0
|
||||
animationCompression: 3
|
||||
animationRotationError: 0.5
|
||||
animationPositionError: 0.5
|
||||
animationScaleError: 0.5
|
||||
animationWrapMode: 0
|
||||
extraExposedTransformPaths: []
|
||||
extraUserProperties: []
|
||||
clipAnimations: []
|
||||
isReadable: 0
|
||||
meshes:
|
||||
lODScreenPercentages: []
|
||||
globalScale: 1
|
||||
meshCompression: 0
|
||||
addColliders: 0
|
||||
useSRGBMaterialColor: 1
|
||||
sortHierarchyByName: 1
|
||||
importPhysicalCameras: 1
|
||||
importVisibility: 1
|
||||
importBlendShapes: 1
|
||||
importCameras: 1
|
||||
importLights: 1
|
||||
nodeNameCollisionStrategy: 1
|
||||
fileIdsGeneration: 2
|
||||
swapUVChannels: 0
|
||||
generateSecondaryUV: 0
|
||||
useFileUnits: 1
|
||||
keepQuads: 0
|
||||
weldVertices: 1
|
||||
bakeAxisConversion: 0
|
||||
preserveHierarchy: 0
|
||||
skinWeightsMode: 0
|
||||
maxBonesPerVertex: 4
|
||||
minBoneWeight: 0.001
|
||||
optimizeBones: 1
|
||||
meshOptimizationFlags: -1
|
||||
indexFormat: 0
|
||||
secondaryUVAngleDistortion: 8
|
||||
secondaryUVAreaDistortion: 15.000001
|
||||
secondaryUVHardAngle: 88
|
||||
secondaryUVMarginMethod: 1
|
||||
secondaryUVMinLightmapResolution: 40
|
||||
secondaryUVMinObjectScale: 1
|
||||
secondaryUVPackMargin: 4
|
||||
useFileScale: 1
|
||||
strictVertexDataChecks: 0
|
||||
tangentSpace:
|
||||
normalSmoothAngle: 60
|
||||
normalImportMode: 0
|
||||
tangentImportMode: 3
|
||||
normalCalculationMode: 4
|
||||
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
||||
blendShapeNormalImportMode: 1
|
||||
normalSmoothingSource: 0
|
||||
referencedClips: []
|
||||
importAnimation: 1
|
||||
humanDescription:
|
||||
serializedVersion: 3
|
||||
human: []
|
||||
skeleton: []
|
||||
armTwist: 0.5
|
||||
foreArmTwist: 0.5
|
||||
upperLegTwist: 0.5
|
||||
legTwist: 0.5
|
||||
armStretch: 0.05
|
||||
legStretch: 0.05
|
||||
feetSpacing: 0
|
||||
globalScale: 1
|
||||
rootMotionBoneName:
|
||||
hasTranslationDoF: 0
|
||||
hasExtraRoot: 1
|
||||
skeletonHasParents: 1
|
||||
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
||||
autoGenerateAvatarMappingIfUnspecified: 1
|
||||
animationType: 2
|
||||
humanoidOversampling: 1
|
||||
avatarSetup: 0
|
||||
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
||||
importBlendShapeDeformPercent: 1
|
||||
remapMaterialsIfMaterialImportModeIsNone: 0
|
||||
additionalBone: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -125,7 +125,11 @@ namespace UnityEngine.Rendering.Universal
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
if (targetCamera == null) return;
|
||||
if (targetCamera == null)
|
||||
{
|
||||
targetCamera ??= Camera.main;
|
||||
return;
|
||||
}
|
||||
|
||||
if (showCullingSpheres)
|
||||
{
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.Experimental.Rendering.RenderGraphModule;
|
||||
|
||||
namespace UnityEngine.Rendering.Universal.Internal
|
||||
|
||||
@ -784,7 +784,7 @@ namespace UnityEngine.Rendering.Universal
|
||||
{
|
||||
if (shaderTagIdList == null || shaderTagIdList.Count == 0)
|
||||
{
|
||||
Debug.LogWarning("ShaderTagId list is invalid. DrawingSettings is created with default pipeline ShaderTagId");
|
||||
UnityEngine.Debug.LogWarning("ShaderTagId list is invalid. DrawingSettings is created with default pipeline ShaderTagId");
|
||||
return CreateDrawingSettings(new ShaderTagId("UniversalPipeline"), ref renderingData, sortingCriteria);
|
||||
}
|
||||
|
||||
|
||||
@ -1,131 +1,131 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
//using System;
|
||||
//using System.Runtime.InteropServices;
|
||||
//using Unity.Collections.LowLevel.Unsafe;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.Rendering;
|
||||
//using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace X.Rendering.Feature
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Capsule
|
||||
{
|
||||
public Vector3 a, b;
|
||||
public float radius;
|
||||
}
|
||||
//namespace X.Rendering.Feature
|
||||
//{
|
||||
// [StructLayout(LayoutKind.Sequential)]
|
||||
// public struct Capsule
|
||||
// {
|
||||
// public Vector3 a, b;
|
||||
// public float radius;
|
||||
// }
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct Character
|
||||
{
|
||||
public Vector3 position;
|
||||
public float radius;
|
||||
public Vector4 lightDir; //xyz:lightDir, w:根据lightColor 算个系数
|
||||
public int startID, endID;
|
||||
}
|
||||
// [StructLayout(LayoutKind.Sequential)]
|
||||
// public struct Character
|
||||
// {
|
||||
// public Vector3 position;
|
||||
// public float radius;
|
||||
// public Vector4 lightDir; //xyz:lightDir, w:根据lightColor 算个系数
|
||||
// public int startID, endID;
|
||||
// }
|
||||
|
||||
public class CapsuleAO : ScriptableRendererFeature
|
||||
{
|
||||
[Serializable]
|
||||
public class Settings
|
||||
{
|
||||
public RenderPassEvent RenderPassEvent = RenderPassEvent.BeforeRenderingTransparents;
|
||||
public float AmbientIntensity = 0.2f;
|
||||
public float ShadowIntensity = 0.4f;
|
||||
public float ShadowSharpness = 20;
|
||||
[Range(1, 90)]
|
||||
public float ConeAngle = 1;
|
||||
public Material CapsuleAOMat;
|
||||
}
|
||||
// public class CapsuleAO : ScriptableRendererFeature
|
||||
// {
|
||||
// [Serializable]
|
||||
// public class CapsuleAOSettings
|
||||
// {
|
||||
// public RenderPassEvent RenderPassEvent = RenderPassEvent.BeforeRenderingTransparents;
|
||||
// public float AmbientIntensity = 0.2f;
|
||||
// public float ShadowIntensity = 0.4f;
|
||||
// public float ShadowSharpness = 20;
|
||||
// [Range(1, 90)]
|
||||
// public float ConeAngle = 1;
|
||||
// public Material CapsuleAOMat;
|
||||
// }
|
||||
|
||||
[SerializeField]
|
||||
Settings settings;
|
||||
CapsuleAOPass capsuleAOPass;
|
||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
{
|
||||
{
|
||||
renderer.EnqueuePass(capsuleAOPass);
|
||||
}
|
||||
}
|
||||
// [SerializeField]
|
||||
// CapsuleAOSettings settings;
|
||||
// CapsuleAOPass capsuleAOPass;
|
||||
// public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||
// {
|
||||
// {
|
||||
// renderer.EnqueuePass(capsuleAOPass);
|
||||
// }
|
||||
// }
|
||||
|
||||
public override void Create()
|
||||
{
|
||||
capsuleAOPass = new(settings);
|
||||
}
|
||||
// public override void Create()
|
||||
// {
|
||||
// capsuleAOPass = new(settings);
|
||||
// }
|
||||
|
||||
class CapsuleAOPass : ScriptableRenderPass, IDisposable
|
||||
{
|
||||
private Settings settings;
|
||||
private GraphicsBuffer capsuleDataBuffer;
|
||||
private GraphicsBuffer characterDataBuffer;
|
||||
private ProfilingSampler profiler;
|
||||
// class CapsuleAOPass : ScriptableRenderPass, IDisposable
|
||||
// {
|
||||
// private CapsuleAOSettings settings;
|
||||
// private GraphicsBuffer capsuleDataBuffer;
|
||||
// private GraphicsBuffer characterDataBuffer;
|
||||
// private ProfilingSampler profiler;
|
||||
|
||||
|
||||
|
||||
public CapsuleAOPass(Settings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
profiler = new (nameof(CapsuleAOPass));
|
||||
renderPassEvent = settings.RenderPassEvent;
|
||||
}
|
||||
// public CapsuleAOPass(CapsuleAOSettings settings)
|
||||
// {
|
||||
// this.settings = settings;
|
||||
// profiler = new(nameof(CapsuleAOPass));
|
||||
// renderPassEvent = settings.RenderPassEvent;
|
||||
// }
|
||||
|
||||
|
||||
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
|
||||
{
|
||||
base.Configure(cmd, cameraTextureDescriptor);
|
||||
ConfigureInput(ScriptableRenderPassInput.Depth | ScriptableRenderPassInput.Normal);
|
||||
}
|
||||
// public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
|
||||
// {
|
||||
// base.Configure(cmd, cameraTextureDescriptor);
|
||||
// ConfigureInput(ScriptableRenderPassInput.Depth | ScriptableRenderPassInput.Normal);
|
||||
// }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
capsuleDataBuffer?.Dispose();
|
||||
capsuleDataBuffer = null;
|
||||
characterDataBuffer?.Dispose();
|
||||
characterDataBuffer = null;
|
||||
}
|
||||
// public void Dispose()
|
||||
// {
|
||||
// capsuleDataBuffer?.Dispose();
|
||||
// capsuleDataBuffer = null;
|
||||
// characterDataBuffer?.Dispose();
|
||||
// characterDataBuffer = null;
|
||||
// }
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
if (!XRenderFeatureManager.Instance)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ref var characterArray = ref XRenderFeatureManager.Instance.CharacterArray;
|
||||
ref var capsuleArray = ref XRenderFeatureManager.Instance.CapsuleArray;
|
||||
if (!capsuleArray.IsCreated)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
// {
|
||||
// if (!XRenderFeatureManager.Instance)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// ref var characterArray = ref XRenderFeatureManager.Instance.CharacterArray;
|
||||
// ref var capsuleArray = ref XRenderFeatureManager.Instance.CapsuleArray;
|
||||
// if (!capsuleArray.IsCreated)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(capsuleDataBuffer == null || capsuleDataBuffer.count != capsuleArray.Length)
|
||||
{
|
||||
capsuleDataBuffer?.Release();
|
||||
capsuleDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, capsuleArray.Length, UnsafeUtility.SizeOf<Capsule>());
|
||||
}
|
||||
// if (capsuleDataBuffer == null || capsuleDataBuffer.count != capsuleArray.Length)
|
||||
// {
|
||||
// capsuleDataBuffer?.Release();
|
||||
// capsuleDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, capsuleArray.Length, UnsafeUtility.SizeOf<Capsule>());
|
||||
// }
|
||||
|
||||
if (characterDataBuffer == null || characterDataBuffer.count != characterArray.Length)
|
||||
{
|
||||
characterDataBuffer?.Release();
|
||||
characterDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, characterArray.Length, UnsafeUtility.SizeOf<Character>());
|
||||
}
|
||||
// if (characterDataBuffer == null || characterDataBuffer.count != characterArray.Length)
|
||||
// {
|
||||
// characterDataBuffer?.Release();
|
||||
// characterDataBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, characterArray.Length, UnsafeUtility.SizeOf<Character>());
|
||||
// }
|
||||
|
||||
capsuleDataBuffer.SetData(capsuleArray);
|
||||
characterDataBuffer.SetData(characterArray);
|
||||
// capsuleDataBuffer.SetData(capsuleArray);
|
||||
// characterDataBuffer.SetData(characterArray);
|
||||
|
||||
var cmd = renderingData.commandBuffer;
|
||||
using var scp = new ProfilingScope(cmd, profiler);
|
||||
cmd.SetGlobalBuffer("_CapsuleData", capsuleDataBuffer);
|
||||
cmd.SetGlobalBuffer("_CharacterData", characterDataBuffer);
|
||||
cmd.SetGlobalInt("_CapsulesCount", capsuleArray.Length);
|
||||
cmd.SetGlobalInt("_CharactersCount", characterArray.Length);
|
||||
cmd.SetGlobalFloat("_AmbientIntensity", settings.AmbientIntensity);
|
||||
cmd.SetGlobalFloat("_ShadowIntensity", settings.ShadowIntensity);
|
||||
cmd.SetGlobalFloat("_ShadowSharpness", settings.ShadowSharpness);
|
||||
cmd.SetGlobalFloat("_ConeAngle", settings.ConeAngle);
|
||||
var renderer = renderingData.cameraData.renderer;
|
||||
// var cmd = renderingData.commandBuffer;
|
||||
// using var scp = new ProfilingScope(cmd, profiler);
|
||||
// cmd.SetGlobalBuffer("_CapsuleData", capsuleDataBuffer);
|
||||
// cmd.SetGlobalBuffer("_CharacterData", characterDataBuffer);
|
||||
// cmd.SetGlobalInt("_CapsulesCount", capsuleArray.Length);
|
||||
// cmd.SetGlobalInt("_CharactersCount", characterArray.Length);
|
||||
// cmd.SetGlobalFloat("_AmbientIntensity", settings.AmbientIntensity);
|
||||
// cmd.SetGlobalFloat("_ShadowIntensity", settings.ShadowIntensity);
|
||||
// cmd.SetGlobalFloat("_ShadowSharpness", settings.ShadowSharpness);
|
||||
// cmd.SetGlobalFloat("_ConeAngle", settings.ConeAngle);
|
||||
// var renderer = renderingData.cameraData.renderer;
|
||||
|
||||
cmd.SetRenderTarget(renderer.cameraColorTargetHandle, loadAction: RenderBufferLoadAction.Load, storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, settings.CapsuleAOMat, 0, MeshTopology.Triangles, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// cmd.SetRenderTarget(renderer.cameraColorTargetHandle, loadAction: RenderBufferLoadAction.Load, storeAction: RenderBufferStoreAction.Store);
|
||||
// cmd.DrawProcedural(Matrix4x4.identity, settings.CapsuleAOMat, 0, MeshTopology.Triangles, 3);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@ -387,11 +387,11 @@ Shader "XRP/CapsuleAO"
|
||||
if (IsInBounds(worldPos, c.position, c.radius*2, intensity))
|
||||
{
|
||||
float tempIntensity = intensity / saturate(1 * smoothstep(0.1, 2, c.lightDir.w));
|
||||
// float tempShadow = CalcCapsuleShadowByIndex(worldPos, _MainLightPosition.xyz, c.startID, c.endID, _ShadowSharpness, tempIntensity);
|
||||
// //float tempShadow = CalcCapsuleShadowByIndexV2(worldPos, cone, c.startID, c.endID, _ShadowSharpness, tempIntensity);
|
||||
// shadow = min(shadow, tempShadow);
|
||||
//occlusion *= CalcCapsuleOcclusionByIndex(worldPos, worldNormal, c.startID, c.endID, intensity);
|
||||
occlusion *= CalcCapsuleOcclusionByIndexV2(worldPos, worldNormal, c.startID, c.endID,cone, intensity);
|
||||
float tempShadow = CalcCapsuleShadowByIndex(worldPos, _MainLightPosition.xyz, c.startID, c.endID, _ShadowSharpness, tempIntensity);
|
||||
//float tempShadow = CalcCapsuleShadowByIndexV2(worldPos, cone, c.startID, c.endID, _ShadowSharpness, tempIntensity);
|
||||
shadow = min(shadow, tempShadow);
|
||||
occlusion *= CalcCapsuleOcclusionByIndex(worldPos, worldNormal, c.startID, c.endID, intensity);
|
||||
// occlusion *= CalcCapsuleOcclusionByIndexV2(worldPos, worldNormal, c.startID, c.endID,cone, intensity);
|
||||
}
|
||||
}
|
||||
return shadow * occlusion;
|
||||
|
||||
@ -21,6 +21,7 @@ namespace X.Rendering.Feature
|
||||
|
||||
public enum ShadowResolution
|
||||
{
|
||||
_128 = 128,
|
||||
_256 = 256,
|
||||
_512 = 512,
|
||||
_768 = 768,
|
||||
@ -38,12 +39,10 @@ namespace X.Rendering.Feature
|
||||
public SoftQuality softQuality = SoftQuality.Medium;
|
||||
public float softScaleByDistance = 1.0f;
|
||||
public float softGradientDistance = 15f;
|
||||
[Range(0.0f, 1.0f)]
|
||||
public float minSoft = 0.1f;
|
||||
[Range(0.0f, 1.0f)] public float minSoft = 0.1f;
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private Settings settings = new();
|
||||
[SerializeField] private Settings settings = new();
|
||||
PlanarShadowRenderPass pnanarShaowPass;
|
||||
|
||||
/// <inheritdoc/>
|
||||
@ -65,7 +64,10 @@ namespace X.Rendering.Feature
|
||||
private RTHandle shadowDistanceTarget;
|
||||
private RTHandle softShadowRenderTarget;
|
||||
private Settings settings;
|
||||
private ShaderTagId[] planarShadowShaderIds = new ShaderTagId[] { new ShaderTagId("PlanarShadow") , new ShaderTagId("UniversalForward") };
|
||||
|
||||
private ShaderTagId[] planarShadowShaderIds = new ShaderTagId[]
|
||||
{ new ShaderTagId("PlanarShadow"), new ShaderTagId("UniversalForward") };
|
||||
|
||||
private ProfilingSampler profiler;
|
||||
|
||||
static GlobalKeyword planarShadowKeyword;
|
||||
@ -77,6 +79,7 @@ namespace X.Rendering.Feature
|
||||
static Vector4[] mediumSoftOperator;
|
||||
static Vector4[] highSoftOperator;
|
||||
|
||||
static readonly string disableSoftShadow = "SOFT_SHADOW_OFF";
|
||||
static readonly int playerLayer = LayerMask.NameToLayer("Player");
|
||||
|
||||
public PlanarShadowRenderPass(Settings settings)
|
||||
@ -108,7 +111,8 @@ namespace X.Rendering.Feature
|
||||
Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero,
|
||||
Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero,
|
||||
Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero,
|
||||
Vector4.zero,Vector4.zero,};
|
||||
Vector4.zero, Vector4.zero,
|
||||
};
|
||||
mediumSoftOperator = new Vector4[32]
|
||||
{
|
||||
new Vector4(-0.573014f, -0.3037193f, 0.07195906f, 0f),
|
||||
@ -130,9 +134,11 @@ namespace X.Rendering.Feature
|
||||
Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero,
|
||||
Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero,
|
||||
Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero, Vector4.zero,
|
||||
Vector4.zero};
|
||||
Vector4.zero
|
||||
};
|
||||
highSoftOperator = new Vector4[32]
|
||||
{new Vector4(0.4153066f, -0.0570948f, 0.06091154f, 0f),
|
||||
{
|
||||
new Vector4(0.4153066f, -0.0570948f, 0.06091154f, 0f),
|
||||
new Vector4(0.1744031f, 0.1689546f, 0.07693625f, 0f),
|
||||
new Vector4(0.1248782f, -0.3793401f, 0.06292317f, 0f),
|
||||
new Vector4(0.377597f, -0.5691307f, 0.03405317f, 0f),
|
||||
@ -176,15 +182,18 @@ namespace X.Rendering.Feature
|
||||
|
||||
private void RecreateRenderTexture(RenderingData renderingData)
|
||||
{
|
||||
Vector2Int sourceRTSize = new Vector2Int(renderingData.cameraData.scaledWidth, renderingData.cameraData.scaledHeight);
|
||||
Vector2Int sourceRTSize = new Vector2Int(renderingData.cameraData.scaledWidth,
|
||||
renderingData.cameraData.scaledHeight);
|
||||
int shadowResolution = (int)settings.shadowResolution;
|
||||
int resolutionWidth = shadowResolution;
|
||||
int resolutionHeight = shadowResolution;
|
||||
|
||||
if (sourceRTSize.x > sourceRTSize.y)
|
||||
resolutionWidth = Mathf.RoundToInt(shadowResolution * ((float)sourceRTSize.x / (float)sourceRTSize.y));
|
||||
resolutionWidth =
|
||||
Mathf.RoundToInt(shadowResolution * ((float)sourceRTSize.x / (float)sourceRTSize.y));
|
||||
else
|
||||
resolutionHeight = Mathf.RoundToInt(shadowResolution * ((float)sourceRTSize.y / (float)sourceRTSize.x));
|
||||
resolutionHeight =
|
||||
Mathf.RoundToInt(shadowResolution * ((float)sourceRTSize.y / (float)sourceRTSize.x));
|
||||
|
||||
if (resolutionWidth == 0 || resolutionHeight == 0)
|
||||
return;
|
||||
@ -197,15 +206,25 @@ namespace X.Rendering.Feature
|
||||
shadowMapDesc.useMipMap = false;
|
||||
shadowMapDesc.autoGenerateMips = false;
|
||||
shadowMapDesc.dimension = TextureDimension.Tex2D;
|
||||
shadowMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8G8_UNorm, FormatUsage.Linear | FormatUsage.Render)
|
||||
shadowMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8G8_UNorm,
|
||||
FormatUsage.Linear | FormatUsage.Render)
|
||||
? GraphicsFormat.R8G8_UNorm
|
||||
: GraphicsFormat.B8G8R8A8_UNorm;
|
||||
|
||||
SoftQuality softQuality = settings.softQuality;
|
||||
|
||||
FilterMode filterMode = FilterMode.Point;
|
||||
if (softQuality == SoftQuality.None)
|
||||
{
|
||||
filterMode = FilterMode.Bilinear;
|
||||
shadowMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8_UNorm,
|
||||
FormatUsage.Linear | FormatUsage.Render)
|
||||
? GraphicsFormat.R8_UNorm
|
||||
: GraphicsFormat.B8G8R8A8_UNorm;
|
||||
}
|
||||
|
||||
FilterMode filterMode = softQuality == SoftQuality.None ? FilterMode.Bilinear : FilterMode.Point;
|
||||
RenderingUtils.ReAllocateIfNeeded(ref planarShadowRT, shadowMapDesc, filterMode, TextureWrapMode.Clamp, name: "_PlanarShadowMap");
|
||||
RenderingUtils.ReAllocateIfNeeded(ref planarShadowRT, shadowMapDesc, filterMode, TextureWrapMode.Clamp,
|
||||
name: "_PlanarShadowMap");
|
||||
int disMapSize = 64;
|
||||
int disMapHeight = disMapSize;
|
||||
int disMapWidth = disMapSize;
|
||||
@ -216,16 +235,22 @@ namespace X.Rendering.Feature
|
||||
disMapHeight = Mathf.RoundToInt(disMapSize * ((float)sourceRTSize.y / (float)sourceRTSize.x));
|
||||
|
||||
var distanceMapDesc = shadowMapDesc;
|
||||
distanceMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8_UNorm, FormatUsage.Linear | FormatUsage.Render)
|
||||
distanceMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8_UNorm,
|
||||
FormatUsage.Linear | FormatUsage.Render)
|
||||
? GraphicsFormat.R8_UNorm
|
||||
: GraphicsFormat.B8G8R8A8_UNorm;
|
||||
|
||||
|
||||
distanceMapDesc.width = disMapWidth;
|
||||
distanceMapDesc.height = disMapHeight;
|
||||
RenderingUtils.ReAllocateIfNeeded(ref shadowDistanceTempTarget, distanceMapDesc, FilterMode.Point, TextureWrapMode.Clamp);
|
||||
RenderingUtils.ReAllocateIfNeeded(ref shadowDistanceTarget, distanceMapDesc, FilterMode.Bilinear, TextureWrapMode.Clamp);
|
||||
RenderingUtils.ReAllocateIfNeeded(ref shadowDistanceTempTarget, distanceMapDesc, FilterMode.Point,
|
||||
TextureWrapMode.Clamp);
|
||||
RenderingUtils.ReAllocateIfNeeded(ref shadowDistanceTarget, distanceMapDesc, FilterMode.Bilinear,
|
||||
TextureWrapMode.Clamp);
|
||||
|
||||
var softMapDesc = shadowMapDesc;
|
||||
softMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8_UNorm, FormatUsage.Linear | FormatUsage.Render)
|
||||
softMapDesc.graphicsFormat = RenderingUtils.SupportsGraphicsFormat(GraphicsFormat.R8_UNorm,
|
||||
FormatUsage.Linear | FormatUsage.Render)
|
||||
? GraphicsFormat.R8_UNorm
|
||||
: GraphicsFormat.B8G8R8A8_UNorm;
|
||||
RenderingUtils.ReAllocateIfNeeded(ref softShadowRenderTarget, softMapDesc,
|
||||
@ -245,7 +270,8 @@ namespace X.Rendering.Feature
|
||||
float softScaleByDistance = settings.softScaleByDistance;
|
||||
float softGradientDistance = settings.softGradientDistance;
|
||||
float minSoft = settings.minSoft;
|
||||
var rendererListDesc = new RendererListDesc(planarShadowShaderIds, renderingData.cullResults, cameraData.camera)
|
||||
var rendererListDesc =
|
||||
new RendererListDesc(planarShadowShaderIds, renderingData.cullResults, cameraData.camera)
|
||||
{
|
||||
renderQueueRange = RenderQueueRange.all,
|
||||
sortingCriteria = SortingCriteria.OptimizeStateChanges,
|
||||
@ -262,19 +288,28 @@ namespace X.Rendering.Feature
|
||||
cmd.SetGlobalVector("_PlanarShadowCastPlane", shadowCasterPlane);
|
||||
cmd.SetGlobalFloat("_MinSoft", Mathf.Clamp01(minSoft));
|
||||
cmd.SetGlobalFloat("_PlanarShadowMaxSoftDistance", softGradientDistance);
|
||||
cmd.SetViewProjectionMatrices(cameraData.camera.worldToCameraMatrix, cameraData.camera.projectionMatrix);
|
||||
cmd.SetRenderTarget(planarShadowRT, loadAction: RenderBufferLoadAction.DontCare, storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.SetViewProjectionMatrices(cameraData.camera.worldToCameraMatrix,
|
||||
cameraData.camera.projectionMatrix);
|
||||
cmd.SetRenderTarget(planarShadowRT, loadAction: RenderBufferLoadAction.DontCare,
|
||||
storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.ClearRenderTarget(false, true, Color.clear);
|
||||
if (softQuality == SoftQuality.None)
|
||||
{
|
||||
cmd.EnableShaderKeyword(disableSoftShadow);
|
||||
}
|
||||
|
||||
cmd.DrawRendererList(rendererList);
|
||||
cmd.EndSample("PlanarShadow");
|
||||
|
||||
if (softQuality != SoftQuality.None)
|
||||
{
|
||||
cmd.BeginSample("BlurShadow");
|
||||
VisibleLight mainLight = renderingData.lightData.visibleLights[renderingData.lightData.mainLightIndex];
|
||||
VisibleLight mainLight =
|
||||
renderingData.lightData.visibleLights[renderingData.lightData.mainLightIndex];
|
||||
Vector3 lightDirection = -mainLight.localToWorldMatrix.GetColumn(2);
|
||||
lightDirection.y = 0;
|
||||
Vector3 pixelOffset = cameraData.camera.WorldToScreenPoint(Vector3.zero) - cameraData.camera.WorldToScreenPoint(lightDirection);
|
||||
Vector3 pixelOffset = cameraData.camera.WorldToScreenPoint(Vector3.zero) -
|
||||
cameraData.camera.WorldToScreenPoint(lightDirection);
|
||||
pixelOffset.z = 0;
|
||||
pixelOffset = pixelOffset.normalized;
|
||||
Vector4 shadowScreenVDir = new Vector4(pixelOffset.x, pixelOffset.y, 0, 0);
|
||||
@ -283,12 +318,15 @@ namespace X.Rendering.Feature
|
||||
int disMapHeight = shadowDistanceTempTarget.rt.height;
|
||||
cmd.SetGlobalVector("_ShadowScreenHDir", shadowScreenHDir);
|
||||
cmd.SetGlobalVector("_ShadowScreenVDir", shadowScreenVDir);
|
||||
cmd.SetGlobalVector("_EdgeMapTexelSize", new Vector4(1.0f / disMapWidth, 1.0f / disMapHeight, disMapWidth, disMapHeight));
|
||||
cmd.SetGlobalVector("_EdgeMapTexelSize",
|
||||
new Vector4(1.0f / disMapWidth, 1.0f / disMapHeight, disMapWidth, disMapHeight));
|
||||
cmd.SetGlobalTexture("_SourceTex", planarShadowRT);
|
||||
cmd.SetRenderTarget(shadowDistanceTempTarget, loadAction: RenderBufferLoadAction.DontCare, storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.SetRenderTarget(shadowDistanceTempTarget, loadAction: RenderBufferLoadAction.DontCare,
|
||||
storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, settings.PlanarShadowMat, 1, MeshTopology.Triangles, 3);
|
||||
cmd.SetGlobalTexture("_SourceTex", shadowDistanceTempTarget);
|
||||
cmd.SetRenderTarget(shadowDistanceTarget, loadAction: RenderBufferLoadAction.DontCare, storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.SetRenderTarget(shadowDistanceTarget, loadAction: RenderBufferLoadAction.DontCare,
|
||||
storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, settings.PlanarShadowMat, 0, MeshTopology.Triangles, 3);
|
||||
|
||||
Vector4[] possionOperator = lowSoftOperator;
|
||||
@ -310,19 +348,25 @@ namespace X.Rendering.Feature
|
||||
cmd.SetGlobalTexture("_DistanceTex", shadowDistanceTarget);
|
||||
cmd.SetGlobalVectorArray(Shader.PropertyToID("_PossionOperator"), possionOperator);
|
||||
cmd.SetGlobalTexture("_SourceTex", planarShadowRT);
|
||||
cmd.SetRenderTarget(softShadowRenderTarget, loadAction: RenderBufferLoadAction.DontCare, storeAction: RenderBufferStoreAction.Store);
|
||||
cmd.SetRenderTarget(softShadowRenderTarget, loadAction: RenderBufferLoadAction.DontCare,
|
||||
storeAction: RenderBufferStoreAction.Store);
|
||||
|
||||
cmd.DisableShaderKeyword(disableSoftShadow);
|
||||
cmd.DrawProcedural(Matrix4x4.identity, settings.PlanarShadowMat, 2, MeshTopology.Triangles, 3);
|
||||
cmd.EndSample("BlurShadow");
|
||||
}
|
||||
|
||||
|
||||
cmd.EnableKeyword(planarShadowKeyword);
|
||||
cmd.SetGlobalColor("_PlanarShadowColor", settings.planarShadowColor);
|
||||
cmd.SetGlobalTexture("_PlanarShadowMap", softQuality == SoftQuality.None ? planarShadowRT : softShadowRenderTarget);
|
||||
cmd.SetGlobalTexture("_PlanarShadowMap",
|
||||
softQuality == SoftQuality.None ? planarShadowRT : softShadowRenderTarget);
|
||||
}
|
||||
|
||||
public override void OnFinishCameraStackRendering(CommandBuffer cmd)
|
||||
{
|
||||
cmd.DisableKeyword(planarShadowKeyword);
|
||||
cmd.DisableShaderKeyword(disableSoftShadow);
|
||||
base.OnFinishCameraStackRendering(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,6 +140,7 @@ Shader "XRP/PlanarShadow"
|
||||
#pragma multi_compile_instancing
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
#pragma shader_feature_local TRANSPARENT_SHADOW_CASTER
|
||||
#pragma multi_compile_fragment _ SOFT_SHADOW_OFF
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
@ -208,7 +209,11 @@ Shader "XRP/PlanarShadow"
|
||||
#else
|
||||
float4 col = 1;
|
||||
#endif
|
||||
#ifdef SOFT_SHADOW_OFF
|
||||
return half4(col.a, 0,0, 0);
|
||||
#else
|
||||
return half4(i.softValue,col.a,0, 0);
|
||||
#endif
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
|
||||
@ -1,118 +1,118 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
namespace X.Rendering.Feature
|
||||
{
|
||||
public class XRenderFeatureManager : MonoBehaviour
|
||||
{
|
||||
public static XRenderFeatureManager Instance
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
//using System.Collections.Generic;
|
||||
//using Unity.Collections;
|
||||
//using UnityEngine;
|
||||
//namespace X.Rendering.Feature
|
||||
//{
|
||||
// public class XRenderFeatureManager : MonoBehaviour
|
||||
// {
|
||||
// public static XRenderFeatureManager Instance
|
||||
// {
|
||||
// get; private set;
|
||||
// }
|
||||
|
||||
#region CapsuleAO
|
||||
public NativeArray<Character> CharacterArray;
|
||||
public NativeArray<Capsule> CapsuleArray;
|
||||
// #region CapsuleAO
|
||||
// public NativeArray<Character> CharacterArray;
|
||||
// public NativeArray<Capsule> CapsuleArray;
|
||||
|
||||
public Transform TestLightTrans;
|
||||
public Transform TestCharacterTrans;
|
||||
public float TestW;
|
||||
// public Transform TestLightTrans;
|
||||
// public Transform TestCharacterTrans;
|
||||
// public float TestW;
|
||||
|
||||
private Dictionary<Transform, CapsuleCollider[]> characterTransform2CapsuleCollider = new();
|
||||
private int capsuleColliderCount = 0;
|
||||
// private Dictionary<Transform, CapsuleCollider[]> characterTransform2CapsuleCollider = new();
|
||||
// private int capsuleColliderCount = 0;
|
||||
|
||||
public void AddCapsuleAOCharacter(Transform transform)
|
||||
{
|
||||
var oldCapsuleArray = CapsuleArray;
|
||||
var oldCharacterArray = CharacterArray;
|
||||
// public void AddCapsuleAOCharacter(Transform transform)
|
||||
// {
|
||||
// var oldCapsuleArray = CapsuleArray;
|
||||
// var oldCharacterArray = CharacterArray;
|
||||
|
||||
var capsules = transform.GetComponentsInChildren<CapsuleCollider>(true);
|
||||
characterTransform2CapsuleCollider.Add(transform, capsules);
|
||||
capsuleColliderCount += capsules.Length;
|
||||
CapsuleArray = new (capsuleColliderCount, Allocator.Persistent);
|
||||
CharacterArray = new (characterTransform2CapsuleCollider.Count, Allocator.Persistent);
|
||||
// var capsules = transform.GetComponentsInChildren<CapsuleCollider>(true);
|
||||
// characterTransform2CapsuleCollider.Add(transform, capsules);
|
||||
// capsuleColliderCount += capsules.Length;
|
||||
// CapsuleArray = new (capsuleColliderCount, Allocator.Persistent);
|
||||
// CharacterArray = new (characterTransform2CapsuleCollider.Count, Allocator.Persistent);
|
||||
|
||||
if (oldCharacterArray.IsCreated)
|
||||
{
|
||||
oldCharacterArray.Dispose();
|
||||
oldCapsuleArray.Dispose();
|
||||
}
|
||||
}
|
||||
// if (oldCharacterArray.IsCreated)
|
||||
// {
|
||||
// oldCharacterArray.Dispose();
|
||||
// oldCapsuleArray.Dispose();
|
||||
// }
|
||||
// }
|
||||
|
||||
public void RemoveCapsuleAOCharacter(Transform transform)
|
||||
{
|
||||
capsuleColliderCount -= characterTransform2CapsuleCollider[transform].Length;
|
||||
characterTransform2CapsuleCollider.Remove(transform);
|
||||
var oldCapsuleArray = CapsuleArray;
|
||||
var oldCharacterArray = CharacterArray;
|
||||
// public void RemoveCapsuleAOCharacter(Transform transform)
|
||||
// {
|
||||
// capsuleColliderCount -= characterTransform2CapsuleCollider[transform].Length;
|
||||
// characterTransform2CapsuleCollider.Remove(transform);
|
||||
// var oldCapsuleArray = CapsuleArray;
|
||||
// var oldCharacterArray = CharacterArray;
|
||||
|
||||
CapsuleArray = new(capsuleColliderCount, Allocator.Persistent);
|
||||
CharacterArray = new(characterTransform2CapsuleCollider.Count, Allocator.Persistent);
|
||||
// CapsuleArray = new(capsuleColliderCount, Allocator.Persistent);
|
||||
// CharacterArray = new(characterTransform2CapsuleCollider.Count, Allocator.Persistent);
|
||||
|
||||
if (oldCharacterArray.IsCreated)
|
||||
{
|
||||
oldCharacterArray.Dispose();
|
||||
oldCapsuleArray.Dispose();
|
||||
}
|
||||
}
|
||||
// if (oldCharacterArray.IsCreated)
|
||||
// {
|
||||
// oldCharacterArray.Dispose();
|
||||
// oldCapsuleArray.Dispose();
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
// #endregion
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
// private void Awake()
|
||||
// {
|
||||
// Instance = this;
|
||||
// }
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
AddCapsuleAOCharacter(TestCharacterTrans);
|
||||
}
|
||||
// private void Start()
|
||||
// {
|
||||
// AddCapsuleAOCharacter(TestCharacterTrans);
|
||||
// }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Transform transform = null;
|
||||
int capsuleArrayIndex = 0;
|
||||
int characterArrayIndex = 0;
|
||||
int startID = 0;
|
||||
Instance = this;
|
||||
// private void Update()
|
||||
// {
|
||||
// Transform transform = null;
|
||||
// int capsuleArrayIndex = 0;
|
||||
// int characterArrayIndex = 0;
|
||||
// int startID = 0;
|
||||
// Instance = this;
|
||||
|
||||
foreach (var item in characterTransform2CapsuleCollider)
|
||||
{
|
||||
for (int i = 0; i < item.Value.Length; i++)
|
||||
{
|
||||
var capsule = item.Value[i];
|
||||
//capsule.direction
|
||||
var a = capsule.center - new Vector3(0, capsule.height / 2 - capsule.radius, 0);
|
||||
var b = capsule.center + new Vector3(0, capsule.height / 2 - capsule.radius, 0);
|
||||
//var a = capsule.center - new Vector3(0, capsule.height / 2, 0);
|
||||
//var b = capsule.center + new Vector3(0, capsule.height / 2, 0);
|
||||
a = capsule.transform.TransformPoint(a);
|
||||
b = capsule.transform.TransformPoint(b);
|
||||
CapsuleArray[capsuleArrayIndex++] = new()
|
||||
{
|
||||
a = a,
|
||||
b = b,
|
||||
radius = capsule.radius,
|
||||
};
|
||||
}
|
||||
// foreach (var item in characterTransform2CapsuleCollider)
|
||||
// {
|
||||
// for (int i = 0; i < item.Value.Length; i++)
|
||||
// {
|
||||
// var capsule = item.Value[i];
|
||||
// //capsule.direction
|
||||
// var a = capsule.center - new Vector3(0, capsule.height / 2 - capsule.radius, 0);
|
||||
// var b = capsule.center + new Vector3(0, capsule.height / 2 - capsule.radius, 0);
|
||||
// //var a = capsule.center - new Vector3(0, capsule.height / 2, 0);
|
||||
// //var b = capsule.center + new Vector3(0, capsule.height / 2, 0);
|
||||
// a = capsule.transform.TransformPoint(a);
|
||||
// b = capsule.transform.TransformPoint(b);
|
||||
// CapsuleArray[capsuleArrayIndex++] = new()
|
||||
// {
|
||||
// a = a,
|
||||
// b = b,
|
||||
// radius = capsule.radius,
|
||||
// };
|
||||
// }
|
||||
|
||||
if (transform != item.Key)
|
||||
{
|
||||
transform = item.Key;
|
||||
CharacterArray[characterArrayIndex++] = new()
|
||||
{
|
||||
position = transform.position,
|
||||
radius = transform.lossyScale.x,
|
||||
lightDir = -new Vector4(TestLightTrans.position.x, TestLightTrans.position.y, TestLightTrans.position.z, -TestW),
|
||||
startID = startID,
|
||||
endID = capsuleArrayIndex,
|
||||
};
|
||||
startID = capsuleArrayIndex;
|
||||
}
|
||||
// if (transform != item.Key)
|
||||
// {
|
||||
// transform = item.Key;
|
||||
// CharacterArray[characterArrayIndex++] = new()
|
||||
// {
|
||||
// position = transform.position,
|
||||
// radius = transform.lossyScale.x,
|
||||
// lightDir = -new Vector4(TestLightTrans.position.x, TestLightTrans.position.y, TestLightTrans.position.z, -TestW),
|
||||
// startID = startID,
|
||||
// endID = capsuleArrayIndex,
|
||||
// };
|
||||
// startID = capsuleArrayIndex;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
279
Packages/com.unity.render-pipelines.universal@14.0.11/ShaderLibrary/CapsuleShadow.hlsl
vendored
Normal file
279
Packages/com.unity.render-pipelines.universal@14.0.11/ShaderLibrary/CapsuleShadow.hlsl
vendored
Normal file
@ -0,0 +1,279 @@
|
||||
#ifndef CAPSULE_SHADOW_INCLUDED
|
||||
#define CAPSULE_SHADOW_INCLUDED
|
||||
#pragma multi_compile_fragment _ _MultiCapsule_Shadow_AO_ON
|
||||
#pragma multi_compile_fragment _ _MultiCapsule_AO_ON
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
struct Capsule
|
||||
{
|
||||
half3 a, b;
|
||||
half radius;
|
||||
};
|
||||
|
||||
struct Character
|
||||
{
|
||||
half3 position;
|
||||
half radius;
|
||||
int capsuleStartID, capsuleEndID;
|
||||
uint capsuleAOSettingMask;
|
||||
};
|
||||
|
||||
struct CapsuleShadowArea
|
||||
{
|
||||
half AmbientIntensity;
|
||||
half ConeAngle;
|
||||
half ShadowIntensity;
|
||||
half ShadowSharpness;
|
||||
int lightStartID, lightEndID;
|
||||
};
|
||||
|
||||
StructuredBuffer<Capsule> _CapsuleData;
|
||||
uint _CapsulesCount;
|
||||
StructuredBuffer<Character> _CharacterData;
|
||||
uint _CharactersCount;
|
||||
|
||||
StructuredBuffer<CapsuleShadowArea> _CapsuleShadowData;
|
||||
uint _CapsuleShadowDataCount;
|
||||
|
||||
half4 _CapsuleLightsDir[32];
|
||||
uint _CapsuleLightsCount;
|
||||
|
||||
float CalcCapsuleShadowByIndex(float3 ro, float3 rd, uint s, uint e, in float k, float intensity, float intensity1)
|
||||
{
|
||||
float shadow = 1.0;
|
||||
for (uint i = s; i < e; ++i)
|
||||
{
|
||||
Capsule c = _CapsuleData[i];
|
||||
float3 a = c.a;
|
||||
float3 b = c.b;
|
||||
float r = c.radius;
|
||||
float3 ba = b - a;
|
||||
float3 oa = ro - a;
|
||||
|
||||
float oad = dot(oa, rd);
|
||||
float dba = dot(rd, ba);
|
||||
float baba = dot(ba, ba);
|
||||
float oaba = dot(oa, ba);
|
||||
float2 th = float2(-oad * baba + dba * oaba, oaba - oad * dba) / (baba - dba * dba);
|
||||
|
||||
th.x = max(th.x, 0.0001);
|
||||
th.y = saturate(th.y);
|
||||
|
||||
//线段ab上离射线最近的点p
|
||||
float3 p = a + ba * th.y;
|
||||
//射线rord 找到距离线段 ab 最近的点q
|
||||
float3 q = ro + rd * th.x;
|
||||
//沿着光的方向发射射线, 射线离胶囊体最短的距离
|
||||
float d = length(p - q) - r;
|
||||
|
||||
float s = saturate(k * d / th.x + 0.3);
|
||||
s = s * s * (3.0 - 2.0 * s);
|
||||
shadow *= s;
|
||||
}
|
||||
|
||||
shadow = saturate(lerp(1, shadow, intensity));
|
||||
return saturate(lerp(1, shadow, intensity1));
|
||||
}
|
||||
|
||||
float CalcCapsuleOcclusionByIndex(float3 p, float3 n, uint s, uint e, float intensity, float intensity1)
|
||||
{
|
||||
float ao = 1.0;
|
||||
for (uint i = s; i < e; ++i)
|
||||
{
|
||||
Capsule capsule = _CapsuleData[i];
|
||||
float3 a = capsule.a;
|
||||
float3 b = capsule.b;
|
||||
float r = capsule.radius;
|
||||
float3 ba = b - a;
|
||||
float3 pa = p - a;
|
||||
float h = saturate(dot(pa, ba) / dot(ba, ba));
|
||||
// 地面点 p 到 ab 最近点 x, 向量 xp = d
|
||||
float3 d = pa - h * ba;
|
||||
float l = length(d);
|
||||
float nl = dot(-d, n);
|
||||
float o = 1.0 - max(0.0, nl) * r * r / (l * l * l);
|
||||
// multiplier o *= 1.0 + r*(l-r)/(l*l);
|
||||
o = sqrt(o * o * o);
|
||||
ao *= o;
|
||||
}
|
||||
|
||||
ao = saturate(lerp(1, ao, intensity));
|
||||
return clamp(lerp(1, ao, intensity1), 0.6, 1);
|
||||
}
|
||||
|
||||
#define sq(x) (x * x)
|
||||
float acosFast(float x)
|
||||
{
|
||||
// Lagarde 2014, "Inverse trigonometric functions GPU optimization for AMD GCN architecture"
|
||||
// This is the approximation of degree 1, with a max absolute error of 9.0x10^-3
|
||||
float y = abs(x);
|
||||
float p = -0.1565827 * y + 1.570796;
|
||||
p *= sqrt(1.0 - y);
|
||||
return x >= 0.0 ? p : PI - p;
|
||||
}
|
||||
|
||||
float acosFastPositive(float x)
|
||||
{
|
||||
// Lagarde 2014, "Inverse trigonometric functions GPU optimization for AMD GCN architecture"
|
||||
float p = -0.1565827 * x + 1.570796;
|
||||
return p * sqrt(1.0 - x);
|
||||
}
|
||||
|
||||
/*
|
||||
ref: https://developer.amd.com/wordpress/media/2012/10/Oat-AmbientApetureLighting.pdf
|
||||
Approximate the area of intersection of two spherical caps.
|
||||
|
||||
With some modifcations proposed by the shadertoy implementation
|
||||
*/
|
||||
float SphericalCapsIntersectionAreaFast(float cosCap1, float cosCap2, float cap2, float cosDistance)
|
||||
{
|
||||
// Precompute constants
|
||||
float radius1 = acosFastPositive(cosCap1); // First caps radius (arc length in radians)
|
||||
float radius2 = cap2; // Second caps radius (in radians)
|
||||
float dist = acosFast(cosDistance); // Distance between caps (radians between centers of caps)
|
||||
|
||||
// Conditional expressions instead of if-else
|
||||
float check1 = min(radius1, radius2) <= max(radius1, radius2) - dist;
|
||||
float check2 = radius1 + radius2 <= dist;
|
||||
|
||||
// Ternary operator to replace if-else
|
||||
float result = check1 ? (1.0 - max(cosCap1, cosCap2)) : (check2 ? 0.0 : 1.0 - max(cosCap1, cosCap2));
|
||||
|
||||
float delta = abs(radius1 - radius2);
|
||||
float x = 1.0 - saturate((dist - delta) / max(radius1 + radius2 - delta, FLT_EPS));
|
||||
|
||||
// simplified smoothstep()
|
||||
float area = sq(x) * (-2.0 * x + 3.0);
|
||||
|
||||
// Multiply by (1.0 - max(cosCap1, cosCap2)) only once
|
||||
return area * result;
|
||||
}
|
||||
|
||||
float DirectionalOcclusionSphere(float3 rayPosition, float3 spherePosition, float sphereRadius, float4 coneProperties)
|
||||
{
|
||||
float3 occluderPosition = spherePosition.xyz - rayPosition;
|
||||
float occluderLength2 = dot(occluderPosition, occluderPosition);
|
||||
float3 occluderDir = occluderPosition * rsqrt(occluderLength2);
|
||||
|
||||
float cosPhi = dot(occluderDir, coneProperties.xyz);
|
||||
// sq(sphere.w) should be a uniform --> capsuleRadius^2
|
||||
float cosTheta = sqrt(occluderLength2 / (sq(sphereRadius) + occluderLength2));
|
||||
float cosCone = cos(coneProperties.w);
|
||||
|
||||
return 1.0 - SphericalCapsIntersectionAreaFast(cosTheta, cosCone, coneProperties.w, cosPhi) / (1.0 - cosCone);
|
||||
}
|
||||
|
||||
float DirectionalOcclusionCapsule(float3 rayPosition, float3 capsuleA, float3 capsuleB, float capsuleRadius, float4 coneProperties)
|
||||
{
|
||||
float3 Ld = capsuleB - capsuleA;
|
||||
float3 L0 = capsuleA - rayPosition;
|
||||
float a = dot(coneProperties.xyz, Ld);
|
||||
float t = saturate(dot(L0, a * coneProperties.xyz - Ld) / (dot(Ld, Ld) - a * a));
|
||||
float3 positionToRay = capsuleA + t * Ld;
|
||||
|
||||
return DirectionalOcclusionSphere(rayPosition, positionToRay, capsuleRadius, coneProperties);
|
||||
}
|
||||
|
||||
float CalcCapsuleShadowByIndexV2(float3 ro, float4 cone, uint s, uint e, float intensity, float intensity1)
|
||||
{
|
||||
float shadow = 1.0;
|
||||
for (uint i = s; i < e; ++i)
|
||||
{
|
||||
Capsule c = _CapsuleData[i];
|
||||
shadow*= DirectionalOcclusionCapsule(ro, c.a, c.b, c.radius, cone);
|
||||
}
|
||||
shadow = saturate(lerp(1, shadow, intensity));
|
||||
return saturate(lerp(1, shadow, intensity1));
|
||||
}
|
||||
float CalcSphereOcclusion2(in float3 pos, in float3 nor, in float4 sph)
|
||||
{
|
||||
float3 di = sph.xyz - pos;
|
||||
float l = length(di);
|
||||
float rad = sph.w;
|
||||
float nl = max(0.0, dot(nor, di / l));
|
||||
return (1.0 - nl * rad * rad / (l * l ));
|
||||
|
||||
// float3 di = (sph.xyz - pos) / sph.w;
|
||||
// float sqL = dot(di, di);
|
||||
// return clamp(1.0 - dot(nor, di) * rsqrt(sqL * sqL * sqL), 0.1, 1);
|
||||
}
|
||||
float CalcCapsuleOcclusionByIndexV2(float3 p, float3 n, uint s, uint e, float intensity, float intensity1)
|
||||
{
|
||||
float ao = 1.0;
|
||||
for (uint i = s; i < e; ++i)
|
||||
{
|
||||
Capsule capsule = _CapsuleData[i];
|
||||
float3 ba = capsule.b - capsule.a;
|
||||
float3 pa = p - capsule.a;
|
||||
float l = dot(ba, ba);
|
||||
// p 在 ba 上投影长度与 ba 长度比值
|
||||
float t = /* abs(l) < 1e-8f ? 0.0 : */ saturate(dot(pa, ba) / l);
|
||||
float3 positionToRay = capsule.a + t * ba;
|
||||
ao *= CalcSphereOcclusion2(p, n, float4(positionToRay, capsule.radius));
|
||||
}
|
||||
ao = saturate(lerp(1, ao, intensity));
|
||||
return saturate(lerp(1, ao, intensity1));
|
||||
}
|
||||
|
||||
bool IsInBounds(float3 p, float3 c, float b, out float intensity)
|
||||
{
|
||||
float3 diff = abs(p - c);
|
||||
if (diff.x < b && diff.y < b && diff.z < b)
|
||||
{
|
||||
intensity = saturate(dot(b, b) / dot(diff.xz, diff.xz));
|
||||
return true;
|
||||
}
|
||||
intensity = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
float4 GetConeProperties(float3 lightDir, float coneAngle)
|
||||
{
|
||||
float4 cone = float4(lightDir.xyz, radians(coneAngle) * 0.5);
|
||||
cone.xyz = normalize(cone.xyz);
|
||||
return cone;
|
||||
}
|
||||
|
||||
float CalcCapsuleShadow(float3 worldPos, float3 worldNormal)
|
||||
{
|
||||
float shadow = 1.0;
|
||||
float occlusion = 1.0;
|
||||
#if _MultiCapsule_Shadow_AO_ON || _MultiCapsule_AO_ON
|
||||
for (uint i = 0; i < _CharactersCount; ++i)
|
||||
{
|
||||
float intensity = 1;
|
||||
Character c = _CharacterData[i];
|
||||
if (IsInBounds(worldPos, c.position, c.radius * 3, intensity))
|
||||
{
|
||||
|
||||
#ifdef _MultiCapsule_Shadow_AO_ON
|
||||
uint mask = c.capsuleAOSettingMask;
|
||||
uint areaCnt = countbits(mask);
|
||||
for (uint a = 0; a < areaCnt; ++a)
|
||||
{
|
||||
uint index = firstbitlow(mask);
|
||||
mask ^= 1 << index;
|
||||
CapsuleShadowArea area = _CapsuleShadowData[index];
|
||||
for (uint b = area.lightStartID; b < area.lightEndID; ++b)
|
||||
{
|
||||
float4 lightDir = _CapsuleLightsDir[a];
|
||||
float4 cone = GetConeProperties(lightDir.xyz, area.ConeAngle);
|
||||
float tempIntensity = intensity / saturate(1 * smoothstep(0.1, 2, lightDir.w));
|
||||
float tempShadow = CalcCapsuleShadowByIndex(worldPos, cone.xyz, c.capsuleStartID, c.capsuleEndID, area.ShadowSharpness, tempIntensity, area.ShadowIntensity);
|
||||
// float tempShadow = CalcCapsuleShadowByIndexV2(worldPos, cone, c.capsuleStartID, c.capsuleEndID, tempIntensity, area.ShadowIntensity);
|
||||
shadow = min(shadow, tempShadow);
|
||||
}
|
||||
}
|
||||
//occlusion *= CalcCapsuleOcclusionByIndex(worldPos, worldNormal, c.capsuleStartID, c.capsuleEndID, intensity, _CapsuleShadowData[0].AmbientIntensity);
|
||||
//occlusion *= CalcCapsuleOcclusionByIndexV2(worldPos, worldNormal, c.capsuleStartID, c.capsuleEndID, intensity, _CapsuleShadowData[0].AmbientIntensity);
|
||||
#elif defined(_MultiCapsule_AO_ON)
|
||||
// occlusion *= CalcCapsuleOcclusionByIndex(worldPos, worldNormal, c.capsuleStartID, c.capsuleEndID, intensity, _CapsuleShadowData[0].AmbientIntensity);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return shadow * occlusion;
|
||||
}
|
||||
#endif
|
||||
3
Packages/com.unity.render-pipelines.universal@14.0.11/ShaderLibrary/CapsuleShadow.hlsl.meta
vendored
Normal file
3
Packages/com.unity.render-pipelines.universal@14.0.11/ShaderLibrary/CapsuleShadow.hlsl.meta
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 42783c425ffd49be8cede19a6a9539a1
|
||||
timeCreated: 1757934640
|
||||
@ -169,8 +169,10 @@ Shader "Universal Render Pipeline/Lit"
|
||||
#pragma instancing_options renderinglayer
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
|
||||
|
||||
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/CapsuleShadow.hlsl"
|
||||
|
||||
#pragma multi_compile_vertex _ ENABLE_VS_SKINNING
|
||||
// #pragma enable_d3d11_debug_symbols
|
||||
#pragma enable_d3d11_debug_symbols
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/Shaders/LitForwardPass.hlsl"
|
||||
|
||||
@ -226,6 +228,12 @@ Shader "Universal Render Pipeline/Lit"
|
||||
surfaceData.clearCoatMask, specularHighlightsOff);
|
||||
// * (step(0.01, 1 - mainLight.shadowAttenuation) /* * step( 1 - mainLight.shadowAttenuation, 0.3) */?
|
||||
// lerp(0, half3(0.5, 0, 0) * (1 - mainLight.shadowAttenuation), mainLight.shadowAttenuation) * 0 : 1);
|
||||
|
||||
|
||||
float ao = CalcCapsuleShadow(inputData.positionWS.xyz, inputData.normalWS);
|
||||
// ao = lerp(ao, 1, step(0.5, mainLight.shadowAttenuation));
|
||||
lightingData.mainLightColor *= ao;
|
||||
|
||||
#ifdef _ShadowRemapON
|
||||
half4 remapValue = tex2D(_ShadowRemap, float3(mainLight.shadowAttenuation, 0, 0));
|
||||
lightingData.mainLightColor *= remapValue.rgb * remapValue.a;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.shaunfong.bonevisualizer": "https://github.com/Shaun-Fong/UnityBoneVisualizer.git",
|
||||
"com.unity.burst": "1.8.19",
|
||||
"com.unity.cinemachine": "2.10.3",
|
||||
"com.unity.collab-proxy": "2.7.1",
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.shaunfong.bonevisualizer": {
|
||||
"version": "https://github.com/Shaun-Fong/UnityBoneVisualizer.git",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "0fd18b0f977325bc7b45155848eba3935d717568"
|
||||
},
|
||||
"com.unity.burst": {
|
||||
"version": "1.8.19",
|
||||
"depth": 0,
|
||||
@ -106,11 +113,11 @@
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.editorcoroutines": "1.0.0",
|
||||
"com.unity.burst": "1.8.0",
|
||||
"com.unity.collections": "1.2.3",
|
||||
"com.unity.mathematics": "1.2.1",
|
||||
"com.unity.burst": "1.8.0",
|
||||
"com.unity.profiling.core": "1.0.0"
|
||||
"com.unity.profiling.core": "1.0.0",
|
||||
"com.unity.editorcoroutines": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
@ -190,9 +197,9 @@
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.settings-manager": "1.0.3",
|
||||
"com.unity.mathematics": "1.2.1",
|
||||
"com.unity.modules.imgui": "1.0.0"
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.settings-manager": "1.0.3"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
@ -221,9 +228,9 @@
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.director": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user