Exemplo n.º 1
0
 public void Apply(int pass)
 {
     shaderParams.Set(amountKey, new Vector4(ChromaticAberration * Red, ChromaticAberration * Green, ChromaticAberration * Blue, BarrelPincushion));
     PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState);
     PlatformRenderer.SetShaderProgram(DistortionShaderProgram.GetInstance(Opaque));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 2
0
 public void Apply(int pass)
 {
     if (pass == 0)
     {
         if (shaderProgramPass1 == null)
         {
             shaderProgramPass1 = new ShaderProgram(
                 new Shader[] { new VertexShader(vs), new FragmentShader(fsPass1) },
                 ShaderPrograms.Attributes.GetLocations(), ShaderPrograms.GetSamplers());
         }
         PlatformRenderer.SetBlendState(Blending.LcdTextFirstPass.GetBlendState());
         PlatformRenderer.SetShaderProgram(shaderProgramPass1);
     }
     else
     {
         if (shaderProgramPass2 == null)
         {
             shaderProgramPass2 = new ShaderProgram(
                 new Shader[] { new VertexShader(vs), new FragmentShader(fsPass2) },
                 ShaderPrograms.Attributes.GetLocations(), ShaderPrograms.GetSamplers());
         }
         PlatformRenderer.SetBlendState(Blending.LcdTextSecondPass.GetBlendState());
         PlatformRenderer.SetShaderProgram(shaderProgramPass2);
     }
 }
Exemplo n.º 3
0
 public void Apply(int pass)
 {
     shaderParams.Set(texelStepKey, TexelStep);
     shaderParams.Set(amountKey, new Vector4(LumaTreshold, 0.25f / MulReduce, 1f / MinReduce, MaxSpan));
     PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState);
     PlatformRenderer.SetShaderProgram(FXAAShaderProgram.GetInstance(Opaque));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 4
0
 public void Apply(int pass)
 {
     shaderParams.Set(stepKey, Step);
     shaderParams.Set(sharpnessKey, new Vector3(Strength, Strength * 0.25f, Limit));
     PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState);
     PlatformRenderer.SetShaderProgram(SharpenShaderProgram.GetInstance(Opaque));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 5
0
 public void Apply(int pass)
 {
     shaderParams.Set(stepKey, Dir * Radius * Step);
     shaderParams.Set(alphaCorrectionKey, 1f / AlphaCorrection);
     PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState);
     PlatformRenderer.SetShaderProgram(BlurShaderProgram.GetInstance(BlurShaderId, Opaque));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 6
