浏览代码

Partially fix broken sky lighting on scene reload

/Branch_Batching2
Evgenii Golubev 8 年前
当前提交
8ced0098
共有 3 个文件被更改,包括 19 次插入6 次删除
  1. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  2. 7
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettings.cs
  3. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


m_DebugDisplayLatlong = Utilities.CreateEngineMaterial("Hidden/HDRenderPipeline/DebugDisplayLatlong");
}
public void OnSceneLoad()
{
// Recreate the textures which went NULL, and set 'isInit' to 'false'.
m_LitRenderLoop.Build();
}
public override void Dispose()
{
base.Dispose();

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


void OnEnable()
{
SceneSettingsManager.instance.AddSceneSettings(this);
HDRenderPipelineInstance hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipelineInstance;
if (hdPipeline != null)
{
hdPipeline.OnSceneLoad();
}
}
void OnDisable()

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


SkyRenderer m_Renderer = null;
int m_SkyParametersHash = -1;
bool m_NeedLowLevelUpdateEnvironment = false;
bool m_UpdateRequired = true;
int m_UpdatedFramesRequired = 2; // The first frame after the scene load is currently not rendered correctly
float m_CurrentUpdateTime = 0.0f;
bool m_useMIS = false;

m_SkyParametersHash = -1;
m_SkySettings = value;
m_UpdateRequired = true;
m_UpdatedFramesRequired = 2;
if (value != null)
{

m_SkyboxConditionalCdfRT.Create();
}
m_UpdateRequired = true; // Special case. Even if update mode is set to OnDemand, we need to regenerate the environment after destroying the texture.
m_UpdatedFramesRequired = 2; // Special case. Even if update mode is set to OnDemand, we need to regenerate the environment after destroying the texture.
}
m_CubemapScreenSize = new Vector4((float)resolution, (float)resolution, 1.0f / (float)resolution, 1.0f / (float)resolution);

public void RequestEnvironmentUpdate()
{
m_UpdateRequired = true;
m_UpdatedFramesRequired = Math.Max(m_UpdatedFramesRequired, 1);
}
public void UpdateEnvironment(HDCamera camera, Light sunLight, ScriptableRenderContext renderContext)

m_BuiltinParameters.sunLight = sunLight;
if (
(skySettings.updateMode == EnvironementUpdateMode.OnDemand && m_UpdateRequired) ||
m_UpdatedFramesRequired > 0 ||
(skySettings.updateMode == EnvironementUpdateMode.OnChanged && skySettings.GetHash() != m_SkyParametersHash) ||
(skySettings.updateMode == EnvironementUpdateMode.Realtime && m_CurrentUpdateTime > skySettings.updatePeriod)
)

RenderCubemapGGXConvolution(renderContext, m_BuiltinParameters, skySettings, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
m_NeedLowLevelUpdateEnvironment = true;
m_UpdateRequired = false;
m_UpdatedFramesRequired--;
m_SkyParametersHash = skySettings.GetHash();
m_CurrentUpdateTime = 0.0f;
}

正在加载...
取消
保存