Esempio n. 1
0
    void LoadGlobalUniforms(OpenGL gl, uint shaderProgram)
    {
        int KaUniformLocation = gl.GetUniformLocation(shaderProgram, "Ka");
        int KdUniformLocation = gl.GetUniformLocation(shaderProgram, "Kd");
        int KsUniformLocation = gl.GetUniformLocation(shaderProgram, "Ks");
        int IaUniformLocation = gl.GetUniformLocation(shaderProgram, "Ia");
        int IlUniformLocation = gl.GetUniformLocation(shaderProgram, "Il");
        int IpUniformLocation = gl.GetUniformLocation(shaderProgram, "Ip");
        int KUniformLocation  = gl.GetUniformLocation(shaderProgram, "K");

        gl.Uniform3(KaUniformLocation, 1, Ka.ToFloatArray());
        gl.Uniform3(KdUniformLocation, 1, Kd.ToFloatArray());
        gl.Uniform3(KsUniformLocation, 1, Ks.ToFloatArray());
        gl.Uniform3(IaUniformLocation, 1, Ia.ToFloatArray());
        gl.Uniform3(IlUniformLocation, 1, Il.ToFloatArray());
        gl.Uniform1(IpUniformLocation, (float)Ip);
        gl.Uniform1(KUniformLocation, (float)K);

        int CameraPositionUniformLocation = gl.GetUniformLocation(shaderProgram, "CameraPosition");
        int LightPositionUniformLocation  = gl.GetUniformLocation(shaderProgram, "LightPosition");

        gl.Uniform1(CameraPositionUniformLocation, (float)CameraPosition);
        gl.Uniform3(LightPositionUniformLocation, 1, LightPosition.ToFloatArray());

        int objectColorUniformLocation = gl.GetUniformLocation(shaderProgram, "objectColor");

        gl.Uniform3(objectColorUniformLocation, 1, ObjectColor.ToFloatArray());
    }
Esempio n. 2
0
    void LoadGlobalUniforms(OpenGL gl, uint shaderProgram)
    {
        int KaUniformLocation = gl.GetUniformLocation(shaderProgram, "Ka");
        int KdUniformLocation = gl.GetUniformLocation(shaderProgram, "Kd");
        int KsUniformLocation = gl.GetUniformLocation(shaderProgram, "Ks");
        int IaUniformLocation = gl.GetUniformLocation(shaderProgram, "Ia");
        int IlUniformLocation = gl.GetUniformLocation(shaderProgram, "Il");
        int IpUniformLocation = gl.GetUniformLocation(shaderProgram, "Ip");
        int KUniformLocation  = gl.GetUniformLocation(shaderProgram, "K");

        gl.Uniform3(KaUniformLocation, 1, Ka.ToFloatArray());
        gl.Uniform3(KdUniformLocation, 1, Kd.ToFloatArray());
        gl.Uniform3(KsUniformLocation, 1, Ks.ToFloatArray());
        gl.Uniform3(IaUniformLocation, 1, Ia.ToFloatArray());
        gl.Uniform3(IlUniformLocation, 1, Il.ToFloatArray());
        gl.Uniform1(IpUniformLocation, (float)Ip);
        gl.Uniform1(KUniformLocation, (float)K);


        int MagicCoefUniformLocation  = gl.GetUniformLocation(shaderProgram, "magicCoef");
        int DistToFragUniformLocation = gl.GetUniformLocation(shaderProgram, "distToFrag");

        gl.Uniform1(MagicCoefUniformLocation, MagicCoef);

        if (EffectMode == Mode.FRAG)
        {
            gl.Uniform1(DistToFragUniformLocation, 1);
        }
        else
        {
            gl.Uniform1(DistToFragUniformLocation, 0);
        }

        int CameraPositionUniformLocation     = gl.GetUniformLocation(shaderProgram, "CameraPosition");
        int LightPositionUniformLocation      = gl.GetUniformLocation(shaderProgram, "LightPosition");
        int magicPointPositionUniformLocation = gl.GetUniformLocation(shaderProgram, "magicPointPosition");

        gl.Uniform1(CameraPositionUniformLocation, (float)CameraPosition);
        gl.Uniform3(LightPositionUniformLocation, 1, LightPosition.ToFloatArray());
        gl.Uniform3(magicPointPositionUniformLocation, 1, magicPointPosition.ToFloatArray());


        int objectColorUniformLocation = gl.GetUniformLocation(shaderProgram, "objectColor");

        gl.Uniform3(objectColorUniformLocation, 1, ObjectColor.ToFloatArray());
    }