Added new fabirc pbr mode;
Added new stocking surface feature; Fixed the issue that diffuse bsdf is not energy conserving. Fixed the bug that shader can not render alpha clip properly;
This commit is contained in:
@@ -11,10 +11,10 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
Highlight = 1 << 6,
|
Highlight = 1 << 6,
|
||||||
Rimlight = 1 << 7,
|
Rimlight = 1 << 7,
|
||||||
MatCap = 1 << 8,
|
MatCap = 1 << 8,
|
||||||
AngelRing = 1 << 9,
|
Stocking = 1 << 9,
|
||||||
Emission = 1 << 10,
|
AngelRing = 1 << 10,
|
||||||
Outline = 1 << 11,
|
Emission = 1 << 11,
|
||||||
TessellationLegacy = 1 << 12,
|
Outline = 1 << 12,
|
||||||
TessellationHDRP = 1 << 13,
|
TessellationHDRP = 1 << 13,
|
||||||
SceneLight = 1 << 14,
|
SceneLight = 1 << 14,
|
||||||
EnvironmentalLightEffectiveness = 1 << 15,
|
EnvironmentalLightEffectiveness = 1 << 15,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
public static MaterialProperty rimLightColor;
|
public static MaterialProperty rimLightColor;
|
||||||
public static MaterialProperty rimLightIntensity;
|
public static MaterialProperty rimLightIntensity;
|
||||||
|
|
||||||
|
public static MaterialProperty albedoAffectRimLight;
|
||||||
public static MaterialProperty screenSpaceRimLight;
|
public static MaterialProperty screenSpaceRimLight;
|
||||||
public static MaterialProperty rimLightLevel;
|
public static MaterialProperty rimLightLevel;
|
||||||
public static MaterialProperty rimLightClipping;
|
public static MaterialProperty rimLightClipping;
|
||||||
@@ -28,6 +29,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
public static readonly GUIContent rimLightColorText = new("Rim Light Color", "Specifies the color of rim light.");
|
public static readonly GUIContent rimLightColorText = new("Rim Light Color", "Specifies the color of rim light.");
|
||||||
public static readonly GUIContent rimLightIntensityText = new("Rim Light Strength", "Specifies Rim Light strength.");
|
public static readonly GUIContent rimLightIntensityText = new("Rim Light Strength", "Specifies Rim Light strength.");
|
||||||
|
|
||||||
|
public static readonly GUIContent albedoAffectRimLightText = new("Albedo Affect Rim Light", "Enable to let the albedo color affect the rim light color. The alpha channel of rim light color will be the blending weight.");
|
||||||
public static readonly GUIContent screenSpaceRimLightText = new("Screen Space Rim Light", "Enable to make the rim light width constant in screen space.");
|
public static readonly GUIContent screenSpaceRimLightText = new("Screen Space Rim Light", "Enable to make the rim light width constant in screen space.");
|
||||||
public static readonly GUIContent rimLightLevelText = new("Rim Light Level", "Specifies Rim Light power intensity.");
|
public static readonly GUIContent rimLightLevelText = new("Rim Light Level", "Specifies Rim Light power intensity.");
|
||||||
public static readonly GUIContent rimLightClippingText = new("Rim Light Clipping", "Enable to Clip the rim light at specific level");
|
public static readonly GUIContent rimLightClippingText = new("Rim Light Clipping", "Enable to Clip the rim light at specific level");
|
||||||
@@ -46,6 +48,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
Properties.rimLightColor = FindProperty(RIM_LIGHT_COLOR);
|
Properties.rimLightColor = FindProperty(RIM_LIGHT_COLOR);
|
||||||
Properties.rimLightIntensity = FindProperty(RIM_LIGHT_INTENSITY);
|
Properties.rimLightIntensity = FindProperty(RIM_LIGHT_INTENSITY);
|
||||||
|
|
||||||
|
Properties.albedoAffectRimLight = FindProperty(ALBEDO_AFFECT_RIM_LIGHT);
|
||||||
Properties.screenSpaceRimLight = FindProperty(SCREEN_SPACE_RIM_LIGHT);
|
Properties.screenSpaceRimLight = FindProperty(SCREEN_SPACE_RIM_LIGHT);
|
||||||
Properties.rimLightLevel = FindProperty(RIM_LIGHT_LEVEL);
|
Properties.rimLightLevel = FindProperty(RIM_LIGHT_LEVEL);
|
||||||
Properties.rimLightClipping = FindProperty(RIM_LIGHT_CLIPPING);
|
Properties.rimLightClipping = FindProperty(RIM_LIGHT_CLIPPING);
|
||||||
@@ -60,6 +63,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
|
editor.ShaderProperty(Properties.rimLightColor, Styles.rimLightColorText);
|
||||||
editor.ShaderProperty(Properties.rimLightIntensity, Styles.rimLightIntensityText);
|
editor.ShaderProperty(Properties.rimLightIntensity, Styles.rimLightIntensityText);
|
||||||
|
|
||||||
|
editor.ShaderProperty(Properties.albedoAffectRimLight, Styles.albedoAffectRimLightText);
|
||||||
editor.ShaderProperty(Properties.screenSpaceRimLight, Styles.screenSpaceRimLightText);
|
editor.ShaderProperty(Properties.screenSpaceRimLight, Styles.screenSpaceRimLightText);
|
||||||
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
|
editor.ShaderProperty(Properties.rimLightLevel, Styles.rimLightLevelText);
|
||||||
|
|
||||||
|
|||||||
22
Editor/MeterialEditor/UIScopes/StockingScope.cs
Normal file
22
Editor/MeterialEditor/UIScopes/StockingScope.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Misaki.ShaderGUI;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Misaki.HdrpToon.Editor
|
||||||
|
{
|
||||||
|
public class StockingScope : MaterialUIScope<ShaderGUIExpandable>
|
||||||
|
{
|
||||||
|
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Stocking;
|
||||||
|
|
||||||
|
protected override GUIContent Header => throw new System.NotImplementedException();
|
||||||
|
|
||||||
|
public override void LoadMaterialProperties()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawContent()
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Editor/MeterialEditor/UIScopes/StockingScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/StockingScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9e91add2c76ce49448b768421496d94d
|
||||||
@@ -127,7 +127,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
if (materials.All(mat =>
|
if (materials.All(mat =>
|
||||||
{
|
{
|
||||||
var pbrMode = mat.GetPBRMode();
|
var pbrMode = mat.GetPBRMode();
|
||||||
return pbrMode != PBRMode.KKHair && pbrMode != PBRMode.Toon;
|
return pbrMode != PBRMode.Hair && pbrMode != PBRMode.Toon;
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
editor.ShaderProperty(Properties.metallic, Styles.metallicText);
|
editor.ShaderProperty(Properties.metallic, Styles.metallicText);
|
||||||
@@ -137,11 +137,11 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (materials.All(mat => mat.GetPBRMode() == PBRMode.Anisotropy || mat.GetPBRMode() == PBRMode.KKHair))
|
if (materials.All(mat => mat.GetPBRMode() == PBRMode.Anisotropy || mat.GetPBRMode() == PBRMode.Hair))
|
||||||
{
|
{
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
editor.KeywordTexturePropertySingleLine(Styles.anisotropyMapText, Properties.anisotropyMap, Properties.anisotropy);
|
editor.KeywordTexturePropertySingleLine(Styles.anisotropyMapText, Properties.anisotropyMap, Properties.anisotropy);
|
||||||
if (materials.All(mat => mat.GetPBRMode() == PBRMode.KKHair))
|
if (materials.All(mat => mat.GetPBRMode() == PBRMode.Hair))
|
||||||
{
|
{
|
||||||
editor.ShaderProperty(Properties.kkColor, Styles.kkColorText);
|
editor.ShaderProperty(Properties.kkColor, Styles.kkColorText);
|
||||||
editor.ShaderProperty(Properties.bsdfContribution, Styles.bsdfContributionText);
|
editor.ShaderProperty(Properties.bsdfContribution, Styles.bsdfContributionText);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Misaki.ShaderGUI;
|
using Misaki.ShaderGUI;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
namespace Misaki.HdrpToon.Editor
|
namespace Misaki.HdrpToon.Editor
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,22 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
{
|
{
|
||||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, (MaterialType)material.GetInteger("_Material_Type") == MaterialType.FrontHair);
|
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_SHADOW_CASTER_PASS_NAME, (MaterialType)material.GetInteger("_Material_Type") == MaterialType.FrontHair);
|
||||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, material.GetInteger("_HairBlendingTarget") == 1);
|
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, material.GetInteger("_HairBlendingTarget") == 1);
|
||||||
|
|
||||||
|
if (material.GetInteger("_AlphaCutoffEnable") > 0.0f)
|
||||||
|
{
|
||||||
|
material.SetInt("_ZTestGBuffer", (int)CompareFunction.Equal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
material.SetInt("_ZTestGBuffer", (int)CompareFunction.LessEqual);
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (surfaceType == SurfaceType.Opaque)
|
||||||
|
//{
|
||||||
|
material.SetInt("_ZTestDepthEqualForOpaque", (int)CompareFunction.Equal);
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
// material.SetInt(kZTestDepthEqualForOpaque, (int)material.GetTransparentZTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||||
|
|||||||
@@ -26,8 +26,9 @@ namespace Misaki.HdrpToon
|
|||||||
{
|
{
|
||||||
public const string RIM_LIGHT_COLOR = "_RimLightColor";
|
public const string RIM_LIGHT_COLOR = "_RimLightColor";
|
||||||
public const string RIM_LIGHT_INTENSITY = "_RimLightIntensity";
|
public const string RIM_LIGHT_INTENSITY = "_RimLightIntensity";
|
||||||
public const string RIM_LIGHT_LEVEL = "_RimLightLevel";
|
public const string ALBEDO_AFFECT_RIM_LIGHT = "_AlbedoAffectRimLight";
|
||||||
public const string SCREEN_SPACE_RIM_LIGHT = "_Screen_Space_Rim_Light";
|
public const string SCREEN_SPACE_RIM_LIGHT = "_Screen_Space_Rim_Light";
|
||||||
|
public const string RIM_LIGHT_LEVEL = "_RimLightLevel";
|
||||||
|
|
||||||
public const string LIGHT_BASE_RIM_LIGHT = "_Light_Base_Rim_Light";
|
public const string LIGHT_BASE_RIM_LIGHT = "_Light_Base_Rim_Light";
|
||||||
public const string LIGHT_DIRECTION_RIM_LIGHT_LEVEL = "_LightDirectionRimLightLevel";
|
public const string LIGHT_DIRECTION_RIM_LIGHT_LEVEL = "_LightDirectionRimLightLevel";
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ namespace Misaki.HdrpToon
|
|||||||
Off,
|
Off,
|
||||||
Standard,
|
Standard,
|
||||||
Anisotropy,
|
Anisotropy,
|
||||||
KKHair,
|
Hair,
|
||||||
|
Fabric,
|
||||||
Toon
|
Toon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ namespace Misaki.HdrpToon
|
|||||||
public enum SurfaceFeature
|
public enum SurfaceFeature
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
RimLight = 1 << 0,
|
Stocking = 1 << 0,
|
||||||
Stocking = 1 << 1,
|
RimLight = 1 << 1,
|
||||||
AngelRing = 1 << 2
|
AngelRing = 1 << 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
// Misaki.HdrpToon.SurfaceFeature: static fields
|
// Misaki.HdrpToon.SurfaceFeature: static fields
|
||||||
//
|
//
|
||||||
#define SURFACEFEATURE_NONE (0)
|
#define SURFACEFEATURE_NONE (0)
|
||||||
#define SURFACEFEATURE_RIM_LIGHT (1)
|
#define SURFACEFEATURE_STOCKING (1)
|
||||||
#define SURFACEFEATURE_STOCKING (2)
|
#define SURFACEFEATURE_RIM_LIGHT (2)
|
||||||
#define SURFACEFEATURE_ANGEL_RING (4)
|
#define SURFACEFEATURE_ANGEL_RING (4)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -82,12 +82,12 @@ Shader "HDRP/Toon"
|
|||||||
|
|
||||||
// Surface Options
|
// Surface Options
|
||||||
[Popup] _TransparentEnabled("Transparent Mode", Integer) = 0
|
[Popup] _TransparentEnabled("Transparent Mode", Integer) = 0
|
||||||
[Popup(_ALPHATEST_ON)] _AlphaCutoffEnable("Alpha Cutoff Enable", Float) = 0.0
|
[Popup(_ALPHATEST_ON)] _AlphaCutoffEnable("Alpha Cutoff Enable", Integer) = 0.0
|
||||||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
||||||
[Enum(Off, 0, Front, 1, Back, 2)] _CullMode("Cull Mode", Integer) = 2
|
[Enum(Off, 0, Front, 1, Back, 2)] _CullMode("Cull Mode", Integer) = 2
|
||||||
[KeywordEnum(Standard, SDF)] _Shading_Mode("Shading mode", Integer) = 0
|
[KeywordEnum(Standard, SDF)] _Shading_Mode("Shading mode", Integer) = 0
|
||||||
[KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", Integer) = 0
|
[KeywordEnum(Standard, FrontHair, Face, Eye)] _Material_Type("Material Type", Integer) = 0
|
||||||
[KeywordEnum(Off, Standard, Anisotropy, Hair, Toon)] _PBR_Mode("PBR Mode", Integer) = 0
|
[KeywordEnum(Off, Standard, Anisotropy, Hair, Fabric, Toon)] _PBR_Mode("PBR Mode", Integer) = 0
|
||||||
[PassPopup(HairBlendingTarget)] _HairBlendingTarget("Hair Blending Target", Integer) = 0
|
[PassPopup(HairBlendingTarget)] _HairBlendingTarget("Hair Blending Target", Integer) = 0
|
||||||
[EnumFlagsUI(Misaki.HdrpToon.SurfaceFeature, Misaki.HdrpToon)]_SurfaceFeatures("Surface Features", Integer) = 0
|
[EnumFlagsUI(Misaki.HdrpToon.SurfaceFeature, Misaki.HdrpToon)]_SurfaceFeatures("Surface Features", Integer) = 0
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ Shader "HDRP/Toon"
|
|||||||
[Popup] _Receive_Hair_Shadow("Receive Hair Shadow", Integer) = 0
|
[Popup] _Receive_Hair_Shadow("Receive Hair Shadow", Integer) = 0
|
||||||
|
|
||||||
_ShadowDistanceBias("ShadowBias", Range(0.0, 5.0)) = 0.0
|
_ShadowDistanceBias("ShadowBias", Range(0.0, 5.0)) = 0.0
|
||||||
_ShadowNormalBias("ShadowNormalBias", Range(0.0, 5.0)) = 0.0
|
_ShadowNormalBias("ShadowNormalBias", Range(-5.0, 5.0)) = 0.0
|
||||||
//_Tweak_SystemShadowsLevel("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0
|
//_Tweak_SystemShadowsLevel("Tweak_SystemShadowsLevel", Range(-0.5, 0.5)) = 0
|
||||||
|
|
||||||
// Surface Inputs
|
// Surface Inputs
|
||||||
@@ -195,6 +195,7 @@ Shader "HDRP/Toon"
|
|||||||
// Rim Light
|
// Rim Light
|
||||||
_RimLightColor("Rim Light Color", Color) = (1, 1, 1, 1)
|
_RimLightColor("Rim Light Color", Color) = (1, 1, 1, 1)
|
||||||
_RimLightIntensity("Rim Light Intensity", Range(0, 10)) = 1
|
_RimLightIntensity("Rim Light Intensity", Range(0, 10)) = 1
|
||||||
|
[ToggleUI] _AlbedoAffectRimLight("Albedo Affect Rim Light", Integer) = 0
|
||||||
[Popup] _Screen_Space_Rim_Light ("Screen Space Rim Light", Integer) = 0
|
[Popup] _Screen_Space_Rim_Light ("Screen Space Rim Light", Integer) = 0
|
||||||
_RimLightLevel("RimLight Level", Range(0, 1)) = 0.1
|
_RimLightLevel("RimLight Level", Range(0, 1)) = 0.1
|
||||||
[ToggleUI] _RimLightClipping("Rim Light Clipping", Float) = 0.25
|
[ToggleUI] _RimLightClipping("Rim Light Clipping", Float) = 0.25
|
||||||
@@ -238,7 +239,7 @@ Shader "HDRP/Toon"
|
|||||||
[ToggleUI] _UseSmoothedNormal("Use Smoothed Normal", Float) = 0
|
[ToggleUI] _UseSmoothedNormal("Use Smoothed Normal", Float) = 0
|
||||||
|
|
||||||
// Advance
|
// Advance
|
||||||
_LightIntensityMultiplier("Light_Intensity_Multiplier" , Range(0, 1)) = 0.5
|
_LightIntensityMultiplier("Light_Intensity_Multiplier" , Range(0, 3)) = 1
|
||||||
[ToggleUI] _ClampLightColor("VRChat : SceneLights HiCut_Filter", Float) = 0
|
[ToggleUI] _ClampLightColor("VRChat : SceneLights HiCut_Filter", Float) = 0
|
||||||
_Minimal_Diffuse_Contribution("Minimal_Diffuse_Contribution", Range(0, 1)) = 0.05
|
_Minimal_Diffuse_Contribution("Minimal_Diffuse_Contribution", Range(0, 1)) = 0.05
|
||||||
[KeywordEnum(Single, Full, Custom)] _Light_Loop_Mode ("Light Loop Mode", Float) = 1
|
[KeywordEnum(Single, Full, Custom)] _Light_Loop_Mode ("Light Loop Mode", Float) = 1
|
||||||
@@ -423,7 +424,7 @@ Shader "HDRP/Toon"
|
|||||||
#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"
|
||||||
|
|
||||||
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/ShaderPass/UtsShaderPassGBuffer.hlsl"
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl"
|
||||||
#pragma vertex Vert
|
#pragma vertex Vert
|
||||||
#pragma fragment Frag
|
#pragma fragment Frag
|
||||||
|
|
||||||
@@ -510,6 +511,10 @@ Shader "HDRP/Toon"
|
|||||||
|
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
|
|
||||||
|
#pragma shader_feature_local_fragment _MASKMAP
|
||||||
|
#pragma shader_feature_local _NORMALMAP
|
||||||
|
#pragma shader_feature_local_fragment _NORMALMAP_TANGENT_SPACE
|
||||||
|
|
||||||
#pragma shader_feature_local _ALPHATEST_ON
|
#pragma shader_feature_local _ALPHATEST_ON
|
||||||
|
|
||||||
// In deferred, depth only pass don't output anything.
|
// In deferred, depth only pass don't output anything.
|
||||||
@@ -707,19 +712,26 @@ Shader "HDRP/Toon"
|
|||||||
Tags { "LightMode" = "ForwardOnly" }
|
Tags { "LightMode" = "ForwardOnly" }
|
||||||
|
|
||||||
ZWrite [_ZWriteMode]
|
ZWrite [_ZWriteMode]
|
||||||
ZTest [_ZTestMode]
|
ZTest [_ZTestDepthEqualForOpaque]
|
||||||
Cull [_CullMode]
|
Cull [_CullMode]
|
||||||
Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend]
|
|
||||||
Stencil {
|
|
||||||
|
|
||||||
|
Blend [_SrcBlend] [_DstBlend], [_AlphaSrcBlend] [_AlphaDstBlend]
|
||||||
|
// ForwardOpaque | ForwardTransparent
|
||||||
|
Blend 1 One OneMinusSrcAlpha // VT feedback | VT feedback <- if VT is off, all targets below are shifted by 1
|
||||||
|
Blend 2 One [_DstBlend2] // diffuse lighting | motion vector
|
||||||
|
Blend 3 One [_DstBlend2] // SSS buffer | before refraction <- This target (or the one above if VT off) needs blending in transparent but not in opaque
|
||||||
|
Blend 4 One OneMinusSrcAlpha // | before refraction alpha
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
Ref[_StencilNo]
|
Ref[_StencilNo]
|
||||||
|
|
||||||
Comp[_StencilComp]
|
Comp[_StencilComp]
|
||||||
Pass[_StencilOpPass]
|
Pass[_StencilOpPass]
|
||||||
Fail[_StencilOpFail]
|
Fail[_StencilOpFail]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
#pragma multi_compile _ DEBUG_DISPLAY
|
#pragma multi_compile _ DEBUG_DISPLAY
|
||||||
#pragma multi_compile _ LIGHTMAP_ON
|
#pragma multi_compile _ LIGHTMAP_ON
|
||||||
@@ -752,7 +764,7 @@ Shader "HDRP/Toon"
|
|||||||
|
|
||||||
#pragma shader_feature_local_fragment _SHADING_MODE_STANDARD _SHADING_MODE_SDF
|
#pragma shader_feature_local_fragment _SHADING_MODE_STANDARD _SHADING_MODE_SDF
|
||||||
#pragma shader_feature_local_fragment _MATERIAL_TYPE_STANDARD _MATERIAL_TYPE_FRONTHAIR _MATERIAL_TYPE_FACE _MATERIAL_TYPE_EYE
|
#pragma shader_feature_local_fragment _MATERIAL_TYPE_STANDARD _MATERIAL_TYPE_FRONTHAIR _MATERIAL_TYPE_FACE _MATERIAL_TYPE_EYE
|
||||||
#pragma shader_feature_local_fragment _PBR_MODE_OFF _PBR_MODE_STANDARD _PBR_MODE_ANISOTROPY _PBR_MODE_HAIR _PBR_MODE_TOON
|
#pragma shader_feature_local_fragment _PBR_MODE_OFF _PBR_MODE_STANDARD _PBR_MODE_ANISOTROPY _PBR_MODE_HAIR _PBR_MODE_FABRIC _PBR_MODE_TOON
|
||||||
|
|
||||||
#pragma shader_feature_local_fragment _USE_SHADING_RAMP_MAP_ON
|
#pragma shader_feature_local_fragment _USE_SHADING_RAMP_MAP_ON
|
||||||
|
|
||||||
@@ -789,10 +801,6 @@ Shader "HDRP/Toon"
|
|||||||
#define USE_FPTL_LIGHTLIST
|
#define USE_FPTL_LIGHTLIST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(DEBUG_DISPLAY)
|
|
||||||
#define SHADERPASS_FORWARD_BYPASS_ALPHA_TEST
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
|
||||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"
|
||||||
|
|
||||||
@@ -890,7 +898,7 @@ Shader "HDRP/Toon"
|
|||||||
Tags { "LightMode" = "Outline" }
|
Tags { "LightMode" = "Outline" }
|
||||||
|
|
||||||
Cull Front
|
Cull Front
|
||||||
Blend Off
|
Blend SrcAlpha OneMinusSrcAlpha
|
||||||
|
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,57 @@ float3 UtsComputeDiffuseColor(float3 baseColor, float metallic)
|
|||||||
return UtsComputeDiffuseColor(baseColor, metallic, 0.0);
|
return UtsComputeDiffuseColor(baseColor, metallic, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Random(float2 uv)
|
||||||
|
{
|
||||||
|
return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453);
|
||||||
|
}
|
||||||
|
|
||||||
|
float unity_noise_interpolate (float a, float b, float t)
|
||||||
|
{
|
||||||
|
return (1.0-t)*a + (t*b);
|
||||||
|
}
|
||||||
|
|
||||||
|
float ValueNoise (float2 uv)
|
||||||
|
{
|
||||||
|
float2 i = floor(uv);
|
||||||
|
float2 f = frac(uv);
|
||||||
|
f = f * f * (3.0 - 2.0 * f);
|
||||||
|
|
||||||
|
uv = abs(frac(uv) - 0.5);
|
||||||
|
float2 c0 = i + float2(0.0, 0.0);
|
||||||
|
float2 c1 = i + float2(1.0, 0.0);
|
||||||
|
float2 c2 = i + float2(0.0, 1.0);
|
||||||
|
float2 c3 = i + float2(1.0, 1.0);
|
||||||
|
float r0 = Random(c0);
|
||||||
|
float r1 = Random(c1);
|
||||||
|
float r2 = Random(c2);
|
||||||
|
float r3 = Random(c3);
|
||||||
|
|
||||||
|
float bottomOfGrid = unity_noise_interpolate(r0, r1, f.x);
|
||||||
|
float topOfGrid = unity_noise_interpolate(r2, r3, f.x);
|
||||||
|
float t = unity_noise_interpolate(bottomOfGrid, topOfGrid, f.y);
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
float SimpleNoise(float2 UV, float Scale)
|
||||||
|
{
|
||||||
|
float t = 0.0;
|
||||||
|
|
||||||
|
float freq = pow(2.0, float(0));
|
||||||
|
float amp = pow(0.5, float(3-0));
|
||||||
|
t += ValueNoise(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
|
||||||
|
|
||||||
|
freq = pow(2.0, float(1));
|
||||||
|
amp = pow(0.5, float(3-1));
|
||||||
|
t += ValueNoise(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
|
||||||
|
|
||||||
|
freq = pow(2.0, float(2));
|
||||||
|
amp = pow(0.5, float(3-2));
|
||||||
|
t += ValueNoise(float2(UV.x*Scale/freq, UV.y*Scale/freq))*amp;
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
#define SampleRampSignalLine(texture, u) (SAMPLE_TEXTURE2D_LOD(texture, s_linear_clamp_sampler, float2(u, 0.5), 0))
|
#define SampleRampSignalLine(texture, u) (SAMPLE_TEXTURE2D_LOD(texture, s_linear_clamp_sampler, float2(u, 0.5), 0))
|
||||||
|
|
||||||
// Exposure
|
// Exposure
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ void UtsGetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInput
|
|||||||
#else
|
#else
|
||||||
float alphaCutoff = _AlphaCutoff;
|
float alphaCutoff = _AlphaCutoff;
|
||||||
#endif
|
#endif
|
||||||
|
// clip(-0.1);
|
||||||
GENERIC_ALPHA_TEST(alphaValue, alphaCutoff);
|
GENERIC_ALPHA_TEST(alphaValue, alphaCutoff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,22 @@
|
|||||||
#ifndef UTS_SURFACE_FEATURE_EVALUATION
|
#ifndef UTS_SURFACE_FEATURE_EVALUATION
|
||||||
#define UTS_SURFACE_FEATURE_EVALUATION
|
#define UTS_SURFACE_FEATURE_EVALUATION
|
||||||
|
|
||||||
|
void UtsEvaluateLighting_Stocking(FragInputs input, PositionInputs posInput, float3 normalWS, float3 V, inout AggregateLighting aggregateLighting)
|
||||||
|
{
|
||||||
|
float NdotV = saturate(dot(normalize(V), normalWS));
|
||||||
|
|
||||||
|
NdotV = pow(NdotV, 2.0);
|
||||||
|
|
||||||
|
// TODO: Move sparkle to bsdf evaluation?
|
||||||
|
// float sparkle = Random(posInput.positionNDC.xy);
|
||||||
|
// sparkle = step(0.995, sparkle);
|
||||||
|
// float noise = SimpleNoise(posInput.positionNDC.xy, 500.0);
|
||||||
|
// sparkle = noise < sparkle ? 1.0 : 0.0;
|
||||||
|
|
||||||
|
aggregateLighting.direct.diffuse *= NdotV;
|
||||||
|
// aggregateLighting.direct.specular = saturate(aggregateLighting.direct.specular + sparkle * (1.0 - NdotV) * 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
DirectLighting UtsEvaluateLighting_RimLight(PositionInputs posInput, UtsBSDFData bsdfData, PreLightData preLightData
|
DirectLighting UtsEvaluateLighting_RimLight(PositionInputs posInput, UtsBSDFData bsdfData, PreLightData preLightData
|
||||||
#if _LIGHT_BASE_RIM_LIGHT_ON
|
#if _LIGHT_BASE_RIM_LIGHT_ON
|
||||||
, float3 L, float3 lightColor
|
, float3 L, float3 lightColor
|
||||||
@@ -11,6 +27,7 @@ DirectLighting UtsEvaluateLighting_RimLight(PositionInputs posInput, UtsBSDFData
|
|||||||
ZERO_INITIALIZE(DirectLighting, lighting);
|
ZERO_INITIALIZE(DirectLighting, lighting);
|
||||||
|
|
||||||
float3 rimLightColor = _RimLightColor.rgb * _RimLightIntensity;
|
float3 rimLightColor = _RimLightColor.rgb * _RimLightIntensity;
|
||||||
|
rimLightColor = lerp(rimLightColor, rimLightColor * bsdfData.diffuseColor.rgb, _AlbedoAffectRimLight * _RimLightColor.a);
|
||||||
|
|
||||||
#if _SCREEN_SPACE_RIM_LIGHT_ON
|
#if _SCREEN_SPACE_RIM_LIGHT_ON
|
||||||
float3 normalVS = normalize(mul((float3x3)UNITY_MATRIX_V, bsdfData.geomNormalWS));
|
float3 normalVS = normalize(mul((float3x3)UNITY_MATRIX_V, bsdfData.geomNormalWS));
|
||||||
|
|||||||
@@ -53,6 +53,17 @@ bool UtsUseScreenSpaceShadow(DirectionalLightData light, float3 normalWS)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsNonZeroBSDF(float3 L, UtsBSDFData bsdfData)
|
||||||
|
{
|
||||||
|
#if _MATERIAL_TYPE_FACE
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
float NdotL = dot(bsdfData.normalWS, L);
|
||||||
|
|
||||||
|
return NdotL > 0.0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bsdfData, BuiltinData builtinData,
|
void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bsdfData, BuiltinData builtinData,
|
||||||
float3 V, uint featureFlags, out LightLoopOutput lightLoopOutput)
|
float3 V, uint featureFlags, out LightLoopOutput lightLoopOutput)
|
||||||
{
|
{
|
||||||
@@ -87,6 +98,7 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
|||||||
float3 L = -light.forward;
|
float3 L = -light.forward;
|
||||||
|
|
||||||
// Is it worth sampling the shadow map?
|
// Is it worth sampling the shadow map?
|
||||||
|
// Should we skip it if NdotL is negative? (i.e. transmission)
|
||||||
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0))
|
if ((light.lightDimmer > 0) && (light.shadowDimmer > 0))
|
||||||
{
|
{
|
||||||
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
|
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
|
||||||
@@ -345,6 +357,11 @@ void UtsLightLoop(FragInputs fragInputs, PositionInputs posInput, UtsBSDFData bs
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_STOCKING))
|
||||||
|
{
|
||||||
|
UtsEvaluateLighting_Stocking(fragInputs, posInput, bsdfData.normalWS, V, aggregateLighting);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _LIGHT_BASE_RIM_LIGHT_ON
|
#ifndef _LIGHT_BASE_RIM_LIGHT_ON
|
||||||
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_RIM_LIGHT))
|
if (HasFlag(bsdfData.surfaceFeatures, SURFACEFEATURE_RIM_LIGHT))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,8 +57,14 @@ float3 ComputeSpecularTerm(UtsBSDFData bsdfData, PreLightData preLightData, floa
|
|||||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||||
DV = D_KajiyaKay(t, H, specularExponent);
|
DV = D_KajiyaKay(t, H, specularExponent);
|
||||||
|
|
||||||
float normalizeSpec = DV * rcp(specularExponent + 2) * 2 * PI;
|
float normalizeSpec = DV * rcp(specularExponent + 2.0) * TWO_PI;
|
||||||
DV = DV * normalizeSpec * _KKColor.rgb;
|
DV = DV * normalizeSpec * _KKColor.rgb;
|
||||||
|
#elif _PBR_MODE_FABRIC
|
||||||
|
float D = D_Charlie(NdotH, bsdfData.roughnessT);
|
||||||
|
// V_Charlie is expensive, use approx with V_Ashikhmin instead
|
||||||
|
// float V = V_Charlie(NdotL, clampedNdotV, bsdfData.roughness);
|
||||||
|
float Vis = V_Ashikhmin(NdotL, clampedNdotV);
|
||||||
|
DV = D * Vis;
|
||||||
#elif _PBR_MODE_TOON
|
#elif _PBR_MODE_TOON
|
||||||
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
float specularExponent = RoughnessToBlinnPhongSpecularExponent(PerceptualRoughnessToRoughness(bsdfData.perceptualRoughness));
|
||||||
DV = pow(NdotH, 5.0 * specularExponent);
|
DV = pow(NdotH, 5.0 * specularExponent);
|
||||||
@@ -139,12 +145,12 @@ DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, Pr
|
|||||||
|
|
||||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(halfLambert * shadow.x, rampMask), _ShadingIndex).rgb;
|
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(halfLambert * shadow.x, rampMask), _ShadingIndex).rgb;
|
||||||
|
|
||||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
diffuseTerm = bsdfData.diffuseColor * rampColor * INV_PI;
|
||||||
specularTerm *= saturate(NdotL) * sharpShadow;
|
specularTerm *= saturate(NdotL) * sharpShadow;
|
||||||
#elif _SHADING_MODE_SDF
|
#elif _SHADING_MODE_SDF
|
||||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(sdfShadowMask * sharpShadow.x, rampMask), _ShadingIndex).rgb;
|
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(sdfShadowMask * sharpShadow.x, rampMask), _ShadingIndex).rgb;
|
||||||
|
|
||||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
diffuseTerm = bsdfData.diffuseColor * rampColor * INV_PI;
|
||||||
specularTerm = (specularTerm + sdfHighlight) * sdfShadowMask * sharpShadow;
|
specularTerm = (specularTerm + sdfHighlight) * sdfShadowMask * sharpShadow;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@@ -159,12 +165,12 @@ DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, Pr
|
|||||||
// float secondColorFeatherForMask = lerp(_2ndShadeColorFeather, 0.0, max(_SecondShadeOverridden, _ComposerMaskMode));
|
// float secondColorFeatherForMask = lerp(_2ndShadeColorFeather, 0.0, max(_SecondShadeOverridden, _ComposerMaskMode));
|
||||||
float firstShadeMask = saturate((halfLambert - (_2ndShadeColorStep - _2ndShadeColorFeather)) / (_2ndShadeColorStep - (_2ndShadeColorStep - _2ndShadeColorFeather)));
|
float firstShadeMask = saturate((halfLambert - (_2ndShadeColorStep - _2ndShadeColorFeather)) / (_2ndShadeColorStep - (_2ndShadeColorStep - _2ndShadeColorFeather)));
|
||||||
|
|
||||||
diffuseTerm = lerp(lerp(bsdfData.secondShadingDiffuseColor, bsdfData.firstShadingDiffuseColor, firstShadeMask), bsdfData.diffuseColor, baseShadeMask);
|
diffuseTerm = lerp(lerp(bsdfData.secondShadingDiffuseColor, bsdfData.firstShadingDiffuseColor, firstShadeMask), bsdfData.diffuseColor, baseShadeMask) * INV_PI;
|
||||||
specularTerm *= baseShadeMask;
|
specularTerm *= baseShadeMask;
|
||||||
#elif _SHADING_MODE_SDF
|
#elif _SHADING_MODE_SDF
|
||||||
float shadeMask = sdfShadowMask * sdfTexture.b * sharpShadow.x;
|
float shadeMask = sdfShadowMask * sdfTexture.b * sharpShadow.x;
|
||||||
|
|
||||||
diffuseTerm = lerp(bsdfData.firstShadingDiffuseColor, bsdfData.diffuseColor, shadeMask);
|
diffuseTerm = lerp(bsdfData.firstShadingDiffuseColor, bsdfData.diffuseColor, shadeMask) * INV_PI;
|
||||||
specularTerm = (specularTerm + sdfHighlight) * shadeMask;
|
specularTerm = (specularTerm + sdfHighlight) * shadeMask;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ float GetHairShadow(PositionInputs posInput, float3 L)
|
|||||||
float2 shadowLength = float2(shadowLengthY * 2.0f, shadowLengthY);
|
float2 shadowLength = float2(shadowLengthY * 2.0f, shadowLengthY);
|
||||||
|
|
||||||
float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
float3 cameraDirOS = normalize(TransformWorldToObject(GetCameraPositionWS()));
|
||||||
float cameraDirFactor = 1 - smoothstep(0.1, 0.9, cameraDirOS.y);
|
float cameraDirFactor = 1.0 - smoothstep(0.1, 0.9, cameraDirOS.y);
|
||||||
shadowLength.y *= cameraDirFactor;
|
// shadowLength.y *= cameraDirFactor;
|
||||||
|
|
||||||
// TODO: sample point is still shifting when fov change.
|
// TODO: sample point is still shifting when fov change.
|
||||||
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.
|
float2 samplingPoint = (posInput.positionSS + shadowLength * viewLightDir.xy) * _ScreenSize.zw; // Use 1080p as the reference resolution to achieve consistent shadow lengths across various screen resolutions.
|
||||||
|
|
||||||
float2 scaledUVs = samplingPoint * _RTHandleScale.xy; // 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 * _RTHandleScale.xy; // 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 hairShadow = SAMPLE_TEXTURE2D_SHADOW(_HairShadowTex, s_linear_clamp_compare_sampler, float3(scaledUVs, posInput.deviceDepth + _HairShadowDepthBias)).r;
|
float hairShadow = SAMPLE_TEXTURE2D_SHADOW(_HairShadowTex, s_linear_clamp_compare_sampler, float3(scaledUVs, posInput.deviceDepth + _HairShadowDepthBias)).r;
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ float _SSRWeight;
|
|||||||
//Rim Light
|
//Rim Light
|
||||||
float4 _RimLightColor;
|
float4 _RimLightColor;
|
||||||
float _RimLightIntensity;
|
float _RimLightIntensity;
|
||||||
|
half _AlbedoAffectRimLight;
|
||||||
float _RimLightLevel;
|
float _RimLightLevel;
|
||||||
half _RimLightClipping;
|
half _RimLightClipping;
|
||||||
float _RimLightClippingLevel;
|
float _RimLightClippingLevel;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
//Unity Toon Shader/HDRP
|
#include "Packages/com.misaki.hdrp-toon/Runtime/Shaders/Includes/Common/UtsLitData.hlsl"
|
||||||
//nobuyuki@unity3d.com
|
|
||||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
|
||||||
|
|
||||||
#define APPROXIMATE_POLY_LIGHT_AS_SPHERE_LIGHT
|
#define APPROXIMATE_POLY_LIGHT_AS_SPHERE_LIGHT
|
||||||
|
|
||||||
@@ -97,16 +95,15 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
||||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
||||||
|
|
||||||
|
|
||||||
#ifdef VARYINGS_NEED_POSITION_WS
|
#ifdef VARYINGS_NEED_POSITION_WS
|
||||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
||||||
|
|
||||||
#ifdef MATERIAL_TYPE_EYE
|
#ifdef MATERIAL_TYPE_EYE
|
||||||
// Must have view Dir to work
|
// Must have view Dir to work
|
||||||
float2 viewT = TransformObjectToTangent(V, input.tangentToWorld);
|
float2 viewT = TransformObjectToTangent(V, input.tangentToWorld);
|
||||||
float2 parallaxOffset = viewT;
|
float2 parallaxOffset = viewT;
|
||||||
parallaxOffset.y = -parallaxOffset.y;
|
parallaxOffset.y = -parallaxOffset.y;
|
||||||
input.texCoord0.xy = clamp(input.texCoord0.xy -_EyeParallaxAmount * parallaxOffset, 0, 1);
|
input.texCoord0.xy = clamp(input.texCoord0.xy -_EyeParallaxAmount * parallaxOffset, 0, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -121,7 +118,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
|
|
||||||
SurfaceData tempSurfaceData;
|
SurfaceData tempSurfaceData;
|
||||||
BuiltinData builtinData;
|
BuiltinData builtinData;
|
||||||
GetSurfaceAndBuiltinData(input, V, posInput, tempSurfaceData, builtinData);
|
UtsGetSurfaceAndBuiltinData(input, V, posInput, tempSurfaceData, builtinData);
|
||||||
UTSSurfaceData surfaceData = GetUTSSurfaceData(input, V);
|
UTSSurfaceData surfaceData = GetUTSSurfaceData(input, V);
|
||||||
UtsBSDFData bsdfData = ConvertUTSSurfaceDataToUTSBSDFData(surfaceData);
|
UtsBSDFData bsdfData = ConvertUTSSurfaceDataToUTSBSDFData(surfaceData);
|
||||||
|
|
||||||
@@ -132,11 +129,9 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
context.shadowContext = InitShadowContext();
|
context.shadowContext = InitShadowContext();
|
||||||
context.shadowValue = 1;
|
context.shadowValue = 1;
|
||||||
context.sampleReflection = 0.0;
|
context.sampleReflection = 0.0;
|
||||||
#if UNITY_VERSION >= 202120 && UNITY_VERSION < 202320
|
|
||||||
context.splineVisibility = -1;
|
|
||||||
#endif
|
|
||||||
#ifdef APPLY_FOG_ON_SKY_REFLECTIONS
|
#ifdef APPLY_FOG_ON_SKY_REFLECTIONS
|
||||||
context.positionWS = posInput.positionWS;
|
context.positionWS = posInput.positionWS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// With XR single-pass and camera-relative: offset position to do lighting computations from the combined center view (original camera matrix).
|
// With XR single-pass and camera-relative: offset position to do lighting computations from the combined center view (original camera matrix).
|
||||||
@@ -151,18 +146,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
|
|
||||||
UtsLightLoop(input, posInput, bsdfData, builtinData, V, featureFlags, lightLoopOutput);
|
UtsLightLoop(input, posInput, bsdfData, builtinData, V, featureFlags, lightLoopOutput);
|
||||||
|
|
||||||
float3 finalColor = lightLoopOutput.diffuseLighting + lightLoopOutput.specularLighting;
|
outColor = ApplyBlendMode(lightLoopOutput.diffuseLighting, lightLoopOutput.specularLighting, builtinData.opacity);
|
||||||
|
|
||||||
|
|
||||||
// #if _SURFACE_TYPE_TRANSPARENT
|
|
||||||
// float alpha = channelAlpha;
|
|
||||||
// outColor = EvaluateAtmosphericScattering(posInput, V, float4(finalColor, 1));
|
|
||||||
// #else
|
|
||||||
// float alpha = lerp(1.0, channelAlpha, _AlphaCutoffEnable);
|
|
||||||
// #endif
|
|
||||||
//
|
|
||||||
// alpha = lerp(alpha, step(_AlphaCutoff, alpha), _AlphaCutoffEnable);
|
|
||||||
outColor = float4(finalColor, 1.0);
|
|
||||||
|
|
||||||
#if _MATERIAL_TYPE_FRONTHAIR && ENABLE_UTS_HAIR_BLENDING
|
#if _MATERIAL_TYPE_FRONTHAIR && ENABLE_UTS_HAIR_BLENDING
|
||||||
float2 screenUV = posInput.positionSS; // * _HairBlendingRTHandleScale.xy; // Why we don't need to scale? Does unity handle it internally?
|
float2 screenUV = posInput.positionSS; // * _HairBlendingRTHandleScale.xy; // Why we don't need to scale? Does unity handle it internally?
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Misaki.HdrpToon
|
|||||||
public BoolParameter enableHairShadow = new(false);
|
public BoolParameter enableHairShadow = new(false);
|
||||||
public ClampedFloatParameter shadowDistance = new(5.0f, 0.0f, 20.0f);
|
public ClampedFloatParameter shadowDistance = new(5.0f, 0.0f, 20.0f);
|
||||||
public ClampedFloatParameter shadowDistanceScale = new(0.5f, 0.0f, 1.0f);
|
public ClampedFloatParameter shadowDistanceScale = new(0.5f, 0.0f, 1.0f);
|
||||||
public ClampedFloatParameter shadowDepthBias = new(0f, 0.0f, 0.01f);
|
public ClampedFloatParameter shadowDepthBias = new(0f, -0.01f, 0.01f);
|
||||||
public FloatParameter shadowFadeIn = new(45f);
|
public FloatParameter shadowFadeIn = new(45f);
|
||||||
public FloatParameter shadowFadeOut = new(50f);
|
public FloatParameter shadowFadeOut = new(50f);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.misaki.hdrp-toon",
|
"name": "com.misaki.hdrp-toon",
|
||||||
"version": "2.1.0",
|
"version": "3.0.1-pre",
|
||||||
"displayName": "HDRP Toon",
|
"displayName": "HDRP Toon",
|
||||||
"description": "A high quality toon shader for High Definition Render Pipeline(HDRP)",
|
"description": "A high quality toon shader for High Definition Render Pipeline(HDRP)",
|
||||||
"changelogUrl": "https://git.personalnas.com/Misaki/hdrp-toon/src/branch/develop/CHANGELOG.md",
|
"changelogUrl": "https://git.personalnas.com/Misaki/hdrp-toon/src/branch/develop/CHANGELOG.md",
|
||||||
@@ -21,6 +21,6 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"com.unity.render-pipelines.high-definition": "17.0.0",
|
"com.unity.render-pipelines.high-definition": "17.0.0",
|
||||||
"com.misaki.shader-gui": "1.1.2"
|
"com.misaki.shader-gui": "1.1.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user