浏览代码

Update after last merge

/main
Julien Ignace 7 年前
当前提交
688234ed
共有 4 个文件被更改,包括 37 次插入39 次删除
  1. 2
      SampleScenes/HDTest/GlobalIlluminationTest/TestRealtime.cs
  2. 6
      ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  3. 64
      ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs
  4. 4
      ScriptableRenderPipeline/HDRenderPipeline/Sky/VisualEnvironment.cs

2
SampleScenes/HDTest/GlobalIlluminationTest/TestRealtime.cs


{
if (m_SceneSettings != null)
{
HDRISky skyParams = VolumeManager.instance.GetComponent<HDRISky>();
HDRISky skyParams = VolumeManager.instance.stack.GetComponent<HDRISky>();
if (skyParams != null)
skyParams.rotation.value = (skyParams.rotation + Time.deltaTime * m_RotationSpeed) % 360.0f;
}

6
ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


public void UpdateShadowSettings()
{
var shadowSettings = VolumeManager.instance.GetComponent<HDShadowSettings>();
var shadowSettings = VolumeManager.instance.stack.GetComponent<HDShadowSettings>();
m_ShadowSettings.maxShadowDistance = shadowSettings.maxShadowDistance;
//m_ShadowSettings.directionalLightNearPlaneOffset = commonSettings.shadowNearPlaneOffset;

}
ApplyDebugDisplaySettings(cmd);
UpdateShadowSettings();
UpdateShadowSettings();
if (!m_IBLFilterGGX.IsInitialized())
m_IBLFilterGGX.Initialize(cmd);

void RenderSky(HDCamera hdCamera, CommandBuffer cmd)
{
// Rendering the sky is the first time in the frame where we need fog parameters so we push them here for the whole frame.
var visualEnv = VolumeManager.instance.GetComponent<VisualEnvironment>();
var visualEnv = VolumeManager.instance.stack.GetComponent<VisualEnvironment>();
visualEnv.PushFogShaderParameters(cmd, m_DebugDisplaySettings.renderingDebugSettings);
m_SkyManager.RenderSky(hdCamera, m_LightLoop.GetCurrentSunLight(), m_CameraColorBufferRT, m_CameraDepthStencilBufferRT, cmd);

64
ScriptableRenderPipeline/HDRenderPipeline/Sky/SkyManager.cs


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;

4
ScriptableRenderPipeline/HDRenderPipeline/Sky/VisualEnvironment.cs


}
case FogType.Linear:
{
var fogSettings = VolumeManager.instance.GetComponent<LinearFog>();
var fogSettings = VolumeManager.instance.stack.GetComponent<LinearFog>();
var fogSettings = VolumeManager.instance.GetComponent<ExponentialFog>();
var fogSettings = VolumeManager.instance.stack.GetComponent<ExponentialFog>();
fogSettings.PushShaderParameters(cmd, renderingDebug);
break;
}

正在加载...
取消
保存