public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (material.IsKeywordEnabled("_COLOR_GRADING_LDR_2D") == false)
                {
                    material.EnableKeyword("_COLOR_GRADING_LDR_2D");
                }
                material.SetVector("_Lut2D_Params",
                                   new Vector3(
                                       1.0f / internalLdrLut.width,
                                       1.0f / internalLdrLut.height,
                                       internalLdrLut.height - 1.0f));
                material.SetTexture("_Lut2D", internalLdrLut);
            }
            else if (material.IsKeywordEnabled("_COLOR_GRADING_LDR_2D") != false)
            {
                material.DisableKeyword("_COLOR_GRADING_LDR_2D");
            }
            return(rebuild);
        }
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                if (cacheFlipHorizontal != flipHorizontal)
                {
                    if (flipHorizontal != false)
                    {
                        if (material.IsKeywordEnabled(kShaderKeywordFlipHorizontal) == false)
                        {
                            material.EnableKeyword(kShaderKeywordFlipHorizontal);
                        }
                    }
                    else if (material.IsKeywordEnabled(kShaderKeywordFlipHorizontal) != false)
                    {
                        material.DisableKeyword(kShaderKeywordFlipHorizontal);
                    }
                    cacheFlipHorizontal = flipHorizontal;
                }
                Color mixedColor = ColorBlending();
                if (cacheColor != mixedColor)
                {
                    material.SetColor(kShaderPropertyColor, mixedColor);
                    cacheColor = mixedColor;
                }
            }
            return(rebuild);
        }
Example #3
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     if (context.CompareSource0ToTarget0() != false)
     {
         int temporary = pipeline.GetTemporaryRT();
         if (nextProcess == null)
         {
             commandBuffer.SetRenderTarget(
                 new RenderTargetIdentifier(temporary),
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.Store,
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.DontCare);
             commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
             pipeline.SetViewport(commandBuffer, nextProcess);
             pipeline.DrawCopy(commandBuffer);
             context.SetSource0(temporary);
         }
         else
         {
             commandBuffer.SetRenderTarget(
                 new RenderTargetIdentifier(temporary),
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.Store,
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.DontCare);
             commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.target0);
             pipeline.SetViewport(commandBuffer, nextProcess);
             pipeline.DrawCopy(commandBuffer);
             context.SetTarget0(temporary);
         }
     }
     else
     {
         commandBuffer.SetRenderTarget(
             context.target0,
             RenderBufferLoadAction.DontCare,
             RenderBufferStoreAction.Store,
             RenderBufferLoadAction.DontCare,
             RenderBufferStoreAction.DontCare);
         commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
         pipeline.SetViewport(commandBuffer, nextProcess);
         pipeline.DrawCopy(commandBuffer);
     }
     commandBuffer.SetRenderTarget(
         context.target0,
         (Properties.StencilCompare != CompareFunction.Always)?
         RenderBufferLoadAction.Load    :
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.Store,
         pipeline.DepthStencilBuffer,
         RenderBufferLoadAction.Load,
         RenderBufferStoreAction.DontCare);
     commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
     pipeline.SetViewport(commandBuffer, nextProcess);
     pipeline.DrawFill(commandBuffer, material, 0);
     context.duplicated = false;
     return(true);
 }
Example #4
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     if (context.CompareSource0ToTarget0() != false)
     {
         int temporary = pipeline.GetTemporaryRT();
         if (nextProcess == null)
         {
             commandBuffer.Blit(context.source0, temporary);
             context.SetSource0(temporary);
         }
         else
         {
             context.SetTarget0(temporary);
         }
     }
     commandBuffer.SetRenderTarget(
         context.target0,
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.Store,
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.DontCare);
     commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
     pipeline.SetViewport(commandBuffer, nextProcess);
     pipeline.DrawFill(commandBuffer, material, 0);
     context.duplicated = false;
     return(true);
 }
Example #5
0
 public sealed override bool UpdateProperties(RenderPipeline pipeline, bool clearCache)
 {
     if (clearCache != false)
     {
         ClearPropertiesCache();
     }
     return(OnUpdateProperties(pipeline, material));
 }
Example #6
0
 internal void ResetProperty(RenderPipeline pipeline)
 {
     foreach (var property in properties)
     {
         property.GetProperties().UpdateUbarProperties(pipeline, material, true);
     }
     properties.Clear();
 }
