|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |