浏览代码

Render black sky when lux meter is enabled

/main
Antoine Lelievre 6 年前
当前提交
028117d7
共有 3 个文件被更改,包括 92 次插入2 次删除
  1. 19
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderingContext.cs
  2. 66
      com.unity.render-pipelines.high-definition/HDRP/Sky/BlackSky.shader
  3. 9
      com.unity.render-pipelines.high-definition/HDRP/Sky/BlackSky.shader.meta

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


m_BuiltinParameters.debugSettings = debugSettings;
skyContext.renderer.SetRenderTargets(m_BuiltinParameters);
// When rendering the visual sky for reflection probes, we need to remove the sun disk if skySettings.includeSunInBaking is false.
skyContext.renderer.RenderSky(m_BuiltinParameters, false, hdCamera.camera.cameraType != CameraType.Reflection || skyContext.skySettings.includeSunInBaking);
// If the luxmeter is enabled, we render a black sky
if (debugSettings.lightingDebugSettings.debugLightingMode != DebugLightingMode.LuxMeter)
{
// When rendering the visual sky for reflection probes, we need to remove the sun disk if skySettings.includeSunInBaking is false.
skyContext.renderer.RenderSky(m_BuiltinParameters, false, hdCamera.camera.cameraType != CameraType.Reflection || skyContext.skySettings.includeSunInBaking);
}
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:
正在加载...
取消
保存