0
 public void Apply(int pass)
 {
     shaderParams.Set(brightThresholdKey, BrightThreshold);
     shaderParams.Set(inversedGammaCorrectionKey, InversedGammaCorrection);
     PlatformRenderer.SetBlendState(disabledBlendingState);
     PlatformRenderer.SetShaderProgram(BloomShaderProgram.GetInstance());
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 7
0
 public void Apply(int pass)
 {
     shaderParams.Set(hslKey, HSL);
     shaderParams.Set(brightnessKey, Brightness);
     shaderParams.Set(contrastKey, Contrast);
     PlatformRenderer.SetBlendState(!Opaque ? Blending.GetBlendState() : disabledBlendingState);
     PlatformRenderer.SetShaderProgram(ColorCorrectionShaderProgram.GetInstance(RequiredBrightnessContrastProcess, RequiredHSLProcess, Opaque));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 8
0
 public void Apply(int pass)
 {
     shaderParams.Set(angleKey, Angle);
     shaderParams.Set(uv1Key, UV1);
     shaderParams.Set(uv0Key, UV0);
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetShaderProgram(TwistShaderProgram.Instance);
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 9
0
 public void Apply(int pass)
 {
     shaderParams.Set(brightThresholdKey, BrightThreshold);
     shaderParams.Set(darkThresholdKey, DarkThreshold);
     shaderParams.Set(softLightKey, SoftLight);
     PlatformRenderer.SetBlendState(!Opaque ? Blending.Alpha.GetBlendState() : disabledBlendingState);
     PlatformRenderer.SetShaderProgram(NoiseShaderProgram.GetInstance(Opaque));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 10
0
 public void Apply(int pass)
 {
     shaderParams.Set(radiusKey, Radius);
     shaderParams.Set(brightnessKey, Brightness);
     shaderParams.Set(colorKey, Color);
     PlatformRenderer.SetTexture(1, MaskTexture);
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetShaderProgram(AlphaIntensityShaderProgram.Instance);
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 11
0
 public void Apply(int pass)
 {
     shaderParams.Set(brightnessKey, Brightness);
     shaderParams.Set(rangeKey, Range);
     shaderParams.Set(colorKey, Color);
     PlatformRenderer.SetTexture(1, MaskTexture);
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetShaderProgram(DissolveMaterialShaderProgram.Instance);
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 12
0
 public void Apply(int pass)
 {
     shaderParams.Set(radiusKey, Radius);
     shaderParams.Set(softnessKey, Softness);
     shaderParams.Set(uv1Key, UV1);
     shaderParams.Set(uvOffsetKey, UVOffset);
     shaderParams.Set(colorKey, Color.ToVector4());
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetShaderProgram(VignetteShaderProgram.GetInstance());
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 13
0
 public void Apply(int pass)
 {
     shaderParams.Set(angleKey, Angle);
     shaderParams.Set(uv1Key, UV1);
     shaderParams.Set(uv0Key, UV0);
     shaderParams.Set(pivotKey, Pivot);
     // coefficient 1.11104f for backward compatibility
     shaderParams.Set(radiusFactorKey, RadiusFactor * 1.11104f);
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetShaderProgram(TwistShaderProgram.Instance);
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 14
0
 public void Apply(int pass)
 {
     shaderParams.Set(phaseKey, Phase * Mathf.TwoPi);
     shaderParams.Set(frequencyKey, Frequency);
     shaderParams.Set(pivotKey, Pivot);
     shaderParams.Set(amplitudeKey, Amplitude);
     shaderParams.Set(uv0Key, UV0);
     shaderParams.Set(uv1Key, UV1);
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetShaderProgram(WaveShaderProgram.GetInstance(Type, IsClamped));
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 15
0
 public void Apply(int pass)
 {
     if (PassCount == 2 && pass == 0)
     {
         PlatformRenderer.SetBlendState(Blending.Alpha.GetBlendState(PremulAlpha));
     }
     else
     {
         PlatformRenderer.SetBlendState(Blending.GetBlendState(PremulAlpha));
     }
     PlatformRenderer.SetShaderParams(shaderParamsArray);
     PlatformRenderer.SetShaderProgram(ShaderProgram);
 }
Exemplo n.º 16
0
 public void Apply(int pass)
 {
     PlatformRenderer.SetTexture(Texture1, 0);
     PlatformRenderer.SetTexture(Texture2, 1);
     if (PassCount == 2 && pass == 0)
     {
         PlatformRenderer.SetBlending(Blending.Alpha, PremulAlpha);
     }
     else
     {
         PlatformRenderer.SetBlending(Blending, PremulAlpha);
     }
     PlatformRenderer.SetShaderProgram(ShaderProgram);
 }
Exemplo n.º 17
0
 public void Apply(int pass)
 {
     PlatformRenderer.SetTexture(Texture, 0);
     PlatformRenderer.SetTexture(null, 1);
     if (pass == 0)
     {
         PlatformRenderer.SetBlending(Blending.LcdTextFirstPass, false);
         PlatformRenderer.SetShaderProgram(shaderProgramPass1);
     }
     else
     {
         PlatformRenderer.SetBlending(Blending.LcdTextSecondPass, false);
         PlatformRenderer.SetShaderProgram(shaderProgramPass2);
     }
 }
Exemplo n.º 18
0
        public void Apply(int pass)
        {
            var texture = ShaderPrograms.ColorfulTextShaderProgram.GradientRampTexture;

            if (texture == null || texture.IsStubTexture)
            {
                var warningText = "GradientMap texture doesnt exist at './Data/Fonts/GradientMap.png' If you want to use it, create it and dont forget cooking rule file to disable texture atlas for it.";
#if DEBUG
                throw new Lime.Exception(warningText);
#else
                Console.WriteLine(warningText);
#endif
            }
            PlatformRenderer.SetBlendState(blendState);
            PlatformRenderer.SetTextureLegacy(1, ShaderPrograms.ColorfulTextShaderProgram.GradientRampTexture);
            PlatformRenderer.SetShaderProgram(ShaderPrograms.ColorfulTextShaderProgram.GetInstance());
            PlatformRenderer.SetShaderParams(shaderParamsArray);
        }
Exemplo n.º 19
0
 public void Apply(int pass)
 {
     PrepareShaderProgram();
     shaderParams.Set(shaderParamKeys.World, Renderer.World);
     shaderParams.Set(shaderParamKeys.WorldView, Renderer.WorldView);
     shaderParams.Set(shaderParamKeys.WorldViewProj, Renderer.WorldViewProjection);
     shaderParams.Set(shaderParamKeys.ColorFactor, Renderer.ColorFactor.ToVector4());
     shaderParams.Set(shaderParamKeys.DiffuseColor, DiffuseColor.ToVector4());
     shaderParams.Set(shaderParamKeys.FogColor, FogColor.ToVector4());
     shaderParams.Set(shaderParamKeys.FogStart, FogStart);
     shaderParams.Set(shaderParamKeys.FogEnd, FogEnd);
     shaderParams.Set(shaderParamKeys.FogDensity, FogDensity);
     if (skinEnabled)
     {
         shaderParams.Set(shaderParamKeys.Bones, boneTransforms, boneCount);
     }
     PlatformRenderer.SetBlendState(Blending.GetBlendState());
     PlatformRenderer.SetTextureLegacy(CommonMaterialProgram.DiffuseTextureStage, diffuseTexture);
     PlatformRenderer.SetShaderProgram(program);
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 20
0
        public void Render(Widget parentWidget)
        {
            Renderer.Flush();
            var animationTime = parentWidget.AnimationTime;
            // Find the morph targets to interpolate in between.
            MorphTarget target0, target1;

            if (MorphTargets.Count == 1)
            {
                target0 = target1 = MorphTargets[0];
            }
            else
            {
                while (true)
                {
                    target0 = MorphTargets[currentTarget];
                    target1 = MorphTargets[currentTarget + 1];
                    if (animationTime < target0.Timestamp)
                    {
                        if (currentTarget == 0)
                        {
                            break;
                        }
                        currentTarget--;
                    }
                    else if (animationTime <= target1.Timestamp)
                    {
                        break;
                    }
                    else if (currentTarget >= MorphTargets.Count - 2)
                    {
                        // We got across the rightmost target.
                        target0 = target1;
                        break;
                    }
                    else
                    {
                        currentTarget++;
                    }
                }
            }
            // Create the mesh if there is no any.
            if (target0.Mesh == null)
            {
                target0.Mesh = new Mesh {
                    VertexBuffers = new IVertexBuffer[] { UVBuffer, target0.PosColorBuffer, target1.PosColorBuffer },
                    Attributes    = new[] {
                        new[] { ShaderPrograms.Attributes.UV1 },
                        new[] { ShaderPrograms.Attributes.Pos1, ShaderPrograms.Attributes.Color1 },
                        new[] { ShaderPrograms.Attributes.Pos2, ShaderPrograms.Attributes.Color2 }
                    },
                    IndexBuffer = IndexBuffer
                };
            }
            // Calculate the interpolation koefficient.
            float t;

            if (animationTime <= target0.Timestamp)
            {
                t = 0;
            }
            else if (animationTime >= target1.Timestamp)
            {
                t = 1;
            }
            else
            {
                t = (float)((animationTime - target0.Timestamp) / (target1.Timestamp - target0.Timestamp));
            }
            // Render all of it.
            if (shaderProgram == null)
            {
                var options = ShaderOptions.VertexAnimation;
                shaderProgram      = ShaderPrograms.Instance.GetShaderProgram(ShaderId.Diffuse, 1, options);
                morphKoeffUid      = shaderProgram.GetUniformId("morphKoeff");
                globalColorUid     = shaderProgram.GetUniformId("globalColor");
                globalTransformUid = shaderProgram.GetUniformId("globalTransform");
            }
            PlatformRenderer.SetBlending(Blending.Alpha);
            PlatformRenderer.SetShaderProgram(shaderProgram);
            var globalColor = parentWidget.GlobalColor;

            shaderProgram.LoadFloat(morphKoeffUid, t);
            if (loadedGlobalColor.ABGR != globalColor.ABGR)
            {
                loadedGlobalColor = globalColor;
                var globalColorVec4 = (globalColor.ABGR == 0xFFFFFFFF) ?
                                      Vector4.One : new Vector4(
                    globalColor.R / 255f,
                    globalColor.G / 255f,
                    globalColor.B / 255f,
                    globalColor.A / 255f);
                shaderProgram.LoadVector4(globalColorUid, globalColorVec4);
            }
            shaderProgram.LoadMatrix(globalTransformUid, (Matrix44)parentWidget.LocalToWorldTransform);
            foreach (var sm in Batches)
            {
                PlatformRenderer.SetTexture(sm.Texture, 0);
                PlatformRenderer.DrawTriangles(target0.Mesh, sm.StartIndex, sm.IndexCount);
            }
        }
Exemplo n.º 21
0
 public void Apply(int pass)
 {
     PlatformRenderer.SetBlendState(blendState);
     PlatformRenderer.SetShaderProgram(YUVtoRGBProgram.GetInstance());
     PlatformRenderer.SetShaderParams(shaderParamsArray);
 }
Exemplo n.º 22
0
 public void Apply(int pass)
 {
     PlatformRenderer.SetBlendState(Blending.Alpha.GetBlendState());
     PlatformRenderer.SetShaderParams(shaderParamsArray);
     PlatformRenderer.SetShaderProgram(ShaderPrograms.DashedLineShaderProgram.GetInstance());
 }