浏览代码

Clear sky color to black when lux meter is enabled

/main
Antoine Lelievre 6 年前
当前提交
87a6834f
共有 4 个文件被更改,包括 8 次插入86 次删除
  1. 7
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs
  2. 12
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderingContext.cs
  3. 66
      com.unity.render-pipelines.high-definition/HDRP/Sky/BlackSky.shader
  4. 9
      com.unity.render-pipelines.high-definition/HDRP/Sky/BlackSky.shader.meta

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


using (new ProfilingSample(cmd, "Clear HDR target", CustomSamplerId.ClearHDRTarget.GetSampler()))
{
if (hdCamera.clearColorMode == HDAdditionalCameraData.ClearColorMode.BackgroundColor ||
// If the luxmeter is enabled, the sky isn't rendered so we clear the background color
m_DebugDisplaySettings.lightingDebugSettings.debugLightingMode == DebugLightingMode.LuxMeter ||
// If we want the sky but the sky don't exist, still clear with background color
(hdCamera.clearColorMode == HDAdditionalCameraData.ClearColorMode.Sky && !m_SkyManager.IsVisualSkyValid()) ||
// Special handling for Preview we force to clear with background color (i.e black)

{
Color clearColor = hdCamera.backgroundColorHDR;
// We set the background color to black when the luxmeter is enabled to avoid picking the sky color
if (m_DebugDisplaySettings.lightingDebugSettings.debugLightingMode == DebugLightingMode.LuxMeter)
clearColor = Color.black;
HDUtils.SetRenderTarget(cmd, hdCamera, m_CameraColorBuffer, m_CameraDepthStencilBuffer, ClearFlag.Color, clearColor);
}
}

12
com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderingContext.cs


skyContext.renderer.SetRenderTargets(m_BuiltinParameters);
// If the luxmeter is enabled, we render a black sky
// If the luxmeter is enabled, we don't render the sky
}
else
{
RenderBlackSky(cmd, false);
}
void RenderBlackSky(CommandBuffer cmd, bool renderToCubemap)
{
Material blackMaterial = new Material(Shader.Find("Hidden/HDRenderPipeline/Sky/Black"));
CoreUtils.DrawFullScreen(cmd, blackMaterial, null, renderToCubemap ? 0 : 1);
}
}
}

66
com.unity.render-pipelines.high-definition/HDRP/Sky/BlackSky.shader


Shader "Hidden/HDRenderPipeline/Sky/Black"
{
HLSLINCLUDE
#pragma vertex Vert
#pragma fragment Frag
#pragma target 4.5
#pragma only_renderers d3d11 ps4 xboxone vulkan metal switch
#include "CoreRP/ShaderLibrary/Common.hlsl"
struct Attributes
{
uint vertexID : SV_VertexID;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
};
Varyings Vert(Attributes input)
{
Varyings output;
output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID, UNITY_RAW_FAR_CLIP_VALUE);
return output;
}
float4 Frag(Varyings input) : SV_Target
{
return float4(0, 0, 0, 1.0);
}
ENDHLSL
SubShader
{
// For cubemap
Pass
{
ZWrite Off
ZTest Always
Blend Off
Cull Off
HLSLPROGRAM
ENDHLSL
}
// For fullscreen Sky
Pass
{
ZWrite Off
ZTest LEqual
Blend Off
Cull Off
HLSLPROGRAM
ENDHLSL
}
}
Fallback Off
}

9
com.unity.render-pipelines.high-definition/HDRP/Sky/BlackSky.shader.meta


fileFormatVersion: 2
guid: 753e66d8688b76342acec2ab764d9b62
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存