src/opengl/util/radial_brush.glsl
author Eckhart Koeppen <eckhart.koppen@nokia.com>
Wed, 21 Apr 2010 12:15:23 +0300
branchRCL_3
changeset 12 cc75c76972ee
parent 0 1918ee327afb
permissions -rw-r--r--
a69086a7359b3de9db0823ce58d9aab8b5c369be

uniform sampler1D palette;
uniform vec2 fmp;
uniform float fmp2_m_radius2;
uniform vec3 inv_matrix_m0;
uniform vec3 inv_matrix_m1;
uniform vec3 inv_matrix_m2;

vec4 brush()
{
    mat3 mat;

    mat[0] = inv_matrix_m0;
    mat[1] = inv_matrix_m1;
    mat[2] = inv_matrix_m2;

    vec3 hcoords = mat * vec3(gl_FragCoord.xy, 1);
    vec2 A = hcoords.xy / hcoords.z;
    vec2 B = fmp;

    float a = fmp2_m_radius2;
    float b = 2.0*dot(A, B);
    float c = -dot(A, A);

    float val = (-b + sqrt(b*b - 4.0*a*c)) / (2.0*a);

    return texture1D(palette, val);
}