Jump to content
  • Advertisement
Sign in to follow this  
Wavesonics

OpenGL OpenGL Drawing Lines and Points at perspective corrected sizes

This topic is 3065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!