Fixed the bug from shader gui drawer : [Worker0] Failed to create MaterialEnum, enum UnityEditor.Rendering.HighDefinition.TransparentCullMode not found;
Fixed the bug that outline does not rendering when material type is set to transparent; Fixed the bug that hair shadow buffer does not rendering the object that material type is set to transparent;
This commit is contained in:
@@ -18,8 +18,6 @@ namespace Unity.Toonshader.Editor
|
|||||||
return base.CreateInspectorGUI();
|
return base.CreateInspectorGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
var boxLightAdjustment = (BoxLightAdjustment)target;
|
|
||||||
|
|
||||||
var root = new VisualElement
|
var root = new VisualElement
|
||||||
{
|
{
|
||||||
dataSource = target
|
dataSource = target
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Unity.Toonshader
|
|||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorBuildSettings.AddConfigObject(UTS_RENDERING_SETTINGS_NAME, renderingSettings, false);
|
EditorBuildSettings.AddConfigObject(UTS_RENDERING_SETTINGS_NAME, renderingSettings, true);
|
||||||
|
|
||||||
return renderingSettings;
|
return renderingSettings;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b8d9ae1381ecb2141b4a741976d1c827
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!114 &11400000
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 02a9f5e1730430c4090d73e427a7f7a3, type: 3}
|
|
||||||
m_Name: UTSRenderSettings
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
outlineSetting:
|
|
||||||
enable: 1
|
|
||||||
renderingLayer:
|
|
||||||
serializedVersion: 0
|
|
||||||
m_Bits: 2
|
|
||||||
hairShadowSetting:
|
|
||||||
enable: 1
|
|
||||||
CasterRenderingLayer:
|
|
||||||
serializedVersion: 0
|
|
||||||
m_Bits: 4
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 37f2c2f5a413a874b9ec560b74248a71
|
|
||||||
NativeFormatImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
mainObjectFileID: 11400000
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -184,7 +184,7 @@ Shader "HDRP/Toon"
|
|||||||
[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0
|
[HideInInspector][ToggleUI] _TransparentZWrite("_TransparentZWrite", Float) = 0.0
|
||||||
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
|
[HideInInspector] _CullMode("__cullmode", Float) = 2.0
|
||||||
[HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent
|
[HideInInspector] _CullModeForward("__cullmodeForward", Float) = 2.0 // This mode is dedicated to Forward to correctly handle backface then front face rendering thin transparent
|
||||||
[Enum(UnityEditor.Rendering.HighDefinition.TransparentCullMode)] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default
|
[HideInInspector] _TransparentCullMode("_TransparentCullMode", Int) = 2 // Back culling by default
|
||||||
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
|
[HideInInspector] _ZTestDepthEqualForOpaque("_ZTestDepthEqualForOpaque", Int) = 4 // Less equal
|
||||||
[HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8
|
[HideInInspector] _ZTestModeDistortion("_ZTestModeDistortion", Int) = 8
|
||||||
[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4
|
[HideInInspector] _ZTestGBuffer("_ZTestGBuffer", Int) = 4
|
||||||
|
|||||||
@@ -1,130 +0,0 @@
|
|||||||
Shader "Renderers/HairShadowRenderer"
|
|
||||||
{
|
|
||||||
Properties
|
|
||||||
{
|
|
||||||
_Color("Color", Color) = (1,1,1,1)
|
|
||||||
_ColorMap("ColorMap", 2D) = "white" {}
|
|
||||||
|
|
||||||
// Transparency
|
|
||||||
_AlphaCutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
|
|
||||||
[HideInInspector]_BlendMode("_BlendMode", Range(0.0, 1.0)) = 0.5
|
|
||||||
}
|
|
||||||
|
|
||||||
HLSLINCLUDE
|
|
||||||
|
|
||||||
#pragma target 4.5
|
|
||||||
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
|
|
||||||
|
|
||||||
// #pragma enable_d3d11_debug_symbols
|
|
||||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
||||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPass.cs.hlsl"
|
|
||||||
//#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/FragInputs.hlsl"
|
|
||||||
|
|
||||||
//enable GPU instancing support
|
|
||||||
#pragma multi_compile_instancing
|
|
||||||
#pragma multi_compile _ DOTS_INSTANCING_ON
|
|
||||||
|
|
||||||
ENDHLSL
|
|
||||||
|
|
||||||
SubShader
|
|
||||||
{
|
|
||||||
Tags{ "RenderPipeline" = "HDRenderPipeline" }
|
|
||||||
|
|
||||||
Pass
|
|
||||||
{
|
|
||||||
Name "HairShadow"
|
|
||||||
Tags { "LightMode" = "HairShadow" }
|
|
||||||
|
|
||||||
Blend Off
|
|
||||||
ZWrite On
|
|
||||||
ZTest LEqual
|
|
||||||
|
|
||||||
Cull Front
|
|
||||||
|
|
||||||
HLSLPROGRAM
|
|
||||||
|
|
||||||
#define _SURFACE_TYPE_OPAQUE
|
|
||||||
|
|
||||||
// Toggle the alpha test
|
|
||||||
#define _ALPHATEST_ON
|
|
||||||
|
|
||||||
// Toggle transparency
|
|
||||||
// #define _SURFACE_TYPE_TRANSPARENT
|
|
||||||
|
|
||||||
// Toggle fog on transparent
|
|
||||||
#define _ENABLE_FOG_ON_TRANSPARENT
|
|
||||||
|
|
||||||
// List all the attributes needed in your shader (will be passed to the vertex shader)
|
|
||||||
// you can see the complete list of these attributes in VaryingMesh.hlsl
|
|
||||||
#define ATTRIBUTES_NEED_TEXCOORD0
|
|
||||||
#define ATTRIBUTES_NEED_NORMAL
|
|
||||||
#define ATTRIBUTES_NEED_TANGENT
|
|
||||||
|
|
||||||
// List all the varyings needed in your fragment shader
|
|
||||||
#define VARYINGS_NEED_TEXCOORD0
|
|
||||||
#define VARYINGS_NEED_TANGENT_TO_WORLD
|
|
||||||
|
|
||||||
#define SHADERPASS SHADERPASS_FORWARD_UNLIT
|
|
||||||
|
|
||||||
int _HairShadowPassChannel;
|
|
||||||
TEXTURE2D(_ColorMap);
|
|
||||||
TEXTURE2D(_HairShadowTex);
|
|
||||||
SAMPLER(sampler_HairShadowTex);
|
|
||||||
|
|
||||||
// Declare properties in the UnityPerMaterial cbuffer to make the shader compatible with SRP Batcher.
|
|
||||||
CBUFFER_START(UnityPerMaterial)
|
|
||||||
float4 _ColorMap_ST;
|
|
||||||
float4 _Color;
|
|
||||||
|
|
||||||
float _AlphaCutoff;
|
|
||||||
float _BlendMode;
|
|
||||||
CBUFFER_END
|
|
||||||
|
|
||||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassRenderersV2.hlsl"
|
|
||||||
|
|
||||||
// If you need to modify the vertex datas, you can uncomment this code
|
|
||||||
// Note: all the transformations here are done in object space
|
|
||||||
// #define HAVE_MESH_MODIFICATION
|
|
||||||
// AttributesMesh ApplyMeshModification(AttributesMesh input, float3 timeParameters)
|
|
||||||
// {
|
|
||||||
// input.positionOS += input.normalOS * 0.0001; // inflate a bit the mesh to avoid z-fight
|
|
||||||
// return input;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Put the code to render the objects in your custom pass in this function
|
|
||||||
void GetSurfaceAndBuiltinData(FragInputs fragInputs, float3 viewDirection, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
|
|
||||||
{
|
|
||||||
float cDepth = SampleCameraDepth(posInput.positionNDC);
|
|
||||||
float mDepth = posInput.deviceDepth;
|
|
||||||
|
|
||||||
float opacity = 1;
|
|
||||||
// const float3 color = float3(LinearEyeDepth(posInput.deviceDepth, _ZBufferParams), 0, 0);
|
|
||||||
|
|
||||||
// A manual depth test is needed here. Custom pass will always draw with no regard of depth.
|
|
||||||
// This test was given a quite large leeway to avoid discarding when cDepth = mDepth [Suomi, 20230915]
|
|
||||||
|
|
||||||
//float3 color = float3(cDepth < mDepth + 0.01 ? mDepth : 0, 0, 0); // Can get that in HDRP directly
|
|
||||||
float3 color = float3(0, 0, 0);
|
|
||||||
color.r = mDepth;
|
|
||||||
|
|
||||||
#ifdef _ALPHATEST_ON
|
|
||||||
DoAlphaTest(opacity, _AlphaCutoff);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Write back the data to the output structures
|
|
||||||
ZERO_BUILTIN_INITIALIZE(builtinData); // No call to InitBuiltinData as we don't have any lighting
|
|
||||||
ZERO_INITIALIZE(SurfaceData, surfaceData);
|
|
||||||
builtinData.opacity = opacity;
|
|
||||||
builtinData.emissiveColor = float3(0, 0, 0);
|
|
||||||
surfaceData.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForwardUnlit.hlsl"
|
|
||||||
|
|
||||||
#pragma vertex Vert
|
|
||||||
#pragma fragment Frag
|
|
||||||
|
|
||||||
ENDHLSL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: b3740fc2ef8a5094a81cfb53915422de
|
|
||||||
ShaderImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
defaultTextures: []
|
|
||||||
nonModifiableTextures: []
|
|
||||||
preprocessorOverride: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -972,9 +972,6 @@ void Frag(PackedVaryingsToPS packedInput,
|
|||||||
// _EyeBrowBlendingFactor
|
// _EyeBrowBlendingFactor
|
||||||
outColor.a = _EyeBrowBlendingFactor;
|
outColor.a = _EyeBrowBlendingFactor;
|
||||||
outColor.a = hairPixel > 0.01 ? outColor.a : 1 ;
|
outColor.a = hairPixel > 0.01 ? outColor.a : 1 ;
|
||||||
|
|
||||||
|
|
||||||
//outColor.rgb = float3(hDepth.rg * 5,0);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
#if defined(UTS_DEBUG_SHADOWMAP) || defined(UTS_DEBUG_SELFSHADOW)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class UTSHairShadowPass : DrawRenderersCustomPass
|
|||||||
|
|
||||||
var result = new RendererListDesc(HDShaderPassNames.s_DepthForwardOnlyName, ctx.cullingResults, ctx.hdCamera.camera)
|
var result = new RendererListDesc(HDShaderPassNames.s_DepthForwardOnlyName, ctx.cullingResults, ctx.hdCamera.camera)
|
||||||
{
|
{
|
||||||
renderQueueRange = GetRenderQueueRange(renderQueueType),
|
renderQueueRange = GetRenderQueueRange(RenderQueueType.All),
|
||||||
sortingCriteria = sortingCriteria,
|
sortingCriteria = sortingCriteria,
|
||||||
excludeObjectMotionVectors = false,
|
excludeObjectMotionVectors = false,
|
||||||
stateBlock = stateBlock,
|
stateBlock = stateBlock,
|
||||||
|
|||||||
@@ -33,11 +33,8 @@ public class UTSOutlinePass : DrawRenderersCustomPass
|
|||||||
var result = new UnityEngine.Rendering.RendererUtils.RendererListDesc(outlineTag, ctx.cullingResults, ctx.hdCamera.camera)
|
var result = new UnityEngine.Rendering.RendererUtils.RendererListDesc(outlineTag, ctx.cullingResults, ctx.hdCamera.camera)
|
||||||
{
|
{
|
||||||
rendererConfiguration = renderConfig,
|
rendererConfiguration = renderConfig,
|
||||||
renderQueueRange = GetRenderQueueRange(renderQueueType),
|
renderQueueRange = GetRenderQueueRange(RenderQueueType.All),
|
||||||
sortingCriteria = sortingCriteria,
|
|
||||||
excludeObjectMotionVectors = false,
|
excludeObjectMotionVectors = false,
|
||||||
overrideMaterial = overrideMaterial,
|
|
||||||
overrideMaterialPassIndex = (overrideMaterial != null) ? overrideMaterial.FindPass(overrideMaterialPassName) : 0,
|
|
||||||
stateBlock = stateBlock,
|
stateBlock = stateBlock,
|
||||||
renderingLayerMask = renderingLayerMask,
|
renderingLayerMask = renderingLayerMask,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -41,27 +41,27 @@ namespace Unity.Toonshader
|
|||||||
[RuntimeInitializeOnLoadMethod]
|
[RuntimeInitializeOnLoadMethod]
|
||||||
public static void RegisterCustomPasses()
|
public static void RegisterCustomPasses()
|
||||||
{
|
{
|
||||||
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.AfterOpaqueAndSky, _outlinePass);
|
|
||||||
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, _hairShadowPass);
|
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.AfterOpaqueDepthAndNormal, _hairShadowPass);
|
||||||
|
CustomPassVolume.RegisterUniqueGlobalCustomPass(CustomPassInjectionPoint.BeforePostProcess, _outlinePass);
|
||||||
|
|
||||||
_outlinePass.enabled = _renderSetting.outlineSetting.enable;
|
|
||||||
_hairShadowPass.SetEnable(_renderSetting.hairShadowSetting.enable);
|
_hairShadowPass.SetEnable(_renderSetting.hairShadowSetting.enable);
|
||||||
|
_outlinePass.enabled = _renderSetting.outlineSetting.enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UnregisterGlobalCustomPass()
|
public static void UnregisterGlobalCustomPass()
|
||||||
{
|
{
|
||||||
CustomPassVolume.UnregisterGlobalCustomPass(_outlinePass);
|
|
||||||
CustomPassVolume.UnregisterGlobalCustomPass(_hairShadowPass);
|
CustomPassVolume.UnregisterGlobalCustomPass(_hairShadowPass);
|
||||||
|
CustomPassVolume.UnregisterGlobalCustomPass(_outlinePass);
|
||||||
_hairShadowPass.Release();
|
_hairShadowPass.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void NotifyRendererSettingChanged()
|
public static void NotifyRendererSettingChanged()
|
||||||
{
|
{
|
||||||
_outlinePass.enabled = _renderSetting.outlineSetting.enable;
|
|
||||||
_outlinePass.renderingLayerMask = _renderSetting.outlineSetting.renderingLayer;
|
|
||||||
|
|
||||||
_hairShadowPass.SetEnable(_renderSetting.hairShadowSetting.enable);
|
_hairShadowPass.SetEnable(_renderSetting.hairShadowSetting.enable);
|
||||||
_hairShadowPass.renderingLayerMask = _renderSetting.hairShadowSetting.CasterRenderingLayer;
|
_hairShadowPass.renderingLayerMask = _renderSetting.hairShadowSetting.CasterRenderingLayer;
|
||||||
|
|
||||||
|
_outlinePass.enabled = _renderSetting.outlineSetting.enable;
|
||||||
|
_outlinePass.renderingLayerMask = _renderSetting.outlineSetting.renderingLayer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user