Folder clean up;

Added Emissive;
This commit is contained in:
Misaki
2025-01-29 12:27:09 +09:00
parent 1a82022a6f
commit 018300e046
81 changed files with 120 additions and 399 deletions

View File

@@ -9,6 +9,11 @@ namespace Misaki.HdrpToon.Editor
{ {
SerializedObject m_SerializedObject; SerializedObject m_SerializedObject;
public static AnimationCurve DefaultAnimationCurve()
{
return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f);
}
public override void OnInspectorGUI() public override void OnInspectorGUI()
{ {
@@ -93,7 +98,7 @@ namespace Misaki.HdrpToon.Editor
var curve2 = obj.m_AnimationCurve; var curve2 = obj.m_AnimationCurve;
if (buttonIsPressed) if (buttonIsPressed)
{ {
curve2 = SceneToonEvAdjustment.DefaultAnimationCurve(); curve2 = DefaultAnimationCurve();
} }
if (EditorGUI.EndChangeCheck()) if (EditorGUI.EndChangeCheck())
{ {

View File

@@ -544,8 +544,8 @@ namespace UnityEditor.Rendering.Toon
angelRing_Sampler = FindProperty("_AngelRing_Sampler", props, false); angelRing_Sampler = FindProperty("_AngelRing_Sampler", props, false);
angelRing_Color = FindProperty("_AngelRing_Color", props, false); angelRing_Color = FindProperty("_AngelRing_Color", props, false);
emissive_Tex = FindProperty("_Emissive_Tex", props); emissive_Tex = FindProperty("_EmissiveColorMap", props);
emissive_Color = FindProperty("_Emissive_Color", props); emissive_Color = FindProperty("_EmissiveColor", props);
outline_Sampler = FindProperty(ShaderProp_Outline_Sampler, props, false); outline_Sampler = FindProperty(ShaderProp_Outline_Sampler, props, false);
@@ -1573,7 +1573,7 @@ namespace UnityEditor.Rendering.Toon
case ShadowMode.Normal: case ShadowMode.Normal:
{ {
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.Normal); material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.Normal);
material.DisableKeyword(new LocalKeyword(material.shader, "_SDFShadow")); material.DisableKeyword(new LocalKeyword(material.shader, "_SHADOW_MODE_SDF"));
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_StepText); GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_StepText);
GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_FeatherText); GUI_RangeProperty(material, Styles.shaderProp1st_ShadeColor_FeatherText);
@@ -1591,7 +1591,7 @@ namespace UnityEditor.Rendering.Toon
case ShadowMode.SDF: case ShadowMode.SDF:
{ {
material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.SDF); material.SetFloat(ShaderPropShadowMode, (int)ShadowMode.SDF);
material.EnableKeyword(new LocalKeyword(material.shader, "_SDFShadow")); material.EnableKeyword(new LocalKeyword(material.shader, "_SHADOW_MODE_SDF"));
m_MaterialEditor.TexturePropertySingleLine(Styles.SDFShadowText, SDFShadowMap); m_MaterialEditor.TexturePropertySingleLine(Styles.SDFShadowText, SDFShadowMap);
GUI_RangeProperty(material, Styles.SDFShadowLevelText); GUI_RangeProperty(material, Styles.SDFShadowLevelText);
GUI_RangeProperty(material, Styles.SDFSmoothGammaText); GUI_RangeProperty(material, Styles.SDFSmoothGammaText);
@@ -1707,13 +1707,14 @@ namespace UnityEditor.Rendering.Toon
SwitchKeywrod(material, PbrModeDefines[(int)m_pbrMode], PbrModeDefines); SwitchKeywrod(material, PbrModeDefines[(int)m_pbrMode], PbrModeDefines);
m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale); m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalMap, normalScale);
material.SetKeyword(new LocalKeyword(material.shader, "_NORMAL_MAP"), normalMap.textureValue != null);
if (m_pbrMode != PBRMode.Off) if (m_pbrMode != PBRMode.Off)
{ {
m_MaterialEditor.TexturePropertySingleLine(Styles.MaskMapText, Mask); m_MaterialEditor.TexturePropertySingleLine(Styles.MaskMapText, Mask);
if (Mask.textureValue == null) if (Mask.textureValue == null)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
if (m_pbrMode != PBRMode.KKHair) if (m_pbrMode != PBRMode.KKHair)
{ {
GUI_RangeProperty(material, Styles.MetallicText); GUI_RangeProperty(material, Styles.MetallicText);
@@ -1722,7 +1723,7 @@ namespace UnityEditor.Rendering.Toon
} }
else else
{ {
material.EnableKeyword(new LocalKeyword(material.shader, "_MASKMAP")); material.EnableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
m_MaterialEditor.MinMaxShaderProperty(MetallicRemapMin, MetallicRemapMax, minLimit: 0, 1, Styles.MetallicRemap); m_MaterialEditor.MinMaxShaderProperty(MetallicRemapMin, MetallicRemapMax, minLimit: 0, 1, Styles.MetallicRemap);
m_MaterialEditor.MinMaxShaderProperty(AORemapMin, AORemapMax, 0, 1, Styles.AORemap); m_MaterialEditor.MinMaxShaderProperty(AORemapMin, AORemapMax, 0, 1, Styles.AORemap);
m_MaterialEditor.MinMaxShaderProperty(RoughnessRemapMin, RoughnessRemapMax, 0, 1, Styles.RoughnessRemap); m_MaterialEditor.MinMaxShaderProperty(RoughnessRemapMin, RoughnessRemapMax, 0, 1, Styles.RoughnessRemap);
@@ -1730,9 +1731,9 @@ namespace UnityEditor.Rendering.Toon
} }
else else
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_MASKMAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_MASK_MAP"));
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPYMAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULARCOLORMAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
} }
@@ -1751,11 +1752,11 @@ namespace UnityEditor.Rendering.Toon
if (AnisotropyMap.textureValue == null) if (AnisotropyMap.textureValue == null)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPYMAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
} }
else else
{ {
material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPYMAP")); material.EnableKeyword(new LocalKeyword(material.shader, "_ANISOTROPY_MAP"));
} }
} }
@@ -1764,11 +1765,11 @@ namespace UnityEditor.Rendering.Toon
m_MaterialEditor.TexturePropertySingleLine(new GUIContent("Specular Color Map"), SpecColorMap, SpecColor); m_MaterialEditor.TexturePropertySingleLine(new GUIContent("Specular Color Map"), SpecColorMap, SpecColor);
if (SpecColorMap.textureValue == null) if (SpecColorMap.textureValue == null)
{ {
material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULARCOLORMAP")); material.DisableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
} }
else else
{ {
material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULARCOLORMAP")); material.EnableKeyword(new LocalKeyword(material.shader, "_SPECULAR_COLOR_MAP"));
} }
m_MaterialEditor.MinMaxShaderProperty(SpecFeather, SpecStep, 0, 1, Styles.SpecRemap); m_MaterialEditor.MinMaxShaderProperty(SpecFeather, SpecStep, 0, 1, Styles.SpecRemap);
} }
@@ -2242,9 +2243,9 @@ namespace UnityEditor.Rendering.Toon
void GUI_Emissive(Material material) void GUI_Emissive(Material material)
{ {
m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveTexText, emissive_Tex, emissive_Color); m_MaterialEditor.TexturePropertySingleLine(Styles.emissiveTexText, emissive_Tex, emissive_Color);
m_MaterialEditor.TextureScaleOffsetProperty(emissive_Tex); m_MaterialEditor.TextureScaleOffsetProperty(emissive_Tex);
material.SetKeyword(new LocalKeyword(material.shader, "_EMISSIVE_COLOR_MAP"), emissive_Tex.textureValue != null);
var _EmissiveMode_Setting = MaterialGetInt(material, "_EMISSIVE"); var _EmissiveMode_Setting = MaterialGetInt(material, "_EMISSIVE");
if ((int)EmissionMode.SimpleEmissive == _EmissiveMode_Setting) if ((int)EmissionMode.SimpleEmissive == _EmissiveMode_Setting)

View File

@@ -1,8 +1,2 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Unity.ToonShader.Editor")] [assembly: InternalsVisibleTo("Misaki.HdrpToon.Editor")]
[assembly: InternalsVisibleTo("Unity.VisualCompositor")]
[assembly: InternalsVisibleTo("Unity.VisualCompositor.Tests")]
[assembly: InternalsVisibleTo("Unity.VisualCompositor.Editor")]
[assembly: InternalsVisibleTo("Unity.VisualCompositor.EditorTests")]

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 29660dd543a3ad04ea860b6366d28b54
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,22 +0,0 @@
using UnityEngine;
[ExecuteInEditMode]
public class UTSMeshRenderer : MonoBehaviour
{
private const string Shader_Prop_Object_Center_Name = "_ObjectCenterPositionWS";
public Material material;
public Transform objectCenter;
private void Update()
{
if (material == null)
return;
if (objectCenter != null)
{
material.SetVector(Shader_Prop_Object_Center_Name, objectCenter.position);
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ee7513f8cc93a9d4f981fd4b10f8dfc1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,205 +0,0 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Misaki.HdrpToon
{
[ExecuteAlways]
[DisallowMultipleComponent]
[UTSHelpURL("ToonEVAdjustment")]
public class SceneToonEvAdjustment : MonoBehaviour
{
// flags
bool m_initialized = false;
bool m_srpCallbackInitialized = false;
const int kAdjustmentCurvePrecision = 128;
const string kCompensationPorpName = "_ToonEvAdjustmentCompensation";
const string kExposureAdjustmentPropName = "_ToonEvAdjustmentCurve";
const string kExposureArrayPropName = "_ToonEvAdjustmentValueArray";
const string kExposureMinPropName = "_ToonEvAdjustmentValueMin";
const string kExposureMaxPropName = "_ToonEvAdjustmentValueMax";
const string kToonLightFilterPropName = "_ToonLightHiCutFilter";
const string kIgonoreVolumeExposurePropName = "_ToonIgnoreExposureMultiplier";
internal bool m_ToonLightHiCutFilter = false;
internal bool m_ExposureAdjustmnt = false;
internal bool m_IgnorVolumeExposure = false;
internal AnimationCurve m_AnimationCurve = DefaultAnimationCurve();
internal float[] m_ExposureArray;
internal float m_Max, m_Min;
internal float m_Compensation;
private static SceneToonEvAdjustment instance;
#if UNITY_EDITOR
#pragma warning restore CS0414
bool m_isCompiling = false;
#endif
void Awake()
{
if (instance == null)
{
instance = this as SceneToonEvAdjustment;
return;
}
else if (instance == this)
{
return;
}
Debug.LogError("There is ToonEvAdjustmentCurve instance in hierarchy.");
#if UNITY_EDITOR
DestroyImmediate(this);
Selection.activeGameObject = instance.gameObject;
#else
Destroy(this);
#endif
}
void Reset()
{
OnDisable();
OnEnable();
DefaultAnimationCurve();
}
public static AnimationCurve DefaultAnimationCurve()
{
return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f);
}
void Update()
{
Initialize();
GetValues();
// Fail safe in case the curve is deleted / has 0 point
var curve = m_AnimationCurve;
if (curve == null || curve.length == 0)
{
m_Min = 0f;
m_Max = 0f;
for (var i = 0; i < kAdjustmentCurvePrecision; i++)
m_ExposureArray[i] = 0.0f;
}
else
{
m_Min = curve[0].time;
m_Max = curve[curve.length - 1].time;
var step = (m_Max - m_Min) / (kAdjustmentCurvePrecision - 1f);
for (var i = 0; i < kAdjustmentCurvePrecision; i++)
m_ExposureArray[i] = curve.Evaluate(m_Min + step * i);
}
#if UNITY_EDITOR
// handle script recompile
if (EditorApplication.isCompiling && !m_isCompiling)
{
// on compile begin
m_isCompiling = true;
// Release(); no need
return; //
}
else if (!EditorApplication.isCompiling && m_isCompiling)
{
// on compile end
m_isCompiling = false;
}
#endif
Shader.SetGlobalFloatArray(kExposureArrayPropName, m_ExposureArray);
Shader.SetGlobalFloat(kExposureMinPropName, m_Min);
Shader.SetGlobalFloat(kExposureMaxPropName, m_Max);
Shader.SetGlobalInt(kExposureAdjustmentPropName, m_ExposureAdjustmnt ? 1 : 0);
Shader.SetGlobalInt(kToonLightFilterPropName, m_ToonLightHiCutFilter ? 1 : 0);
Shader.SetGlobalInt(kIgonoreVolumeExposurePropName, m_IgnorVolumeExposure ? 1 : 0);
Shader.SetGlobalFloat(kCompensationPorpName, m_Compensation);
}
private void GetValues()
{
}
void EnableSrpCallbacks()
{
if (!m_srpCallbackInitialized)
{
m_srpCallbackInitialized = true;
}
}
void DisableSrpCallbacks()
{
if (m_srpCallbackInitialized)
{
m_srpCallbackInitialized = false;
}
}
void OnEnable()
{
Initialize();
EnableSrpCallbacks();
}
void OnDisable()
{
DisableSrpCallbacks();
Release();
}
void Initialize()
{
if (m_initialized)
{
return;
}
#if UNITY_EDITOR
// initializing renderer can interfere GI baking. so wait until it is completed.
if (EditorApplication.isCompiling)
return;
#endif
if (m_ExposureArray == null || m_ExposureArray.Length != kAdjustmentCurvePrecision)
{
m_ExposureArray = new float[kAdjustmentCurvePrecision];
}
m_initialized = true;
}
void Release()
{
if (m_initialized)
{
m_ExposureArray = null;
Shader.SetGlobalInt(kExposureAdjustmentPropName, 0);
Shader.SetGlobalInt(kToonLightFilterPropName, 0);
}
m_initialized = false;
}
}
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: db8edd5c572b6e648974dac4815d5619
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -119,6 +119,8 @@ Shader "HDRP/Toon"
_EmissiveIntensity("Emissive Intensity", Float) = 1 _EmissiveIntensity("Emissive Intensity", Float) = 1
_EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0 _EmissiveExposureWeight("Emissive Pre Exposure", Range(0.0, 1.0)) = 1.0
[Enum(WorldSpace, 0, ObjectSpace, 1)] _ObjectSpaceUVMappingEmissive("Mapping space", Float) = 0.0
_DistortionVectorMap("DistortionVectorMap", 2D) = "black" {} _DistortionVectorMap("DistortionVectorMap", 2D) = "black" {}
[ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0 [ToggleUI] _DistortionEnable("Enable Distortion", Float) = 0.0
[ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0 [ToggleUI] _DistortionDepthTest("Distortion Depth Test Enable", Float) = 1.0
@@ -445,8 +447,6 @@ Shader "HDRP/Toon"
// //
//v.2.0.7 Emissive //v.2.0.7 Emissive
[KeywordEnum(SIMPLE, ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0 [KeywordEnum(SIMPLE, ANIMATION)] _EMISSIVE("EMISSIVE MODE", Float) = 0
_Emissive_Tex("Emissive_Tex", 2D) = "white" {}
[HDR]_Emissive_Color("Emissive_Color", Color) = (0, 0, 0, 1)
_Base_Speed("Base_Speed", Float) = 0 _Base_Speed("Base_Speed", Float) = 0
_Scroll_EmissiveU("Scroll_EmissiveU", Range(-1, 1)) = 0 _Scroll_EmissiveU("Scroll_EmissiveU", Range(-1, 1)) = 0
_Scroll_EmissiveV("Scroll_EmissiveV", Range(-1, 1)) = 0 _Scroll_EmissiveV("Scroll_EmissiveV", Range(-1, 1)) = 0
@@ -595,7 +595,7 @@ Shader "HDRP/Toon"
// variable declaration // variable declaration
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Properties/UtsHdrpProperties.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Properties/UtsHdrpProperties.hlsl"
// TODO: // TODO:
// Currently, Lit.hlsl and LitData.hlsl are included for every pass. Split Lit.hlsl in two: // Currently, Lit.hlsl and LitData.hlsl are included for every pass. Split Lit.hlsl in two:
@@ -1017,10 +1017,11 @@ Shader "HDRP/Toon"
#pragma shader_feature_local_fragment _INDIRECT_DIFFUSE_OFF _INDIRECT_DIFFUSE_IBL _INDIRECT_DIFFUSE_MATCAP _INDIRECT_DIFFUSE_RAMP #pragma shader_feature_local_fragment _INDIRECT_DIFFUSE_OFF _INDIRECT_DIFFUSE_IBL _INDIRECT_DIFFUSE_MATCAP _INDIRECT_DIFFUSE_RAMP
#pragma shader_feature_local_fragment _INDIRECT_SPECULAR_OFF _INDIRECT_SPECULAR_IBL _INDIRECT_SPECULAR_MATCAP #pragma shader_feature_local_fragment _INDIRECT_SPECULAR_OFF _INDIRECT_SPECULAR_IBL _INDIRECT_SPECULAR_MATCAP
#pragma shader_feature_local_fragment _MASKMAP #pragma shader_feature_local_fragment _MASK_MAP
#pragma shader_feature_local_fragment _NORMALMAP #pragma shader_feature_local_fragment _NORMAL_MAP
#pragma shader_feature_local_fragment _ANISOTROPYMAP #pragma shader_feature_local_fragment _ANISOTROPY_MAP
#pragma shader_feature_local_fragment _SPECULARCOLORMAP #pragma shader_feature_local_fragment _SPECULAR_COLOR_MAP
#pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
#pragma shader_feature_local_fragment _RECEIVE_HAIR_SHADOW_ON #pragma shader_feature_local_fragment _RECEIVE_HAIR_SHADOW_ON
@@ -1041,7 +1042,7 @@ Shader "HDRP/Toon"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
#ifdef DEBUG_DISPLAY #ifdef DEBUG_DISPLAY
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsCommon.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl"
#endif #endif
// The light loop (or lighting architecture) is in charge to: // The light loop (or lighting architecture) is in charge to:
@@ -1056,16 +1057,16 @@ Shader "HDRP/Toon"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsHead.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsHead.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl"
#ifdef DEBUG_DISPLAY #ifdef DEBUG_DISPLAY
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/ShaderPass/ShaderPassForward.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/ShaderPassForward.hlsl"
#else #else
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Lighting/UtsLightLoop.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsLightLoop.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/ShaderPass/UtsShaderPassForward.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/UtsShaderPassForward.hlsl"
#endif #endif
#pragma vertex Vert #pragma vertex Vert
@@ -1173,8 +1174,8 @@ Shader "HDRP/Toon"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsHead.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsHead.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/ShaderPass/HDRPToonOutline.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/HDRPToonOutline.hlsl"
#pragma vertex Vert #pragma vertex Vert
#pragma fragment Frag #pragma fragment Frag
@@ -1234,8 +1235,8 @@ Shader "HDRP/Toon"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl"
#endif #endif
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsHead.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsHead.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/ShaderPass/HDRPToonHairBlending.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/HDRPToonHairBlending.hlsl"
#pragma vertex Vert #pragma vertex Vert
#pragma fragment Frag #pragma fragment Frag

View File

@@ -115,6 +115,12 @@ float3 GetExposureAdjustedColor(float3 originalColor)
} }
} }
void ApplyExposureAdjustment(inout float3 color)
{
color = GetExposureAdjustedColor(color);
color = ApplyCompensation(color);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Transform // Transform
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -5,7 +5,7 @@
#ifndef UCTS_HDRP_INCLUDED #ifndef UCTS_HDRP_INCLUDED
#define UCTS_HDRP_INCLUDED #define UCTS_HDRP_INCLUDED
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsCommon.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsCommon.hlsl"
#define UTS_LAYER_VISIBILITY #define UTS_LAYER_VISIBILITY
@@ -105,32 +105,34 @@ UTSSurfaceData ConvertSurfaceDataToUTSSurfaceData(SurfaceData surfaceData)
return output; return output;
} }
UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V, float2 UV) UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
{ {
UTSSurfaceData output; UTSSurfaceData output;
//ZERO_INITIALIZE(UTSSurfaceData, output); //ZERO_INITIALIZE(UTSSurfaceData, output);
output.materialFeatures = 0; output.materialFeatures = 0;
float4 mainTexture = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(UV, _BaseColorMap)); float4 mainTexture = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
output.baseColor = mainTexture.rgb * _BaseColor.rgb; output.baseColor = mainTexture.rgb * _BaseColor.rgb;
output.alpha = mainTexture.a; output.alpha = mainTexture.a;
float4 firstShadingTexture = SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap, TRANSFORM_TEX(UV, _BaseColorMap)); float4 firstShadingTexture = SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
float4 secondShadingTexture = SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap, TRANSFORM_TEX(UV, _BaseColorMap)); float4 secondShadingTexture = SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_BaseColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
output.firstShadingColor = lerp(firstShadingTexture.rgb, mainTexture.rgb, _Use_BaseAs1st) * _1st_ShadeColor.rgb; output.firstShadingColor = lerp(firstShadingTexture.rgb, mainTexture.rgb, _Use_BaseAs1st) * _1st_ShadeColor.rgb;
output.secondShadingColor = lerp(secondShadingTexture.rgb, output.firstShadingColor, _Use_1stAs2nd) * _2nd_ShadeColor.rgb; output.secondShadingColor = lerp(secondShadingTexture.rgb, output.firstShadingColor, _Use_1stAs2nd) * _2nd_ShadeColor.rgb;
float4 normalLocal = 0; float4 normalLocal = float4(0, 0, 1.0, 1.0);
#if _NORMAL_MAP
if (_Use_SSSLut) if (_Use_SSSLut)
{ {
normalLocal = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(UV, _BaseColorMap), _SSSIntensity); normalLocal = SAMPLE_TEXTURE2D_LOD(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap), _SSSIntensity);
} }
else else
{ {
normalLocal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(UV, _BaseColorMap)); normalLocal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
}
normalLocal.rgb = UnpackNormalScale(normalLocal, _NormalScale); normalLocal.rgb = UnpackNormalScale(normalLocal, _NormalScale);
}
#endif
float3 normalWS = normalize(mul(normalLocal.rgb, input.tangentToWorld)); float3 normalWS = normalize(mul(normalLocal.rgb, input.tangentToWorld));
#if _PBR_MODE_OFF #if _PBR_MODE_OFF
float smoothness = 0.0; float smoothness = 0.0;
@@ -143,8 +145,8 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V, float2 UV)
float3 specularColor = 1; float3 specularColor = 1;
float anisotropy = 0; float anisotropy = 0;
#ifdef _MASKMAP #ifdef _MASK_MAP
float4 _MaskMap_var = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, TRANSFORM_TEX(UV, _BaseColorMap)); float4 _MaskMap_var = SAMPLE_TEXTURE2D(_MaskMap, sampler_MaskMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap));
metallic = _MaskMap_var.x; metallic = _MaskMap_var.x;
metallic = lerp(_MetallicRemapMin, _MetallicRemapMax, metallic); metallic = lerp(_MetallicRemapMin, _MetallicRemapMax, metallic);
ao = _MaskMap_var.y; ao = _MaskMap_var.y;
@@ -153,8 +155,8 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V, float2 UV)
smoothness = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, smoothness); smoothness = lerp(_SmoothnessRemapMin, _SmoothnessRemapMax, smoothness);
#endif #endif
#ifdef _ANISOTROPYMAP #ifdef _ANISOTROPY_MAP
anisotropy = SAMPLE_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, TRANSFORM_TEX(UV, _AnisotropyMap)).r; anisotropy = SAMPLE_TEXTURE2D(_AnisotropyMap, sampler_AnisotropyMap, TRANSFORM_TEX(input.texCoord0, _AnisotropyMap)).r;
#if _PBR_Mode_KK #if _PBR_Mode_KK
anisotropy += _Anisotropy - 0.5; anisotropy += _Anisotropy - 0.5;
#else #else
@@ -171,8 +173,8 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V, float2 UV)
#endif #endif
#ifdef _PBR_Mode_TOON #ifdef _PBR_Mode_TOON
#ifdef _SPECULARCOLORMAP #ifdef _SPECULAR_COLOR_MAP
specularColor = SAMPLE_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, TRANSFORM_TEX(UV, _BaseColorMap)).rgb * _SpecularColor; specularColor = SAMPLE_TEXTURE2D(_SpecularColorMap, sampler_SpecularColorMap, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)).rgb * _SpecularColor;
#endif #endif
specularColor = GetSpecularColor(_MainTex_var.rgb * _BaseColor.rgb, metallic); specularColor = GetSpecularColor(_MainTex_var.rgb * _BaseColor.rgb, metallic);
#endif #endif
@@ -187,7 +189,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V, float2 UV)
output.geomNormalWS = input.tangentToWorld[2]; output.geomNormalWS = input.tangentToWorld[2];
output.tangentWS = Orthonormalize(input.tangentToWorld[0].rgb, normalWS); output.tangentWS = Orthonormalize(input.tangentToWorld[0].rgb, normalWS);
output.subsurfaceColor = SAMPLE_TEXTURE2D(_SSSLutMap, sampler_MainTex, TRANSFORM_TEX(UV, _BaseColorMap)) * _SSSIntensity; output.subsurfaceColor = SAMPLE_TEXTURE2D(_SSSLutMap, sampler_MainTex, TRANSFORM_TEX(input.texCoord0, _BaseColorMap)) * _SSSIntensity;
output.anisotropy = anisotropy; output.anisotropy = anisotropy;
@@ -214,7 +216,7 @@ UtsBSDFData ConvertUTSSurfaceDataToUTSBSDFData(UTSSurfaceData surfaceData)
output.ambientOcclusion = surfaceData.ambientOcclusion; output.ambientOcclusion = surfaceData.ambientOcclusion;
output.specularOcclusion = surfaceData.specularOcclusion; output.specularOcclusion = surfaceData.specularOcclusion;
output.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness); output.perceptualRoughness = PerceptualSmoothnessToPerceptualRoughness(surfaceData.perceptualSmoothness);\
output.subsurfaceColor = surfaceData.subsurfaceColor.rgb * surfaceData.subsurfaceColor.a; output.subsurfaceColor = surfaceData.subsurfaceColor.rgb * surfaceData.subsurfaceColor.a;

