private void releaseTemporalRT() { if (m_temporalAccumRT != null) { for (int i = 0; i < m_temporalAccumRT.Length; i++) { AmplifyOcclusionCommon.SafeReleaseRT(ref m_temporalAccumRT[i]); } } m_temporalAccumRT = null; }
void Reset() { if (m_commandBuffer_Parameters.cmdBuffer != null) { cleanupCommandBuffer(ref m_commandBuffer_Parameters); } if (m_commandBuffer_Occlusion.cmdBuffer != null) { cleanupCommandBuffer(ref m_commandBuffer_Occlusion); } if (m_commandBuffer_Apply.cmdBuffer != null) { cleanupCommandBuffer(ref m_commandBuffer_Apply); } AmplifyOcclusionCommon.SafeReleaseRT(ref m_occlusionDepthRT); AmplifyOcclusionCommon.SafeReleaseRT(ref m_depthMipmap); releaseTemporalRT(); m_tmpMipString = null; }
private void checkParamsChanged() { bool HDR = m_targetCamera.allowHDR; // && tier? bool MSAA = m_targetCamera.allowMSAA && m_targetCamera.actualRenderingPath != RenderingPath.DeferredLighting && m_targetCamera.actualRenderingPath != RenderingPath.DeferredShading && QualitySettings.antiAliasing >= 1; int antiAliasing = MSAA ? QualitySettings.antiAliasing : 1; if (m_occlusionDepthRT != null) { if ((m_occlusionDepthRT.width != m_target.width) || (m_occlusionDepthRT.height != m_target.height) || (m_prevMSAA != MSAA) || (!m_occlusionDepthRT.IsCreated()) || (m_temporalAccumRT != null && (!m_temporalAccumRT[0].IsCreated() || !m_temporalAccumRT[1].IsCreated())) #if UNITY_EDITOR || ((m_prevIsPlaying == true) && (EditorApplication.isPlaying == false)) #endif ) { AmplifyOcclusionCommon.SafeReleaseRT(ref m_occlusionDepthRT); AmplifyOcclusionCommon.SafeReleaseRT(ref m_depthMipmap); releaseTemporalRT(); m_paramsChanged = true; } else { if (m_prevFilterEnabled != FilterEnabled) { releaseTemporalRT(); } } } if (m_temporalAccumRT != null) { if (AmplifyOcclusionCommon.IsStereoMultiPassEnabled(m_targetCamera) == true) { if (m_temporalAccumRT.Length != 4) { m_temporalAccumRT = null; } } else { if (m_temporalAccumRT.Length != 2) { m_temporalAccumRT = null; } } } if (m_occlusionDepthRT == null) { m_occlusionDepthRT = AmplifyOcclusionCommon.SafeAllocateRT("_AO_OcclusionDepthTexture", m_target.width, m_target.height, m_occlusionRTFormat, RenderTextureReadWrite.Linear, FilterMode.Bilinear); } if (m_temporalAccumRT == null && FilterEnabled) { if (AmplifyOcclusionCommon.IsStereoMultiPassEnabled(m_targetCamera) == true) { m_temporalAccumRT = new RenderTexture[4]; } else { m_temporalAccumRT = new RenderTexture[2]; } for (int i = 0; i < m_temporalAccumRT.Length; i++) { m_temporalAccumRT[i] = AmplifyOcclusionCommon.SafeAllocateRT("_AO_TemporalAccum_" + i.ToString(), m_target.width, m_target.height, m_accumTemporalRTFormat, RenderTextureReadWrite.Linear, FilterMode.Bilinear, antiAliasing); } m_clearHistory = true; } if ((CacheAware == true) && (m_depthMipmap == null)) { m_depthMipmap = AmplifyOcclusionCommon.SafeAllocateRT("_AO_DepthMipmap", m_target.width >> 1, m_target.height >> 1, RenderTextureFormat.RFloat, RenderTextureReadWrite.Linear, FilterMode.Point, 1, true); int minSize = (int)Mathf.Min(m_target.width, m_target.height); m_numberMips = (int)(Mathf.Log((float)minSize, 2.0f) + 1.0f) - 1; m_tmpMipString = null; m_tmpMipString = new string[m_numberMips]; for (int i = 0; i < m_numberMips; i++) { m_tmpMipString[i] = "_AO_TmpMip_" + i.ToString(); } } else { if ((CacheAware == false) && (m_depthMipmap != null)) { AmplifyOcclusionCommon.SafeReleaseRT(ref m_depthMipmap); m_tmpMipString = null; } } if ((m_prevSampleCount != SampleCount) || (m_prevDownsample != Downsample) || (m_prevCacheAware != CacheAware) || (m_prevBlurEnabled != BlurEnabled) || (((m_prevBlurPasses != BlurPasses) || (m_prevBlurRadius != BlurRadius)) && (BlurEnabled == true)) || (m_prevFilterEnabled != FilterEnabled) || (m_prevHDR != HDR) || (m_prevMSAA != MSAA)) { m_clearHistory |= (m_prevHDR != HDR); m_clearHistory |= (m_prevMSAA != MSAA); m_HDR = HDR; m_MSAA = MSAA; m_paramsChanged = true; } #if UNITY_EDITOR m_prevIsPlaying = EditorApplication.isPlaying; #endif }