OpenGL Drawing Lines and Points at perspective corrected sizes
So OpenGL lines and points seem to always render the same size on screen regardless of how far from the viewer they are in the world. Is there a way to make them properly perspective corrected for distance?
Not with glLineWidth. The best way to do it is to just render the lines as camera aligned quads. That way, you get perspective corrected distance for the line width, it's not that much slower, and you can add geometry like line caps to fill the gaps caused by lines with non-unit width.
I don't believe so. Found this bit on opengl.org:
Lines and points technically have no width so it doesn't really make sense to perspective correct them. If you want a perspective correct line with real thickness I think you need to just use a thin quad.
Quote:
In particular, the size of OpenGL points is not affected by perspective projections. To render more realistic looking small light sources it is necessary to change some combination of the size and brightness of the source as a function of distance from the eye.
Lines and points technically have no width so it doesn't really make sense to perspective correct them. If you want a perspective correct line with real thickness I think you need to just use a thin quad.
You can attenuate point size with distance using glPointParameter and passing the relevant flags.
Here's a link to the documentation:
http://www.opengl.org/sdk/docs/man/xhtml/glPointParameter.xml
I don't have my example code of it on my laptop but can dig it out on my desktop later if you need.
EDIT:
Here's another link with an example for guidance at the bottom:
http://www.opengl.org/resources/code/samples/mjktips/particles/index.html
Here's a link to the documentation:
http://www.opengl.org/sdk/docs/man/xhtml/glPointParameter.xml
I don't have my example code of it on my laptop but can dig it out on my desktop later if you need.
EDIT:
Here's another link with an example for guidance at the bottom:
http://www.opengl.org/resources/code/samples/mjktips/particles/index.html
Answer #1: "Billboard," as others have said.
Answer #2: Really you're trying to draw spheres and cylinders. These can be raytraced by a pixel shader. See e.g. this.
Answer #2: Really you're trying to draw spheres and cylinders. These can be raytraced by a pixel shader. See e.g. this.
Ah great thanks _Unicron_, this is what I was looking for, but I guess there is nothing like this for lines like the rest of the posters were saying huh.
Quote:Original post by _Unicron_I am fairly sure these only work with point sprites, not basic points.
You can attenuate point size with distance using glPointParameter and passing the relevant flags.
Here's a link to the documentation:
http://www.opengl.org/sdk/docs/man/xhtml/glPointParameter.xml
Quote:Original post by swiftcoderQuote:Original post by _Unicron_I am fairly sure these only work with point sprites, not basic points.
You can attenuate point size with distance using glPointParameter and passing the relevant flags.
Here's a link to the documentation:
http://www.opengl.org/sdk/docs/man/xhtml/glPointParameter.xml
No, the link to the example I posted is using plain points. I'm sure I wasn't using point sprites when I tried this a while ago.
Quote:Original post by _Unicron_Hmm, you are right. I never reallised that this extension was distinct from the point_sprite extension.
No, the link to the example I posted is using plain points. I'm sure I wasn't using point sprites when I tried this a while ago.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement