浏览代码

Added one frame delay to DynamicGI.UpdateEnvironment call in order to wait for the input cubemap to be rendered by the RenderLoop first.

/main
Julien Ignace 8 年前
当前提交
3b1edbe4
共有 1 个文件被更改,包括 17 次插入8 次删除
  1. 25
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs

25
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs


BuiltinSkyParameters m_BuiltinParameters = new BuiltinSkyParameters();
SkyRenderer m_Renderer = new HDRISkyRenderer();
int m_SkyParametersHash = 0;
bool m_NeedUpdateEnvironment = false;
protected Mesh BuildSkyMesh(Vector3 cameraPosition, Matrix4x4 cameraInvViewProjectionMatrix, bool forceUVBottom)
{

m_BuiltinParameters.renderLoop = renderLoop;
m_BuiltinParameters.sunLight = sunLight;
// 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_NeedUpdateEnvironment)
{
// 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_NeedUpdateEnvironment = false;
}
if (skyParameters.GetHash() != m_SkyParametersHash)
{
using (new Utilities.ProfilingSample("Sky Pass: Render Cubemap", renderLoop))

// Convolve downsampled cubemap
RenderCubemapGGXConvolution(renderLoop, m_BuiltinParameters, skyParameters, m_SkyboxCubemapRT, m_SkyboxGGXCubemapRT);
// 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_NeedUpdateEnvironment = true;
}
m_SkyParametersHash = skyParameters.GetHash();

正在加载...
取消
保存