Ejemplo n.º 1
0
        public override void Render(CommandBuffer cmd, ref RenderingData renderingData, PostProcessingRenderContext context)
        {
            if (!_shader)
            {
                return;
            }
            if (!_material)
            {
                _material = new Material(_shader);
            }

            var DOFParams = new Vector4(
                rcpf,
                _focalLength,
                1 / (_focalLength * rcpf * _aperture),
                0
                );

            _material.SetVector("_DOFParams", DOFParams);

            for (var i = 0; i < _blurIteratorCount; i++)
            {
                //水平blur
                context.BlitAndSwap(cmd, _material, 0);
                //垂直blur
                context.BlitAndSwap(cmd, _material, 1);
            }
        }
Ejemplo n.º 2
0
 public override void Render(CommandBuffer cmd, ref RenderingData renderingData, PostProcessingRenderContext context)
 {
     _blurBlitter.SetSource(context.activeRenderTarget, context.sourceRenderTextureDescriptor);
     _blurBlitter.Render(cmd);
 }
Ejemplo n.º 3
0
        public override void Render(CommandBuffer cmd, ref RenderingData renderingData, PostProcessingRenderContext context)
        {
            if (!_shader)
            {
                return;
            }
            if (!_material)
            {
                _material = new Material(_shader);
            }

            if (_debug)
            {
                _material.EnableKeyword("_BloomDebug");
            }
            else
            {
                _material.DisableKeyword("_BloomDebug");
            }

            _material.SetFloat("_Threshold", _threshold);

            var descriptor = context.sourceRenderTextureDescriptor;

            var temp1 = context.GetTemporaryRT(cmd, descriptor, FilterMode.Bilinear);

            //first pass,提取光亮部分
            cmd.Blit(context.activeRenderTarget, temp1, _material, 0);

            //模糊处理
            _blurBlitter.SetSource(temp1, descriptor);

            _blurBlitter.downSample    = downSample;
            _blurBlitter.iteratorCount = _blurIteratorCount;
            _blurBlitter.blurType      = BlurType.Box;

            _blurBlitter.Render(cmd);

            cmd.SetGlobalTexture("_BloomTex", temp1);

            //combine
            context.BlitAndSwap(cmd, _material, 3);

            context.ReleaseTemporaryRT(cmd, temp1);
        }
Ejemplo n.º 4
0
 public override void Render(CommandBuffer cmd, ref RenderingData renderingData, PostProcessingRenderContext context)
 {
     if (!_shader)
     {
         return;
     }
     if (_material == null)
     {
         _material = new Material(_shader);
         UpdateMaterialProperties();
     }
     context.BlitAndSwap(cmd, _material);
 }
Ejemplo n.º 5
0
 public abstract void Render(CommandBuffer cmd, ref RenderingData renderingData, PostProcessingRenderContext context);
Ejemplo n.º 6
0
        public override void Render(CommandBuffer cmd, ref RenderingData renderingData, PostProcessingRenderContext context)
        {
            if (!_shader)
            {
                return;
            }
            if (_material == null)
            {
                _material = new Material(_shader);
            }
            this.UpdateMaterialProperties();
            var projMatrix = renderingData.cameraData.GetGPUProjectionMatrix();

            _material.SetMatrix("CustomProjMatrix", projMatrix);
            _material.SetMatrix("CustomInvProjMatrix", projMatrix.inverse);
            if (_blur)
            {
                _material.EnableKeyword("_Blur");
            }
            else
            {
                _material.DisableKeyword("_Blur");
            }
            if (_blur)
            {
                var temp1 = context.GetTemporaryRT(cmd);
                var temp2 = context.GetTemporaryRT(cmd);
                _blitter.Prepare(temp1, temp2);
                //first pass, calculate AO
                _blitter.BlitAndSwap(cmd, _material, 0);

                //second pass, blur horizantal
                _blitter.BlitAndSwap(cmd, _material, 1);

                //third pass, blur vertical
                _blitter.BlitAndSwap(cmd, _material, 2);

                cmd.SetGlobalTexture("_AOTex", _blitter.pingRT);

                context.BlitAndSwap(cmd, _material, 3);

                context.ReleaseTemporaryRT(cmd, temp1);
                context.ReleaseTemporaryRT(cmd, temp2);
            }
            else
            {
                context.BlitAndSwap(cmd, _material);
            }
        }