浏览代码

Add proper configuration of unlit.shader to render with new depth test

/stochastic_alpha_test
Sebastien Lagarde 7 年前
当前提交
fc851786
共有 4 个文件被更改,包括 79 次插入1 次删除
  1. 47
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader
  2. 11
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/UnlitData.hlsl
  3. 12
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/ShaderPass/UnlitDepthPass.hlsl
  4. 10
      ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/ShaderPass/UnlitDepthPass.hlsl.meta

47
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader


Pass
{
Name "DepthOnly"
Tags{ "LightMode" = "DepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/UnlitDepthPass.hlsl"
#include "UnlitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
// Unlit opaque material need to be render with ForwardOnlyOpaqueDepthOnly. Unlike Lit that can be both deferred and forward,
// unlit require to be forward only, that's why we need this pass.
// Also in case of forward rendering, unlit will use regular DepthOnly pass.
// (Code is exactly the same as "Forward", it simply allow our system to filter objects correctly)
Pass
{
Name "ForwardOnlyOpaqueDepthOnly"
Tags{ "LightMode" = "ForwardOnlyOpaqueDepthOnly" }
Cull[_CullMode]
ZWrite On
HLSLPROGRAM
#define SHADERPASS SHADERPASS_DEPTH_ONLY
#include "../../ShaderVariables.hlsl"
#include "../../Material/Material.hlsl"
#include "ShaderPass/UnlitDepthPass.hlsl"
#include "UnlitData.hlsl"
#include "../../ShaderPass/ShaderPassDepthOnly.hlsl"
ENDHLSL
}
Pass
{
Name "ForwardUnlit"
Tags { "LightMode" = "Forward" }

// Unlit opaque material need to be render with ForwardOnlyOpaque. Unlike Lit that can be both deferred and forward,
// unlit require to be forward only, that's why we need this pass. Unlit transparent will use regular Forward pass
// Also in case of forward rendering, unlit will use regular forward pass too
// (Code is exactly the same as "Forward", it simply allow our system to filter objects correctly)
Pass
{

11
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/UnlitData.hlsl


// Fill SurfaceData/Builtin data function
//-------------------------------------------------------------------------------------
void DoAlphaTest(float alpha, float alphaCutoff)
{
// For Forward (Full forward or ForwardOnlyOpaque in deferred):
// Opaque geometry always has a depth pre-pass so we never want to do the clip here. For transparent we perform the clip as usual.
#if (SHADER_PASS == SHADERPASS_FORWARD_UNLIT && defined(SURFACE_TYPE_TRANSPARENT))
clip(alpha - alphaCutoff);
#endif
}
void GetSurfaceAndBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, out SurfaceData surfaceData, out BuiltinData builtinData)
{
surfaceData.color = SAMPLE_TEXTURE2D(_ColorMap, sampler_ColorMap, input.texCoord0).rgb * _Color.rgb;

clip(alpha - _AlphaCutoff);
DoAlphaTest(alpha, _AlphaCutoff);
#endif
// Builtin Data

12
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/ShaderPass/UnlitDepthPass.hlsl


#ifndef SHADERPASS
#error Undefine_SHADERPASS
#endif
#ifdef _ALPHATEST_ON
#define ATTRIBUTES_NEED_TEXCOORD0
#define VARYINGS_NEED_TEXCOORD0
#endif
// This include will define the various Attributes/Varyings structure
#include "../../ShaderPass/VaryingMesh.hlsl"

10
ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/ShaderPass/UnlitDepthPass.hlsl.meta


fileFormatVersion: 2
guid: f211364c93a5e8d49b005301800e84f7
timeCreated: 1507844863
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存