Example #7
0
 protected override bool OnUpdateProperties(RenderPipeline pipeline, Material material)
 {
     return(Properties.UpdateProperties(pipeline, material, (width, height) =>
     {
         descriptor = new RenderTextureDescriptor(width, height, TextureUtil.DefaultHDR);
         descriptor.useMipMap = false;
         descriptor.autoGenerateMips = false;
     }));
 }
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                Cache(Time.renderedFrameCount);

                if (internalLdrLut == null)
                {
                    internalLdrLut = new RenderTexture(kLut2DSize * kLut2DSize, kLut2DSize, 0, GetLutFormat(), RenderTextureReadWrite.Linear)
                    {
                        name             = "Color Grading Strip Lut",
                        hideFlags        = HideFlags.DontSave,
                        filterMode       = FilterMode.Bilinear,
                        wrapMode         = TextureWrapMode.Clamp,
                        anisoLevel       = 0,
                        autoGenerateMips = false,
                        useMipMap        = false
                    };
                    internalLdrLut.Create();
                }
                material.SetVector("_Lut2D_Params",
                                   new Vector4(kLut2DSize, 0.5f / (kLut2DSize * kLut2DSize),
                                               0.5f / kLut2DSize, kLut2DSize / (kLut2DSize - 1.0f)));

                var colorBalance = ColorUtilities.ComputeColorBalance(temperature, tint);
                material.SetVector("_ColorBalance", colorBalance);
                material.SetVector("_ColorFilter", colorFilter);

                material.SetVector("_HueSatCon", new Vector3(
                                       hueShift / 360.0f,
                                       saturation / 100.0f + 1.0f,
                                       contrast / 100.0f + 1.0f));

                var channelMixerR = new Vector3(mixerRedOutRedIn, mixerRedOutGreenIn, mixerRedOutBlueIn);
                var channelMixerG = new Vector3(mixerGreenOutRedIn, mixerGreenOutGreenIn, mixerGreenOutBlueIn);
                var channelMixerB = new Vector3(mixerBlueOutRedIn, mixerBlueOutGreenIn, mixerBlueOutBlueIn);
                material.SetVector("_ChannelMixerRed", channelMixerR / 100.0f);
                material.SetVector("_ChannelMixerGreen", channelMixerG / 100.0f);
                material.SetVector("_ChannelMixerBlue", channelMixerB / 100.0f);

                material.SetVector("_Lift", ColorUtilities.ColorToLift(lift));
                material.SetVector("_InvGamma", ColorUtilities.ColorToInverseGamma(gamma));
                material.SetVector("_Gain", ColorUtilities.ColorToGain(gain));

                material.SetFloat("_Brightness", (brightness + 100.0f) / 100.0f);
            }
            return(rebuild);
        }
Example #9
0
        public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (cacheX != x)
                {
                    if (x != false)
                    {
                        if (material.IsKeywordEnabled(kShaderKeywordFlipX) == false)
                        {
                            material.EnableKeyword(kShaderKeywordFlipX);
                        }
                    }
                    else if (material.IsKeywordEnabled(kShaderKeywordFlipX) != false)
                    {
                        material.DisableKeyword(kShaderKeywordFlipX);
                    }
                    cacheX = x;
                }
                if (cacheY != y)
                {
                    if (y != false)
                    {
                        if (material.IsKeywordEnabled(kShaderKeywordFlipY) == false)
                        {
                            material.EnableKeyword(kShaderKeywordFlipY);
                        }
                    }
                    else if (material.IsKeywordEnabled(kShaderKeywordFlipY) != false)
                    {
                        material.DisableKeyword(kShaderKeywordFlipY);
                    }
                    cacheY = y;
                }
            }
            else
            {
                if (material.IsKeywordEnabled(kShaderKeywordFlipX) != false)
                {
                    material.DisableKeyword(kShaderKeywordFlipX);
                }
                if (material.IsKeywordEnabled(kShaderKeywordFlipY) != false)
                {
                    material.DisableKeyword(kShaderKeywordFlipY);
                }
            }
            return(rebuild);
        }
