Пример #1
0
        static void RenderOutline_Optimized(PostProcessRenderContext context, PropertySheet sheet, RenderTargetIdentifier source, RenderTargetIdentifier destination, OutlineCollection collection)
        {
            context.command.SetGlobalFloat(_MaxDistance, collection.def.maxRenderDistance);

            //render objects
            context.command.SetRenderTarget(drawTarget, (RenderTargetIdentifier)BuiltinRenderTextureType.Depth);
            context.command.ClearRenderTarget(false, true, Color.clear, 1.0f);
            DrawRenderGroup(context.command, collection, false);

            //render overlayed
            context.command.SetRenderTarget(drawTarget, drawTarget);
            DrawRenderGroup(context.command, collection, true);

            //blur
            Blur.BlurImage(context, drawTarget, context.screenWidth, context.screenHeight, RenderTextureFormat.Default, blurTarget, collection.def.blur);

            // mask out insides
            context.command.SetGlobalTexture(_MaskOut, drawTarget);
            context.command.BlitFullscreenTriangle(blurTarget, depthTarget, sheet, maskOutPass + 2);

            // add to final
            context.command.SetGlobalTexture(_AddOverlay, depthTarget);
            context.command.SetGlobalVector(_Intensity_Heaviness, new Vector2(collection.def.intensity, collection.def.heaviness));
            context.command.BlitFullscreenTriangle(source, destination, sheet, finalPass + 2);
        }
Пример #2
0
        public override void Render(PostProcessRenderContext context)
        {
            var sheet = context.propertySheets.Get(distanceBlurShader);

            if (settings.debugVisuals)
            {
                context.command.EnableShaderKeyword("DEBUG_VISUAL");
            }
            else
            {
                context.command.DisableShaderKeyword("DEBUG_VISUAL");
            }

            int blurredID = Blur.BlurImage(context, context.source, context.screenWidth, context.screenHeight, context.sourceFormat, settings.downsample, settings.blurSize, settings.blurIterations);

            GetBlurredDepthMap(context, sheet, settings.fadeDownsample, settings.fadeBlurSize, settings.fadeBlurIterations);

            context.command.SetGlobalTexture(_BlurredSource, blurredID);
            context.command.SetGlobalTexture(_DepthBlurMap, _DepthBlurMapID);

            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 3);

            context.command.ReleaseTemporaryRT(blurredID);
            context.command.ReleaseTemporaryRT(_DepthBlurMapID);
        }
Пример #3
0
        public override void Render(PostProcessRenderContext context)
        {
            RenderTextureFormat format = RenderTextureFormat.Default;
            int w = context.screenWidth >> settings.downsample;
            int h = context.screenHeight >> settings.downsample;

            var sheet = context.propertySheets.Get(shader);

            sheet.properties.SetVector(_GhostParameters, new Vector3(settings.ghosts, settings.ghostDisplacement, settings.ghostThreshold));
            sheet.properties.SetVector(_HaloParameters, new Vector3(settings.haloRadius, settings.haloThickness, settings.haloThreshold));
            sheet.properties.SetTexture(_LensColor, lensColor);

            context.command.GetTemporaryRT(RT_features, w, h, 0, FilterMode.Bilinear, format);
            context.command.BlitFullscreenTriangle(context.source, RT_features, sheet, 0);

            // CHROMATIC ABERRATION
            context.command.GetTemporaryRT(RT_aberration, w, h, 0, FilterMode.Bilinear, format);
            ColorShiftRenderer.DoRender(context, RT_features, RT_aberration, settings.chromaticDisplacement, true);

            // BLUR
            int RT_blur1 = Blur.BlurImage(context, RT_aberration, w, h, format, 0, settings.blurSize, settings.blurIterations);

            // COMPOSITE
            context.command.SetGlobalTexture(_LensArtifacts, RT_blur1);
            context.command.SetGlobalTexture(_LensDirt, lensDirt);
            context.command.SetGlobalTexture(_LensStar, noiseLookup);
            context.command.SetGlobalVector(_CamFwd, context.camera.transform.forward);
            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 1);

            context.command.ReleaseTemporaryRT(RT_features);
            context.command.ReleaseTemporaryRT(RT_aberration);
            context.command.ReleaseTemporaryRT(RT_blur1);
        }
