浏览代码

- Fixed a bug where setting sky settings to none would not removed the sky.

- Fixed a bug where setting the sky to none would not update correctly the default light probe and reflections
/fptl_cleanup
Julien Ignace 8 年前
当前提交
4bb0fc26
共有 3 个文件被更改,包括 42 次插入39 次删除
  1. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs
  2. 60
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  3. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs

7
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs


{
if(settings)
{
if (settings.commonSettings != null)
CommonSettingsSingleton.overrideSettings = settings.commonSettings;
if (settings.skySettings != null)
SkySettingsSingleton.overrideSettings = settings.skySettings;
CommonSettingsSingleton.overrideSettings = settings.commonSettings;
SkySettingsSingleton.overrideSettings = settings.skySettings;
}
else
{

60
Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


BuiltinSkyParameters m_BuiltinParameters = new BuiltinSkyParameters();
SkyRenderer m_Renderer = null;
int m_SkyParametersHash = 0;
int m_SkyParametersHash = -1;
bool m_NeedLowLevelUpdateEnvironment = false;
bool m_UpdateRequired = true;
float m_CurrentUpdateTime = 0.0f;

m_Renderer = null;
}
m_SkyParametersHash = 0;
m_SkyParametersHash = -1;
m_SkySettings = value;
m_UpdateRequired = true;

{
using (new Utilities.ProfilingSample("Sky Environment Pass", renderContext))
{
// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed direclty but the renderloop is not (so we need to wait for the sky texture to be rendered first)
if (m_NeedLowLevelUpdateEnvironment)
{
// TODO: Properly send the cubemap to Enlighten. Currently workaround is to set the cubemap in a Skybox/cubemap material
m_StandardSkyboxMaterial.SetTexture("_Tex", m_SkyboxCubemapRT);
RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings
RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
RenderSettings.reflectionIntensity = 1.0f;
RenderSettings.customReflection = null;
DynamicGI.UpdateEnvironment();
m_NeedLowLevelUpdateEnvironment = false;
}
if (IsSkyValid())
{
m_CurrentUpdateTime += Time.deltaTime;

// We need one frame delay for this update to work since DynamicGI.UpdateEnvironment is executed direclty but the renderloop is not (so we need to wait for the sky texture to be rendered first)
if (m_NeedLowLevelUpdateEnvironment)
{
// TODO: Properly send the cubemap to Enlighten. Currently workaround is to set the cubemap in a Skybox/cubemap material
m_StandardSkyboxMaterial.SetTexture("_Tex", m_SkyboxCubemapRT);
RenderSettings.skybox = m_StandardSkyboxMaterial; // Setup this material as the default to be use in RenderSettings
RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
RenderSettings.reflectionIntensity = 1.0f;
RenderSettings.customReflection = null;
DynamicGI.UpdateEnvironment();
m_NeedLowLevelUpdateEnvironment = false;
}
if (
(skySettings.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) ||
(skySettings.updateMode == EnvironementUpdateMode.OnChanged && skySettings.GetHash() != m_SkyParametersHash) ||

}
else
{
// Disabled for now.
// We need to remove RenderSkyToCubemap from the RenderCubemapGGXConvolution first as it needs the skyparameter to be valid.
//if(m_SkyParametersHash != 0)
//{
// // Clear sky light probe
// RenderSettings.skybox = null;
// RenderSettings.ambientIntensity = 1.0f; // fix this to 1, this parameter should not exist!
// RenderSettings.ambientMode = UnityEngine.Rendering.AmbientMode.Skybox; // Force skybox for our HDRI
// RenderSettings.reflectionIntensity = 1.0f;
// RenderSettings.customReflection = null;
// DynamicGI.UpdateEnvironment();
if(m_SkyParametersHash != 0)
{
// Clear temp cubemap and redo GGX from black and then feed it to enlighten for default light probe.
Utilities.ClearCubemap(renderContext, m_SkyboxCubemapRT, Color.black);
RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skySettings, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// // Clear temp cubemap and redo GGX from black
// Utilities.SetRenderTarget(renderContext, m_SkyboxCubemapRT, ClearFlag.ClearColor);
// RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// m_SkyParametersHash = 0;
//}
m_SkyParametersHash = 0;
m_NeedLowLevelUpdateEnvironment = true;
}
}
}
}

14
Assets/ScriptableRenderPipeline/HDRenderPipeline/Utilities.cs


cmd.Dispose();
}
public static void ClearCubemap(ScriptableRenderContext renderContext, RenderTargetIdentifier buffer, Color clearColor)
{
var cmd = new CommandBuffer();
cmd.name = "";
for(int i = 0 ; i < 6 ; ++i)
{
SetRenderTarget(renderContext, buffer, ClearFlag.ClearColor, Color.black, 0, (CubemapFace)i);
}
renderContext.ExecuteCommandBuffer(cmd);
cmd.Dispose();
}
// Miscellanous
public static Material CreateEngineMaterial(string shaderPath)
{

正在加载...
取消
保存