View File

@@ -133,11 +133,15 @@ float3 SampleSDFTexture(float3 L, float2 uv, out float angle)
return isRightSide ? right_SDFTex : left_SDFTex; return isRightSide ? right_SDFTex : left_SDFTex;
} }
float GetHairShadow(PositionInputs posInput, float3 L, float2 positionSS) float GetHairShadow(PositionInputs posInput, float3 L)
{ {
float shadow = 1.0;
// Push the face fragment view space position towards the light for a little bit // Push the face fragment view space position towards the light for a little bit
float hairShadowOpacity = saturate(Remap(length(posInput.positionWS), float2(_HairShadowFadeOutDistance, _HairShadowFadeInDistance), float2(0, 1))); float hairShadowOpacity = saturate(Remap(length(posInput.positionWS), float2(_HairShadowFadeOutDistance, _HairShadowFadeInDistance), float2(0, 1)));
if (hairShadowOpacity > 0.0)
{
float3 viewLightDir = TransformWorldToViewDir(L); // / posInput.deviceDepth; when linearDepth grows large, the movement amount should be lower since we are getting further from the face. float3 viewLightDir = TransformWorldToViewDir(L); // / posInput.deviceDepth; when linearDepth grows large, the movement amount should be lower since we are getting further from the face.
float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS())); float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
float shadowLengthY = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor) / posInput.linearDepth; float shadowLengthY = _HairShadowDistance * 5.0 * max(0.5, posInput.linearDepth * _HairShadowDistanceScaleFactor) / posInput.linearDepth;
@@ -147,20 +151,22 @@ float GetHairShadow(PositionInputs posInput, float3 L, float2 positionSS)
float camDirFactor = 1 - smoothstep(0.1, 0.9, camDirOS.y); float camDirFactor = 1 - smoothstep(0.1, 0.9, camDirOS.y);
shadowLength.y *= camDirFactor; shadowLength.y *= camDirFactor;
float2 samplingPoint = (positionSS + shadowLength * viewLightDir.xy * (_ScreenSize.xy / float2 (1920.0f, 1080.0f))) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions. float2 samplingPoint = (posInput.positionSS + shadowLength * viewLightDir.xy * (_ScreenSize.xy / float2(1920.0f, 1080.0f))) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions.
// Then sample the hair buffer, to see if the fragment lands in shadow. // Then sample the hair buffer, to see if the fragment lands in shadow.
float2 scaledUVs = samplingPoint * _HairShadowRTHandleScale; // We have to including the scaling factor for our shadow map since we are not going to allocate new texture if the rendering resolution changed. float2 scaledUVs = samplingPoint * _HairShadowRTHandleScale; // We have to including the scaling factor for our shadow map since we are not going to allocate new texture if the rendering resolution changed.
float hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, scaledUVs).r; float hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, scaledUVs).r;
float depthCorrect = posInput.deviceDepth <= hairDepth + _HairShadowDepthBias ? 1 : 0; // Hair < Face means Hair are closer to camera float shadowMask = posInput.deviceDepth <= hairDepth + _HairShadowDepthBias ? 1 : 0; // Hair < Face means Hair are closer to camera
// Note that we have LinearEyeDepth in the buffer. A comparison of depth is needed so that we don't project the shadow of hair behind the face. // Note that we have LinearEyeDepth in the buffer. A comparison of depth is needed so that we don't project the shadow of hair behind the face.
float hairShadow = lerp(0,hairShadowOpacity,depthCorrect); shadow = lerp(1, 1.0 - hairShadowOpacity, shadowMask);
} }
UtsShadeMask GetShadeMak(float3 normalWS, float3 L, SHADOW_TYPE shadow, float2 uv, out float additionalSpecular) return shadow;
}
UtsShadeMask GetShadeMak(PositionInputs posInput, float3 normalWS, float3 L, SHADOW_TYPE shadow, float2 uv, out float additionalSpecular)
{ {
UtsShadeMask shadeMask; UtsShadeMask shadeMask;
ZERO_INITIALIZE(UtsShadeMask, shadeMask);
#if _SHADOW_MODE_NORMAL #if _SHADOW_MODE_NORMAL
float NdotL = dot(normalWS, L); float NdotL = dot(normalWS, L);
@@ -182,18 +188,25 @@ UtsShadeMask GetShadeMak(float3 normalWS, float3 L, SHADOW_TYPE shadow, float2 u
float shadowLevel = _SDFShadowLevel / 10.0f; float shadowLevel = _SDFShadowLevel / 10.0f;
float3 sdfTexture = SampleSDFTexture(L, uv, angle); // r: sdf shadow, g: sdf noise highlight, b: fixed shadow float3 sdfTexture = SampleSDFTexture(L, uv, angle); // r: sdf shadow, g: sdf noise highlight, b: fixed shadow
float sdfShadowMask = smoothstep(sdfTexture.r - smoothGamma, sdfTexture.r + smoothGamma, angle - shadowLevel); float sdfShadowMask = 1.0 - smoothstep(sdfTexture.r - smoothGamma, sdfTexture.r + smoothGamma, angle - shadowLevel);
shadeMask.baseShadeMask = sdfShadowMask * sdfTexture.b; shadeMask.baseShadeMask = sdfShadowMask * sdfTexture.b;
shadeMask.firstShadeMask = 1.0;
additionalSpecular = sdfTexture.g; additionalSpecular = sdfTexture.g;
#endif #endif
shadow = smoothstep(0.4, 0.6, shadow);
#if _RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW
shadow *= GetHairShadow(posInput, L);
#endif
shadeMask.baseShadeMask = APPLY_WEIGHT(shadeMask.baseShadeMask, shadow, _Set_SystemShadowsToBase); shadeMask.baseShadeMask = APPLY_WEIGHT(shadeMask.baseShadeMask, shadow, _Set_SystemShadowsToBase);
return shadeMask; return shadeMask;
} }
DirectLighting UtsShadeSurface(UtsBSDFData bsdfData, PreLightData preLightData, SHADOW_TYPE shadow, DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, PreLightData preLightData, SHADOW_TYPE shadow,
float3 lightColor, float3 V, float3 L, float2 uv, float3 lightColor, float3 V, float3 L, float2 uv,
float diffuseDimmer, float specularDimmer) float diffuseDimmer, float specularDimmer)
{ {
@@ -203,7 +216,7 @@ DirectLighting UtsShadeSurface(UtsBSDFData bsdfData, PreLightData preLightData,
if (Max3(lightColor.r, lightColor.g, lightColor.b) > 0.0) if (Max3(lightColor.r, lightColor.g, lightColor.b) > 0.0)
{ {
float additionalSpecular; float additionalSpecular;
UtsShadeMask shadeMask = GetShadeMak(bsdfData.normalWS, L, shadow, uv, additionalSpecular); UtsShadeMask shadeMask = GetShadeMak(posInput, bsdfData.normalWS, L, shadow, uv, additionalSpecular);
float3 diffuseTerm = lerp(lerp(bsdfData.secondShadingDiffuseColor, bsdfData.firstShadingDiffuseColor, shadeMask.firstShadeMask), bsdfData.diffuseColor, shadeMask.baseShadeMask); float3 diffuseTerm = lerp(lerp(bsdfData.secondShadingDiffuseColor, bsdfData.firstShadingDiffuseColor, shadeMask.firstShadeMask), bsdfData.diffuseColor, shadeMask.baseShadeMask);
float3 specularTerm = (ComputeSpecularTerm(bsdfData, preLightData, V, L) + additionalSpecular) * shadeMask.baseShadeMask; float3 specularTerm = (ComputeSpecularTerm(bsdfData, preLightData, V, L) + additionalSpecular) * shadeMask.baseShadeMask;

View File

@@ -55,7 +55,7 @@ DirectLighting UtsEvaluateBSDF_Directional(LightLoopContext lightLoopContext, Po
UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness); UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness);
lighting = UtsShadeSurface(bsdfData, preLightData, shadow, lightColor.rgb, V, L, uv0, lightData.diffuseDimmer, lightData.specularDimmer); lighting = UtsShadeSurface(posInput, bsdfData, preLightData, shadow, lightColor.rgb, V, L, uv0, lightData.diffuseDimmer, lightData.specularDimmer);
} }
return lighting; return lighting;
@@ -84,7 +84,7 @@ DirectLighting UtsEvaluateBSDF_Punctual(LightLoopContext lightLoopContext, Posit
UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness); UtsClampRoughness(preLightData, bsdfData, lightData.minRoughness);
lighting = UtsShadeSurface(bsdfData, preLightData, shadow, lightColor.rgb, V, L, uv0, lightData.diffuseDimmer, lightData.specularDimmer); lighting = UtsShadeSurface(posInput, bsdfData, preLightData, shadow, lightColor.rgb, V, L, uv0, lightData.diffuseDimmer, lightData.specularDimmer);
} }
return lighting; return lighting;
@@ -250,10 +250,15 @@ void UtsPostEvaluateBSDF(PositionInputs posInput, PreLightData preLightData, Uts
builtinData.bakeDiffuseLighting = ApplyCurrentExposureMultiplier(builtinData.bakeDiffuseLighting * bsdfData.diffuseColor * preLightData.diffuseFGD * _ID_Intensity); builtinData.bakeDiffuseLighting = ApplyCurrentExposureMultiplier(builtinData.bakeDiffuseLighting * bsdfData.diffuseColor * preLightData.diffuseFGD * _ID_Intensity);
lighting.indirect.specularReflected = ApplyCurrentExposureMultiplier(lighting.indirect.specularReflected * bsdfData.fresnel0 * _IR_Intensity); lighting.indirect.specularReflected = ApplyCurrentExposureMultiplier(lighting.indirect.specularReflected * bsdfData.fresnel0 * _IR_Intensity);
lightLoopOutput.diffuseLighting = lighting.direct.diffuse + builtinData.bakeDiffuseLighting + builtinData.emissiveColor; lightLoopOutput.diffuseLighting = lighting.direct.diffuse + builtinData.bakeDiffuseLighting;
lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected; lightLoopOutput.specularLighting = lighting.direct.specular + lighting.indirect.specularReflected;
// Rescale the GGX to account for the multiple scattering. // Rescale the GGX to account for the multiple scattering.
lightLoopOutput.specularLighting *= 1.0 + bsdfData.fresnel0 * preLightData.energyCompensation; lightLoopOutput.specularLighting *= 1.0 + bsdfData.fresnel0 * preLightData.energyCompensation;
ApplyExposureAdjustment(lightLoopOutput.diffuseLighting);
ApplyExposureAdjustment(lightLoopOutput.specularLighting);
lightLoopOutput.diffuseLighting += builtinData.emissiveColor;
} }
#endif #endif

