PDA

View Full Version : Problem with GL_POINT_DISTANCE_ATTENUATION



bobGL
08-13-2008, 04:19 AM
I have the following code:


float quadratic[] = { 1.0f, 0.01f, 0.0f };
glPointParameterfv( GL_POINT_DISTANCE_ATTENUATION, quadratic );
glPointParameterf( GL_POINT_FADE_THRESHOLD_SIZE, 60.0f );
glPointParameterf( GL_POINT_SIZE_MIN, 1.0f );
glPointParameterf( GL_POINT_SIZE_MAX, 15.0f );


glEnable(GL_POINT_SPRITE_OES);
glTexEnvi(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);
glPointSize( 15.0f );


Whatever I go near or far the point doesn't seems to change the way I want... In any case it never reach 15.0f.... What Im doing wrong here? I am missing something?


Tks in advance!

bobGL
08-14-2008, 01:22 AM
I manage to found the following obscure code:

float att[] = { 0.0f, 0.0f, 0.0f };


float H = 320;
double h = 2.0 / camera->mat_projection[5];
double D0 = sqrt(2.0)*H/h;
double k = 1.0/(1.0 + 2.0 * (1/camera->mat_projection[5])*(1/camera->mat_projection[5]));
att[1] = (float)(1.0/(D0*D0)*k);

glPointParameterfv( GL_POINT_DISTANCE_ATTENUATION, att );

But still the point sprite seems to grow when moving backward and shrink when moving forward... I tried to inverse the value but the result is even worst...

Any clue? someone? anyone?


ps: My Up vector is Z so the forward vector should be Y so att[1] right?