Пример #4
0
        static void RenderOutlines(PostProcessRenderContext context, PropertySheet sheet, RenderTargetIdentifier source, RenderTargetIdentifier destination, OutlineCollection collection, bool needsDepth, bool needsOverlay)
        {
            context.command.SetGlobalFloat(_MaxDistance, collection.def.maxRenderDistance);

            if (needsDepth)
            {
                // render only the highlited objects that are depth tested
                RenderLoop(context.command, collection, false, true);

                // blur the render texture we've been drawing to with the tempCamera
                Blur.BlurImage(context, drawTarget, context.screenWidth, context.screenHeight, RenderTextureFormat.Default, blurTarget, collection.def.blur);

                /*
                 *  alternative if blurred outlines against occludign non outlined geometry is bugging you...
                 *
                 *  this remakes the mask to take out the insides of the outlines, except is uses a non depth tested render.
                 *  this comes with it's own artifacts, specifically when two outlined objects are seperated by an occulder
                 *  e.g.
                 *      camera ->  OutlinedA    Wall    OutlinedB
                 *  in the above situation if outlinedB is larger than OutlinedA, OutlinedA's outline will not be visible
                 */
                if (settings.alternateDepthOutlines)
                {
                    RenderLoop(context.command, collection, false, false);
                }

                // now mask out the insides (as well as the alpha)
                MaskOutInsides(context.command, sheet, depthTarget, 1);
            }

            //do overlay highlights
            if (needsOverlay)
            {
                RenderLoop(context.command, collection, true, false);

                Blur.BlurImage(context, drawTarget, context.screenWidth, context.screenHeight, RenderTextureFormat.Default, blurTarget, collection.def.blur);

                // mask out the insides, except for alpha (maskAlphaSubtractMult == 0)
                // we need the alpha of the overlay inside to cancel out any
                // highlight within it that's been drawn by the depth tested passes
                MaskOutInsides(context.command, sheet, overlayTarget, 0);
            }

            // the final pass
            context.command.SetGlobalTexture(_AddHighlight, needsDepth ? depthTarget : (RenderTargetIdentifier)RenderUtils.blackTexture);
            context.command.SetGlobalTexture(_AddOverlay, needsOverlay ? overlayTarget : (RenderTargetIdentifier)RenderUtils.blackTexture);

            // we need to pass in the original overlay mask to cancel out the alpha
            // after it cancels out any overlapped depth tested highlights
            // the mask is contained in the camera target
            context.command.SetGlobalTexture(_OverlayMask, needsOverlay ? drawTarget : (RenderTargetIdentifier)RenderUtils.blackTexture);

            context.command.SetGlobalVector(_Intensity_Heaviness_OverlayAlphaHelper, new Vector3(collection.def.intensity, collection.def.heaviness, settings.outlineOverlayAlphaHelper));

            context.command.BlitFullscreenTriangle(source, destination, sheet, finalPass);
        }
Пример #5
0
        void GetBlurredDepthMap(PostProcessRenderContext context, PropertySheet sheet, int downsample, float size, int iterations)
        {
            sheet.properties.SetFloat(_SkyboxBleed, settings.skyboxBleed);
            sheet.properties.SetVector(_DistBlurParams, new Vector4(settings.startDistance, settings.fadeRange, settings.fadeSteepness, settings.maxDistance));

            int rtW = context.screenWidth >> downsample;
            int rtH = context.screenHeight >> downsample;

            context.command.GetTemporaryRT(_UnblurredMapID, rtW, rtH, 0, FilterMode.Bilinear, RenderTextureFormat.RHalf, RenderTextureReadWrite.Linear);
            context.command.GetTemporaryRT(_DepthBlurMapID, rtW, rtH, 0, FilterMode.Bilinear, RenderTextureFormat.R8);

            // build map
            context.command.BlitFullscreenTriangle(_DepthBlurMapID, _UnblurredMapID, sheet, 0);
            context.command.SetGlobalTexture(_UnblurredMap, _UnblurredMapID);

            Blur.DoBlurLoop(context, sheet, 1, _UnblurredMapID, context.screenWidth, context.screenHeight, RenderTextureFormat.R8, _DepthBlurMapID, downsample, size, iterations);

            context.command.ReleaseTemporaryRT(_UnblurredMapID);
        }