|
キャストの仕方が違う(ja)
// FragmentProgram
#extension GL_EXT_gpu_shader4: enable
varying vec4 p;
void main()
{
int MOD = 360;
float MODF = 360.0;
float DIVF = 64.0;
int n = 0;
float x0 = p.x/DIVF - 1.5;
float y0 = p.y/DIVF;
float x = x0;
float y = y0;
float x2 = x*x;
float y2 = y*y;
while( ( n<MOD*3 )&&( x2+y2 < 4.0 ) ) {
float xx = x2 - y2 + x0;
y = 2.0*x*y + y0;
x = xx;
n++;
x2 = x*x;
y2 = y*y;
}
// 色を出力
int nn = n % MOD;
switch( n/MOD ) {
case 0:
gl_FragColor = vec4( float(nn)/MODF, 0, 0, 0 );
break;
case 1:
gl_FragColor = vec4( 0, float(nn)/MODF, 0, 0 );
break;
case 2:
gl_FragColor = vec4( 0, 0, float(nn)/MODF, 0 );
break;
}
return;
}
// end.
|