浏览代码

HDRenderPipeline: Finish to fix issue with AO

Store inverse AO in the buffer to to waste a sampler in lightloop
/Branch_Batching2
sebastienlagarde 8 年前
当前提交
6efb11c7
共有 9 个文件被更改,包括 50 次插入19 次删除
  1. 4
      Assets/GraphicsTests/RenderPipeline/LowEndMobilePipeline/Scenes/Shaders/LDPipe_LitBakedEmission/LightingData.asset
  2. 10
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs
  3. 2
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/AmbientOcclusion.cs
  4. 5
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/Resources/Composition.hlsl
  5. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/Resources/Estimation.hlsl
  6. 3
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
  7. 14
      Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
  8. 19
      Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultAmbientOcclusionSettings.asset
  9. 9
      Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultAmbientOcclusionSettings.asset.meta

4
Assets/GraphicsTests/RenderPipeline/LowEndMobilePipeline/Scenes/Shaders/LDPipe_LitBakedEmission/LightingData.asset
文件差异内容过多而无法显示
查看文件

10
Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/SceneSettingsManagementWindow.cs


CreateAsset<CommonSettings>("NewCommonSettings");
}
if (GUILayout.Button("Create new HDRI Sky params"))
if (GUILayout.Button("Create new HDRI Sky Settings"))
if (GUILayout.Button("Create new Procedural Sky params"))
if (GUILayout.Button("Create new Procedural Sky Settings"))
CreateAsset<ProceduralSkySettings>("NewProceduralSkyParameters");
CreateAsset<ProceduralSkySettings>("NewProceduralSkySettings");
if (GUILayout.Button("Create new Ambient Occlusion params"))
if (GUILayout.Button("Create new Ambient Occlusion Settings"))
CreateAsset<ScreenSpaceAmbientOcclusionSettings>("NewAmbientOcclusionParameters");
CreateAsset<ScreenSpaceAmbientOcclusionSettings>("NewAmbientOcclusionSettings");
}
EditorGUILayout.Space();

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


if (settings.enable == false || isForward)
{
var cmd2 = new CommandBuffer { name = "Setup neutral Ambient Occlusion (1x1)" };
cmd2.SetGlobalTexture("_AmbientOcclusionTexture", PostProcessing.RuntimeUtilities.whiteTexture);
cmd2.SetGlobalTexture("_AmbientOcclusionTexture", PostProcessing.RuntimeUtilities.blackTexture); // Neutral is black, see the comment in the shaders
renderContext.ExecuteCommandBuffer(cmd2);
cmd2.Dispose();

5
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/Resources/Composition.hlsl


ao += GetPackedAO(p4) * w4;
ao /= w0 + w1 + w2 + w3 + w4;
return half4(1 - ao, 0, 0, 0);
// Note: When we ImageLoad outside of texture size, the value returned by Load is 0.
// We use this property to have a neutral value for AO that doesn't consume a sampler and work also with compute shader (i.e use ImageLoad)
// We store inverse AO so neutral is black. So either we sample inside or outside the texture it return 0 in case of neutral
return half4(ao, 0, 0, 0); // <= we don't invert ao here but when we sample the texture for reasons explain above
}
#endif // UNITY_HDRENDERPIPELINE_AMBIENTOCCLUSION_COMPOSITION

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/Resources/Estimation.hlsl


ao += a1 / a2;
}
// TODO: Check with Keijiro but ao is inverted here...
//ao = 1.0 - ao;
// Apply intensity normalization/amplifier/contrast.
ao = pow(max(0, ao * _Radius * _Intensity / _SampleCount), kContrast);

3
Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl


// ----------------------------------------------------------------------------
TEXTURE2D(_AmbientOcclusionTexture);
// TODO: Create a variant for it
#define APPLY_AMBIENT_OCCLUSION

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


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// LightLoop
// ----------------------------------------------------------------------------

out float3 specularLighting)
{
LightLoopContext context;
context.ambientOcclusion = 1; // LOAD_TEXTURE2D(_AmbientOcclusionTexture, posInput.unPositionSS).x;
// Note: When we ImageLoad outside of texture size, the value returned by Load is 0 (Note: On Metal maybe it clamp to value of texture which is also fine)
// We use this property to have a neutral value for AO that doesn't consume a sampler and work also with compute shader (i.e use ImageLoad)
// We store inverse AO so neutral is black. So either we sample inside or outside the texture it return 0 in case of neutral
context.ambientOcclusion = 1.0 - LOAD_TEXTURE2D(_AmbientOcclusionTexture, posInput.unPositionSS).x;
context.sampleShadow = 0;
context.sampleReflection = 0;
context.shadowContext = InitShadowContext();

out float3 diffuseLighting,
out float3 specularLighting)
{
LightLoopContext context;
context.ambientOcclusion = 1; // LOAD_TEXTURE2D(_AmbientOcclusionTexture, posInput.unPositionSS).x;
LightLoopContext context;
// Note: When we ImageLoad outside of texture size, the value returned by Load is 0 (Note: On Metal maybe it clamp to value of texture which is also fine)
// We use this property to have a neutral value for AO that doesn't consume a sampler and work also with compute shader (i.e use ImageLoad)
// We store inverse AO so neutral is black. So either we sample inside or outside the texture it return 0 in case of neutral
context.ambientOcclusion = 1.0 - LOAD_TEXTURE2D(_AmbientOcclusionTexture, posInput.unPositionSS).x;
context.sampleShadow = 0;
context.sampleReflection = 0;
context.shadowContext = InitShadowContext();

19
Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultAmbientOcclusionSettings.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7d48b3fd85781a41844f6983c10d47d, type: 3}
m_Name: DefaultAmbientOcclusionSettings
m_EditorClassIdentifier:
m_Settings:
m_Enable: 1
m_Intensity: 1
m_Radius: 0.2
m_SampleCount: 8
m_Downsampling: 1

9
Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/DefaultAmbientOcclusionSettings.asset.meta


fileFormatVersion: 2
guid: b6ad359e4ffb6654b99a63579da693d2
timeCreated: 1496230889
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存