Example #1
0
        public virtual void setDefaultshaderVariables(Matrix4 offset, Matrix4 my_offset, Camera c)
        {
            getDisplayManager().getGraphicsContext().SetTexture(0, this.getMaterial().getTexture());

            Matrix4 modelMatrix      = c.getViewMatrix();
            Matrix4 projectionMatrix = c.getProjectionMatrix();
            Vector4 color            = this.getMaterial().getColor().getAsVector();

            //Matrix's
            this.shaderProgram.SetUniformValue(0, ref modelMatrix);
            this.shaderProgram.SetUniformValue(1, ref projectionMatrix);
            this.shaderProgram.SetUniformValue(2, ref my_offset);

            //Material
            this.shaderProgram.SetUniformValue(3, ref color);

            //Externals
            this.shaderProgram.SetUniformValue(4, lightPositions.Length);
            this.shaderProgram.SetUniformValue(5, lightPositions, 0, 0, lightPositions.Length);
            this.shaderProgram.SetUniformValue(6, lightColors, 0, 0, lightColors.Length);
            this.shaderProgram.SetUniformValue(7, lightIntensities, 0, 0, lightIntensities.Length);

            //Ambient
            Vector3 ambientColor = getDisplayManager().getAmbientLight().getColor().getAsVector3();

            this.shaderProgram.SetUniformValue(8, ref ambientColor);
            this.shaderProgram.SetUniformValue(9, getDisplayManager().getAmbientLight().getIntensity());

            Vector3 skyColor = getDisplayManager().getClearColor().getAsVector3();

            this.shaderProgram.SetUniformValue(10, ref skyColor);

            this.getShaderProgram().SetUniformValue(11, this.getMaterial().getTexture() != null ? 1 : 0);
        }
Example #2
0
        public static void newFrame(Camera c)
        {
            List <Light> lights = getDisplayManager().getLights();

            lightPositions   = new Vector3[lights.Count];
            lightColors      = new Vector3[lights.Count];
            lightIntensities = new float[lights.Count];
            for (int i = 0; i < lights.Count; i++)
            {
                if (lights[i] == null)
                {
                    continue;
                }
                if (lights[i].getLocation() == null)
                {
                    continue;
                }
                lock (lights[i]) {
                    lightPositions[i]   = Matrix4.TransformPoint(c.getViewMatrix(), lights[i].getLocation().getAsVector());
                    lightColors[i]      = lights[i].getColor().getAsVector3();
                    lightIntensities[i] = lights[i].getIntensity();
                }
            }
        }