Exemple #1
0
 public void CopyFrom(IUniformValue source)
 {
     foreach (var f in array)
     {
         f.CopyFrom(source);
     }
 }                                                                                        // also IUniformValue
Exemple #2
0
        public void Set(IUniformValue source)
        {
            UniformValueInt1 other = source as UniformValueInt1;

            if (other == null)
            {
                return;
            }
            X = other.X;
        }
Exemple #3
0
        public bool GetUniformValue(UniformUsage usage, out IUniformValue value)
        {
            value = null;
            if (usage == UniformUsage.World)
            {
                value = UniformValue.Create(World);
            }
            else if (usage == UniformUsage.WorldView)
            {
                if (_camera != null)
                {
                    value = UniformValue.Create(Matrix4.Mult(World, _camera.View));
                }
                else
                {
                    value = UniformValue.Create(World);
                }
            }
            else if (usage == UniformUsage.WorldViewProj)
            {
                if (_camera != null)
                {
                    value = UniformValue.Create(Matrix4.Mult(World, _viewProjection));
                }
                else
                {
                    value = UniformValue.Create(World);
                }
            }
            else if (usage == UniformUsage.ViewPort)
            {
                if (_camera != null)
                {
                    value = UniformValue.Create(_camera.Viewport.GetAsVector4());
                }
                else
                {
                    value = UniformValue.Create(new Vector4(0, 0, Width, Height));
                }
            }
            else if (usage == UniformUsage.NearFar)
            {
                if (_camera != null)
                {
                    value = UniformValue.Create(new Vector2(_camera.Near, _camera.Far));
                }
                else
                {
                    value = UniformValue.Create(new Vector2(1f, 100f));
                }
            }

            return(value != null);
        }
Exemple #4
0
        public void AddShaderUniform(string shader, string uniform, IUniformValue value)
        {
            Dictionary <string, IUniformValue> shaderDict;

            if (!ShaderUniforms.TryGetValue(shader, out shaderDict))
            {
                shaderDict             = new Dictionary <string, IUniformValue>();
                ShaderUniforms[shader] = shaderDict;
            }
            shaderDict[uniform] = value;
        }
Exemple #5
0
        public void Set(IUniformValue source)
        {
            UniformValueFloat2 other = source as UniformValueFloat2;

            if (other == null)
            {
                return;
            }
            X = other.X;
            Y = other.Y;
        }
Exemple #6
0
        public void Set(IUniformValue source)
        {
            UniformValueMatrix other = source as UniformValueMatrix;

            if (other == null)
            {
                return;
            }
            M         = other.M;
            transpose = other.transpose;
        }
Exemple #7
0
        public void Set(IUniformValue source)
        {
            UniformValueInt3 other = source as UniformValueInt3;

            if (other == null)
            {
                return;
            }
            X = other.X;
            Y = other.Y;
            Z = other.Z;
        }
Exemple #8
0
        public void Set(IUniformValue source)
        {
            UniformValueUint4 other = source as UniformValueUint4;

            if (other == null)
            {
                return;
            }
            X = other.X;
            Y = other.Y;
            Z = other.Z;
            W = other.W;
        }
Exemple #9
0
        void SetUniform(string name, IUniformValue uniformValue)
        {
            bool same = false;

            if (_uniformValues.ContainsKey(name))
            {
                same = _uniformValues[name].Equals(uniformValue);
                _uniformValues[name] = uniformValue;
            }
            else
            {
                _uniformValues.Add(name, uniformValue);
            }

            // Do not attempt to set uniform for invalid shaders
            if (!same && _valid)
            {
                uniformValue.Set(_handle, GetUniformLocation(name));
            }
        }
Exemple #10
0
        public void CopyFrom(IUniformValue src)
        {
            TextureRL other = (TextureRL)src;

            textureObject = other.textureObject;
        }
Exemple #11
0
 public bool Equals(IUniformValue other)
 {
     return(Equals((object)other));
 }