Example #10
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     commandBuffer.ClearRenderTarget(
         Properties.ClearDepth,
         Properties.ClearColor,
         Properties.Color,
         Properties.Depth);
     context.duplicated = false;
     return(false);
 }
        public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (cacheAmount != amount ||
                    cacheScale != scale)
                {
                    float value = 1.6f * Mathf.Max(Mathf.Abs(amount), 1.0f);
                    float theta = Mathf.Deg2Rad * Mathf.Min(160f, value);
                    float sigma = 2.0f * Mathf.Tan(theta * 0.5f);

                    material.SetVector(kShaderPropertyAmount,
                                       new Vector4((amount >= 0.0f)? theta : 1.0f / theta, sigma, 1.0f / scale, amount));
                    cacheAmount = amount;
                    cacheScale  = scale;
                }
                if (cacheCenterX != centerX ||
                    cacheCenterY != centerY ||
                    cacheIntensityX != intensityX ||
                    cacheIntensityY != intensityY)
                {
                    material.SetVector(kShaderPropertyCenterScale,
                                       new Vector4(centerX, centerY, intensityX, intensityY));
                    cacheCenterX    = centerX;
                    cacheCenterY    = centerY;
                    cacheIntensityX = intensityX;
                    cacheIntensityY = intensityY;
                }
                if (Mathf.Approximately(amount, 0.0f) == false && (intensityX > 0.0f || intensityY > 0.0f))
                {
                    if (material.IsKeywordEnabled(kShaderKeywordLensDistortion) == false)
                    {
                        material.EnableKeyword(kShaderKeywordLensDistortion);
                    }
                }
                else if (material.IsKeywordEnabled(kShaderKeywordLensDistortion) != false)
                {
                    material.DisableKeyword(kShaderKeywordLensDistortion);
                }
            }
            else if (material.IsKeywordEnabled(kShaderKeywordLensDistortion) != false)
            {
                material.DisableKeyword(kShaderKeywordLensDistortion);
            }
            return(rebuild);
        }
Example #12
0
        public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (material.IsKeywordEnabled(kShaderKeywordVignette) == false)
                {
                    material.EnableKeyword(kShaderKeywordVignette);
                }
                if (cacheColor != color)
                {
                    material.SetColor(kShaderPropertyColor, color);
                    cacheColor = color;
                }
                if (cacheCenter != center)
                {
                    material.SetVector(kShaderPropertyCenter, new Vector4(center.x, center.y, 0, 0));
                    cacheCenter = center;
                }
                if (cacheIntensity != intensity ||
                    cacheSmoothness != smoothness ||
                    cacheRoundness != roundness ||
                    cacheRounded != rounded)
                {
                    intensity  = Mathf.Clamp(intensity, 0.0f, 1.0f);
                    smoothness = Mathf.Clamp(smoothness, 0.0f, 1.0f);
                    roundness  = Mathf.Clamp(roundness, 0.0f, 1.0f);
                    material.SetVector(kShaderPropertyParam,
                                       new Vector4(
                                           intensity * 3.0f,
                                           Mathf.Max(1e-4f, smoothness * 5.0f),
                                           Mathf.Lerp(6.0f, 1.0f, roundness),
                                           (rounded == false)? 0.0f : 1.0f));
                    cacheIntensity  = intensity;
                    cacheSmoothness = smoothness;
                    cacheRoundness  = roundness;
                    cacheRounded    = rounded;
                }
            }
            else if (material.IsKeywordEnabled(kShaderKeywordVignette) != false)
            {
                material.DisableKeyword(kShaderKeywordVignette);
            }
            return(rebuild);
        }
Example #13
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     commandBuffer.SetRenderTarget(
         Properties.GetInternalStripLut(),
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.Store,
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.DontCare);
     commandBuffer.SetGlobalTexture("_Curves", Properties.GetCurveTexture(false));
     pipeline.SetViewport(commandBuffer, nextProcess);
     pipeline.DrawFill(commandBuffer, material, 0);
     context.duplicated = false;
     return(true);
 }
Example #14
0
        public bool UpdateProperties(RenderPipeline pipeline, bool clearCache)
        {
            bool rebuild = false;

            if (clearCache != false)
            {
                ClearPropertiesCache();
            }
            foreach (var property in properties)
            {
                if (property.GetProperties().UpdateUbarProperties(pipeline, material, property.Independent()) != false)
                {
                    rebuild = true;
                }
            }
            return(rebuild);
        }
