浏览代码

- Fixed shadow map debug max slider value with the correct number of visible shadows

- Fixed the shadow debug display shader to use the full screen quad GetVertexPosition method.
/main
Julien Ignace 8 年前
当前提交
fe794f54
共有 4 个文件被更改,包括 25 次插入37 次删除
  1. 26
      Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader
  2. 13
      Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
  3. 14
      Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs
  4. 9
      Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl

26
Assets/ScriptableRenderLoop/HDRenderPipeline/Debug/Resources/DebugDisplayShadowMap.shader


Varyings Vert(Attributes input)
{
float4 positions[] =
{
float4(-1.0, -1.0, 0.0f, 1.0),
float4( 1.0, -1.0, 0.0f, 1.0),
float4( 1.0, 1.0, 0.0f, 1.0),
float4( 1.0, 1.0, 0.0f, 1.0),
float4(-1.0, 1.0, 0.0f, 1.0),
float4(-1.0, -1.0, 0.0f, 1.0)
};
float2 texcoords[] =
{
float2(0.0, 1.0),
float2(1.0, 1.0),
float2(1.0, 0.0),
float2(1.0, 0.0),
float2(0.0, 0.0),
float2(0.0, 1.0),
};
output.positionCS = positions[input.vertexID];
output.texcoord = texcoords[input.vertexID] * _TextureScaleBias.xy + _TextureScaleBias.zw;
output.positionCS = GetFullscreenTriangleVertexPosition(input.vertexID);
output.texcoord = GetFullscreenTriangleTexcoord(input.vertexID) * _TextureScaleBias.xy + _TextureScaleBias.zw;
return output;
}

13
Assets/ScriptableRenderLoop/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs


method.Invoke(asset, new object[0]);
}
private void DebuggingUI(HDRenderPipeline renderContext)
private void DebuggingUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
{
EditorGUILayout.LabelField(styles.debugging);

DebugParametersUI(renderContext);
EditorGUILayout.Space();
ShadowDebugParametersUI(renderContext);
ShadowDebugParametersUI(renderContext, renderpipelineInstance);
EditorGUI.indentLevel--;
}

}
}
private void ShadowDebugParametersUI(HDRenderPipeline renderContext)
private void ShadowDebugParametersUI(HDRenderPipeline renderContext, HDRenderPipelineInstance renderpipelineInstance)
{
m_ShowDebugShadow.boolValue = EditorGUILayout.Foldout(m_ShowDebugShadow.boolValue, styles.shadowDebugParameters);
if (!m_ShowDebugShadow.boolValue)

{
if ((ShadowDebugMode)m_DebugShadowVisualizationMode.intValue == ShadowDebugMode.VisualizeShadowMap)
{
EditorGUILayout.IntSlider(m_DebugShadowVisualizeShadowIndex, 0, 5/*renderContext.GetCurrentShadowCount() - 1*/, styles.shadowDebugVisualizeShadowIndex);
EditorGUILayout.IntSlider(m_DebugShadowVisualizeShadowIndex, 0, renderpipelineInstance.GetCurrentShadowCount() - 1, styles.shadowDebugVisualizeShadowIndex);
}
}
EditorGUI.indentLevel--;

public override void OnInspectorGUI()
{
var renderContext = target as HDRenderPipeline;
HDRenderPipelineInstance renderpipelineInstance = UnityEngine.Experimental.Rendering.RenderPipelineManager.currentPipeline as HDRenderPipelineInstance;
if (!renderContext)
if (!renderContext || renderpipelineInstance == null)
DebuggingUI(renderContext);
DebuggingUI(renderContext, renderpipelineInstance);
SkySettingsUI(renderContext);
ShadowParametersUI(renderContext);
TextureParametersUI(renderContext);

14
Assets/ScriptableRenderLoop/HDRenderPipeline/HDRenderPipeline.cs


Shader.SetGlobalInt("_EnvLightSkyEnabled", 1);
}
else
{
{
}
}
var cmd = new CommandBuffer {name = "Push Global Parameters"};

renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
}
public override void Render(ScriptableRenderContext renderContext, Camera[] cameras)
{

propertyBlock.SetVector("_TextureScaleBias", texcoordScaleBias);
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 6, 1, propertyBlock);
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}

propertyBlock.SetVector("_TextureScaleBias", new Vector4(1.0f, 1.0f, 0.0f, 0.0f));
debugCB.SetViewport(new Rect(x, y, overlaySize, overlaySize));
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 6, 1, propertyBlock);
debugCB.DrawProcedural(Matrix4x4.identity, m_DebugDisplayShadowMap, 0, MeshTopology.Triangles, 3, 1, propertyBlock);
NextOverlayCoord(ref x, ref y, overlaySize, camera.pixelWidth);
}

9
Assets/ScriptableRenderLoop/ShaderLibrary/Common.hlsl


// Generates a triangle in homogeneous clip space, s.t.
// v0 = (-1, -1, 1), v1 = (3, -1, 1), v2 = (-1, 3, 1).
float2 GetFullscreenTriangleTexcoord(uint vertexID)
{
#if UNITY_UV_STARTS_AT_TOP
return float2((vertexID << 1) & 2, 1.0 - (vertexID & 2));
#else
return float2((vertexID << 1) & 2, vertexID & 2);
#endif
}
float4 GetFullscreenTriangleVertexPosition(uint vertexID)
{
float2 uv = float2((vertexID << 1) & 2, vertexID & 2);

正在加载...
取消
保存