Jump to content

  • Log In with Google      Sign In   
  • Create Account


Weird point sprite perspective


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 ic0de   Members   -  Reputation: 804

Like
0Likes
Like

Posted 20 September 2012 - 06:08 PM

So I have this problem where my point sprites are not becoming smaller as the get farther from the camera but rather larger. I tried GL_POINT_DISTANCE_ATTENUATION but it didn't seem to have any affect. I also wrote a shader to scale the point sprites based on there distance:

gl_PointSize = scr_h / distance(-(gl_ModelViewMatrix * gl_Vertex), gl_Vertex);

This works but doesn't stop the sprites from getting bigger, what happens is that the sprite gets smaller with distance but only starting at a certain point before that the are growing forming a sort of "bulge" in the middle of a row of sprites. Any idea where this scaling upward is coming from, is there something that I can disable? I certainly didn't enable anything except this:

glEnable(GL_POINT_SPRITE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);

you know you program too much when you start ending sentences with semicolons;


Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 6956

Like
0Likes
Like

Posted 20 September 2012 - 11:21 PM

gl_PointSize = scr_h / distance(-(gl_ModelViewMatrix * gl_Vertex), gl_Vertex);

What are you doing here ? You take the distance between a point in object space and camera space, what is your object space for point sprites ? When you have a transformed point in camera space, the camera position is (0,0,0), therefore you just need either this for linear depth

// assumption: -z points into the screen
gl_PointSize = scr_h / -(gl_ModelViewMatrix * gl_Vertex).z;

or this for radial depth
vec3 pointInCS = (gl_ModelViewMatrix * gl_Vertex);
gl_PointSize = scr_h / sqrt(dot(pointInCS,pointInCS));


#3 ic0de   Members   -  Reputation: 804

Like
0Likes
Like

Posted 21 September 2012 - 02:03 PM


gl_PointSize = scr_h / distance(-(gl_ModelViewMatrix * gl_Vertex), gl_Vertex);

What are you doing here ? You take the distance between a point in object space and camera space, what is your object space for point sprites ? When you have a transformed point in camera space, the camera position is (0,0,0).


True, I modified my code based on your suggestion for radial depth but the problem seems to be coming from somewhere outside the shader. Is there a way I can make sure that gl_PointSize is only affected by the shader and nothing else?

Edited by ic0de, 21 September 2012 - 02:03 PM.

you know you program too much when you start ending sentences with semicolons;


#4 ic0de   Members   -  Reputation: 804

Like
0Likes
Like

Posted 24 September 2012 - 02:42 PM

Issue seems to be with the NVIDIA driver, I ported the same game from windows to Linux and the problem just went away, no code changes all cross platform libs. I was wondering if anyone knew any workarounds so that the windows one can work?

you know you program too much when you start ending sentences with semicolons;


#5 Ashaman73   Crossbones+   -  Reputation: 6956

Like
0Likes
Like

Posted 25 September 2012 - 07:13 AM

I was wondering if anyone knew any workarounds so that the windows one can work?

Don't use point sprites Posted Image To be honest, point sprites in OGL have a long history of issues, either on ATI or on NVidia videocards. I would use geometry shaders instead and quads as fallback for older videocards.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS