Beispiel #1
0
        protected virtual object EvalSampler_Declaration(ParseTree tree, params object[] paramlist)
        {
            var sampler = new SamplerStateInfo();

            sampler.Name = this.GetValue(tree, TokenType.Identifier, 0) as string;

            foreach (ParseNode node in Nodes)
            {
                node.Eval(tree, sampler);
            }

            var shaderInfo = paramlist[0] as ShaderInfo;

            shaderInfo.SamplerStates.Add(sampler.Name, sampler);

            return(null);
        }
Beispiel #2
0
        protected virtual object EvalSampler_Declaration(ParseTree tree, params object[] paramlist)
        {
            // if there is a comma or closing paren at the end this is a sampler as a parameter of a function
            if (this.GetValue(tree, TokenType.Semicolon, 0) == null)
            {
                return(null);
            }

            var sampler = new SamplerStateInfo();

            sampler.Name = this.GetValue(tree, TokenType.Identifier, 0) as string;

            foreach (ParseNode node in Nodes)
            {
                node.Eval(tree, sampler);
            }

            var shaderInfo = paramlist[0] as ShaderInfo;

            shaderInfo.SamplerStates.Add(sampler.Name, sampler);

            return(null);
        }
Beispiel #3
0
        protected virtual object EvalSampler_Declaration(ParseTree tree, params object[] paramlist)
        {
            if (this.GetValue(tree, TokenType.SamplerState, 0) == null)
            {
                return(null);
            }

            var sampler = new SamplerStateInfo();

            sampler.name  = this.GetValue(tree, TokenType.Identifier, 0) as string;
            sampler.state = new Microsoft.Xna.Framework.Graphics.SamplerState();

            foreach (ParseNode node in Nodes)
            {
                node.Eval(tree, sampler);
            }

            // Figure out what kind of filter to set based on each individual min, mag, and mip filter
            if (sampler.MinFilter == TextureFilterType.Anisotropic)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.Anisotropic;
            }
            else if (sampler.MinFilter == TextureFilterType.Linear && sampler.MagFilter == TextureFilterType.Linear && sampler.MipFilter == TextureFilterType.Linear)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.Linear;
            }
            else if (sampler.MinFilter == TextureFilterType.Linear && sampler.MagFilter == TextureFilterType.Linear && sampler.MipFilter == TextureFilterType.Point)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.LinearMipPoint;
            }
            else if (sampler.MinFilter == TextureFilterType.Linear && sampler.MagFilter == TextureFilterType.Point && sampler.MipFilter == TextureFilterType.Linear)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinLinearMagPointMipLinear;
            }
            else if (sampler.MinFilter == TextureFilterType.Linear && sampler.MagFilter == TextureFilterType.Point && sampler.MipFilter == TextureFilterType.Point)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinLinearMagPointMipPoint;
            }
            else if (sampler.MinFilter == TextureFilterType.Point && sampler.MagFilter == TextureFilterType.Linear && sampler.MipFilter == TextureFilterType.Linear)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinPointMagLinearMipLinear;
            }
            else if (sampler.MinFilter == TextureFilterType.Point && sampler.MagFilter == TextureFilterType.Linear && sampler.MipFilter == TextureFilterType.Point)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.MinPointMagLinearMipPoint;
            }
            else if (sampler.MinFilter == TextureFilterType.Point && sampler.MagFilter == TextureFilterType.Point && sampler.MipFilter == TextureFilterType.Point)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.Point;
            }
            else if (sampler.MinFilter == TextureFilterType.Point && sampler.MagFilter == TextureFilterType.Point && sampler.MipFilter == TextureFilterType.Linear)
            {
                sampler.state.Filter = Microsoft.Xna.Framework.Graphics.TextureFilter.PointMipLinear;
            }

            var shaderInfo = paramlist[0] as ShaderInfo;

            shaderInfo.SamplerStates.Add(sampler.name, sampler);

            return(null);
        }