Added SurfaceFeatureFlags;
Added OutlineScope; Added AngelRingScope; Change up Outline pass
This commit is contained in:
44
Editor/MeterialEditor/UIScopes/AngelRingScope.cs
Normal file
44
Editor/MeterialEditor/UIScopes/AngelRingScope.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using Misaki.ShaderGUI;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Misaki.HdrpToon.Editor
|
||||||
|
{
|
||||||
|
internal class AngelRingScope : MaterialUIScope<ShaderGUIExpandable>
|
||||||
|
{
|
||||||
|
private static class Properties
|
||||||
|
{
|
||||||
|
public static MaterialProperty angelRingColor;
|
||||||
|
public static MaterialProperty angelRingColorMap;
|
||||||
|
public static MaterialProperty angelRingIntensity;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Styles
|
||||||
|
{
|
||||||
|
public static readonly GUIContent angelRingColorText = new("Angel Ring Color", "Specifies the color of the angel ring.");
|
||||||
|
public static readonly GUIContent angelRingIntensityText = new("Angel Ring Intensity", "Specifies the intensity of the angel ring.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ShowSection => owner.GetUIScope<SurfaceOptionsScope>().HasFeature(SurfaceFeatureFlags.AngelRing);
|
||||||
|
|
||||||
|
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.AngelRing;
|
||||||
|
|
||||||
|
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Angel Ring Settings");
|
||||||
|
|
||||||
|
public override void LoadMaterialProperties()
|
||||||
|
{
|
||||||
|
Properties.angelRingColor = FindProperty("_AngelRingColor");
|
||||||
|
Properties.angelRingColorMap = FindProperty("_AngelRingColorMap");
|
||||||
|
Properties.angelRingIntensity = FindProperty("_AngelRingIntensity");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawContent()
|
||||||
|
{
|
||||||
|
editor.TexturePropertySingleLine(Styles.angelRingColorText, Properties.angelRingColorMap, Properties.angelRingColor);
|
||||||
|
editor.ShaderProperty(Properties.angelRingIntensity, Styles.angelRingIntensityText);
|
||||||
|
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
editor.TextureScaleOffsetProperty(Properties.angelRingColorMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Editor/MeterialEditor/UIScopes/AngelRingScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/AngelRingScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f21124eb2f73ac14e8cda9a0340191cd
|
||||||
65
Editor/MeterialEditor/UIScopes/OutlineScope.cs
Normal file
65
Editor/MeterialEditor/UIScopes/OutlineScope.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
using Misaki.ShaderGUI;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Misaki.HdrpToon.Editor
|
||||||
|
{
|
||||||
|
internal class OutlineScope : MaterialUIScope<ShaderGUIExpandable>
|
||||||
|
{
|
||||||
|
private static class Properties
|
||||||
|
{
|
||||||
|
public static MaterialProperty outlineWidth;
|
||||||
|
public static MaterialProperty outlineWidthMap;
|
||||||
|
|
||||||
|
public static MaterialProperty outlineColor;
|
||||||
|
public static MaterialProperty outlineColorMap;
|
||||||
|
public static MaterialProperty albedoAffectOutline;
|
||||||
|
|
||||||
|
public static MaterialProperty fadeIn;
|
||||||
|
public static MaterialProperty fadeOut;
|
||||||
|
|
||||||
|
public static MaterialProperty useSmoothedNormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Styles
|
||||||
|
{
|
||||||
|
public static readonly GUIContent outlineWidthText = new("Outline Width", "Specifies the width of the outline.");
|
||||||
|
public static readonly GUIContent outlineColorText = new("Outline Color", "Specifies the color of the outline.");
|
||||||
|
public static readonly GUIContent albedoAffectOutlineText = new("Albedo Affect Outline", "Enable to affect the outline color with the albedo color.");
|
||||||
|
public static readonly GUIContent fadeInText = new("Fade In Distance", "Specify the nearest distance, where the outline width changes with the distance between the camera and the object. The outline will be the maximum width at this distance.");
|
||||||
|
public static readonly GUIContent fadeOutText = new("Fade Out Distance", "Specify the furthest distance, where the outline width changes with the distance between the camera and the object. The outline will be zero at this distance.");
|
||||||
|
public static readonly GUIContent useSmoothedNormalText = new("Use Smoothed Normal", "Enable to use smoothed normal(that packed in uv2) for outline calculation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool ShowSection => owner.GetUIScope<SurfaceOptionsScope>().HasFeature(SurfaceFeatureFlags.Outline);
|
||||||
|
|
||||||
|
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.Outline;
|
||||||
|
|
||||||
|
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Outline Settings");
|
||||||
|
|
||||||
|
public override void LoadMaterialProperties()
|
||||||
|
{
|
||||||
|
Properties.outlineWidth = FindProperty("_OutlineWidth");
|
||||||
|
Properties.outlineWidthMap = FindProperty("_OutlineWidthMap");
|
||||||
|
|
||||||
|
Properties.outlineColor = FindProperty("_OutlineColor");
|
||||||
|
Properties.outlineColorMap = FindProperty("_OutlineColorMap");
|
||||||
|
Properties.albedoAffectOutline = FindProperty("_AlbedoAffectOutline");
|
||||||
|
|
||||||
|
Properties.fadeIn = FindProperty("_OutlineFadeIn");
|
||||||
|
Properties.fadeOut = FindProperty("_OutlineFadeOut");
|
||||||
|
|
||||||
|
Properties.useSmoothedNormal = FindProperty("_UseSmoothedNormal");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawContent()
|
||||||
|
{
|
||||||
|
editor.TexturePropertySingleLine(Styles.outlineWidthText, Properties.outlineWidthMap, Properties.outlineWidth);
|
||||||
|
editor.TexturePropertySingleLine(Styles.outlineColorText, Properties.outlineColorMap, Properties.outlineColor);
|
||||||
|
editor.ShaderProperty(Properties.albedoAffectOutline, Styles.albedoAffectOutlineText);
|
||||||
|
editor.ShaderProperty(Properties.fadeIn, Styles.fadeInText);
|
||||||
|
editor.ShaderProperty(Properties.fadeOut, Styles.fadeOutText);
|
||||||
|
editor.ShaderProperty(Properties.useSmoothedNormal, Styles.useSmoothedNormalText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Editor/MeterialEditor/UIScopes/OutlineScope.cs.meta
Normal file
2
Editor/MeterialEditor/UIScopes/OutlineScope.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ac42903bc14e05f41a9a06d1e6cf5cd9
|
||||||
@@ -19,6 +19,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
|
|
||||||
public static MaterialProperty receiveHairShadow;
|
public static MaterialProperty receiveHairShadow;
|
||||||
public static MaterialProperty hairBlendingTarget;
|
public static MaterialProperty hairBlendingTarget;
|
||||||
|
public static MaterialProperty surfaceFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Styles
|
private static class Styles
|
||||||
@@ -34,12 +35,18 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
|
|
||||||
public static readonly GUIContent receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
public static readonly GUIContent receiveHairShadowText = new("Receive Hair Shadow", "Enable to receive shadow from hair shadow caster");
|
||||||
public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
|
public static readonly GUIContent hairBlendingTargetText = new("Hair Blending Target", "Enable to be blended with hair");
|
||||||
|
public static readonly GUIContent surfaceFeaturesText = new("Surface Features", "Specifies the surface features.");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
|
protected override ShaderGUIExpandable ExpandableBit => ShaderGUIExpandable.SurfaceOptions;
|
||||||
|
|
||||||
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
protected override GUIContent Header => EditorGUIUtility.TrTextContent("Surface Options");
|
||||||
|
|
||||||
|
public bool HasFeature(SurfaceFeatureFlags feature)
|
||||||
|
{
|
||||||
|
return ((SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue & feature) == feature;
|
||||||
|
}
|
||||||
|
|
||||||
public override void LoadMaterialProperties()
|
public override void LoadMaterialProperties()
|
||||||
{
|
{
|
||||||
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
Properties.transparentMode = FindProperty("_TransparentEnabled");
|
||||||
@@ -53,6 +60,7 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
|
|
||||||
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
Properties.receiveHairShadow = FindProperty("_Receive_Hair_Shadow");
|
||||||
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
Properties.hairBlendingTarget = FindProperty("_HairBlendingTarget");
|
||||||
|
Properties.surfaceFeatures = FindProperty("_SurfaceFeatures");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DrawContent()
|
protected override void DrawContent()
|
||||||
@@ -82,6 +90,18 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f);
|
material.SetShaderPassEnabled(UtsShaderPassName.HAIR_BLENDING_TARGET_PASS_NAME, Properties.hairBlendingTarget.floatValue == 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var surfaceFeatures = (SurfaceFeatureFlags)Properties.surfaceFeatures.floatValue;
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
surfaceFeatures = (SurfaceFeatureFlags)EditorGUILayout.EnumFlagsField(Styles.surfaceFeaturesText, surfaceFeatures);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
Properties.surfaceFeatures.floatValue = (float)surfaceFeatures;
|
||||||
|
foreach (var material in GetMaterials())
|
||||||
|
{
|
||||||
|
material.SetShaderPassEnabled(UtsShaderPassName.OUTLINE_PASS_NAME, HasFeature(SurfaceFeatureFlags.Outline));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2413,14 +2413,14 @@ namespace UnityEditor.Rendering.Toon
|
|||||||
{
|
{
|
||||||
material.SetFloat(ShaderPropOutline, 0);
|
material.SetFloat(ShaderPropOutline, 0);
|
||||||
//The keywords on the UTCS_Outline.cginc side are also toggled around.
|
//The keywords on the UTCS_Outline.cginc side are also toggled around.
|
||||||
material.EnableKeyword("_OUTLINE_NML");
|
material.EnableKeyword("_OUTLINE_MODE_NML");
|
||||||
material.DisableKeyword("_OUTLINE_POS");
|
material.DisableKeyword("_OUTLINE_MODE_POS");
|
||||||
}
|
}
|
||||||
else if (m_outlineMode == OutlineMode.PositionScaling)
|
else if (m_outlineMode == OutlineMode.PositionScaling)
|
||||||
{
|
{
|
||||||
material.SetFloat(ShaderPropOutline, 1);
|
material.SetFloat(ShaderPropOutline, 1);
|
||||||
material.EnableKeyword("_OUTLINE_POS");
|
material.EnableKeyword("_OUTLINE_MODE_POS");
|
||||||
material.DisableKeyword("_OUTLINE_NML");
|
material.DisableKeyword("_OUTLINE_MODE_NML");
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI_FloatProperty(material, Styles.outlineWidthText);
|
GUI_FloatProperty(material, Styles.outlineWidthText);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
private void OnInitialize(MaterialEditor materialEditor, MaterialProperty[] properties)
|
private void OnInitialize(MaterialEditor materialEditor, MaterialProperty[] properties)
|
||||||
{
|
{
|
||||||
AddUIScope(new SurfaceOptionsScope());
|
AddUIScope(new SurfaceOptionsScope());
|
||||||
|
AddUIScope(new AngelRingScope());
|
||||||
|
AddUIScope(new OutlineScope());
|
||||||
|
|
||||||
Initialize(materialEditor, properties);
|
Initialize(materialEditor, properties);
|
||||||
|
|
||||||
|
|||||||
14
Runtime/Models/SurfaceFeatureFlags.cs
Normal file
14
Runtime/Models/SurfaceFeatureFlags.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Misaki.HdrpToon
|
||||||
|
{
|
||||||
|
[Flags]
|
||||||
|
public enum SurfaceFeatureFlags : uint
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
RimLight = 1 << 0,
|
||||||
|
Stocking = 1 << 1,
|
||||||
|
AngelRing = 1 << 2,
|
||||||
|
Outline = 1 << 3,
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Runtime/Models/SurfaceFeatureFlags.cs.meta
Normal file
2
Runtime/Models/SurfaceFeatureFlags.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 737ea728a50a7664b90cba3dd3e21249
|
||||||
@@ -276,6 +276,24 @@ Shader "HDRP/Toon"
|
|||||||
[KeywordEnum(Off, Standard, Anisotropy, Hair, Toon)] _PBR_Mode("PBR MODE", int) = 0
|
[KeywordEnum(Off, Standard, Anisotropy, Hair, Toon)] _PBR_Mode("PBR MODE", int) = 0
|
||||||
[Toggle] _Receive_Hair_Shadow("ReceiveHairShadow", Float) = 0
|
[Toggle] _Receive_Hair_Shadow("ReceiveHairShadow", Float) = 0
|
||||||
[ToggleUI] _HairBlendingTarget("HairBlendingTarget", Float) = 0
|
[ToggleUI] _HairBlendingTarget("HairBlendingTarget", Float) = 0
|
||||||
|
[HideInInspector] _SurfaceFeatures("SurfaceFeatures", Float) = 0
|
||||||
|
|
||||||
|
// Angel Rings
|
||||||
|
_AngelRingColor("AngelRingColor", Color) = (1, 1, 1, 1)
|
||||||
|
_AngelRingColorMap("AngelRingColorMap", 2D) = "black" {}
|
||||||
|
_AngelRingIntensity("AngelRingIntensity", Range(0, 10)) = 1
|
||||||
|
|
||||||
|
// Outline
|
||||||
|
_OutlineWidth("OutlineWidth", Float) = 0
|
||||||
|
_OutlineWidthMap("OutlineTex", 2D) = "white" {}
|
||||||
|
_OutlineColor("OutlineColor", Color) = (0.5, 0.5, 0.5, 1)
|
||||||
|
_OutlineColorMap("OutlineColorMap", 2D) = "white" {}
|
||||||
|
[Toggle(_)] _AlbedoAffectOutline("AlbedoAffectOutline", Float) = 0
|
||||||
|
_OutlineFadeIn("_OutlineFadeIn", Float) = 50
|
||||||
|
_OutlineFadeOut("_OutlineFadeOut", Float) = 100
|
||||||
|
[Toggle(_)] _UseSmoothedNormal("Use Smoothed Normal", Float) = 0
|
||||||
|
//[HideInInspector]_Cutoff("Alpha cutoff", Range(0, 1)) = 0.5
|
||||||
|
_BakedNormal("Baked Normal for Outline", 2D) = "white" {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -434,16 +452,7 @@ Shader "HDRP/Toon"
|
|||||||
[Toggle(_)] _Inverse_MatcapMask("Inverse_MatcapMask", Float) = 0
|
[Toggle(_)] _Inverse_MatcapMask("Inverse_MatcapMask", Float) = 0
|
||||||
//v.2.0.5
|
//v.2.0.5
|
||||||
[Toggle(_)] _Is_Ortho("Orthographic Projection for MatCap", Float) = 0
|
[Toggle(_)] _Is_Ortho("Orthographic Projection for MatCap", Float) = 0
|
||||||
//// Angel Rings
|
|
||||||
[Toggle(_)] _AngelRing("AngelRing", Float) = 0
|
|
||||||
_AngelRing_Sampler("AngelRing_Sampler", 2D) = "black" {}
|
|
||||||
_AngelRing_Color("AngelRing_Color", Color) = (1, 1, 1, 1)
|
|
||||||
[Toggle(_)] _Is_LightColor_AR("Is_LightColor_AR", Float) = 1
|
|
||||||
_AR_Intensity("AR_Intensity", Range(0, 100)) = 1
|
|
||||||
_AR_ShadowIntensity("AR_Intensity", Range(0, 1)) = 0
|
|
||||||
_AR_OffsetU("AR_OffsetU", Range(0, 0.5)) = 0
|
|
||||||
_AR_OffsetV("AR_OffsetV", Range(0, 1)) = 0.3
|
|
||||||
[Toggle(_)] _ARSampler_AlphaOn("ARSampler_AlphaOn", Float) = 0
|
|
||||||
//
|
//
|
||||||
//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
|
||||||
@@ -459,26 +468,6 @@ Shader "HDRP/Toon"
|
|||||||
[HDR]_ViewShift("ViewSift", Color) = (0, 0, 0, 1)
|
[HDR]_ViewShift("ViewSift", Color) = (0, 0, 0, 1)
|
||||||
[Toggle(_)] _Is_ViewCoord_Scroll("Is_ViewCoord_Scroll", Float) = 0
|
[Toggle(_)] _Is_ViewCoord_Scroll("Is_ViewCoord_Scroll", Float) = 0
|
||||||
//
|
//
|
||||||
//Outline
|
|
||||||
[KeywordEnum(NML, POS)] _OUTLINE("OUTLINE MODE", Float) = 0
|
|
||||||
_Outline_Width("Outline_Width", Float) = 0
|
|
||||||
_Farthest_Distance("Farthest_Distance", Float) = 100
|
|
||||||
_Nearest_Distance("Nearest_Distance", Float) = 0.5
|
|
||||||
_Outline_Sampler("Outline_Sampler", 2D) = "white" {}
|
|
||||||
_Outline_Color("Outline_Color", Color) = (0.5, 0.5, 0.5, 1)
|
|
||||||
[Toggle(_)] _Is_BlendBaseColor("Is_BlendBaseColor", Float) = 0
|
|
||||||
// ClippingMask paramaters from Here.
|
|
||||||
[HideInInspector]_Cutoff("Alpha cutoff", Range(0, 1)) = 0.5
|
|
||||||
// ClippingMask paramaters to here.
|
|
||||||
//v.2.0.4
|
|
||||||
[Toggle(_)] _Is_OutlineTex("Is_OutlineTex", Float) = 0
|
|
||||||
_OutlineTex("OutlineTex", 2D) = "white" {}
|
|
||||||
//Offset parameter
|
|
||||||
_Offset_Z("Offset_Camera_Z", Float) = 0
|
|
||||||
//v.2.0.4.3 Baked Nrmal Texture for Outline
|
|
||||||
[Toggle(_)] _Is_BakedNormal("Is_BakedNormal", Float) = 0
|
|
||||||
_BakedNormal("Baked Normal for Outline", 2D) = "white" {}
|
|
||||||
_UseSmoothedNormal("Use Smoothed Normal", Float) = 0
|
|
||||||
//GI Intensity
|
//GI Intensity
|
||||||
_ID_Intensity("GI_Intensity", Range(0, 1)) = 1
|
_ID_Intensity("GI_Intensity", Range(0, 1)) = 1
|
||||||
_IR_Intensity("GI_Intensity", Range(0, 1)) = 1
|
_IR_Intensity("GI_Intensity", Range(0, 1)) = 1
|
||||||
@@ -517,10 +506,6 @@ Shader "HDRP/Toon"
|
|||||||
[Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0
|
[Toggle(_)] _RimLightOverridden("Channel mask", Float) = 0
|
||||||
_RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1)
|
_RimLightMaskColor("Channel mask color", Color) = (1, 0, 1, 1)
|
||||||
|
|
||||||
[Toggle(_)] _OutlineVisible("Channel mask", Float) = 1
|
|
||||||
[Toggle(_)] _OutlineOverridden("Channel mask", Float) = 0
|
|
||||||
_OutlineMaskColor("Channel mask color", Color) = (0, 0, 0, 1)
|
|
||||||
|
|
||||||
[Toggle(_)] _ComposerMaskMode("", Float) = 0
|
[Toggle(_)] _ComposerMaskMode("", Float) = 0
|
||||||
[Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0
|
[Enum(None, 0, BaseColor, 1, FirstShade, 2, SecondShade,3, Highlight, 4, AngelRing, 5, RimLight, 6)] _ClippingMatteMode("Clipping Matte Mode", int) = 0
|
||||||
|
|
||||||
@@ -1023,6 +1008,8 @@ Shader "HDRP/Toon"
|
|||||||
#pragma shader_feature_local_fragment _SPECULAR_COLOR_MAP
|
#pragma shader_feature_local_fragment _SPECULAR_COLOR_MAP
|
||||||
#pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
|
#pragma shader_feature_local_fragment _EMISSIVE_COLOR_MAP
|
||||||
|
|
||||||
|
#pragma shader_feature_local_fragment _OUTLINE_COLOR_MAP
|
||||||
|
|
||||||
#pragma shader_feature_local_fragment _RECEIVE_HAIR_SHADOW_ON
|
#pragma shader_feature_local_fragment _RECEIVE_HAIR_SHADOW_ON
|
||||||
|
|
||||||
#define PUNCTUAL_SHADOW_MEDIUM
|
#define PUNCTUAL_SHADOW_MEDIUM
|
||||||
@@ -1134,7 +1121,7 @@ Shader "HDRP/Toon"
|
|||||||
Tags { "LightMode" = "Outline" }
|
Tags { "LightMode" = "Outline" }
|
||||||
|
|
||||||
Cull Front
|
Cull Front
|
||||||
Blend SrcAlpha OneMinusSrcAlpha
|
Blend Off
|
||||||
|
|
||||||
HLSLPROGRAM
|
HLSLPROGRAM
|
||||||
|
|
||||||
@@ -1143,10 +1130,7 @@ Shader "HDRP/Toon"
|
|||||||
#define SHADERPASS SHADERPASS_FORWARD
|
#define SHADERPASS SHADERPASS_FORWARD
|
||||||
#define SHADOW_LOW
|
#define SHADOW_LOW
|
||||||
#define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
#define LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
|
||||||
|
#define _REQUIRE_UV2
|
||||||
#pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES
|
|
||||||
#pragma multi_compile _OUTLINE_NML _OUTLINE_POS
|
|
||||||
#pragma shader_feature _ _IS_CLIPPING_MATTE
|
|
||||||
|
|
||||||
#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"
|
||||||
@@ -1454,6 +1438,6 @@ Shader "HDRP/Toon"
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI"
|
//CustomEditor "UnityEditor.Rendering.Toon.UTS3GUI"
|
||||||
//CustomEditor "Misaki.HdrpToon.Editor.UTSShaderGUI"
|
CustomEditor "Misaki.HdrpToon.Editor.UTSShaderGUI"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ struct UTSData
|
|||||||
|
|
||||||
struct UTSSurfaceData
|
struct UTSSurfaceData
|
||||||
{
|
{
|
||||||
uint materialFeatures;
|
uint surfaceFeatures;
|
||||||
|
|
||||||
real3 baseColor;
|
real3 baseColor;
|
||||||
real3 firstShadingColor;
|
real3 firstShadingColor;
|
||||||
@@ -56,7 +56,7 @@ struct UTSSurfaceData
|
|||||||
|
|
||||||
struct UtsBSDFData
|
struct UtsBSDFData
|
||||||
{
|
{
|
||||||
uint materialFeatures;
|
uint surfaceFeatures;
|
||||||
|
|
||||||
real3 diffuseColor;
|
real3 diffuseColor;
|
||||||
real3 firstShadingDiffuseColor;
|
real3 firstShadingDiffuseColor;
|
||||||
@@ -87,7 +87,7 @@ UTSSurfaceData ConvertSurfaceDataToUTSSurfaceData(SurfaceData surfaceData)
|
|||||||
UTSSurfaceData output;
|
UTSSurfaceData output;
|
||||||
ZERO_INITIALIZE(UTSSurfaceData, output);
|
ZERO_INITIALIZE(UTSSurfaceData, output);
|
||||||
|
|
||||||
output.materialFeatures = surfaceData.materialFeatures;
|
output.surfaceFeatures = surfaceData.materialFeatures;
|
||||||
output.baseColor = surfaceData.baseColor;
|
output.baseColor = surfaceData.baseColor;
|
||||||
output.alpha = 1.0;
|
output.alpha = 1.0;
|
||||||
output.normalWS = surfaceData.normalWS;
|
output.normalWS = surfaceData.normalWS;
|
||||||
@@ -110,7 +110,7 @@ UTSSurfaceData GetUTSSurfaceData(FragInputs input, float3 V)
|
|||||||
UTSSurfaceData output;
|
UTSSurfaceData output;
|
||||||
//ZERO_INITIALIZE(UTSSurfaceData, output);
|
//ZERO_INITIALIZE(UTSSurfaceData, output);
|
||||||
|
|
||||||
output.materialFeatures = 0;
|
output.surfaceFeatures = _SurfaceFeatures;
|
||||||
|
|
||||||
float4 mainTexture = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(input.texCoord0, _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;
|
||||||
@@ -200,7 +200,7 @@ UtsBSDFData ConvertUTSSurfaceDataToUTSBSDFData(UTSSurfaceData surfaceData)
|
|||||||
{
|
{
|
||||||
UtsBSDFData output;
|
UtsBSDFData output;
|
||||||
|
|
||||||
output.materialFeatures = surfaceData.materialFeatures;
|
output.surfaceFeatures = surfaceData.surfaceFeatures;
|
||||||
|
|
||||||
output.diffuseColor = UtsComputeDiffuseColor(surfaceData.baseColor, surfaceData.metallic, 0.05);
|
output.diffuseColor = UtsComputeDiffuseColor(surfaceData.baseColor, surfaceData.metallic, 0.05);
|
||||||
output.firstShadingDiffuseColor = UtsComputeDiffuseColor(surfaceData.firstShadingColor, surfaceData.metallic, 0.05);
|
output.firstShadingDiffuseColor = UtsComputeDiffuseColor(surfaceData.firstShadingColor, surfaceData.metallic, 0.05);
|
||||||
@@ -298,12 +298,6 @@ PreLightData GetPreLightData_UTS(float3 V, PositionInputs posInput, inout UtsBSD
|
|||||||
// Construct a right-handed view-dependent orthogonal basis around the normal
|
// Construct a right-handed view-dependent orthogonal basis around the normal
|
||||||
preLightData.orthoBasisViewNormal = GetOrthoBasisViewNormal(V, N, preLightData.NdotV);
|
preLightData.orthoBasisViewNormal = GetOrthoBasisViewNormal(V, N, preLightData.NdotV);
|
||||||
|
|
||||||
preLightData.ltcTransformCoat = 0.0;
|
|
||||||
if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT))
|
|
||||||
{
|
|
||||||
preLightData.ltcTransformCoat = SampleLtcMatrix(CLEAR_COAT_PERCEPTUAL_ROUGHNESS, clampedNdotV, LTCLIGHTINGMODEL_GGX);
|
|
||||||
}
|
|
||||||
|
|
||||||
return preLightData;
|
return preLightData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ float GetHairShadow(PositionInputs posInput, float3 L)
|
|||||||
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.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.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 hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, scaledUVs).r;
|
float hairDepth = SAMPLE_TEXTURE2D(_HairShadowTex, s_trilinear_clamp_sampler, scaledUVs).r;
|
||||||
float shadowMask = 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.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
|
TEXTURE2D(_MainTex);
|
||||||
|
SAMPLER(sampler_MainTex);
|
||||||
|
|
||||||
TEXTURE2D(_1st_ShadeMap);
|
TEXTURE2D(_1st_ShadeMap);
|
||||||
TEXTURE2D(_2nd_ShadeMap);
|
TEXTURE2D(_2nd_ShadeMap);
|
||||||
|
|
||||||
@@ -12,9 +14,16 @@ sampler _Set_HighColorMask;
|
|||||||
sampler _Set_RimLightMask;
|
sampler _Set_RimLightMask;
|
||||||
sampler _NormalMapForMatCap;
|
sampler _NormalMapForMatCap;
|
||||||
sampler _Set_MatcapMask;
|
sampler _Set_MatcapMask;
|
||||||
// sampler2D _ClippingMask;
|
|
||||||
TEXTURE2D(_ClippingMask);
|
TEXTURE2D(_ClippingMask);
|
||||||
sampler _AngelRing_Sampler;
|
|
||||||
sampler _Outline_Sampler;
|
TEXTURE2D(_AngelRingColorMap);
|
||||||
sampler _OutlineTex;
|
SAMPLER(sampler_AngelRingColorMap);
|
||||||
sampler _BakedNormal;
|
|
||||||
|
TEXTURE2D(_OutlineWidthMap);
|
||||||
|
SAMPLER(sampler_OutlineWidthMap);
|
||||||
|
|
||||||
|
TEXTURE2D(_OutlineColorMap);
|
||||||
|
SAMPLER(sampler_OutlineColorMap);
|
||||||
|
|
||||||
|
TEXTURE2D(_BakedNormalMap);
|
||||||
|
SAMPLER(sampler_BakedNormalMap);
|
||||||
@@ -5,16 +5,15 @@ float4 _Color;
|
|||||||
fixed _Use_BaseAs1st;
|
fixed _Use_BaseAs1st;
|
||||||
fixed _Use_1stAs2nd;
|
fixed _Use_1stAs2nd;
|
||||||
fixed _Is_LightColor_Base;
|
fixed _Is_LightColor_Base;
|
||||||
float4 _MainTex_ST;
|
|
||||||
float4 _1st_ShadeMap_ST;
|
|
||||||
float4 _1st_ShadeColor;
|
float4 _1st_ShadeColor;
|
||||||
fixed _Is_LightColor_1st_Shade;
|
fixed _Is_LightColor_1st_Shade;
|
||||||
float4 _2nd_ShadeMap_ST;
|
|
||||||
float4 _2nd_ShadeColor;
|
float4 _2nd_ShadeColor;
|
||||||
fixed _Is_LightColor_2nd_Shade;
|
fixed _Is_LightColor_2nd_Shade;
|
||||||
fixed _Is_NormalMapToBase;
|
fixed _Is_NormalMapToBase;
|
||||||
fixed _Set_SystemShadowsToBase;
|
fixed _Set_SystemShadowsToBase;
|
||||||
|
|
||||||
|
float _SurfaceFeatures;
|
||||||
|
|
||||||
float _Tweak_SystemShadowsLevel;
|
float _Tweak_SystemShadowsLevel;
|
||||||
float _ShadowBias;
|
float _ShadowBias;
|
||||||
float _SDFShadowLevel;
|
float _SDFShadowLevel;
|
||||||
@@ -126,7 +125,6 @@ float _Clipping_Level;
|
|||||||
fixed _Inverse_Clipping;
|
fixed _Inverse_Clipping;
|
||||||
float _Tweak_transparency;
|
float _Tweak_transparency;
|
||||||
fixed _AngelRing;
|
fixed _AngelRing;
|
||||||
float4 _AngelRing_Sampler_ST;
|
|
||||||
|
|
||||||
float _BaseColorVisible;
|
float _BaseColorVisible;
|
||||||
float _BaseColorOverridden;
|
float _BaseColorOverridden;
|
||||||
@@ -152,10 +150,6 @@ float _RimLightVisible;
|
|||||||
float _RimLightOverridden;
|
float _RimLightOverridden;
|
||||||
float4 _RimLightMaskColor;
|
float4 _RimLightMaskColor;
|
||||||
|
|
||||||
float _OutlineVisible;
|
|
||||||
float _OutlineOverridden;
|
|
||||||
float4 _OutlineMaskColor;
|
|
||||||
|
|
||||||
float _ComposerMaskMode;
|
float _ComposerMaskMode;
|
||||||
int _ClippingMatteMode;
|
int _ClippingMatteMode;
|
||||||
|
|
||||||
@@ -163,32 +157,17 @@ float _GI_Intensity;
|
|||||||
float _Light_Intensity_Multiplier;
|
float _Light_Intensity_Multiplier;
|
||||||
|
|
||||||
|
|
||||||
float4 _AngelRing_Color;
|
float4 _AngelRingColor;
|
||||||
fixed _Is_LightColor_AR;
|
float4 _AngelRingColorMap_ST;
|
||||||
float _AR_Intensity;
|
float _AR_Intensity;
|
||||||
float _AR_ShadowIntensity;
|
|
||||||
float _AR_OffsetU;
|
|
||||||
float _AR_OffsetV;
|
|
||||||
fixed _ARSampler_AlphaOn;
|
|
||||||
|
|
||||||
// Unity Toon Shader Outline
|
float _OutlineWidth;
|
||||||
|
float4 _OutlineColor;
|
||||||
float _Outline_Width;
|
fixed _AlbedoAffectOutline;
|
||||||
float _Farthest_Distance;
|
float _OutlineFadeIn;
|
||||||
float _Nearest_Distance;
|
float _OutlineFadeOut;
|
||||||
float4 _Outline_Sampler_ST;
|
|
||||||
float4 _Outline_Color;
|
|
||||||
fixed _Is_BlendBaseColor;
|
|
||||||
float _Offset_Z;
|
|
||||||
float4 _OutlineTex_ST;
|
|
||||||
fixed _Is_OutlineTex;
|
|
||||||
float4 _BakedNormal_ST;
|
|
||||||
fixed _Is_BakedNormal;
|
|
||||||
fixed _UseSmoothedNormal;
|
fixed _UseSmoothedNormal;
|
||||||
|
|
||||||
float _ZOverDrawMode;
|
|
||||||
//
|
|
||||||
|
|
||||||
#if defined(_UTS_TOON_EV_PER_MODEL)
|
#if defined(_UTS_TOON_EV_PER_MODEL)
|
||||||
// not in materials
|
// not in materials
|
||||||
int _ToonLightHiCutFilter;
|
int _ToonLightHiCutFilter;
|
||||||
|
|||||||
@@ -67,37 +67,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
{
|
{
|
||||||
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(packedInput);
|
||||||
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
|
FragInputs input = UnpackVaryingsMeshToFragInputs(packedInput.vmesh);
|
||||||
#ifdef _IS_CLIPPING_MASK
|
|
||||||
if (_ClippingMaskMode != 0)
|
|
||||||
{
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef _IS_CLIPPING_MATTE
|
|
||||||
if (_ClippingMatteMode != 0)
|
|
||||||
{
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
#endif // _IS_CLIPPING_MATTE
|
|
||||||
#if defined(UTS_DEBUG_SHADOWMAP_NO_OUTLINE)
|
|
||||||
discard;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//v.2.0.5
|
|
||||||
if (_ZOverDrawMode > 0.99f)
|
|
||||||
{
|
|
||||||
#ifdef _DEPTHOFFSET_ON
|
|
||||||
outputDepth = posInput.deviceDepth;
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
||||||
|
|
||||||
outVTFeedback = builtinData.vtPackedFeedback;
|
|
||||||
#endif
|
|
||||||
outColor = float4(1.0f, 1.0f, 1.0f, 1.0f); // but nothing should be drawn except Z value as colormask is set to 0
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_Color = _BaseColor;
|
_Color = _BaseColor;
|
||||||
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||||
float4 Set_UV0 = input.texCoord0;
|
float4 Set_UV0 = input.texCoord0;
|
||||||
@@ -114,7 +84,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
||||||
ambientSkyColor *= GetCurrentExposureMultiplier();
|
ambientSkyColor *= GetCurrentExposureMultiplier();
|
||||||
|
|
||||||
float4 _BlendingTex_var = SAMPLE_TEXTURE2D(_HairBlendingMap, sampler_HairBlendingMap, TRANSFORM_TEX(Set_UV0, _MainTex));
|
float4 _BlendingTex_var = SAMPLE_TEXTURE2D(_HairBlendingMap, sampler_HairBlendingMap, TRANSFORM_TEX(Set_UV0, _BaseColorMap));
|
||||||
outColor = float4(_BlendingTex_var.rgb * ambientSkyColor, _BlendingTex_var.a);
|
outColor = float4(_BlendingTex_var.rgb * ambientSkyColor, _BlendingTex_var.a);
|
||||||
|
|
||||||
#ifdef _DEPTHOFFSET_ON
|
#ifdef _DEPTHOFFSET_ON
|
||||||
|
|||||||
@@ -129,26 +129,10 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
discard;
|
discard;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//v.2.0.5
|
|
||||||
if (_ZOverDrawMode > 0.99f)
|
|
||||||
{
|
|
||||||
#ifdef _DEPTHOFFSET_ON
|
|
||||||
outputDepth = posInput.deviceDepth;
|
|
||||||
#endif
|
|
||||||
#ifdef UNITY_VIRTUAL_TEXTURING
|
|
||||||
|
|
||||||
outVTFeedback = builtinData.vtPackedFeedback;
|
|
||||||
#endif
|
|
||||||
outColor = float4(1.0f, 1.0f, 1.0f, 1.0f); // but nothing should be drawn except Z value as colormask is set to 0
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_Color = _BaseColor;
|
|
||||||
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||||
float4 Set_UV0 = input.texCoord0;
|
float4 uv0 = input.texCoord0;
|
||||||
|
|
||||||
// The following temporary definition of unity_AmbientEquator is for HDRP only.
|
// The following temporary definition of unity_AmbientEquator is for HDRP only.
|
||||||
//float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo.
|
//float4 unity_AmbientEquator = float4(0.05, 0.05, 0.05, 1.0); //Todo.
|
||||||
//v.2.0.9
|
//v.2.0.9
|
||||||
//float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb > 0.05 ? unity_AmbientEquator.rgb : half3(0.05, 0.05, 0.05);
|
//float3 envLightSource_GradientEquator = unity_AmbientEquator.rgb > 0.05 ? unity_AmbientEquator.rgb : half3(0.05, 0.05, 0.05);
|
||||||
@@ -160,59 +144,26 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
float3 ambientSkyColor = envLightSource_SkyboxIntensity.rgb > 0.0 ? envLightSource_SkyboxIntensity : envLightSource_GradientEquator;
|
||||||
ambientSkyColor *= GetCurrentExposureMultiplier() * 5.0f;
|
ambientSkyColor *= GetCurrentExposureMultiplier() * 5.0f;
|
||||||
|
|
||||||
float4 _MainTex_var = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(Set_UV0, _MainTex));
|
float3 baseColor = SAMPLE_TEXTURE2D(_BaseColorMap, sampler_BaseColorMap, TRANSFORM_TEX(uv0, _BaseColorMap)).rgb;
|
||||||
float3 Set_BaseColor = _BaseColor.rgb*_MainTex_var.rgb;
|
baseColor *= _BaseColor.rgb;
|
||||||
float3 _Is_BlendBaseColor_var = lerp(_Outline_Color.rgb * ambientSkyColor, (_Outline_Color.rgb * ambientSkyColor * Set_BaseColor * Set_BaseColor), _Is_BlendBaseColor);
|
|
||||||
//
|
|
||||||
float3 _OutlineTex_var = tex2D(_OutlineTex,TRANSFORM_TEX(Set_UV0, _OutlineTex)).xyz;
|
|
||||||
|
|
||||||
float4 overridingColor = lerp(_OutlineMaskColor, float4(_OutlineMaskColor.w, _OutlineMaskColor.w, _OutlineMaskColor.w, 1.0f), _ComposerMaskMode);
|
float4 outlineColor = _OutlineColor;
|
||||||
float maskEnabled = max(_OutlineOverridden, _ComposerMaskMode);
|
#if _OUTLINE_COLOR_MAP
|
||||||
|
outlineColor *= SAMPLE_TEXTURE2D(_OutlineColorMap, sampler_OutlineColorMap, TRANSFORM_TEX(uv0, _BaseColorMap)).rgb;
|
||||||
//v.2.0.7.5
|
|
||||||
#ifdef _IS_OUTLINE_CLIPPING_NO
|
|
||||||
float3 Set_Outline_Color = lerp(_Is_BlendBaseColor_var, _OutlineTex_var.rgb*_Outline_Color.rgb * ambientSkyColor, _Is_OutlineTex );
|
|
||||||
if (_OutlineVisible < 0.1)
|
|
||||||
{
|
|
||||||
// Todo.
|
|
||||||
// without this, something is drawn even if _OutlineVisible = 0, in AngelRing(HDRP)
|
|
||||||
discard;
|
|
||||||
}
|
|
||||||
Set_Outline_Color = lerp(Set_Outline_Color, overridingColor.xyz, maskEnabled);
|
|
||||||
float3 volColor, volOpacity;
|
|
||||||
|
|
||||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
|
||||||
// input.positionSS is SV_Position
|
|
||||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
|
||||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
||||||
|
|
||||||
EvaluateAtmosphericScattering(posInput, V, volColor, volOpacity); // Premultiplied alpha
|
|
||||||
Set_Outline_Color.xyz = Set_Outline_Color.xyz * (1 - volOpacity) + volColor * _OutlineVisible;
|
|
||||||
outColor =float4(Set_Outline_Color, _OutlineVisible );
|
|
||||||
|
|
||||||
|
|
||||||
#elif _IS_OUTLINE_CLIPPING_YES
|
|
||||||
float4 _ClippingMask_var = SAMPLE_TEXTURE2D(_ClippingMask, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _ClippingMask));
|
|
||||||
float Set_MainTexAlpha = _MainTex_var.a;
|
|
||||||
float _IsBaseMapAlphaAsClippingMask_var = lerp( _ClippingMask_var.r, Set_MainTexAlpha, _IsBaseMapAlphaAsClippingMask );
|
|
||||||
float _Inverse_Clipping_var = lerp( _IsBaseMapAlphaAsClippingMask_var, (1.0 - _IsBaseMapAlphaAsClippingMask_var), _Inverse_Clipping );
|
|
||||||
float Set_Clipping = saturate((_Inverse_Clipping_var+_Clipping_Level));
|
|
||||||
clip(Set_Clipping - 0.5);
|
|
||||||
float4 Set_Outline_Color = lerp( float4(_Is_BlendBaseColor_var, Set_Clipping), float4((_OutlineTex_var.rgb * _Outline_Color.rgb * ambientSkyColor),Set_Clipping), _Is_OutlineTex );
|
|
||||||
Set_Outline_Color = lerp(Set_Outline_Color, overridingColor, maskEnabled);
|
|
||||||
Set_Outline_Color.w *= _OutlineVisible;
|
|
||||||
|
|
||||||
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
|
||||||
// input.positionSS is SV_Position
|
|
||||||
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
|
||||||
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
|
||||||
|
|
||||||
float3 volColor, volOpacity;
|
|
||||||
EvaluateAtmosphericScattering(posInput, V, volColor, volOpacity); // Premultiplied alpha
|
|
||||||
Set_Outline_Color.xyz = Set_Outline_Color.xyz * (1 - volOpacity.x) + volColor * Set_Outline_Color.w;
|
|
||||||
outColor = Set_Outline_Color;
|
|
||||||
#endif
|
#endif
|
||||||
//outColor.rgb = ambientSkyColor;
|
outlineColor.rgb = lerp(outlineColor.rgb * ambientSkyColor, outlineColor.rgb * ambientSkyColor * baseColor, _AlbedoAffectOutline);
|
||||||
|
|
||||||
|
float3 volColor, volOpacity;
|
||||||
|
|
||||||
|
uint2 tileIndex = uint2(input.positionSS.xy) / GetTileSize();
|
||||||
|
// input.positionSS is SV_Position
|
||||||
|
PositionInputs posInput = GetPositionInput(input.positionSS.xy, _ScreenSize.zw, input.positionSS.z, input.positionSS.w, input.positionRWS.xyz, tileIndex);
|
||||||
|
float3 V = GetWorldSpaceNormalizeViewDir(input.positionRWS);
|
||||||
|
|
||||||
|
EvaluateAtmosphericScattering(posInput, V, volColor, volOpacity); // Premultiplied alpha
|
||||||
|
outlineColor.rgb = outlineColor.rgb * (1 - volOpacity) + volColor;
|
||||||
|
outColor = outlineColor;
|
||||||
|
|
||||||
#ifdef _DEPTHOFFSET_ON
|
#ifdef _DEPTHOFFSET_ON
|
||||||
outputDepth = posInput.deviceDepth;
|
outputDepth = posInput.deviceDepth;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,65 +1,28 @@
|
|||||||
//Unity Toon Shader/HDRP
|
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
||||||
//nobuyuki@unity3d.com
|
|
||||||
//toshiyuki@unity3d.com (Universal RP/HDRP)
|
|
||||||
|
|
||||||
|
float4 _Outline_Sampler_var = SAMPLE_TEXTURE2D_LOD(_OutlineWidthMap, sampler_OutlineWidthMap, TRANSFORM_TEX(inputMesh.uv0, _BaseColorMap), 0.0);
|
||||||
|
//v.2.0.4.3 baked Normal Texture for Outline
|
||||||
|
float3 normalDir = UnityObjectToWorldNormal(inputMesh.normalOS);
|
||||||
|
float3 tangentDir = normalize(mul(unity_ObjectToWorld, float4(inputMesh.tangentOS.xyz, 0.0)).xyz);
|
||||||
|
float3 bitangentDir = normalize(cross(normalDir, tangentDir) * inputMesh.tangentOS.w);
|
||||||
|
float3x3 tangentTransform = float3x3(tangentDir, bitangentDir, normalDir);
|
||||||
|
//end
|
||||||
|
float outlineWidth = (_OutlineWidth * 0.01 * smoothstep(_OutlineFadeOut, _OutlineFadeIn, distance(objPos.rgb, _WorldSpaceCameraPos)) * _Outline_Sampler_var.rgb).r;
|
||||||
|
//v.2.0.7.5
|
||||||
|
float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1));
|
||||||
|
|
||||||
#if 1
|
float3 bakedNormal = float3(inputMesh.uv1, 0);
|
||||||
float4 objPos = mul(unity_ObjectToWorld, float4(0, 0, 0, 1));
|
bakedNormal.z = sqrt(1.0 - saturate(dot(bakedNormal.xy, bakedNormal.xy)));
|
||||||
float2 Set_UV0 = inputMesh.uv0;
|
float3 normalOS = lerp(inputMesh.normalOS, mul(bakedNormal, tangentTransform), _UseSmoothedNormal);
|
||||||
float4 _Outline_Sampler_var = tex2Dlod(_Outline_Sampler, float4(TRANSFORM_TEX(Set_UV0, _Outline_Sampler), 0.0, 0));
|
|
||||||
//v.2.0.4.3 baked Normal Texture for Outline
|
|
||||||
float3 normalDir = UnityObjectToWorldNormal(inputMesh.normalOS);
|
|
||||||
float3 tangentDir = normalize(mul(unity_ObjectToWorld, float4(inputMesh.tangentOS.xyz, 0.0)).xyz);
|
|
||||||
float3 bitangentDir = normalize(cross(normalDir, tangentDir) * inputMesh.tangentOS.w);
|
|
||||||
float3x3 tangentTransform = float3x3(tangentDir, bitangentDir, normalDir);
|
|
||||||
//UnpackNormal() can't be used, and so as follows. Do not specify a bump for the texture to be used.
|
|
||||||
float4 _BakedNormal_var = (tex2Dlod(_BakedNormal, float4(TRANSFORM_TEX(Set_UV0, _BakedNormal), 0.0, 0)) * 2 - 1);
|
|
||||||
float3 _BakedNormalDir = normalize(mul(_BakedNormal_var.rgb, tangentTransform));
|
|
||||||
//end
|
|
||||||
float Set_Outline_Width = (_Outline_Width * 0.01 * smoothstep(_Farthest_Distance, _Nearest_Distance, distance(objPos.rgb, _WorldSpaceCameraPos)) * _Outline_Sampler_var.rgb).r;
|
|
||||||
Set_Outline_Width *= (1.0f - _ZOverDrawMode);
|
|
||||||
//v.2.0.7.5
|
|
||||||
float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1));
|
|
||||||
//v.2.0.7
|
|
||||||
#if defined(UNITY_REVERSED_Z)
|
|
||||||
//v.2.0.4.2 (DX)
|
|
||||||
_Offset_Z = _Offset_Z * -0.01;
|
|
||||||
#else
|
|
||||||
//OpenGL
|
|
||||||
_Offset_Z = _Offset_Z * 0.01;
|
|
||||||
#endif
|
|
||||||
float3 FinalNormal;
|
|
||||||
if(_UseSmoothedNormal == 1)
|
|
||||||
{
|
|
||||||
float3 normal = float3(inputMesh.uv1, 0);
|
|
||||||
normal.z = sqrt(1.0 - saturate(dot(normal.xy, normal.xy)));
|
|
||||||
FinalNormal = mul(normal, tangentTransform);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FinalNormal = lerp(inputMesh.normalOS, _BakedNormalDir, _Is_BakedNormal);
|
|
||||||
}
|
|
||||||
|
|
||||||
//v2.0.4
|
float3 normal = mul((float3x3)transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)), normalOS);
|
||||||
#ifdef _OUTLINE_NML
|
// screen space width
|
||||||
//v.2.0.4.3 baked Normal Texture for Outline
|
float2 extendDir = normalize(TransformWViewToHClip(normal).xy);
|
||||||
float3 normal = mul((float3x3)transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)), FinalNormal);
|
float4 clipPos = UnityObjectToClipPos(inputMesh.positionOS);
|
||||||
#elif _OUTLINE_POS
|
clipPos.xy += extendDir * min(_Outline_MaxWidth, (clipPos.w * outlineWidth));
|
||||||
Set_Outline_Width = Set_Outline_Width * 2;
|
//clipPos.z = clipPos.z + _Offset_Z * _ClipCameraPos.z;
|
||||||
float signVar = dot(normalize(inputMesh.positionOS), normalize(inputMesh.normalOS)) < 0 ? -1 : 1;
|
|
||||||
float3 normal = mul((float3x3)transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V)), signVar * normalize(inputMesh.positionOS));
|
|
||||||
#endif
|
|
||||||
// screen space width
|
|
||||||
float2 extendDir = normalize(TransformWViewToHClip(normal).xy);
|
|
||||||
float4 clipPos = UnityObjectToClipPos(inputMesh.positionOS);
|
|
||||||
clipPos.xy += extendDir * min(_Outline_MaxWidth, (clipPos.w * Set_Outline_Width));
|
|
||||||
clipPos.z = clipPos.z + _Offset_Z * _ClipCameraPos.z;
|
|
||||||
|
|
||||||
float4 rws = mul(UNITY_MATRIX_I_P, clipPos); // use UNITY_MATRIX_I_P instead of unity_CameraInvProjection.
|
float4 rws = mul(UNITY_MATRIX_I_P, clipPos); // use UNITY_MATRIX_I_P instead of unity_CameraInvProjection.
|
||||||
rws = mul(UNITY_MATRIX_I_V, rws); // use UNITY_MATRIX_I_V instead of unity_cameraToWorld.
|
rws = mul(UNITY_MATRIX_I_V, rws); // use UNITY_MATRIX_I_V instead of unity_cameraToWorld.
|
||||||
#ifndef TESSELLATION_ON
|
varyingsType.vmesh.positionCS = clipPos;
|
||||||
varyingsType.vmesh.positionCS = clipPos;
|
varyingsType.vmesh.positionRWS = rws.xyz;
|
||||||
#endif // TESSELLATION_ON
|
|
||||||
varyingsType.vmesh.positionRWS = rws.xyz;
|
|
||||||
|
|
||||||
#endif // #if 1
|
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
outColor = float4(outColor.rgb, Set_Opacity * ApplyChannelAlpha(channelAlpha));
|
outColor = float4(outColor.rgb, Set_Opacity * ApplyChannelAlpha(channelAlpha));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MATERIAL_TYPE_FRONT_HAIR && ENABLE_UTS_HAIR_BLENDING
|
#if _MATERIAL_TYPE_FRONTHAIR && ENABLE_UTS_HAIR_BLENDING
|
||||||
float2 screenUV = posInput.positionNDC * _HairBlendingRTHandleScale.xy;
|
float2 screenUV = posInput.positionNDC * _HairBlendingRTHandleScale.xy;
|
||||||
float4 hairBlendingMap = SAMPLE_TEXTURE2D(_HairBlendingTex, s_trilinear_clamp_sampler, screenUV);
|
float4 hairBlendingMap = SAMPLE_TEXTURE2D(_HairBlendingTex, s_trilinear_clamp_sampler, screenUV);
|
||||||
outColor.rgb = lerp(outColor.rgb, hairBlendingMap.rgb, hairBlendingMap.a * _HairBlendingFactor);
|
outColor.rgb = lerp(outColor.rgb, hairBlendingMap.rgb, hairBlendingMap.a * _HairBlendingFactor);
|
||||||
|
|||||||
Reference in New Issue
Block a user