Example #15
0
        protected override bool OnUpdateProperties(RenderPipeline pipeline, Material material)
        {
            int updateFlags = Properties.UpdateProperties(pipeline);

            if ((updateFlags & BloomProperties.kVerifyDescriptors) != 0)
            {
                updateFlags |= UpdateDescriptors(Properties.ScreenWidth, Properties.ScreenHeight);
            }
            if (updateFlags != 0 && bloomRects != null)
            {
                if (UpdateResources(updateFlags) != false)
                {
                    updateFlags |= BloomProperties.kRebuild;
                }
            }
            return((updateFlags & BloomProperties.kRebuild) != 0);
        }
Example #16
0
        public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                                CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
        {
            if (context.CompareSource0ToTarget0() != false)
            {
                int temporary = pipeline.GetTemporaryRT();
                if (nextProcess == null)
                {
                    commandBuffer.Blit(context.source0, temporary);
                    context.SetSource0(temporary);
                }
                else
                {
                    context.SetTarget0(temporary);
                }
            }
            /**/
            var blurTarget = new RenderTargetIdentifier(kShaderTargetBlur);

            commandBuffer.GetTemporaryRT(kShaderTargetBlur, descriptor, FilterMode.Point);

            commandBuffer.SetRenderTarget(
                blurTarget,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
            pipeline.DrawFill(commandBuffer, material, 0);

            /**/
            commandBuffer.SetRenderTarget(
                context.target0,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
            commandBuffer.SetGlobalTexture(kShaderPropertyBlurTex, blurTarget);
            pipeline.SetViewport(commandBuffer, nextProcess);
            pipeline.DrawFill(commandBuffer, material, 1);

            commandBuffer.ReleaseTemporaryRT(kShaderTargetBlur);
            context.duplicated = false;
            return(true);
        }
Example #17
0
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                if (cacheClearColor != clearColor)
                {
                    rebuild         = true;
                    cacheClearColor = clearColor;
                }
                if (cacheClearDepth != clearDepth)
                {
                    rebuild         = true;
                    cacheClearDepth = clearDepth;
                }
                if (clearColor != false)
                {
                    if (cacheColor != color)
                    {
                        rebuild    = true;
                        cacheColor = color;
                    }
                }
                if (clearDepth != false)
                {
                    if (cacheDepth != depth)
                    {
                        rebuild    = true;
                        cacheDepth = depth;
                    }
                }
            }
            return(rebuild);
        }
Example #18
0
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                if (cacheIntensity != intensity)
                {
                    intensity = Mathf.Clamp(intensity, 0.0f, 0.9999f);
                    material.SetFloat(kShaderPropertyIntensity, intensity);
                    cacheIntensity = intensity;
                }
                if (cacheTimeScale != timeScale)
                {
                    material.SetFloat(kShaderPropertyTimeScale, timeScale);
                    cacheTimeScale = timeScale;
                }
                if (cacheSlice != slice || cacheVolume != volume)
                {
                    var glitchParam = new Vector4(
                        slice.x, slice.y, volume.x, volume.y);
                    material.SetVector(kShaderPropertyGlitchParam, glitchParam);
                    cacheSlice  = slice;
                    cacheVolume = volume;
                }
                if (cacheChromaticAberration != chromaticAberration)
                {
                    material.SetVector(kShaderPropertyChromaticAberration, chromaticAberration);
                    cacheChromaticAberration = chromaticAberration;
                }
            }
            return(rebuild);
        }
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                if (cacheSamples != samples)
                {
                    samples = Mathf.Clamp(samples, 4, 32);
                    material.SetFloat(kShaderPropertySamples, samples);
                    cacheSamples = samples;
                }
                if (cacheIntensity != intensity)
                {
                    intensity = Mathf.Clamp(intensity, 0.0f, 1.0f);
                    material.SetFloat(kShaderPropertyIntensity, intensity);
                    cacheIntensity = intensity;
                }
                if (cacheRadius != radius)
                {
                    radius = Mathf.Clamp(radius, 0.0f, 50.0f);
                    material.SetFloat(kShaderPropertyRadius, radius);
                    cacheRadius = radius;
                }
                if (cacheCenter != center)
                {
                    material.SetVector(kShaderPropertyCenter, center);
                    cacheCenter = center;
                }
            }
            return(rebuild);
        }
        public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (cacheDot != dot)
                {
                    material.SetColor(kShaderPropertyDot, dot);
                    cacheDot = dot;
                }
                if (cacheMultiply != multiply)
                {
                    material.SetColor(kShaderPropertyMultiply, multiply);
                    cacheMultiply = multiply;
                }
                if (cacheAdd != add)
                {
                    material.SetColor(kShaderPropertyAdd, add);
                    cacheAdd = add;
                }
                if (material.IsKeywordEnabled(kShaderKeywordColorFilter) == false)
                {
                    material.EnableKeyword(kShaderKeywordColorFilter);
                }
            }
            else if (material.IsKeywordEnabled(kShaderKeywordColorFilter) != false)
            {
                material.DisableKeyword(kShaderKeywordColorFilter);
            }
            return(rebuild);
        }
