浏览代码

Removed Material from Shadow Debug API (it's now held by the shadow system)

/RenderPassXR_Sandbox
Julien Ignace 8 年前
当前提交
e20b9e23
共有 9 个文件被更改,包括 30 次插入25 次删除
  1. 18
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 10
      Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs
  3. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  4. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs
  5. 6
      Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader
  6. 9
      Assets/ScriptableRenderPipeline/Core/Shadow/Resources.meta
  7. 0
      /Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader.meta
  8. 0
      /Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader

18
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


protected uint[] m_TmpHeights = new uint[ShadowmapBase.ShadowRequest.k_MaxFaceCount];
protected Vector4[] m_TmpSplits = new Vector4[k_MaxCascadesInShader];
protected ShadowAlgoVector m_SupportedAlgorithms = new ShadowAlgoVector( 0, false );
protected Material m_DebugMaterial = null;
protected struct Key
{

public void Initialize( AtlasInit init )
{
m_ShaderKeyword = init.shaderKeyword;
m_ShaderKeyword = init.shaderKeyword;
m_DebugMaterial = new Material(Shader.Find("Hidden/ScriptableRenderPipeline/DebugDisplayShadowMap")) { hideFlags = HideFlags.HideAndDontSave };
}
override public void ReserveSlots( ShadowContextStorage sc )

{
if( m_Shadowmap != null )
m_Shadowmap.Release();
Object.DestroyImmediate(m_DebugMaterial);
}
override public bool Reserve( FrameId frameId, ref ShadowData shadowData, ShadowRequest sr, uint width, uint height, ref VectorArray<ShadowData> entries, ref VectorArray<ShadowPayload> payload, VisibleLight[] lights )

// Nothing to do for this implementation here, as the atlas is reconstructed each frame, instead of keeping state across frames
}
override public void DisplayShadowMap(ScriptableRenderContext renderContext, Material displayMaterial, Vector4 scaleBias, float screenX, float screenY, float screenSizeX, float screenSizeY)
override public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, float screenX, float screenY, float screenSizeX, float screenSizeY)
{
CommandBuffer debugCB = new CommandBuffer();
debugCB.name = "";

propertyBlock.SetVector("_TextureScaleBias", scaleBias);
debugCB.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY));
debugCB.DrawProcedural(Matrix4x4.identity, displayMaterial, displayMaterial.FindPass("RegularShadow"), MeshTopology.Triangles, 3, 1, propertyBlock);
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugMaterial, m_DebugMaterial.FindPass("RegularShadow"), MeshTopology.Triangles, 3, 1, propertyBlock);
renderContext.ExecuteCommandBuffer(debugCB);
}

}
}
public override void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapRequestIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
public override void DisplayShadows(ScriptableRenderContext renderContext, int shadowMapRequestIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
{
if (m_ShadowIndices.Count() == 0)
return;

ShadowData faceData = shadowDatas[(uint)(m_ShadowIndices[index] + offset + faceIndex)];
uint texID, samplerID, slice;
faceData.UnpackShadowmapId(out texID, out samplerID, out slice);
m_Shadowmaps[texID].DisplayShadowMap(renderContext, displayMaterial, faceData.scaleOffset, screenX, screenY, screenSizeX, screenSizeY);
m_Shadowmaps[texID].DisplayShadowMap(renderContext, faceData.scaleOffset, screenX, screenY, screenSizeX, screenSizeY);
public override void DisplayShadowAtlas(ScriptableRenderContext renderContext, Material displayMaterial, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
public override void DisplayShadowAtlas(ScriptableRenderContext renderContext, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY)
m_Shadowmaps[index].DisplayShadowMap(renderContext, displayMaterial, new Vector4(1.0f, 1.0f, 0.0f, 0.0f), screenX, screenY, screenSizeX, screenSizeY);
m_Shadowmaps[index].DisplayShadowMap(renderContext, new Vector4(1.0f, 1.0f, 0.0f, 0.0f), screenX, screenY, screenSizeX, screenSizeY);
}
public override void SyncData()

10
Assets/ScriptableRenderPipeline/Core/Shadow/ShadowBase.cs


abstract public void ReserveSlots( ShadowContextStorage sc );
abstract public void Fill( ShadowContextStorage cs );
abstract protected void Register( GPUShadowType type, ShadowRegistry registry );
abstract public void DisplayShadowMap(ScriptableRenderContext renderContext, Material displayMaterial, Vector4 scaleBias, float screenX, float screenY, float screenSizeX, float screenSizeY);
abstract public void DisplayShadowMap(ScriptableRenderContext renderContext, Vector4 scaleBias, float screenX, float screenY, float screenSizeX, float screenSizeY);
}
interface IShadowManager

// Renders all shadows for lights the were deemed shadow casters after the last call to ProcessShadowRequests
void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
// Debug function to display a shadow at the screen coordinate with the provided material.
void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
void DisplayShadowAtlas(ScriptableRenderContext renderContext, Material displayMaterial, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
void DisplayShadows(ScriptableRenderContext renderContext, int shadowMapIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
void DisplayShadowAtlas(ScriptableRenderContext renderContext, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
// Synchronize data with GPU buffers
void SyncData();
// Binds resources to shader stages just before rendering the lighting pass

{
public abstract void ProcessShadowRequests( FrameId frameId, CullResults cullResults, Camera camera, VisibleLight[] lights, ref uint shadowRequestsCount, int[] shadowRequests, out int[] shadowDataIndices );
public abstract void RenderShadows( FrameId frameId, ScriptableRenderContext renderContext, CullResults cullResults, VisibleLight[] lights );
public abstract void DisplayShadows(ScriptableRenderContext renderContext, Material displayMaterial, int shadowMapIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void DisplayShadowAtlas(ScriptableRenderContext renderContext, Material displayMaterial, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void DisplayShadows(ScriptableRenderContext renderContext, int shadowMapIndex, uint faceIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void DisplayShadowAtlas(ScriptableRenderContext renderContext, uint atlasIndex, float screenX, float screenY, float screenSizeX, float screenSizeY);
public abstract void SyncData();
public abstract void BindResources( ScriptableRenderContext renderContext );
public abstract void UpdateCullingParameters( ref CullingParameters cullingParams );

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


Light m_CurrentSunLight = null;
public Light GetCurrentSunLight() { return m_CurrentSunLight; }
// For displaying shadow map
Material m_DebugDisplayShadowMap;
// shadow related stuff
FrameId m_FrameId = new FrameId();
ShadowSetup m_ShadowSetup; // doesn't actually have to reside here, it would be enough to pass the IShadowManager in from the outside

m_SingleDeferredMaterialMRT.SetInt("_DstBlend", (int)BlendMode.Zero);
m_DebugViewTilesMaterial = Utilities.CreateEngineMaterial(m_Resources.debugViewTilesShader);
m_DebugDisplayShadowMap = Utilities.CreateEngineMaterial(m_Resources.debugDisplayShadowMapShader);
m_DefaultTexture2DArray = new Texture2DArray(1, 1, 1, TextureFormat.ARGB32, false);
m_DefaultTexture2DArray.SetPixels32(new Color32[1] { new Color32(128, 128, 128, 128) }, 0);

Utilities.Destroy(m_SingleDeferredMaterialSRT);
Utilities.Destroy(m_SingleDeferredMaterialMRT);
Utilities.Destroy(m_DebugDisplayShadowMap);
Utilities.Destroy(s_DefaultAdditionalLightDataGameObject);
s_DefaultAdditionalLightDataGameObject = null;

uint faceCount = m_ShadowMgr.GetShadowRequestFaceCount(lightingDebug.shadowMapIndex);
for (uint i = 0; i < faceCount; ++i )
{
m_ShadowMgr.DisplayShadows(renderContext, m_DebugDisplayShadowMap, (int)lightingDebug.shadowMapIndex, i, x, y, overlaySize, overlaySize);
m_ShadowMgr.DisplayShadows(renderContext, (int)lightingDebug.shadowMapIndex, i, x, y, overlaySize, overlaySize);
m_ShadowMgr.DisplayShadowAtlas(renderContext, m_DebugDisplayShadowMap, lightingDebug.shadowAtlasIndex, x, y, overlaySize, overlaySize);
m_ShadowMgr.DisplayShadowAtlas(renderContext, lightingDebug.shadowAtlasIndex, x, y, overlaySize, overlaySize);
Utilities.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, camera.pixelWidth);
}
}

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs


var instance = CreateInstance<RenderPipelineResources>();
instance.debugDisplayLatlongShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayLatlong.Shader");
instance.debugDisplayShadowMapShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayShadowMap.Shader");
instance.debugViewMaterialGBufferShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewMaterialGBuffer.Shader");
instance.debugViewTilesShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewTiles.Shader");
instance.debugFullScreenShader = UnityEditor.AssetDatabase.LoadAssetAtPath<Shader>("Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.Shader");

#endif
// Debug
public Shader debugDisplayLatlongShader;
public Shader debugDisplayShadowMapShader;
public Shader debugViewMaterialGBufferShader;
public Shader debugViewTilesShader;
public Shader debugFullScreenShader;

6
Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader


Shader "Hidden/HDRenderPipeline/DebugDisplayShadowMap"
Shader "Hidden/ScriptableRenderPipeline/DebugDisplayShadowMap"
#include "../../ShaderLibrary/Common.hlsl"
#include "../../../ShaderLibrary/Common.hlsl"
#include "../../ShaderLibrary/Shadow/Shadow.hlsl"
#include "../../../ShaderLibrary/Shadow/Shadow.hlsl"
#undef SHADOW_TILEPASS
float4 _TextureScaleBias;

9
Assets/ScriptableRenderPipeline/Core/Shadow/Resources.meta


fileFormatVersion: 2
guid: 17c6560a19ee38a488a305b841122612
folderAsset: yes
timeCreated: 1496931301
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayShadowMap.shader.meta → /Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader.meta

/Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplayShadowMap.shader → /Assets/ScriptableRenderPipeline/Core/Shadow/Resources/DebugDisplayShadowMap.shader

正在加载...
取消
保存