浏览代码

Merge branch 'master' into volume-asset-switch

/main
Thomas 7 年前
当前提交
efa21d88
共有 10 个文件被更改,包括 32 次插入15 次删除
  1. 10
      ScriptableRenderPipeline/Core/CoreRP/ComponentSingleton.cs
  2. 3
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs
  3. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/BaseLitUI.cs
  4. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  5. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs
  6. 10
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Deferred.shader
  7. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs
  8. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/CombineLighting.shader
  9. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs
  10. 4
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CopyStencilBuffer.shader

10
ScriptableRenderPipeline/Core/CoreRP/ComponentSingleton.cs


{
get
{
return s_Instance ?? (s_Instance = new GameObject("Default " + typeof(TType))
if (s_Instance == null)
hideFlags = HideFlags.HideAndDontSave
}.AddComponent<TType>());
GameObject go = new GameObject("Default " + typeof(TType)) { hideFlags = HideFlags.HideAndDontSave };
go.SetActive(false);
s_Instance = go.AddComponent<TType>();
}
return s_Instance;
}
}
}

3
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Camera/HDCamera.cs


{
// If TAA is enabled projMatrix will hold a jittered projection matrix. The original,
// non-jittered projection matrix can be accessed via nonJitteredProjMatrix.
bool taaEnabled = Application.isPlaying && CoreUtils.IsTemporalAntialiasingActive(postProcessLayer);
bool taaEnabled = Application.isPlaying && camera.cameraType == CameraType.Game &&
CoreUtils.IsTemporalAntialiasingActive(postProcessLayer);
var nonJitteredCameraProj = camera.projectionMatrix;
var cameraProj = taaEnabled

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Material/Lit/BaseLitUI.cs


}
// As we tag both during velocity pass and Gbuffer pass we need a separate state and we need to use the write mask
material.SetInt(kStencilRef, stencilRef);
material.SetInt(kStencilWriteMask, (int)HDRenderPipeline.StencilBitMask.Lighting);
material.SetInt(kStencilWriteMask, (int)HDRenderPipeline.StencilBitMask.LightingMask);
material.SetInt(kStencilRefMV, (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);
material.SetInt(kStencilWriteMaskMV, (int)HDRenderPipeline.StencilBitMask.ObjectVelocity);

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


public enum StencilBitMask
{
Clear = 0, // 0x0
Lighting = 7, // 0x7 - 3 bit
LightingMask = 7, // 0x7 - 3 bit
ObjectVelocity = 128, // 1 bit
All = 255 // 0xFF - 8 bit
}

// General material
m_CopyStencilForNoLighting = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.copyStencilBuffer);
m_CopyStencilForNoLighting.SetInt(HDShaderIDs._StencilRef, (int)StencilLightingUsage.NoLighting);
m_CopyStencilForNoLighting.SetInt(HDShaderIDs._StencilMask, (int)StencilBitMask.LightingMask);
m_CameraMotionVectorsMaterial = CoreUtils.CreateEngineMaterial(asset.renderPipelineResources.cameraMotionVectors);
InitializeDebugMaterials();

// In the material classification shader we will simply test is we are no lighting
// Use ShaderPassID 1 => "Pass 1 - Write 1 if value different from stencilRef to output"
CoreUtils.DrawFullScreen(cmd, m_CopyStencilForNoLighting, m_CameraStencilBufferCopyRT, m_CameraDepthStencilBufferRT, null, 1);
cmd.ClearRandomWriteTargets();
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDStringConstants.cs


public static readonly int _EnvLightDatas = Shader.PropertyToID("_EnvLightDatas");
public static readonly int _EnvLightCount = Shader.PropertyToID("_EnvLightCount");
public static readonly int _ShadowDatas = Shader.PropertyToID("_ShadowDatas");
public static readonly int _DirShadowSplitSpheres = Shader.PropertyToID("_DirShadowSplitSpheres");
public static readonly int _NumTileFtplX = Shader.PropertyToID("_NumTileFtplX");
public static readonly int _NumTileFtplY = Shader.PropertyToID("_NumTileFtplY");
public static readonly int _NumTileClusteredX = Shader.PropertyToID("_NumTileClusteredX");

public static readonly int _ProjectionParams = Shader.PropertyToID("_ProjectionParams");
public static readonly int _WorldSpaceCameraPos = Shader.PropertyToID("_WorldSpaceCameraPos");
public static readonly int _StencilMask = Shader.PropertyToID("_StencilMask");
public static readonly int _StencilRef = Shader.PropertyToID("_StencilRef");
public static readonly int _StencilCmp = Shader.PropertyToID("_StencilCmp");

10
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Deferred.shader


