浏览代码

- Disabled SkyRendering when no HDRI is present.

- Temporarily disabled DynamicGI.UpdateEnvironment() call for now (was too slow if done each frame).
/main
Julien Ignace 8 年前
当前提交
1622e984
共有 1 个文件被更改,包括 29 次插入19 次删除
  1. 48
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyRenderer.cs

48
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyRenderer.cs


}
bool IsSkyValid(SkyParameters parameters)
{
// Later we will also test shader for procedural skies.
return parameters.skyHDRI != null;
}
private void RenderSky(Camera camera, SkyParameters skyParameters, bool forceUVBottom, RenderLoop renderLoop)
{
Mesh skyMesh = BuildSkyMesh(camera, forceUVBottom);

public void RenderSky(Camera camera, SkyParameters skyParameters, RenderTargetIdentifier colorBuffer, RenderTargetIdentifier depthBuffer, RenderLoop renderLoop)
{
// Render sky into a cubemap - doesn't happen every frame, can be control
for (int i = 0; i < 6; ++i)
if (IsSkyValid(skyParameters))
Utilities.SetRenderTarget(renderLoop, m_SkyboxCubemapRT, "", 0, (CubemapFace)i);
Camera faceCamera = m_CubemapFaceCamera[i].GetComponent<Camera>();
RenderSky(faceCamera, skyParameters, true, renderLoop);
}
// Render sky into a cubemap - doesn't happen every frame, can be control
for (int i = 0; i < 6; ++i)
{
Utilities.SetRenderTarget(renderLoop, m_SkyboxCubemapRT, "", 0, (CubemapFace)i);
Camera faceCamera = m_CubemapFaceCamera[i].GetComponent<Camera>();
RenderSky(faceCamera, skyParameters, true, renderLoop);
}
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;
DynamicGI.UpdateEnvironment();
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;
//DynamicGI.UpdateEnvironment();
// TODO: do a render to texture here
// TODO: do a render to texture here
// Downsample the cubemap and provide it to Enlighten
// Downsample the cubemap and provide it to Enlighten
// TODO: currently workaround is to set the cubemap in a Skybox/cubemap material
//m_SkyboxMaterial.SetTexture(cubemap);
// TODO: currently workaround is to set the cubemap in a Skybox/cubemap material
//m_SkyboxMaterial.SetTexture(cubemap);
// Render the sky itself
Utilities.SetRenderTarget(renderLoop, colorBuffer, depthBuffer, "Sky Pass");
RenderSky(camera, skyParameters, false, renderLoop);
// Render the sky itself
Utilities.SetRenderTarget(renderLoop, colorBuffer, depthBuffer, "Sky Pass");
RenderSky(camera, skyParameters, false, renderLoop);
}
}
}
}
正在加载...
取消
保存