OpenGL Drawing Lines and Points at perspective corrected sizes

Started by
7 comments, last by swiftcoder 14 years, 1 month ago
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?
==============================
A Developers Blog | Dark Rock Studios - My Site
Advertisement
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:

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.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game
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
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.
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.
==============================
A Developers Blog | Dark Rock Studios - My Site
Quote:Original post by _Unicron_
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 am fairly sure these only work with point sprites, not basic points.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
Quote:Original post by _Unicron_
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 am fairly sure these only work with point sprites, not basic points.


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_
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.
Hmm, you are right. I never reallised that this extension was distinct from the point_sprite extension.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement