コード例 #1
0
        public static void SetupDepthBuffer(ref DepthRenderTexture depthRenderTexure, bool enabled, Camera camera, RenderTargetProperty renderTargetProperty)
        {
            if (depthRenderTexure != null)
            {
                depthRenderTexure.Release();
                depthRenderTexure = null;
            }

            if (enabled)
            {
                var targetSize = BackgroundRenderTexture.GetRequiredSize(camera, renderTargetProperty);

#if UNITY_IOS || UNITY_ANDROID
                RenderTextureFormat format = RenderTextureFormat.ARGB32;
#else
                RenderTextureFormat format = (camera.allowHDR) ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32;
#endif
                depthRenderTexure = new DepthRenderTexture(targetSize.x, targetSize.y, renderTargetProperty);

                // HACK for some smart phone
                if (depthRenderTexure == null || !depthRenderTexure.Create())
                {
                    depthRenderTexure = null;
                }
            }
        }
コード例 #2
0
        internal void ApplyToCommandBuffer(CommandBuffer cb, DepthRenderTexture depthRenderTexture)
        {
            if (depthRenderTexture != null && depthTargetIdentifier.HasValue)
            {
#if UNITY_EDITOR
                if (grabDepthMat == null)
                {
                    Effekseer.EffekseerSettings.AssignAssets();
                }
#endif

                if (grabDepthMat == null && Effekseer.EffekseerSettings.Instance.grabDepthShader != null)
                {
                    grabDepthMat = new Material(Effekseer.EffekseerSettings.Instance.grabDepthShader);
                }

                cb.Blit(null, depthRenderTexture.renderTexture, grabDepthMat);

                // restore
                if (depthTargetIdentifier.HasValue)
                {
                    cb.SetRenderTarget(colorTargetIdentifier, depthTargetIdentifier.Value);
                }
                else
                {
                    cb.SetRenderTarget(colorTargetIdentifier);
                }
            }
        }
コード例 #3
0
            public void Dispose()
            {
                if (this.commandBuffer != null && !isCommandBufferFromExternal)
                {
                    if (this.camera != null)
                    {
                        this.camera.RemoveCommandBuffer(this.cameraEvent, this.commandBuffer);
                    }
                    this.commandBuffer.Dispose();
                    this.commandBuffer = null;
                }

                if (this.renderTexture != null)
                {
                    this.renderTexture.Release();
                    this.renderTexture = null;
                }

                if (depthTexture != null)
                {
                    depthTexture.Release();
                    depthTexture = null;
                }
            }