source: trunk/src/opengl/util/conical_brush.glsl@ 440

Last change on this file since 440 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 647 bytes
Line 
1// conical gradient shader
2#define M_PI 3.14159265358979323846
3uniform sampler1D palette;
4uniform float angle;
5uniform vec3 inv_matrix_m0;
6uniform vec3 inv_matrix_m1;
7uniform vec3 inv_matrix_m2;
8
9vec4 brush()
10{
11 mat3 mat;
12
13 mat[0] = inv_matrix_m0;
14 mat[1] = inv_matrix_m1;
15 mat[2] = inv_matrix_m2;
16
17 vec3 hcoords = mat * vec3(gl_FragCoord.xy, 1);
18 vec2 A = hcoords.xy / hcoords.z;
19
20/* float val = fmod((atan2(-A.y, A.x) + angle) / (2.0 * M_PI), 1); */
21 if (abs(A.y) == abs(A.x))
22 A.y += 0.002;
23 float t = (atan2(-A.y, A.x) + angle) / (2.0 * M_PI);
24 float val = t - floor(t);
25 return texture1D(palette, val);
26}
27
Note: See TracBrowser for help on using the repository browser.