Properties
{
// We need to be able to control the blend mode for deferred shader in case we do multiple pass
_SrcBlend("", Float) = 1
_DstBlend("", Float) = 1
[HideInInspector] _SrcBlend("", Float) = 1
[HideInInspector] _DstBlend("", Float) = 1
_StencilRef("", Int) = 0
_StencilCmp("", Int) = 3
[HideInInspector] _StencilMask("_StencilMask", Int) = 7
[HideInInspector] _StencilRef("", Int) = 0
[HideInInspector] _StencilCmp("", Int) = 3
}
SubShader

Stencil
{
ReadMask[_StencilMask]
Ref [_StencilRef]
Comp [_StencilCmp]
Pass Keep

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/LightLoop.cs


public List<LightData> lights;
public List<EnvLightData> envLights;
public List<ShadowData> shadows;
public Vector4[] directionalShadowSplitSphereSqr;
public List<SFiniteLightBound> bounds;
public List<LightVolumeData> lightVolumes;

lights = new List<LightData>();
envLights = new List<EnvLightData>();
shadows = new List<ShadowData>();
directionalShadowSplitSphereSqr = new Vector4[k_MaxCascadeCount];
bounds = new List<SFiniteLightBound>();
lightVolumes = new List<LightVolumeData>();

CoreUtils.SetKeyword(m_deferredLightingMaterial[index], "SHADOWS_SHADOWMASK", shadowMask == 1);
CoreUtils.SetKeyword(m_deferredLightingMaterial[index], "DEBUG_DISPLAY", debugDisplay == 1);
m_deferredLightingMaterial[index].SetInt(HDShaderIDs._StencilMask, (int)HDRenderPipeline.StencilBitMask.LightingMask);
m_deferredLightingMaterial[index].SetInt(HDShaderIDs._StencilRef, outputSplitLighting == 1 ? (int)StencilLightingUsage.SplitLighting : (int)StencilLightingUsage.RegularLighting);
m_deferredLightingMaterial[index].SetInt(HDShaderIDs._StencilCmp, (int)CompareFunction.Equal);
m_deferredLightingMaterial[index].SetInt(HDShaderIDs._SrcBlend, (int)BlendMode.One);

cmd.SetGlobalBuffer(HDShaderIDs._EnvLightDatas, s_EnvLightDatas);
cmd.SetGlobalInt(HDShaderIDs._EnvLightCount, m_lightList.envLights.Count);
cmd.SetGlobalBuffer(HDShaderIDs._ShadowDatas, s_shadowDatas);
cmd.SetGlobalVectorArray(HDShaderIDs._DirShadowSplitSpheres, m_lightList.directionalShadowSplitSphereSqr);
cmd.SetGlobalInt(HDShaderIDs._NumTileFtplX, GetNumTileFtplX(camera));
cmd.SetGlobalInt(HDShaderIDs._NumTileFtplY, GetNumTileFtplY(camera));

6
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/CombineLighting.shader


Shader "Hidden/HDRenderPipeline/CombineLighting"
{
Properties
{
[HideInInspector] _StencilMask("_StencilMask", Int) = 7
}
SubShader
{
Pass

ReadMask [_StencilMask]
Ref 1 // StencilLightingUsage.SplitLighting
Comp Equal
Pass Keep

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs


m_SubsurfaceScatteringCS = hdAsset.renderPipelineResources.subsurfaceScatteringCS;
m_SubsurfaceScatteringKernel = m_SubsurfaceScatteringCS.FindKernel("SubsurfaceScattering");
m_CombineLightingPass = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.combineLighting);
m_CombineLightingPass.SetInt(HDShaderIDs._StencilMask, (int)HDRenderPipeline.StencilBitMask.LightingMask);
// Jimenez SSS Model (shader)
m_SssVerticalFilterPass = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.subsurfaceScattering);

m_CopyStencilForSplitLighting = CoreUtils.CreateEngineMaterial(hdAsset.renderPipelineResources.copyStencilBuffer);
m_CopyStencilForSplitLighting.SetInt(HDShaderIDs._StencilRef, (int)StencilLightingUsage.SplitLighting);
m_CopyStencilForSplitLighting.SetInt(HDShaderIDs._StencilMask, (int)HDRenderPipeline.StencilBitMask.LightingMask);
}
public void Cleanup()

4
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CopyStencilBuffer.shader


Properties
{
[HideInInspector] _StencilRef("_StencilRef", Int) = 1
[HideInInspector] _StencilMask("_StencilMask", Int) = 7
}
HLSLINCLUDE

Stencil
{
ReadMask [_StencilMask]
Ref [_StencilRef]
Comp Equal
Pass Keep

Stencil
{
ReadMask [_StencilMask]
Ref [_StencilRef]
Comp NotEqual
Pass Keep

Stencil
{
ReadMask [_StencilMask]
Ref [_StencilRef]
Comp Equal
Pass Keep

正在加载...
取消
保存