Subversion Repositories AndroidProjects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1452 chris 1
#version 120
2
// www.OpenTK.net GLSL Julia Set (c) 2008 Christoph Brandtner
3
 
4
uniform sampler1D COLORTABLE;
5
uniform float CETX;
6
uniform float CETY;
7
uniform float SCALINGX;
8
uniform float SCALINGY;
9
uniform float OFFSETX;
10
uniform float OFFSETY;
11
 
12
const int MAXIterations = 32; // *must* be > 0
13
 
14
void main(void)
15
{
16
  float XPos = gl_FragCoord.x / SCALINGX - OFFSETX;
17
  float YPos = gl_FragCoord.y / SCALINGY - OFFSETY;
18
  float XQuad = pow( XPos, 2.0 );
19
  float YQuad = pow( YPos, 2.0 );
20
  int TableIndex = -1;
21
  int LoopCount = 0;
22
  while ( LoopCount <= MAXIterations )
23
    {
24
      YPos = 2.0 * XPos * YPos + CETY;
25
      XPos = XQuad - YQuad + CETX;
26
      XQuad = pow( XPos, 2.0 );
27
      YQuad = pow( YPos, 2.0 );
28
      TableIndex++;
29
      if ( (XQuad + YQuad) > 4.0 )
30
      {
31
         if (TableIndex == 0)
32
           discard;
33
         LoopCount = MAXIterations;
34
      }
35
      LoopCount++;
36
    }
37
  float FinalTableIndex = float( TableIndex ) / float( MAXIterations );
38
 
39
  gl_FragColor = texture1D( COLORTABLE, FinalTableIndex ); // lookup texture for output
40
  // gl_FragColor.rgb = vec3( FinalTableIndex ); // Debug: output greyscale
41
}