public override void Render(PostProcessRenderContext context) { CommandBuffer command = context.command; command.BeginSample("AutoExposureLookup"); CheckTexture(context.xrActiveEye, 0); CheckTexture(context.xrActiveEye, 1); float x = base.settings.filtering.value.x; float y = base.settings.filtering.value.y; y = Mathf.Clamp(y, 1.01f, 99f); x = Mathf.Clamp(x, 1f, y - 0.01f); float value = base.settings.minLuminance.value; float value2 = base.settings.maxLuminance.value; base.settings.minLuminance.value = Mathf.Min(value, value2); base.settings.maxLuminance.value = Mathf.Max(value, value2); bool flag = m_ResetHistory || !Application.isPlaying; string text = null; text = ((!flag && base.settings.eyeAdaptation.value != EyeAdaptation.Fixed) ? "KAutoExposureAvgLuminance_progressive" : "KAutoExposureAvgLuminance_fixed"); ComputeShader autoExposure = context.resources.computeShaders.autoExposure; int kernelIndex = autoExposure.FindKernel(text); command.SetComputeBufferParam(autoExposure, kernelIndex, "_HistogramBuffer", context.logHistogram.data); command.SetComputeVectorParam(autoExposure, "_Params1", new Vector4(x * 0.01f, y * 0.01f, RuntimeUtilities.Exp2(base.settings.minLuminance.value), RuntimeUtilities.Exp2(base.settings.maxLuminance.value))); command.SetComputeVectorParam(autoExposure, "_Params2", new Vector4(base.settings.speedDown.value, base.settings.speedUp.value, base.settings.keyValue.value, Time.deltaTime)); command.SetComputeVectorParam(autoExposure, "_ScaleOffsetRes", context.logHistogram.GetHistogramScaleOffsetRes(context)); if (flag) { m_CurrentAutoExposure = m_AutoExposurePool[context.xrActiveEye][0]; command.SetComputeTextureParam(autoExposure, kernelIndex, "_Destination", m_CurrentAutoExposure); command.DispatchCompute(autoExposure, kernelIndex, 1, 1, 1); RuntimeUtilities.CopyTexture(command, m_AutoExposurePool[context.xrActiveEye][0], m_AutoExposurePool[context.xrActiveEye][1]); m_ResetHistory = false; } else { int num = m_AutoExposurePingPong[context.xrActiveEye]; RenderTexture tex = m_AutoExposurePool[context.xrActiveEye][++num % 2]; RenderTexture renderTexture = m_AutoExposurePool[context.xrActiveEye][++num % 2]; command.SetComputeTextureParam(autoExposure, kernelIndex, "_Source", tex); command.SetComputeTextureParam(autoExposure, kernelIndex, "_Destination", renderTexture); command.DispatchCompute(autoExposure, kernelIndex, 1, 1, 1); m_AutoExposurePingPong[context.xrActiveEye] = ++num % 2; m_CurrentAutoExposure = renderTexture; } command.EndSample("AutoExposureLookup"); context.autoExposureTexture = m_CurrentAutoExposure; context.autoExposure = base.settings; }
public override void Render(PostProcessRenderContext context) { OutlineResources resources; if (settings.Resources.value) { resources = settings.Resources; } else { if (!_defaultResources) { _defaultResources = ScriptableObject.CreateInstance <OutlineResources>(); _defaultResources.ResetToDefaults(); _defaultResources.FullscreenTriangleMesh = RuntimeUtilities.fullscreenTriangle; } resources = _defaultResources; } if (resources && resources.IsValid) { RuntimeUtilities.CopyTexture(context.command, context.source, context.destination); using (var renderer = new OutlineRenderer(context.command, resources, context.destination, context.camera.actualRenderingPath, new Vector2Int(context.width, context.height))) { _objects.Clear(); settings.Layers.value.GetRenderObjects(_objects); foreach (var obj in _objects) { renderer.Render(obj); } } } }