Пример #1
0
        public float[] GenerateLUTImage(uint width, uint height)
        {
            float ratio = 1.0f / (width - 1);
            int   index = 0;

            float[] data = new float[width * height];

            for (int h = 0; h < height; h++)
            {
                for (int w = 0; w < width; w++)
                {
                    data[index++] = CurveHelper.Interpolate(LutTable[h].Intensity, w * ratio);
                }
            }
            return(data);
        }
        static void UpdateUniforms(ShaderProgram shader)
        {
            var lightingEngine = LightingEngine.LightSettings;

            var colorCorrection = lightingEngine.Resources.ColorCorrectionFiles.FirstOrDefault().Value;

            shader.SetFloat("uGamma", colorCorrection.Gamma);
            shader.SetFloat("uBrightness", colorCorrection.Brightness);
            shader.SetFloat("uSaturation", colorCorrection.Saturation);
            shader.SetFloat("uHue", colorCorrection.Hue);
            shader.SetVector4("uToycamLevel1", colorCorrection.ToyCamLevel1.ToVector4());
            shader.SetVector4("uToycamLevel2", colorCorrection.ToyCamLevel2.ToVector4());

            var curves = colorCorrection.Level;

            if (curves != null)
            {
                float numValues = 256;

                float amount = 1.0f / (numValues - 1f);
                float time   = 0;

                //Level curve
                for (int j = 0; j < numValues; j++)
                {
                    float x = CurveHelper.Interpolate(curves[0], time);
                    float y = CurveHelper.Interpolate(curves[1], time);
                    float z = CurveHelper.Interpolate(curves[2], time);
                    float w = CurveHelper.Interpolate(curves[3], time);

                    Vector4 curveValues = new Vector4(x, y, z, w);
                    GL.Uniform4(GL.GetUniformLocation(shader.program, $"uCurve0[{j}]"), curveValues);
                    GL.Uniform4(GL.GetUniformLocation(shader.program, $"uCurve1[{j}]"), curveValues);

                    time += amount;
                }
            }
        }