浏览代码

Merge pull request #1727 from Unity-Technologies/HDRP/fix-sun-baking

Fixed some issues with ambient probe baking and reflection probe capture
/main
GitHub 6 年前
当前提交
59dc978c
共有 12 个文件被更改,包括 1114 次插入1973 次删除
  1. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1401_StackLit.png
  2. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/9005_Decals-stress-test.png
  3. 999
      TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/9201_Camera-relative-rendering.png
  4. 4
      com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs
  5. 5
      com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/ProceduralSky/ProceduralSkyEditor.cs
  6. 40
      com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/SkySettingsEditor.cs
  7. 2
      com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/HDRISkyRenderer.cs
  8. 25
      com.unity.render-pipelines.high-definition/HDRP/Sky/ProceduralSky/ProceduralSkyRenderer.cs
  9. 4
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkyManager.cs
  10. 2
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderer.cs
  11. 5
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderingContext.cs
  12. 3
      com.unity.render-pipelines.high-definition/HDRP/Sky/SkySettings.cs

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/1401_StackLit.png
文件差异内容过多而无法显示
查看文件

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/9005_Decals-stress-test.png
文件差异内容过多而无法显示
查看文件

999
TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/9201_Camera-relative-rendering.png
文件差异内容过多而无法显示
查看文件

4
com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/HDRISky/HDRISkyEditor.cs


{
base.OnEnable();
// HDRI sky does not have control over sun display.
m_CommonUIElementsMask = 0xFFFFFFFF & ~(uint)(SkySettingsUIElement.IncludeSunInBaking);
var o = new PropertyFetcher<HDRISky>(serializedObject);
m_hdriSky = Unpack(o.Find(x => x.hdriSky));
}

PropertyField(m_hdriSky);
EditorGUILayout.Space();
base.CommonSkySettingsGUI();
}
}

5
com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/ProceduralSky/ProceduralSkyEditor.cs


{
base.OnEnable();
// Procedural sky orientation depends on the sun direction
m_CommonUIElementsMask = 0xFFFFFFFF & ~(uint)(SkySettingsUIElement.Rotation);
var o = new PropertyFetcher<ProceduralSky>(serializedObject);
m_SunSize = Unpack(o.Find(x => x.sunSize));

EditorGUILayout.Space();
base.CommonSkySettingsGUI(false);
base.CommonSkySettingsGUI();
}
}
}

40
com.unity.render-pipelines.high-definition/HDRP/Editor/Sky/SkySettingsEditor.cs


{
public abstract class SkySettingsEditor : VolumeComponentEditor
{
[System.Flags]
protected enum SkySettingsUIElement
{
Exposure = 1 << 0,
Multiplier = 1 << 1,
Rotation = 1 << 2,
UpdateMode = 1 << 3,
IncludeSunInBaking = 1 << 4
}
SerializedDataParameter m_IncludeSunInBaking;
protected uint m_CommonUIElementsMask = 0xFFFFFFFF;
public override void OnEnable()
{

m_SkyRotation = Unpack(o.Find(x => x.rotation));
m_EnvUpdateMode = Unpack(o.Find(x => x.updateMode));
m_EnvUpdatePeriod = Unpack(o.Find(x => x.updatePeriod));
m_IncludeSunInBaking = Unpack(o.Find(x => x.includeSunInBaking));
protected void CommonSkySettingsGUI(bool enableRotation = true)
protected void CommonSkySettingsGUI()
PropertyField(m_SkyExposure);
PropertyField(m_SkyMultiplier);
if (enableRotation)
if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.Exposure) != 0)
PropertyField(m_SkyExposure);
if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.Multiplier) != 0)
PropertyField(m_SkyMultiplier);
if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.Rotation) != 0)
PropertyField(m_EnvUpdateMode);
if (!m_EnvUpdateMode.value.hasMultipleDifferentValues && m_EnvUpdateMode.value.intValue == (int)EnvironementUpdateMode.Realtime)
if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.UpdateMode) != 0)
EditorGUI.indentLevel++;
PropertyField(m_EnvUpdatePeriod);
EditorGUI.indentLevel--;
PropertyField(m_EnvUpdateMode);
if (!m_EnvUpdateMode.value.hasMultipleDifferentValues && m_EnvUpdateMode.value.intValue == (int)EnvironementUpdateMode.Realtime)
{
EditorGUI.indentLevel++;
PropertyField(m_EnvUpdatePeriod);
EditorGUI.indentLevel--;
}
if ((m_CommonUIElementsMask & (uint)SkySettingsUIElement.IncludeSunInBaking) != 0)
PropertyField(m_IncludeSunInBaking);
}
}
}

