Update custom pass to global custom pass

This commit is contained in:
Misaki
2024-10-23 20:15:07 +09:00
parent e441bb7911
commit d0554a73bb
64 changed files with 949 additions and 46128 deletions

View File

@@ -1,12 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine.Rendering;
using UnityEngine.Experimental.Rendering;
using UnityObject = UnityEngine.Object;
using System.Linq;
#if HDRP_IS_INSTALLED_FOR_UTS
@@ -36,7 +32,7 @@ namespace Unity.Rendering.HighDefinition.Toon
internal HDAdditionalLightData m_targetBoxLight;
[SerializeField]
internal bool m_FollowGameObjectPosition = false;
internal bool m_FollowGameObjectPosition = false;
[SerializeField]
internal bool m_FollowGameObjectRotation = false;
@@ -106,18 +102,19 @@ namespace Unity.Rendering.HighDefinition.Toon
return;
}
for (int ii = 0; ii < m_Renderers.Length; ii++)
// TODO: Set rendering layer mask when property changed.
for (var ii = 0; ii < m_Renderers.Length; ii++)
{
m_Renderers[ii].renderingLayerMask &= 0xffffff00;
m_Renderers[ii].renderingLayerMask |= (uint)m_targetBoxLight.lightlayersMask;
}
if ( /* m_targetBoxLight != null && */ m_GameObjects != null && m_GameObjects.Length > 0 && m_GameObjects[0] != null )
if ( /* m_targetBoxLight != null && */ m_GameObjects != null && m_GameObjects.Length > 0 && m_GameObjects[0] != null)
{
if (m_FollowGameObjectPosition )
if (m_FollowGameObjectPosition)
{
m_targetBoxLight.transform.position = m_GameObjects[0].transform.position + m_PositionOffset;
}
if (m_FollowGameObjectRotation )
if (m_FollowGameObjectRotation)
{
m_targetBoxLight.transform.rotation = m_GameObjects[0].transform.rotation * m_RotationOffset;
}
@@ -163,22 +160,22 @@ namespace Unity.Rendering.HighDefinition.Toon
}
internal static GameObject CreateBoxLight(GameObject[] gameObjects)
internal static GameObject CreateBoxLight(GameObject[] gameObjects)
{
if (gameObjects == null || gameObjects[0] == null )
if (gameObjects == null || gameObjects[0] == null)
{
Debug.LogError("Please, select a GameObject you want a Box Light to follow.");
return null;
}
var gameObjectName = "Box Light for " + gameObjects[0].name;
GameObject lightGameObject = new GameObject(gameObjectName);
var lightGameObject = new GameObject(gameObjectName);
#if UNITY_EDITOR
Undo.RegisterCreatedObjectUndo(lightGameObject, "Created Boxlight adjustment");
#endif
HDAdditionalLightData hdLightData = lightGameObject.AddHDLight(HDLightTypeAndShape.BoxSpot);
var hdLightData = lightGameObject.AddHDLight(LightType.Box);
// light size
hdLightData.SetBoxSpotSize(new Vector2(10.0f, 10.0f)); // Size should be culculated with more acculacy?
BoxLightAdjustment boxLightAdjustment = lightGameObject.GetComponent<BoxLightAdjustment>();
var boxLightAdjustment = lightGameObject.GetComponent<BoxLightAdjustment>();
if (boxLightAdjustment == null)
{
#if UNITY_EDITOR
@@ -229,17 +226,17 @@ namespace Unity.Rendering.HighDefinition.Toon
if (EditorApplication.isCompiling)
return;
#endif
if (m_GameObjects == null )
if (m_GameObjects == null)
{
return;
}
int objCount = m_GameObjects.Length;
int rendererCount = 0;
var objCount = m_GameObjects.Length;
var rendererCount = 0;
List<Renderer> rendererList = new List<Renderer>();
for (int ii = 0; ii < objCount; ii++)
var rendererList = new List<Renderer>();
for (var ii = 0; ii < objCount; ii++)
{
if (m_GameObjects[ii] == null )
if (m_GameObjects[ii] == null)
{
continue;
}
@@ -251,20 +248,20 @@ namespace Unity.Rendering.HighDefinition.Toon
rendererCount++;
rendererList.Add(renderer);
}
GameObject[] childGameObjects = m_GameObjects[ii].GetComponentsInChildren<Transform>().Select(t => t.gameObject).ToArray();
int childCount = childGameObjects.Length;
for (int jj = 0; jj < childCount; jj++)
var childGameObjects = m_GameObjects[ii].GetComponentsInChildren<Transform>().Select(t => t.gameObject).ToArray();
var childCount = childGameObjects.Length;
for (var jj = 0; jj < childCount; jj++)
{
if (m_GameObjects[ii] == childGameObjects[jj])
continue;
var modelToonEvAdjustment = childGameObjects[jj].GetComponent<BoxLightAdjustment>();
if ( modelToonEvAdjustment != null )
if (modelToonEvAdjustment != null)
{
break;
}
renderer = childGameObjects[jj].GetComponent<Renderer>();
if ( renderer != null )
if (renderer != null)
{
rendererList.Add(renderer);
rendererCount++;
@@ -278,12 +275,12 @@ namespace Unity.Rendering.HighDefinition.Toon
}
}
if (m_targetBoxLight != null && objCount > 0 )
if (m_targetBoxLight != null && objCount > 0)
{
m_PositionOffset = m_targetBoxLight.transform.position - m_GameObjects[0].transform.position;
m_RotationOffset = Quaternion.Inverse(m_GameObjects[0].transform.rotation) * m_targetBoxLight.transform.rotation;
}
m_initialized = true;
}