浏览代码

First draft

/main
sebastienlagarde 7 年前
当前提交
9269e0af
共有 4 个文件被更改,包括 52 次插入13 次删除
  1. 8
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader
  2. 23
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  3. 32
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/Blit.shader
  4. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CameraMotionVectors.shader

8
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Debug/DebugFullScreen.shader


float2 SampleMotionVectors(float2 coords)
{
#if UNITY_UV_STARTS_AT_TOP
coords.y = 1.0 - coords.y;
// coords.y = 1.0 - coords.y;
mv.y *= -1.0;
// mv.y *= -1.0;
#endif
return mv;

}
if (_FullScreenDebugMode == FULLSCREENDEBUGMODE_NAN_TRACKER)
{
#if UNITY_UV_STARTS_AT_TOP
input.texcoord.y = 1.0 - input.texcoord.y;
#endif
float4 color = SAMPLE_TEXTURE2D(_DebugFullScreenTexture, sampler_DebugFullScreenTexture, input.texcoord);
if (any(isnan(color)) || any(isinf(color)))

23
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


// Fill depth buffer to reduce artifact for transparent object during postprocess
RenderTransparentDepthPostpass(m_CullResults, camera, renderContext, cmd, ForwardPass.Transparent);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, hdCamera, FullScreenDebugMode.NanTracker);
PushFullScreenDebugTexture(cmd, m_CameraColorBuffer, hdCamera, FullScreenDebugMode.NanTracker);
// The final pass either postprocess of Blit will flip the screen (as it is reverse by default due to Unity openGL legacy)
// Postprocess system (that doesn't use cmd.Blit) handle it with configuration (and do not flip in SceneView) or it is automatically done in Blit
// Final blit
if (m_FrameSettings.enablePostprocess && CoreUtils.IsPostProcessingActive(postProcessLayer))
{

{
using (new ProfilingSample(cmd, "Blit to final RT", CustomSamplerId.BlitToFinalRT.GetSampler()))
{
// This Blit will flip the screen anything other than openGL
// Simple blit
cmd.Blit(m_CameraColorBufferRT, BuiltinRenderTextureType.CameraTarget);
}

// Caution: RenderDebug need to take into account that we have flip the screen (so anything capture before the flip will be flipped)
RenderDebug(hdCamera, cmd);
// Make sure to unbind every render texture here because in the next iteration of the loop we might have to reallocate render texture (if the camera size is different)

// Depth texture is now ready, bind it.
cmd.SetGlobalTexture(HDShaderIDs._MainDepthTexture, GetDepthTexture());
// for alpha compositing, color is cleared to 0, alpha to 1
// for alpha compositing, color is cleared to 0, alpha to 1
Color clearColor = new Color(0.0f, 0.0f, 0.0f, 1.0f);
Color clearColor = new Color(0.0f, 0.0f, 0.0f, 1.0f);
CoreUtils.SetRenderTarget(cmd, m_DbufferManager.GetDBuffers(), m_CameraDepthStencilBufferRT, ClearFlag.Color, clearColor);
// we need to do a separate clear for normals, because they are cleared to a different color

{
using (new ProfilingSample(cmd, "Blit DebugView Material Debug", CustomSamplerId.BlitDebugViewMaterialDebug.GetSampler()))
{
// This Blit will flip the screen anything other than openGL
cmd.Blit(m_CameraColorBufferRT, BuiltinRenderTextureType.CameraTarget);
}
}

{
cmd.ReleaseTemporaryRT(m_DebugColorPickerRT);
CoreUtils.CreateCmdTemporaryRT(cmd, m_DebugColorPickerRT, hdCamera.renderTextureDesc, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
cmd.Blit(textureID, m_DebugColorPickerRT);
// RenderDebug() is call after the final pass that flip the screen (if we are not SceneView).
// Mean that when we push the buffer here, we need to flip it to display correctly.
bool flipY = hdCamera.camera.cameraType != CameraType.SceneView;
cmd.Blit(textureID, m_DebugColorPickerRT, m_Blit, flipY ? 2 : 0); // 2 is nearest filtering and flip the image on Y, 1 is without flip
}
}

m_FullScreenDebugPushed = true; // We need this flag because otherwise if no full screen debug is pushed, when we render the result in RenderDebug the temporary RT will not exist.
cmd.ReleaseTemporaryRT(m_DebugFullScreenTempRT);
CoreUtils.CreateCmdTemporaryRT(cmd, m_DebugFullScreenTempRT, hdCamera.renderTextureDesc, 0, FilterMode.Point, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
cmd.Blit(textureID, m_DebugFullScreenTempRT);
// RenderDebug() is call after the final pass that flip the screen (if we are not SceneView).
// Mean that when we push the buffer here, we need to flip it to display correctly.
bool flipY = hdCamera.camera.cameraType != CameraType.SceneView;
cmd.Blit(textureID, m_DebugFullScreenTempRT, m_Blit, flipY ? 2 : 0); // 2 is nearest filtering and flip the image on Y, 1 is without flipY
}
}

32
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/Blit.shader


return SAMPLE_TEXTURE2D(_BlitTexture, sampler_LinearClamp, input.texcoord);
}
float4 FragNearestFlipY(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D(_BlitTexture, sampler_PointClamp, float2(input.texcoord.x, 1.0 - input.texcoord.y));
}
float4 FragBilinearFlipY(Varyings input) : SV_Target
{
return SAMPLE_TEXTURE2D(_BlitTexture, sampler_LinearClamp, float2(input.texcoord.x, 1.0 - input.texcoord.y));
}
ENDHLSL
SubShader

HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragBilinear
ENDHLSL
}
// 2: Nearest + flipY
Pass
{
ZWrite Off ZTest Always Blend Off Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragNearestFlipY
ENDHLSL
}
// 3: Bilinear + flipY
Pass
{
ZWrite Off ZTest Always Blend Off Cull Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment FragBilinearFlipY
ENDHLSL
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/RenderPipelineResources/CameraMotionVectors.shader


float2 previousPositionCS = (prevHPos + 1.0) / 2.0;
float2 positionCS = (curHPos + 1.0) / 2.0;
#if !UNITY_UV_STARTS_AT_TOP
#if UNITY_UV_STARTS_AT_TOP
previousPositionCS.y = 1.0 - previousPositionCS.y;
positionCS.y = 1.0 - positionCS.y;
#endif

正在加载...
取消
保存