View File

@@ -4,8 +4,8 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Macros.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsMaterialEvaluation.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsMaterialEvaluation.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Lighting/UtsLightEvaluation.hlsl" #include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Lighting/UtsLightEvaluation.hlsl"
// Channel mask enum. // Channel mask enum.
// this must be same to UI cs code // this must be same to UI cs code
@@ -158,6 +158,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
uint v_lightListOffset = 0; uint v_lightListOffset = 0;
uint v_lightIdx = lightStart; uint v_lightIdx = lightStart;
[loop] // vulkan shader compiler can not unroll.
#if NEED_TO_CHECK_HELPER_LANE #if NEED_TO_CHECK_HELPER_LANE
// On some platform helper lanes don't behave as we'd expect, therefore we prevent them from entering the loop altogether. // On some platform helper lanes don't behave as we'd expect, therefore we prevent them from entering the loop altogether.
// IMPORTANT! This has implications if ddx/ddy is used on results derived from lighting, however given Lightloop is called in compute we should be // IMPORTANT! This has implications if ddx/ddy is used on results derived from lighting, however given Lightloop is called in compute we should be

View File

@@ -146,6 +146,7 @@ float _PPDLodThreshold;
float3 _EmissiveColor; float3 _EmissiveColor;
float _AlbedoAffectEmissive; float _AlbedoAffectEmissive;
float _EmissiveExposureWeight; float _EmissiveExposureWeight;
float _ObjectSpaceUVMappingEmissive;
int _SpecularOcclusionMode; int _SpecularOcclusionMode;

