public override void Render(PostProcessRenderContext context)
        {
            CommandBuffer cmd   = context.command;
            PropertySheet sheet = context.propertySheets.Get(shader);

            cmd.BeginSample(PROFILER_TAG);

            UpdateNoiseTexture(settings.frequncy, settings.noiseTextureWidth, settings.noiseTextureHeight, settings.stripeLength);

            sheet.properties.SetFloat(ShaderIDs.indensity, settings.intensity);

            if (_noiseTexture != null)
            {
                sheet.properties.SetTexture(ShaderIDs.noiseTex, _noiseTexture);
            }

            if (settings.needStripColorAdjust == true)
            {
                sheet.EnableKeyword("NEED_TRASH_FRAME");
                sheet.properties.SetColor(ShaderIDs.StripColorAdjustColor, settings.StripColorAdjustColor);
                sheet.properties.SetFloat(ShaderIDs.StripColorAdjustIndensity, settings.StripColorAdjustIndensity);
            }
            else
            {
                sheet.DisableKeyword("NEED_TRASH_FRAME");
            }

            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
            cmd.EndSample(PROFILER_TAG);
        }
Esempio n. 2
0
 public static void SetKeyword(this PropertySheet sheet, string prefix, Enum selection)
 {
     foreach (Enum value in Enum.GetValues(selection.GetType()))
     {
         sheet.DisableKeyword(FormatKeyword(prefix, value));
     }
     sheet.EnableKeyword(FormatKeyword(prefix, selection));
 }
Esempio n. 3
0
        public override void Render(PostProcessRenderContext context)
        {
            PropertySheet sheet = context.propertySheets.Get(PPoseidonSettings.Instance.UnderwaterShader);

            sheet.properties.SetFloat(PMat.PP_WATER_LEVEL, settings.waterLevel);
            sheet.properties.SetFloat(PMat.PP_MAX_DEPTH, settings.maxDepth);
            sheet.properties.SetFloat(PMat.PP_SURFACE_COLOR_BOOST, settings.surfaceColorBoost);

            sheet.properties.SetColor(PMat.PP_SHALLOW_FOG_COLOR, settings.shallowFogColor);
            sheet.properties.SetColor(PMat.PP_DEEP_FOG_COLOR, settings.deepFogColor);
            sheet.properties.SetFloat(PMat.PP_VIEW_DISTANCE, settings.viewDistance);

            if (settings.enableCaustic && settings.causticTexture.value != null)
            {
                sheet.EnableKeyword(PMat.KW_PP_CAUSTIC);
                sheet.properties.SetTexture(PMat.PP_NOISE_TEX, PPoseidonSettings.Instance.NoiseTexture);
                sheet.properties.SetTexture(PMat.PP_CAUSTIC_TEX, settings.causticTexture.value);
                sheet.properties.SetFloat(PMat.PP_CAUSTIC_SIZE, settings.causticSize);
                sheet.properties.SetFloat(PMat.PP_CAUSTIC_STRENGTH, settings.causticStrength);
            }
            else
            {
                sheet.DisableKeyword(PMat.KW_PP_CAUSTIC);
            }

            if (settings.enableDistortion && settings.distortionNormalMap.value != null)
            {
                sheet.EnableKeyword(PMat.KW_PP_DISTORTION);
                sheet.properties.SetTexture(PMat.PP_DISTORTION_TEX, settings.distortionNormalMap.value);
                sheet.properties.SetFloat(PMat.PP_DISTORTION_STRENGTH, settings.distortionStrength);
                sheet.properties.SetFloat(PMat.PP_WATER_FLOW_SPEED, settings.waterFlowSpeed);
            }
            else
            {
                sheet.DisableKeyword(PMat.KW_PP_DISTORTION);
            }

            sheet.properties.SetVector(PMat.PP_CAMERA_VIEW_DIR, context.camera.transform.forward);
            sheet.properties.SetFloat(PMat.PP_CAMERA_FOV, context.camera.fieldOfView);
            sheet.properties.SetMatrix(PMat.PP_CAMERA_TO_WORLD_MATRIX, context.camera.cameraToWorldMatrix);
            sheet.properties.SetFloat(PMat.PP_INTENSITY, settings.intensity);

            context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
        }
 private void ParamSwitch(PropertySheet mat, bool paramValue, string paramName)
 {
     if (paramValue)
     {
         mat.EnableKeyword(paramName);
     }
     else
     {
         mat.DisableKeyword(paramName);
     }
 }
