浏览代码

Add DECAL_OFF for decal to remove more variant + rename

/main
Sebastien Lagarde 6 年前
当前提交
fbcdb866
共有 10 个文件被更改,包括 56 次插入28 次删除
  1. 32
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/BaseShaderPreprocessor.cs
  2. 10
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl
  3. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
  4. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl
  5. 6
      com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader
  6. 6
      com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader
  7. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader
  8. 9
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader
  9. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
  10. 2
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

32
com.unity.render-pipelines.high-definition/HDRP/Editor/Material/BaseShaderPreprocessor.cs


protected ShaderKeyword m_TileLighting;
protected ShaderKeyword m_ClusterLighting;
protected ShaderKeyword m_LodFadeCrossFade;
protected ShaderKeyword m_DecalsOFF;
protected ShaderKeyword m_Decals3RT;
protected ShaderKeyword m_Decals4RT;

m_TileLighting = new ShaderKeyword("USE_FPTL_LIGHTLIST");
m_ClusterLighting = new ShaderKeyword("USE_CLUSTERED_LIGHTLIST");
m_LodFadeCrossFade = new ShaderKeyword("LOD_FADE_CROSSFADE");
m_DecalsOFF = new ShaderKeyword("DECALS_OFF");
m_Decals3RT = new ShaderKeyword("DECALS_3RT");
m_Decals4RT = new ShaderKeyword("DECALS_4RT");
}

return true;
// Decal case
// If no decal, remove decal variant
if ((inputData.shaderKeywordSet.IsEnabled(m_Decals3RT) || inputData.shaderKeywordSet.IsEnabled(m_Decals4RT)) && !hdrpAsset.renderPipelineSettings.supportDecals)
return true;
// If decal but with 4RT remove 3RT variant and vice versa
if (inputData.shaderKeywordSet.IsEnabled(m_Decals3RT) && hdrpAsset.renderPipelineSettings.decalSettings.perChannelMask)
return true;
if (inputData.shaderKeywordSet.IsEnabled(m_Decals4RT) && !hdrpAsset.renderPipelineSettings.decalSettings.perChannelMask)
return true;
// If decal support, remove unused variant
if (hdrpAsset.renderPipelineSettings.supportDecals)
{
// Remove the no decal case
if (inputData.shaderKeywordSet.IsEnabled(m_DecalsOFF))
return true;
// If decal but with 4RT remove 3RT variant and vice versa
if (inputData.shaderKeywordSet.IsEnabled(m_Decals3RT) && hdrpAsset.renderPipelineSettings.decalSettings.perChannelMask)
return true;
if (inputData.shaderKeywordSet.IsEnabled(m_Decals4RT) && !hdrpAsset.renderPipelineSettings.decalSettings.perChannelMask)
return true;
}
else
{
// If no decal support, remove decal variant
if (inputData.shaderKeywordSet.IsEnabled(m_Decals3RT) || inputData.shaderKeywordSet.IsEnabled(m_Decals4RT))
return true;
}
return false;
}

10
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl


#define DBufferType1 float4
#define DBufferType2 float4
#ifdef _DECALS_4RT
#ifdef DECALS_4RT
#define DBufferType3 float2
#define OUTPUT_DBUFFER(NAME) \

, out DBufferType0 outDBuffer0
, out DBufferType1 outDBuffer1
, out DBufferType2 outDBuffer2
#ifdef _DECALS_4RT
#ifdef DECALS_4RT
, out DBufferType3 outDBuffer3
#endif
)

outDBuffer2 = surfaceData.mask;
#ifdef _DECALS_4RT
#ifdef DECALS_4RT
outDBuffer3 = surfaceData.MAOSBlend;
#endif
}

, DBufferType1 inDBuffer1
, DBufferType2 inDBuffer2
#ifdef _DECALS_4RT
#ifdef DECALS_4RT
, DBufferType3 inDBuffer3
#endif
, out DecalSurfaceData surfaceData

surfaceData.normalWS.xyz = inDBuffer1.xyz * 2.0 - 1.0;
surfaceData.normalWS.w = inDBuffer1.w;
surfaceData.mask = inDBuffer2;
#ifdef _DECALS_4RT
#ifdef DECALS_4RT
surfaceData.MAOSBlend = inDBuffer3;
#else
surfaceData.MAOSBlend = float2(surfaceData.mask.w, surfaceData.mask.w);

3
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader


#pragma shader_feature _MASK_BLEND_SRC_B
#pragma multi_compile_instancing
#pragma multi_compile _ _DECALS_4RT
// No need to teset for DECALS_3RT we are in decal shader, so there is no OFF state
#pragma multi_compile _ DECALS_4RT
//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------

4
com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl


DBuffer0 = float4(0.0f, 0.0f, 0.0f, 1.0f);
DBuffer1 = float4(0.5f, 0.5f, 0.5f, 1.0f);
DBuffer2 = float4(0.0f, 0.0f, 0.0f, 1.0f);
#ifdef _DECALS_4RT
#ifdef DECALS_4RT
DBuffer3 = float2(1.0f, 1.0f);
#else
float2 DBuffer3 = float2(1.0f, 1.0f);

if (mask & DBUFFERHTILEBIT_MASK)
{
#ifdef _DECALS_4RT // only smoothness in 3RT mode
#ifdef DECALS_4RT // only smoothness in 3RT mode
surfaceData.metallic = surfaceData.metallic * decalSurfaceData.MAOSBlend.x + decalSurfaceData.mask.x;
surfaceData.ambientOcclusion = surfaceData.ambientOcclusion * decalSurfaceData.MAOSBlend.y + decalSurfaceData.mask.y;
#endif

6
com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader


#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#ifdef _ALPHATEST_ON
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

6
com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader


#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#ifdef _ALPHATEST_ON
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

9
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader


#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#ifdef _ALPHATEST_ON
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

9
com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader


#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
#ifdef _ALPHATEST_ON
// When we have alpha test, we will force a depth prepass so we always bypass the clip instruction in the GBuffer

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl"
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

3
com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader


#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile _ DECALS_3RT DECALS_4RT
// Setup DECALS_OFF so the shader stripper can remove variants
#pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT
// #include "../../Lighting/Forward.hlsl" : nothing left in there.
//#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS

2
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


{
if (m_Asset.renderPipelineSettings.supportDecals)
{
CoreUtils.SetKeyword(cmd, "DECALS_OFF", false);
CoreUtils.SetKeyword(cmd, "DECALS_OFF", true);
CoreUtils.SetKeyword(cmd, "DECALS_3RT", false);
CoreUtils.SetKeyword(cmd, "DECALS_4RT", false);
}

正在加载...
取消
保存