View File

@@ -12,7 +12,6 @@ sampler _Set_HighColorMask;
sampler _Set_RimLightMask; sampler _Set_RimLightMask;
sampler _NormalMapForMatCap; sampler _NormalMapForMatCap;
sampler _Set_MatcapMask; sampler _Set_MatcapMask;
sampler _Emissive_Tex;
// sampler2D _ClippingMask; // sampler2D _ClippingMask;
TEXTURE2D(_ClippingMask); TEXTURE2D(_ClippingMask);
sampler _AngelRing_Sampler; sampler _AngelRing_Sampler;

View File

@@ -15,9 +15,6 @@
#define SCALARIZE_LIGHT_LOOP (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER) && !defined(SHADER_API_GAMECORE) && SHADERPASS == SHADERPASS_FORWARD) #define SCALARIZE_LIGHT_LOOP (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER) && !defined(SHADER_API_GAMECORE) && SHADERPASS == SHADERPASS_FORWARD)
#endif #endif
//#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
#include "Packages/com.misaki.hdrp-toon/Runtime/HDRP/Shaders/Includes/Common/UtsCommon.hlsl"
#ifdef _WRITE_TRANSPARENT_MOTION_VECTOR #ifdef _WRITE_TRANSPARENT_MOTION_VECTOR
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/MotionVectorVertexShaderCommon.hlsl"
@@ -42,37 +39,6 @@ PackedVaryingsType Vert(AttributesMesh inputMesh)
#endif // _WRITE_TRANSPARENT_MOTION_VECTOR #endif // _WRITE_TRANSPARENT_MOTION_VECTOR
///////////////////////////////////////////////////////////////////////////////
// Attenuation Functions /
///////////////////////////////////////////////////////////////////////////////
// Grafted from URP
// Matches Unity Vanila attenuation
// Attenuation smoothly decreases to light range.
float DistanceAttenuation(float distanceSqr, half2 distanceAttenuation)
{
// We use a shared distance attenuation for additional directional and puctual lights
// for directional lights attenuation will be 1
float lightAtten = rcp(distanceSqr);
#if SHADER_HINT_NICE_QUALITY
// Use the smoothing factor also used in the Unity lightmapper.
half factor = distanceSqr * distanceAttenuation.x;
half smoothFactor = saturate(1.0h - factor * factor);
smoothFactor = smoothFactor * smoothFactor;
#else
// We need to smoothly fade attenuation to light range. We start fading linearly at 80% of light range
// Therefore:
// fadeDistance = (0.8 * 0.8 * lightRangeSq)
// smoothFactor = (lightRangeSqr - distanceSqr) / (lightRangeSqr - fadeDistance)
// We can rewrite that to fit a MAD by doing
// distanceSqr * (1.0 / (fadeDistanceSqr - lightRangeSqr)) + (-lightRangeSqr / (fadeDistanceSqr - lightRangeSqr)
// distanceSqr * distanceAttenuation.y + distanceAttenuation.z
half smoothFactor = saturate(distanceSqr * distanceAttenuation.x + distanceAttenuation.y);
#endif
return lightAtten * smoothFactor;
}
float ApplyChannelAlpha( float alpha) float ApplyChannelAlpha( float alpha)
{ {
return lerp(1.0, alpha, _ComposerMaskMode); return lerp(1.0, alpha, _ComposerMaskMode);
@@ -85,11 +51,6 @@ float ApplyChannelAlpha( float alpha)
#define EXTRA_BUFFER_TARGET SV_Target1 #define EXTRA_BUFFER_TARGET SV_Target1
#endif #endif
uniform sampler2D _RaytracedHardShadow;
float4 _RaytracedHardShadow_TexelSize;
void Frag(PackedVaryingsToPS packedInput, void Frag(PackedVaryingsToPS packedInput,
#ifdef OUTPUT_SPLIT_LIGHTING #ifdef OUTPUT_SPLIT_LIGHTING
out float4 outColor : SV_Target0, // outSpecularLighting out float4 outColor : SV_Target0, // outSpecularLighting
@@ -167,7 +128,7 @@ void Frag(PackedVaryingsToPS packedInput,
SurfaceData tempSurfaceData; SurfaceData tempSurfaceData;
BuiltinData builtinData; BuiltinData builtinData;
GetSurfaceAndBuiltinData(input, V, posInput, tempSurfaceData, builtinData); GetSurfaceAndBuiltinData(input, V, posInput, tempSurfaceData, builtinData);
UTSSurfaceData surfaceData = GetUTSSurfaceData(input, V, UV0.xy); UTSSurfaceData surfaceData = GetUTSSurfaceData(input, V);
UtsBSDFData bsdfData = ConvertUTSSurfaceDataToUTSBSDFData(surfaceData); UtsBSDFData bsdfData = ConvertUTSSurfaceDataToUTSBSDFData(surfaceData);
#define UNITY_PROJ_COORD(a) a #define UNITY_PROJ_COORD(a) a
@@ -192,13 +153,13 @@ void Frag(PackedVaryingsToPS packedInput,
InitContactShadow(posInput, context); InitContactShadow(posInput, context);
float channelAlpha = 0.0f; float channelAlpha = 0.0f;
float3 finalColor = float3(0.0f, 0.0f, 0.0f);
LightLoopOutput lightLoopOutput; LightLoopOutput lightLoopOutput;
ZERO_INITIALIZE(LightLoopOutput, lightLoopOutput); ZERO_INITIALIZE(LightLoopOutput, lightLoopOutput);
UtsLightLoop(input, posInput, bsdfData, builtinData, V, featureFlags, lightLoopOutput); UtsLightLoop(input, posInput, bsdfData, builtinData, V, featureFlags, lightLoopOutput);
/*
#ifdef _EMISSIVE_SIMPLE #ifdef _EMISSIVE_SIMPLE
float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(UV0, _Emissive_Tex)); float4 _Emissive_Tex_var = tex2D(_Emissive_Tex, TRANSFORM_TEX(UV0, _Emissive_Tex));
float emissiveMask = _Emissive_Tex_var.a; float emissiveMask = _Emissive_Tex_var.a;
@@ -239,10 +200,12 @@ void Frag(PackedVaryingsToPS packedInput,
// //
//v.2.0.6: GI_Intensity with Intensity Multiplier Filter //v.2.0.6: GI_Intensity with Intensity Multiplier Filter
#endif #endif
*/
// We directly calculate custome main light during the light loop in upper code to avoid extra calculation // We directly calculate custome main light during the light loop in upper code to avoid extra calculation
//customMainLight = GetCustomMainLightData(builtinData, mainPunctualLight); //customMainLight = GetCustomMainLightData(builtinData, mainPunctualLight);
/*
#if _SHADOW_MODE_SDF || (_RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW) #if _SHADOW_MODE_SDF || (_RECEIVE_HAIR_SHADOW_ON && ENABLE_UTS_HAIR_SHAOW)
float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz); float3 defaultLightDirection = normalize(UNITY_MATRIX_V[2].xyz + UNITY_MATRIX_V[1].xyz);
float3 defaultLightColor = saturate(max(float3(0.05, 0.05, 0.05) * _Unlit_Intensity, max(ShadeSH9(float4(0.0, 0.0, 0.0, 1.0)), ShadeSH9(float4(0.0, -1.0, 0.0, 1.0)).rgb) * _Unlit_Intensity)); float3 defaultLightColor = saturate(max(float3(0.05, 0.05, 0.05) * _Unlit_Intensity, max(ShadeSH9(float4(0.0, 0.0, 0.0, 1.0)), ShadeSH9(float4(0.0, -1.0, 0.0, 1.0)).rgb) * _Unlit_Intensity));
@@ -300,17 +263,12 @@ void Frag(PackedVaryingsToPS packedInput,
utsAggregateLighting.directDiffuse = lerp(utsAggregateLighting.directDiffuse, _1st_Shade_var, hairShadow * systemShadowValue); utsAggregateLighting.directDiffuse = lerp(utsAggregateLighting.directDiffuse, _1st_Shade_var, hairShadow * systemShadowValue);
utsAggregateLighting.directSpecular = lerp(utsAggregateLighting.directSpecular, 0, hairShadow * systemShadowValue); utsAggregateLighting.directSpecular = lerp(utsAggregateLighting.directSpecular, 0, hairShadow * systemShadowValue);
#endif #endif
*/
//outColor.rgb = lightLoopOutput.diffuseLighting + lightLoopOutput.specularLighting;
//outColor.a = 1.0;
//return;
outColor.rgb = lightLoopOutput.diffuseLighting + lightLoopOutput.specularLighting; float3 finalColor = lightLoopOutput.diffuseLighting + lightLoopOutput.specularLighting;
outColor.a = 1.0;
return;
float3 finalColorWoEmissive = 0;
finalColorWoEmissive = GetExposureAdjustedColor(finalColorWoEmissive);
finalColorWoEmissive = ApplyCompensation(finalColorWoEmissive);
finalColor = finalColorWoEmissive + emissive;
#ifdef _IS_TRANSCLIPPING_OFF #ifdef _IS_TRANSCLIPPING_OFF

View File

@@ -11,7 +11,6 @@ namespace Misaki.HdrpToon
private static UTSRenderPassSettings _renderSetting; private static UTSRenderPassSettings _renderSetting;
private static UTSPass _utsPass; private static UTSPass _utsPass;
//private static UTSHairShadowPass _hairShadowPass;
private static UTSOutlinePass _outlinePass; private static UTSOutlinePass _outlinePass;
static UTSRenderPassRegistrar() => RegisterCustomPasses(); static UTSRenderPassRegistrar() => RegisterCustomPasses();
@@ -32,13 +31,6 @@ namespace Misaki.HdrpToon
targetDepthBuffer = CustomPass.TargetBuffer.None, targetDepthBuffer = CustomPass.TargetBuffer.None,
}; };
//_hairShadowPass = new()
//{
// name = "UTS Hair Shadow Map",
// targetColorBuffer = CustomPass.TargetBuffer.None,
// targetDepthBuffer = CustomPass.TargetBuffer.None,
//};
_outlinePass = new() _outlinePass = new()
{ {
name = "UTS Outline", name = "UTS Outline",