Example #21
0
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                if (cacheThreshold != threshold)
                {
                    material.SetFloat(kShaderPropertyThreshold, threshold);
                    cacheThreshold = threshold;
                }
                if (cacheSharpness != sharpness)
                {
                    material.SetFloat(kShaderPropertySharpness, sharpness);
                    cacheSharpness = sharpness;
                }
            }
            return(rebuild);
        }
Example #22
0
 public bool UpdateProperties(RenderPipeline pipeline, Material material)
 {
     return(UpdateUbarProperties(pipeline, material, false));
 }
Example #23
0
        public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (capture != false || isScreenShot != false)
            {
                if (pipeline.Capture(phase, (capture) =>
                {
                    if (enabled != false)
                    {
                        texture = capture;
                    }
                    onScreenShotComplete?.Invoke(enabled);
                    onScreenShotComplete = null;
                }) == false)
                {
                    onScreenShotComplete?.Invoke(false);
                    onScreenShotComplete = null;
                }
                isScreenShot = false;
            }
            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (material.IsKeywordEnabled(kShaderKeywordOverray) == false)
                {
                    material.EnableKeyword(kShaderKeywordOverray);
                }
                if (cacheTexture != texture)
                {
                    material.SetTexture(kShaderPropertyTexture, (texture != null)? texture : Texture2D.whiteTexture);
                    cacheTexture = texture;
                }
                if (cacheColor != color)
                {
                    material.SetColor(kShaderPropertyColor, color);
                    cacheColor = color;
                }
                if (cacheStencilReference != stencilReference)
                {
                    stencilReference = (byte)Mathf.Clamp(stencilReference, 0, 255);
                    material.SetInt(ShaderProperty.StencilReference, stencilReference);
                    cacheStencilReference = stencilReference;
                }
                if (cacheStencilReadMask != stencilReadMask)
                {
                    stencilReadMask = (byte)Mathf.Clamp(stencilReadMask, 0, 255);
                    material.SetInt(ShaderProperty.StencilReadMask, stencilReadMask);
                    cacheStencilReadMask = stencilReadMask;
                }
                if (cacheStencilCompare != stencilCompare)
                {
                    if (stencilCompare == CompareFunction.Disabled)
                    {
                        stencilCompare = CompareFunction.Always;
                    }
                    bool always      = stencilCompare == CompareFunction.Always;
                    bool cacheAlways = false;

                    if (cacheStencilCompare.HasValue != false)
                    {
                        cacheAlways = cacheStencilCompare.Value == CompareFunction.Always;
                    }
                    if (cacheAlways != always)
                    {
                        rebuild = true;
                    }
                    material.SetInt(ShaderProperty.StencilCompare, (int)stencilCompare);
                    cacheStencilCompare = stencilCompare;
                }
            }
            else if (material.IsKeywordEnabled(kShaderKeywordOverray) != false)
            {
                material.DisableKeyword(kShaderKeywordOverray);
            }
            return(rebuild);
        }
Example #24
0
 protected override bool OnUpdateProperties(RenderPipeline pipeline, Material material)
 {
     return(Properties.UpdateProperties(pipeline, material));
 }
Example #25
0
 protected abstract bool OnUpdateProperties(RenderPipeline pipeline, Material material);