2
com.unity.render-pipelines.high-definition/HDRP/Sky/HDRISky/HDRISkyRenderer.cs


}
}
public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap)
public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk)
{
m_SkyHDRIMaterial.SetTexture(HDShaderIDs._Cubemap, m_HdriSkyParams.hdriSky);
m_SkyHDRIMaterial.SetVector(HDShaderIDs._SkyParam, new Vector4(GetExposure(m_HdriSkyParams, builtinParams.debugSettings), m_HdriSkyParams.multiplier, -m_HdriSkyParams.rotation, 0.0f)); // -rotation to match Legacy...

25
com.unity.render-pipelines.high-definition/HDRP/Sky/ProceduralSky/ProceduralSkyRenderer.cs


}
}
public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap)
public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk)
// Default values when no sun is provided
float sunSize = 0.0f;
sunSize = m_ProceduralSkyParams.sunSize;
m_ProceduralSkyMaterial.SetVector(HDShaderIDs._SkyParam, new Vector4(GetExposure(m_ProceduralSkyParams, builtinParams.debugSettings), m_ProceduralSkyParams.multiplier, 0.0f, 0.0f));
m_ProceduralSkyMaterial.SetFloat(_SunSizeParam, m_ProceduralSkyParams.sunSize);
m_ProceduralSkyMaterial.SetFloat(_SunSizeConvergenceParam, m_ProceduralSkyParams.sunSizeConvergence);
m_ProceduralSkyMaterial.SetFloat(_AtmoshpereThicknessParam, m_ProceduralSkyParams.atmosphereThickness);
m_ProceduralSkyMaterial.SetColor(_SkyTintParam, m_ProceduralSkyParams.skyTint);
m_ProceduralSkyMaterial.SetColor(_GroundColorParam, m_ProceduralSkyParams.groundColor);
m_ProceduralSkyMaterial.SetColor(_SunColorParam, sunColor);
m_ProceduralSkyMaterial.SetVector(_SunDirectionParam, sunDirection);
if (!renderSunDisk)
sunSize = 0.0f;
// This matrix needs to be updated at the draw call frequency.
m_PropertyBlock.SetVector(HDShaderIDs._SkyParam, new Vector4(GetExposure(m_ProceduralSkyParams, builtinParams.debugSettings), m_ProceduralSkyParams.multiplier, 0.0f, 0.0f));
m_PropertyBlock.SetFloat(_SunSizeParam, sunSize);
m_PropertyBlock.SetFloat(_SunSizeConvergenceParam, m_ProceduralSkyParams.sunSizeConvergence);
m_PropertyBlock.SetFloat(_AtmoshpereThicknessParam, m_ProceduralSkyParams.atmosphereThickness);
m_PropertyBlock.SetColor(_SkyTintParam, m_ProceduralSkyParams.skyTint);
m_PropertyBlock.SetColor(_GroundColorParam, m_ProceduralSkyParams.groundColor);
m_PropertyBlock.SetColor(_SunColorParam, sunColor);
m_PropertyBlock.SetVector(_SunDirectionParam, sunDirection);
m_PropertyBlock.SetMatrix(HDShaderIDs._PixelCoordToViewDirWS, builtinParams.pixelCoordToViewDirMatrix);
CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_ProceduralSkyMaterial, m_PropertyBlock, renderForCubemap ? 0 : 1);

4
com.unity.render-pipelines.high-definition/HDRP/Sky/SkyManager.cs


m_NeedUpdateRealtimeEnv = false;
}
// For the baking sky, we don't want to take the sun into account because we usually won't include it (this would cause double highlight in the reflection for example).
// So we pass null so that's it doesn't affect the hash and the rendering.
m_NeedUpdateBakingSky = m_BakingSkyRenderingContext.UpdateEnvironment(m_BakingSky, camera, null, m_UpdateRequired, cmd);
m_NeedUpdateBakingSky = m_BakingSkyRenderingContext.UpdateEnvironment(m_BakingSky, camera, sunLight, m_UpdateRequired, cmd);
SkyUpdateContext currentSky = m_LightingOverrideSky.IsValid() ? m_LightingOverrideSky : m_VisualSky;
m_NeedUpdateRealtimeEnv = m_SkyRenderingContext.UpdateEnvironment(currentSky, camera, sunLight, m_UpdateRequired, cmd);

2
com.unity.render-pipelines.high-definition/HDRP/Sky/SkyRenderer.cs


public abstract void Cleanup();
public abstract void SetRenderTargets(BuiltinSkyParameters builtinParams);
// renderForCubemap: When rendering into a cube map, no depth buffer is available so user has to make sure not to use depth testing or the depth texture.
public abstract void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap);
public abstract void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk);
public abstract bool IsValid();
protected float GetExposure(SkySettings skySettings, DebugDisplaySettings debugSettings)

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


m_BuiltinParameters.hdCamera = null;
CoreUtils.SetRenderTarget(m_BuiltinParameters.commandBuffer, m_SkyboxCubemapRT, ClearFlag.None, 0, (CubemapFace)i);
skyContext.renderer.RenderSky(m_BuiltinParameters, true);
skyContext.renderer.RenderSky(m_BuiltinParameters, true, skyContext.skySettings.includeSunInBaking);
}
// Generate mipmap for our cubemap

m_BuiltinParameters.debugSettings = debugSettings;
skyContext.renderer.SetRenderTargets(m_BuiltinParameters);
skyContext.renderer.RenderSky(m_BuiltinParameters, false);
// 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);
}
}
}

3
com.unity.render-pipelines.high-definition/HDRP/Sky/SkySettings.cs


public EnvUpdateParameter updateMode = new EnvUpdateParameter(EnvironementUpdateMode.OnChanged);
[Tooltip("If environment update is set to realtime, period in seconds at which it is updated (0.0 means every frame).")]
public MinFloatParameter updatePeriod = new MinFloatParameter(0.0f, 0.0f);
[Tooltip("If set to true, the sun disk will be used in baked lighting (ambient and reflection probes).")]
public BoolParameter includeSunInBaking = new BoolParameter(false);
// Unused for now. In the future we might want to expose this option for very high range skies.
bool m_useMIS = false;

//<<<
hash = hash * 23 + updatePeriod.GetHashCode();
hash = hash * 23 + includeSunInBaking.GetHashCode();
return hash;
}
}

正在加载...
取消
保存