Beispiel #1
0
        public unsafe void SetUniform3fv(int location, int count, bool transpose, float[] value)
        {
            mat3 matrix;

            if (transpose)
            {
                matrix = new mat3(
                    new vec3(value[0], value[3], value[6]),
                    new vec3(value[1], value[4], value[7]),
                    new vec3(value[2], value[5], value[8])
                    );
            }
            else
            {
                matrix = new mat3(
                    new vec3(value[0], value[1], value[2]),
                    new vec3(value[3], value[4], value[5]),
                    new vec3(value[6], value[7], value[8])
                    );
            }

            if (count == 1)
            {
                this.SetUniform(location, matrix);
            }
            else
            {
                var v = new mat3[count];
                for (int i = 0; i < count; i++)
                {
                    v[i] = matrix;
                }
                this.SetUniform(location, v);
            }
        }
Beispiel #2
0
        private static void LinearInterpolationTriangle(vec3 pixel, vec3 fragCoord0, vec3 fragCoord1, vec3 fragCoord2, out float p0, out float p1, out float p2)
        {
            var  matrix = new mat3(fragCoord0, fragCoord1, fragCoord2);
            vec3 result = glm.inverse(matrix) * pixel;

            // note: "sum" is not needed.
            //float sum = result.x + result.y + result.z;
            //p0 = result.x / sum; p1 = result.y / sum; p2 = result.z / sum;
            // note: so, just need to assign values to p0, p1, p2.
            p0 = result.x; p1 = result.y; p2 = result.z;
        }