Example #26
0
        public bool UpdateProperties(RenderPipeline pipeline, Material material)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false)
            {
                if (cacheDetectType != detectType)
                {
                    cacheDetectType = detectType;
                    rebuild         = true;
                }
                if (cacheEdgeColor != edgeColor)
                {
                    material.SetColor(kShaderPropertyEdgeColor, edgeColor);
                    cacheEdgeColor = edgeColor;
                }
                if (cacheSampleDistance != sampleDistance)
                {
                    sampleDistance = Mathf.Clamp(sampleDistance, 0, 5);
                    material.SetFloat(kShaderPropertySampleDistance, sampleDistance);
                    cacheSampleDistance = sampleDistance;
                }
                if (cacheStencilReference != stencilReference)
                {
                    stencilReference = (byte)Mathf.Clamp(stencilReference, 0, 255);
                    material.SetInt(kShaderPropertyStencilRef, stencilReference);
                    cacheStencilReference = stencilReference;
                }
                if (cacheStencilReadMask != stencilReadMask)
                {
                    stencilReadMask = (byte)Mathf.Clamp(stencilReadMask, 0, 255);
                    material.SetInt(kShaderPropertyStencilReadMask, stencilReadMask);
                    cacheStencilReadMask = stencilReadMask;
                }
                if (cacheStencilCompare != stencilCompare)
                {
                    if (stencilCompare == CompareFunction.Disabled)
                    {
                        stencilCompare = CompareFunction.Always;
                    }
                    bool always      = stencilCompare == CompareFunction.Always;
                    bool cacheAlways = false;

                    if (cacheStencilCompare.HasValue != false)
                    {
                        cacheAlways = cacheStencilCompare.Value == CompareFunction.Always;
                    }
                    if (cacheAlways != always)
                    {
                        rebuild = true;
                    }
                    material.SetInt(kShaderPropertyStencilComp, (int)stencilCompare);
                    cacheStencilCompare = stencilCompare;
                }
            }
            return(rebuild);
        }
Example #27
0
 public override bool UpdateProperties(RenderPipeline pipeline, bool clearCache)
 {
     return(false);
 }
 public bool UpdateProperties(RenderPipeline pipeline, Material material)
 {
     return(false);
 }
Example #29
0
        public bool UpdateUbarProperties(RenderPipeline pipeline, Material material, bool forcedDisable)
        {
            bool rebuild = false;

            if (cacheEnabled != enabled)
            {
                rebuild      = true;
                cacheEnabled = enabled;
            }
            if (enabled != false && forcedDisable == false)
            {
                if (material.IsKeywordEnabled(kShaderKeywordChromaticAberration) == false)
                {
                    material.EnableKeyword(kShaderKeywordChromaticAberration);
                }
                if (cacheSpectralLut != spectralLut || spectralLut == null)
                {
                    if (spectralLut == null)
                    {
                        if (internalSpectralLut == null)
                        {
                            internalSpectralLut = new Texture2D(3, 1, TextureFormat.RGB24, false)
                            {
                                name       = "ChromaticAberrationSpectralLut",
                                filterMode = FilterMode.Bilinear,
                                wrapMode   = TextureWrapMode.Clamp,
                                anisoLevel = 0,
                                hideFlags  = HideFlags.DontSave
                            };
                            internalSpectralLut.SetPixels(new []
                            {
                                new Color(1.0f, 0.0f, 0.0f),
                                new Color(0.0f, 1.0f, 0.0f),
                                new Color(0.0f, 0.0f, 1.0f)
                            });
                            internalSpectralLut.Apply();
                        }
                        material.SetTexture(kShaderPropertySpectralLut, internalSpectralLut);
                    }
                    else
                    {
                        material.SetTexture(kShaderPropertySpectralLut, spectralLut);
                    }
                    cacheSpectralLut = spectralLut;
                }
                if (cacheIntensity != intensity)
                {
                    material.SetFloat(kShaderPropertyIntensity, intensity * 0.05f);
                    cacheIntensity = intensity;
                }
                if (fastMode != false)
                {
                    if (material.IsKeywordEnabled(kShaderKeywordChromaticAberrationFastMode) == false)
                    {
                        material.EnableKeyword(kShaderKeywordChromaticAberrationFastMode);
                    }
                }
                else if (material.IsKeywordEnabled(kShaderKeywordChromaticAberrationFastMode) != false)
                {
                    material.DisableKeyword(kShaderKeywordChromaticAberrationFastMode);
                }
            }
            else
            {
                if (material.IsKeywordEnabled(kShaderKeywordChromaticAberration) != false)
                {
                    material.DisableKeyword(kShaderKeywordChromaticAberration);
                }
                if (material.IsKeywordEnabled(kShaderKeywordChromaticAberrationFastMode) != false)
                {
                    material.DisableKeyword(kShaderKeywordChromaticAberrationFastMode);
                }
            }
            return(rebuild);
        }
Example #30
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     return(false);
 }