浏览代码

Merge pull request #1757 from Unity-Technologies/HDRP/staging

Merge Hdrp/staging
/main
GitHub 6 年前
当前提交
019f3227
共有 12 个文件被更改,包括 72 次插入40 次删除
  1. 36
      com.unity.render-pipelines.high-definition/HDRP/Editor/Material/BaseShaderPreprocessor.cs
  2. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/UpgradeMenuItem.cs
  3. 10
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.hlsl
  4. 3
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/Decal.shader
  5. 4
      com.unity.render-pipelines.high-definition/HDRP/Material/Decal/DecalUtilities.hlsl
  6. 8
      com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLit.shader
  7. 8
      com.unity.render-pipelines.high-definition/HDRP/Material/LayeredLit/LayeredLitTessellation.shader
  8. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/Lit.shader
  9. 11
      com.unity.render-pipelines.high-definition/HDRP/Material/Lit/LitTessellation.shader
  10. 2
      com.unity.render-pipelines.high-definition/HDRP/Material/Material.hlsl
  11. 5
      com.unity.render-pipelines.high-definition/HDRP/Material/StackLit/StackLit.shader
  12. 10
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

36
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_Decals3RT = new ShaderKeyword("_DECALS_3RT");
m_Decals4RT = new ShaderKeyword("_DECALS_4RT");
m_DecalsOFF = new ShaderKeyword("DECALS_OFF");
m_Decals3RT = new ShaderKeyword("DECALS_3RT");
m_Decals4RT = new ShaderKeyword("DECALS_4RT");
}
public virtual void AddStripperFuncs(Dictionary<string, VariantStrippingFunc> stripperFuncs) {}

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;
}

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Upgraders/UpgradeMenuItem.cs


// When _HdrpVersion don't exist we MUST create it, otherwise next call to
// mat.SetFloat("_HdrpVersion", value) will just put the default value instead of the value we pass!
// a call to GetFloat("_HdrpVersion") solve this.
float useless = mat.GetFloat("_HdrpVersion");
#pragma warning disable 219 // Silent warning
float unused = mat.GetFloat("_HdrpVersion");
#pragma warning restore 219
return 0.0f;
}

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

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


// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// decal 3RT or 4RT toggle
#pragma multi_compile _ _DECALS_3RT _DECALS_4RT
//enable GPU instancing support
#pragma multi_compile_instancing

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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
// 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
#define LIGHTLOOP_TILE_PASS

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


// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// decal 3RT or 4RT toggle
#pragma multi_compile _ _DECALS_3RT _DECALS_4RT
// enable GPU instancing
#pragma multi_compile_instancing

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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
// 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
#define LIGHTLOOP_TILE_PASS

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


// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// decal 3RT or 4RT toggle
#pragma multi_compile _ _DECALS_3RT _DECALS_4RT
//enable GPU instancing support
#pragma multi_compile_instancing

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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
// 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
#define LIGHTLOOP_TILE_PASS

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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
#define LIGHTLOOP_TILE_PASS

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


// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE
// decal 3RT or 4RT toggle
#pragma multi_compile _ _DECALS_3RT _DECALS_4RT
//enable GPU instancing support
#pragma multi_compile_instancing

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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
// 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
#define LIGHTLOOP_TILE_PASS

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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
#define LIGHTLOOP_TILE_PASS

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


// - _ENABLE_FOG_ON_TRANSPARENT if fog is enable on transparent surface
// - _DISABLE_DECALS if the material don't support decals
#define HAVE_DECALS ( (defined(_DECALS_3RT) || defined(_DECALS_4RT)) && !defined(_DISABLE_DECALS) )
#define HAVE_DECALS ( (defined(DECALS_3RT) || defined(DECALS_4RT)) && !defined(_DISABLE_DECALS) )
//-----------------------------------------------------------------------------
// ApplyBlendMode function

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


#pragma shader_feature _STACKLIT_DEBUG
// decal 3RT or 4RT toggle
#pragma multi_compile _ _DECALS_3RT _DECALS_4RT
//enable GPU instancing support
#pragma multi_compile_instancing

#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ SHADOWS_SHADOWMASK
// 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

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


{
if (m_Asset.renderPipelineSettings.supportDecals)
{
CoreUtils.SetKeyword(cmd, "_DECALS_3RT", !m_Asset.GetRenderPipelineSettings().decalSettings.perChannelMask);
CoreUtils.SetKeyword(cmd, "_DECALS_4RT", m_Asset.GetRenderPipelineSettings().decalSettings.perChannelMask);
CoreUtils.SetKeyword(cmd, "DECALS_OFF", false);
CoreUtils.SetKeyword(cmd, "DECALS_3RT", !m_Asset.GetRenderPipelineSettings().decalSettings.perChannelMask);
CoreUtils.SetKeyword(cmd, "DECALS_4RT", m_Asset.GetRenderPipelineSettings().decalSettings.perChannelMask);
CoreUtils.SetKeyword(cmd, "_DECALS_3RT", false);
CoreUtils.SetKeyword(cmd, "_DECALS_4RT", false);
CoreUtils.SetKeyword(cmd, "DECALS_OFF", true);
CoreUtils.SetKeyword(cmd, "DECALS_3RT", false);
CoreUtils.SetKeyword(cmd, "DECALS_4RT", false);
}
}

正在加载...
取消
保存