Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit 543093b

Browse files
committed
Support ScalableAO in XR
This was originally supported before AO refactor. Scalable must be less useful one, but it was easy to port back.
1 parent bc7f051 commit 543093b

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

PostProcessing/Runtime/Effects/ScalableAO.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,17 @@ void DoLazyInitialization(PostProcessRenderContext context)
7171

7272
if (m_Result == null || !m_Result.IsCreated())
7373
{
74+
var tempAORTDesc = context.GetDescriptor(0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
75+
7476
// Initial allocation
75-
m_Result = new RenderTexture(context.width, context.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear)
77+
m_Result = new RenderTexture(tempAORTDesc)
7678
{
7779
hideFlags = HideFlags.DontSave,
7880
filterMode = FilterMode.Bilinear
7981
};
8082
reset = true;
8183
}
82-
else if (m_Result.width != context.width || m_Result.height != context.height)
84+
else if (m_Result.width != context.width || m_Result.height != context.height) // TODO: convert this to RT width when I implement it
8385
{
8486
// Release and reallocate
8587
m_Result.Release();
@@ -123,23 +125,24 @@ void Render(PostProcessRenderContext context, CommandBuffer cmd, int occlusionSo
123125
}
124126

125127
// Texture setup
126-
int tw = context.width;
127-
int th = context.height;
128128
int ts = downsampling ? 2 : 1;
129-
const RenderTextureFormat kFormat = RenderTextureFormat.ARGB32;
130-
const RenderTextureReadWrite kRWMode = RenderTextureReadWrite.Linear;
131129
const FilterMode kFilter = FilterMode.Bilinear;
132130

131+
var tempAORTDesc = context.GetDescriptor(0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
132+
tempAORTDesc.width /= ts;
133+
tempAORTDesc.height /= ts;
134+
var tempBlurRTDesc = context.GetDescriptor(0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
135+
133136
// AO buffer
134137
var rtMask = ShaderIDs.OcclusionTexture1;
135-
cmd.GetTemporaryRT(rtMask, tw / ts, th / ts, 0, kFilter, kFormat, kRWMode);
138+
cmd.GetTemporaryRT(rtMask, tempAORTDesc, kFilter);
136139

137140
// AO estimation
138141
cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, rtMask, sheet, (int)Pass.OcclusionEstimationForward + occlusionSource);
139142

140143
// Blur buffer
141144
var rtBlur = ShaderIDs.OcclusionTexture2;
142-
cmd.GetTemporaryRT(rtBlur, tw, th, 0, kFilter, kFormat, kRWMode);
145+
cmd.GetTemporaryRT(rtBlur, tempBlurRTDesc, kFilter);
143146

144147
// Separable blur (horizontal pass)
145148
cmd.BlitFullscreenTriangle(rtMask, rtBlur, sheet, (int)Pass.HorizontalBlurForward + occlusionSource);

0 commit comments

Comments
 (0)