public Texture skyReflection
{
get
get
{
if ( m_LightingOverrideSky . skySettings ! = null )
return m_LightingOverrideSky . reflectionTexture ;
}
}
{
SkySettings newSkySettings = null ;
var visualEnv = VolumeManager . instance . GetComponent < VisualEnvironment > ( ) ;
switch ( visualEnv . skyType . value )
case SkyType . HDRISky :
SkySettings newSkySettings = null ;
var visualEnv = VolumeManager . instance . stack . GetComponent < VisualEnvironment > ( ) ;
switch ( visualEnv . skyType . value )
newSkySettings = VolumeManager . instance . GetComponent < HDRISky > ( ) ;
case SkyType . HDRISky :
{
newSkySettings = VolumeManager . instance . stack . GetComponent < HDRISky > ( ) ;
}
}
{
newSkySettings = VolumeManager . instance . GetComponent < ProceduralSky > ( ) ;
{
newSkySettings = VolumeManager . instance . stack . GetComponent < ProceduralSky > ( ) ;
}
}
m_VisualSky . skySettings = newSkySettings ;
m_BakingSky . skySettings = SkySettings . GetBakingSkySettings ( ) ;
m_BlitCubemapMaterial = CoreUtils . CreateEngineMaterial ( renderPipelineResources . blitCubemap ) ;
m_OpaqueAtmScatteringMaterial = CoreUtils . CreateEngineMaterial ( renderPipelineResources . opaqueAtmosphericScattering ) ;
m_CurrentUpdateTime = 0.0f ;
}
public void Cleanup ( )
public bool IsSkyValid ( )
{
return m_VisualSky . IsValid ( ) ;
}
}
void BlitCubemap ( CommandBuffer cmd , Cubemap source , RenderTexture dest )
// When building the player, for some reason we end up in a state where frameCount is not updated but all currently setup shader texture are reset to null
// resulting in a rendering error (compute shader property not bound) that makes the player building fails...
// So we just check if the texture is bound here so that we can setup a pink one to avoid the error without breaking half the world.
if ( Shader . GetGlobalTexture ( HDShaderIDs . _SkyTexture ) = = null )
if ( Shader . GetGlobalTexture ( HDShaderIDs . _SkyTexture ) = = null )
cmd . SetGlobalTexture ( HDShaderIDs . _SkyTexture , CoreUtils . magentaCubeTexture ) ;
if ( m_LastFrameUpdated = = Time . frameCount )
// Here we update the global SkyMaterial so that it uses our baking sky cubemap. This way, next time the GI is baked, the right sky will be present.
float intensity = m_BakingSky . IsValid ( ) ? 1.0f : 0.0f ; // Eliminate all diffuse if we don't have a skybox (meaning for now the background is black in HDRP)
m_StandardSkyboxMaterial . SetTexture ( "_Tex" , m_BakingSky . cubemapRT ) ;
RenderSettings . skybox = m_StandardSkyboxMaterial ; // Setup this material as the default to be use in RenderSettings
RenderSettings . ambientIntensity = intensity ;
RenderSettings . ambientMode = AmbientMode . Skybox ; // Force skybox for our HDRI
RenderSettings . reflectionIntensity = intensity ;
RenderSettings . customReflection = null ;
RenderSettings . skybox = m_StandardSkyboxMaterial ; // Setup this material as the default to be use in RenderSettings
RenderSettings . ambientIntensity = intensity ;
RenderSettings . ambientMode = AmbientMode . Skybox ; // Force skybox for our HDRI
RenderSettings . reflectionIntensity = intensity ;
RenderSettings . customReflection = null ;
DynamicGI . UpdateEnvironment ( ) ;
DynamicGI . UpdateEnvironment ( ) ;
if ( m_NeedUpdateRealtimeEnv )
if ( m_NeedUpdateRealtimeEnv )
{
// TODO: Here we need to do that in case we are using real time GI. Unfortunately we don't have a way to check that atm.
//DynamicGI.SetEnvironmentData();
UpdateCurrentSkySettings ( ) ;
m_NeedUpdateBakingSky = m_BakingSky . UpdateEnvironment ( camera , sunLight , m_UpdateRequired , cmd ) ;
if ( m_LightingOverrideSky . IsValid ( ) )
{
if ( m_LightingOverrideSky . IsValid ( ) )
{
{
{
}
}
m_UpdateRequired = false ;
if ( IsSkyValid ( ) )
{
cmd . SetGlobalInt ( HDShaderIDs . _EnvLightSkyEnabled , 1 ) ;
}
}
}
}
}
}
CoreUtils . DrawFullScreen ( cmd , m_OpaqueAtmScatteringMaterial ) ;
}
CoreUtils . DrawFullScreen ( cmd , m_OpaqueAtmScatteringMaterial ) ;
}
if ( ! m_VisualSky . IsValid ( ) )
if ( ! m_VisualSky . IsValid ( ) )
{
Debug . LogError ( "Cannot export sky to a texture, no Sky is setup." ) ;
return null ;