Esempio n. 5
0
 protected override void SetKeyword(string keyword, bool enabled)
 {
     if (enabled)
     {
         _sheet.EnableKeyword(keyword);
     }
     else
     {
         _sheet.DisableKeyword(keyword);
     }
 }
Esempio n. 6
0
 public static void SetKeyword(this PropertySheet sheet, string keyword, bool value)
 {
     if (value)
     {
         sheet.EnableKeyword(keyword);
     }
     else
     {
         sheet.DisableKeyword(keyword);
     }
 }
        public override void Render(PostProcessRenderContext context)
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif
            if (ShadowMapCaster.shadowMapRenderTarget == null)
            {
                return;
            }

            if (_shader == null || context == null)
            {
                return;
            }

            PropertySheet propertySheet = context.propertySheets.Get(_shader);
            if (propertySheet == null)
            {
                return;
            }

            propertySheet.ClearKeywords();
            Matrix4x4 projectionMatrix = GL.GetGPUProjectionMatrix(context.camera.projectionMatrix, false);
            propertySheet.properties.SetMatrix(Shader.PropertyToID("_InverseProjectionMatrix"), projectionMatrix.inverse);
            propertySheet.properties.SetMatrix(Shader.PropertyToID("_InverseViewMatrix"), context.camera.cameraToWorldMatrix);
            propertySheet.properties.SetMatrix(Shader.PropertyToID("_InverseViewProjectionMatrix"), Matrix4x4.Inverse(projectionMatrix * context.camera.worldToCameraMatrix));

            if (settings.isBlur.value)
            {
                propertySheet.EnableKeyword("PCF_SHADOW");
            }
            else
            {
                propertySheet.DisableKeyword("PCF_SHADOW");
            }
            propertySheet.properties.SetMatrix("_CustomShadowMapLightSpaceMatrix", ShadowMapCaster.lightSpaceMatrix);
            propertySheet.properties.SetColor("_ShadowColor", settings.shadowColor.value);
            propertySheet.properties.SetFloat("_ShadowStrength", settings.strength.value);
            propertySheet.properties.SetTexture("_CustomShadowMap", ShadowMapCaster.shadowMapRenderTarget);
            propertySheet.properties.SetFloat("_ShadowBias", settings.shadowBias.value);
            propertySheet.properties.SetFloat("_ShadowPCFSpread", settings.shadowPcfSpread.value);
            propertySheet.properties.SetVector("_LightDir", ShadowMapCaster.lightDir);

            context.command.BlitFullscreenTriangle(context.source, context.destination, propertySheet, 0);
        }
        void UpdateFrequency(PropertySheet sheet)
        {
            if (settings.intervalType.value == IntervalType.Random)
            {
                randomFrequency = UnityEngine.Random.Range(0, settings.frequency);
            }

            if (settings.intervalType.value == IntervalType.Infinite)
            {
                sheet.EnableKeyword("USING_FREQUENCY_INFINITE");
            }
            else
            {
                sheet.DisableKeyword("USING_FREQUENCY_INFINITE");
            }
        }
        void UpdateFrequency(PropertySheet sheet)
        {
            if (settings.intervalType.value == IntervalType.Random)
            {
                if (frameCount > settings.Frequency)
                {
                    frameCount      = 0;
                    randomFrequency = UnityEngine.Random.Range(0, settings.Frequency);
                }
                frameCount++;
            }

            if (settings.intervalType.value == IntervalType.Infinite)
            {
                sheet.EnableKeyword("USING_Frequency_INFINITE");
            }
            else
            {
                sheet.DisableKeyword("USING_Frequency_INFINITE");
            }
        }
        public override void Render(PostProcessRenderContext context)
        {
            CommandBuffer cmd   = context.command;
            PropertySheet sheet = context.propertySheets.Get(shader);

            cmd.BeginSample(PROFILER_TAG);

            UpdateFrequency(sheet);

            if (settings.jitterDirection.value == Direction.Horizontal)
            {
                sheet.EnableKeyword("JITTER_DIRECTION_HORIZONTAL");
            }
            else
            {
                sheet.DisableKeyword("JITTER_DIRECTION_HORIZONTAL");
            }

            sheet.properties.SetVector(ShaderIDs.Params, new Vector4(settings.splittingNumber, settings.amount, settings.speed * 100f,
                                                                     settings.intervalType.value == IntervalType.Random ? randomFrequency : settings.frequency));

            cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, settings.splittingDirection.value == Direction.Horizontal ? 0 : 1);
            cmd.EndSample(PROFILER_TAG);
        }