浏览代码

HDRenderPipeline: Update SSAO settings

/Branch_Batching2
Sebastien Lagarde 8 年前
当前提交
9fc86a1e
共有 8 个文件被更改,包括 42 次插入37 次删除
  1. 12
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
  2. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs
  3. 30
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/AmbientOcclusion.cs
  4. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
  5. 8
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  6. 6
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettings.cs
  7. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs
  8. 9
      Assets/EmissionTest.meta

12
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs


using (new Utilities.ProfilingSample("Build Light list and render shadows", renderContext))
{
// TODO: Everything here (SSAO, Shadow, Build light list, material and light classification can be parallelize with Async compute)
// Note: Currently there is no SSAO in forward as we don't have normal
ScreenSpaceAmbientOcclusionSettings.Settings ssaoSettings = m_Asset.ssaoSettingsToUse;
if (/* ssaoSettings != null && */ !m_Asset.renderingSettings.useForwardRenderingOnly)
{
m_SsaoEffect.Render(m_Asset.ssaoSettingsToUse, camera, renderContext, GetDepthTexture());
}
m_SsaoEffect.Render(m_Asset.ssaoSettingsToUse, camera, renderContext, GetDepthTexture(), m_Asset.renderingSettings.useForwardRenderingOnly);
m_LightLoop.PrepareLightsForGPU(m_Asset.shadowSettings, cullResults, camera);
m_LightLoop.RenderShadows(renderContext, cullResults);
renderContext.SetupCameraProperties(camera); // Need to recall SetupCameraProperties after m_ShadowPass.Render

if (debugDisplaySettings.renderingDebugSettings.enableSSS)
{
// Output split lighting for materials tagged with the SSS stencil bit.
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, debugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, new RenderTargetIdentifier(GetDepthTexture()), true);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, debugDisplaySettings, m_Asset.ssaoSettingsToUse, colorRTs, m_CameraDepthStencilBufferRT, new RenderTargetIdentifier(GetDepthTexture()), true);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, debugDisplaySettings, colorRTs, m_CameraDepthStencilBufferRT, new RenderTargetIdentifier(GetDepthTexture()), false);
m_LightLoop.RenderDeferredLighting(hdCamera, renderContext, debugDisplaySettings, m_Asset.ssaoSettingsToUse, colorRTs, m_CameraDepthStencilBufferRT, new RenderTargetIdentifier(GetDepthTexture()), false);
}
// Combines specular lighting and diffuse lighting with subsurface scattering.

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.cs


}
[SerializeField]
private ScreenSpaceAmbientOcclusionSettings.Settings m_SsaoSettings;
private ScreenSpaceAmbientOcclusionSettings.Settings m_SsaoSettings = ScreenSpaceAmbientOcclusionSettings.Settings.s_Defaultsettings;
public ScreenSpaceAmbientOcclusionSettings.Settings ssaoSettingsToUse
{

30
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/AmbientOcclusion.cs


[Serializable]
public struct Settings
{
[Range(0, 2)]
bool m_Enable;
[Range(1, 32)]
public bool enable { set { m_Enable = value; } get { return m_Enable; } }
public float intensity { set { m_Intensity = value; OnValidate(); } get { return m_Intensity; } }
public float radius { set { m_Radius = value; OnValidate(); } get { return m_Radius; } }
public int sampleCount { set { m_SampleCount = value; OnValidate(); } get { return m_SampleCount; } }

public static readonly Settings s_Defaultsettings = new Settings
{
m_Enable = false,
m_Intensity = 1.0f,
m_Radius = 0.5f,
m_SampleCount = 8,

[SerializeField]
Settings m_Settings = Settings.s_Defaultsettings;
Settings m_Settings = Settings.s_Defaultsettings;
public Settings settings
{

m_Sheet = new PropertySheet(material);
}
public void Render(ScreenSpaceAmbientOcclusionSettings.Settings settings, Camera camera, ScriptableRenderContext renderContext, RenderTargetIdentifier depthID)
public void Render(ScreenSpaceAmbientOcclusionSettings.Settings settings, Camera camera, ScriptableRenderContext renderContext, RenderTargetIdentifier depthID, bool isForward)
/* if (settings == null) return; */ // TODO
// Note: Currently there is no SSAO in forward as we don't have normal buffer
if (settings.enable == false || isForward)
{
var cmd2 = new CommandBuffer { name = "Ambient Occlusion (1x1)" };
// TODO: Create a white 1x1 texture to setup here when AO is disabled (we could also do a variant in shader, but this increase number of combination)
cmd2.GetTemporaryRT(Uniforms._AOBuffer, 1, 1, 0, kFilter, kFormat, kRWMode);
cmd2.SetRenderTarget(Uniforms._AOBuffer);
cmd2.ClearRenderTarget(false, true, Color.white);
// Setup texture for lighting pass (automatic of unity)
cmd2.SetGlobalTexture("_AmbientOcclusionTexture", Uniforms._AOBuffer);
// Register the command buffer and release it.
renderContext.ExecuteCommandBuffer(cmd2);
cmd2.Dispose();
return ;
}
var width = camera.pixelWidth;
var height = camera.pixelHeight;

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs


cmd.Dispose();
}
public void RenderDeferredLighting(HDCamera hdCamera, ScriptableRenderContext renderContext,
DebugDisplaySettings debugDisplaySettings,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthStencilBuffer, RenderTargetIdentifier depthStencilTexture,
bool outputSplitLightingForSSS)
public void RenderDeferredLighting( HDCamera hdCamera, ScriptableRenderContext renderContext,
DebugDisplaySettings debugDisplaySettings,
ScreenSpaceAmbientOcclusionSettings.Settings ambientOcclusionSettings,
RenderTargetIdentifier[] colorBuffers, RenderTargetIdentifier depthStencilBuffer, RenderTargetIdentifier depthStencilTexture,
bool outputSplitLightingForSSS)
{
var bUseClusteredForDeferred = !usingFptl;

cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture1", Shader.PropertyToID("_GBufferTexture1"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture2", Shader.PropertyToID("_GBufferTexture2"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_GBufferTexture3", Shader.PropertyToID("_GBufferTexture3"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_AmbientOcclusionTexture", Shader.PropertyToID("_AmbientOcclusionTexture"));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_LtcData", Shader.GetGlobalTexture(Shader.PropertyToID("_LtcData")));
cmd.SetComputeTextureParam(shadeOpaqueShader, kernel, "_PreIntegratedFGD", Shader.GetGlobalTexture("_PreIntegratedFGD"));

8
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl


out float3 specularLighting)
{
LightLoopContext context;
#ifdef APPLY_AMBIENT_OCCLUSION
#else
context.ambientOcclusion = 1.0;
#endif
context.sampleShadow = 0;
context.sampleReflection = 0;
context.shadowContext = InitShadowContext();

out float3 specularLighting)
{
LightLoopContext context;
#ifdef APPLY_AMBIENT_OCCLUSION
#else
context.ambientOcclusion = 1.0;
#endif
context.sampleShadow = 0;
context.sampleReflection = 0;
context.shadowContext = InitShadowContext();

6
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettings.cs


get { return m_SkySettings; }
}
public ScreenSpaceAmbientOcclusionSettings ssaoSettings
{
get { return m_SsaoSettings; }
}
[SerializeField] private ScreenSpaceAmbientOcclusionSettings m_SsaoSettings = null;
// Use this for initialization
void OnEnable()

2
Assets/ScriptableRenderPipeline/HDRenderPipeline/SceneSettings/SceneSettingsManager.cs


{
CommonSettingsSingleton.overrideSettings = settings.commonSettings;
SkySettingsSingleton.overrideSettings = settings.skySettings;
ScreenSpaceAmbientOcclusionSettingsSingleton.overrideSettings = settings.ssaoSettings;
ScreenSpaceAmbientOcclusionSettingsSingleton.overrideSettings = null;
}
}
}

9
Assets/EmissionTest.meta


fileFormatVersion: 2
guid: 1945477d2df5e054098f9c6b80e70514
folderAsset: yes
timeCreated: 1496149030
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存