浏览代码

Hair sorting passes

/projects-TheLastStand
John Parsaie 7 年前
当前提交
93b78ad8
共有 2 个文件被更改,包括 147 次插入1 次删除
  1. 34
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  2. 114
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/Hair/LightweightHair.shader

34
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


private static readonly ShaderPassName m_UnlitPassName = new ShaderPassName("SRPDefaultUnlit"); // Renders all shaders without a lightmode tag
private static readonly ShaderPassName m_DebugViewPass = new ShaderPassName("DebugView");
//TLS pass names
private static readonly ShaderPassName m_TransparentBackfaceName = new ShaderPassName("TransparentBackFace");
private static readonly ShaderPassName m_TransparentFrontfaceName = new ShaderPassName("TransparentFrontFace");
// Legacy pass names
public static readonly ShaderPassName s_AlwaysName = new ShaderPassName("Always");
public static readonly ShaderPassName s_ForwardBaseName = new ShaderPassName("ForwardBase");

};
context.DrawRenderers(m_CullResults.visibleRenderers, ref transparentSettings, transparentFilterSettings);
//The Last Stand: Hair Transparency Sorting
//#############################################################################
//#############################################################################
//Transparent backfacing hair cards.
var transparentBackFaceSettings = new DrawRendererSettings(m_CurrCamera, m_TransparentBackfaceName);
transparentBackFaceSettings.sorting.flags = SortFlags.CommonOpaque;
transparentBackFaceSettings.rendererConfiguration = config;
var transparentBackFaceFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque
};
context.DrawRenderers(m_CullResults.visibleRenderers, ref transparentBackFaceSettings, transparentBackFaceFilterSettings);
//Transparent frontfacing hair cards.
var transparentFrontFaceSettings = new DrawRendererSettings(m_CurrCamera, m_TransparentFrontfaceName);
transparentFrontFaceSettings.sorting.flags = SortFlags.CommonOpaque;
transparentFrontFaceSettings.rendererConfiguration = config;
var transparentFrontFaceFilterSettings = new FilterRenderersSettings(true)
{
renderQueueRange = RenderQueueRange.opaque
};
context.DrawRenderers(m_CullResults.visibleRenderers, ref transparentFrontFaceSettings, transparentFrontFaceFilterSettings);
//#############################################################################
//#############################################################################
// Render objects that did not match any shader pass with error shader
RenderObjectsWithError(ref context, transparentFilterSettings, SortFlags.None);

114
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/Hair/LightweightHair.shader


Tags{"LightMode" = "LightweightForward"}
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
ZWrite On
ZTest Less
Cull[_Cull]
HLSLPROGRAM

#pragma shader_feature _SPECGLOSSMAP
#include "LWRP/ShaderLibrary/LightweightPassMeta.hlsl"
ENDHLSL
}
Pass
{
Tags {"LightMode" = "TransparentBackFace"}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
ZTest Less
Cull Front
HLSLPROGRAM
// Required to compile gles 2.0 with standard SRP library
// All shaders must be compiled with HLSLcc and currently only gles is not using HLSLcc by default
#pragma prefer_hlslcc gles
#pragma target 3.0
// -------------------------------------
// Material Keywords
#pragma shader_feature _NORMALMAP
//#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _GLOSSYREFLECTIONS_OFF
#pragma shader_feature _SPECULAR_SETUP
#pragma shader_feature _TWO_SIDED
#pragma shader_feature _HAIR_RECEIVE_SHADOWS
// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ FOG_LINEAR FOG_EXP2
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma vertex LitPassVertex
#pragma fragment LitPassFragment
#include "LightweightPassLit.hlsl"
ENDHLSL
}
Pass
{
Tags {"LightMode" = "TransparentFrontFace"}
Blend SrcAlpha OneMinusSrcAlpha
ZWrite On
ZTest Less
Cull Back
HLSLPROGRAM
// Required to compile gles 2.0 with standard SRP library
// All shaders must be compiled with HLSLcc and currently only gles is not using HLSLcc by default
#pragma prefer_hlslcc gles
#pragma target 3.0
// -------------------------------------
// Material Keywords
#pragma shader_feature _NORMALMAP
//#pragma shader_feature _ALPHATEST_ON
#pragma shader_feature _ALPHAPREMULTIPLY_ON
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICSPECGLOSSMAP
#pragma shader_feature _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature _OCCLUSIONMAP
#pragma shader_feature _SPECULARHIGHLIGHTS_OFF
#pragma shader_feature _GLOSSYREFLECTIONS_OFF
#pragma shader_feature _SPECULAR_SETUP
#pragma shader_feature _TWO_SIDED
#pragma shader_feature _HAIR_RECEIVE_SHADOWS
// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ FOG_LINEAR FOG_EXP2
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma vertex LitPassVertex
#pragma fragment LitPassFragment
#include "LightweightPassLit.hlsl"
ENDHLSL
}

正在加载...
取消
保存