How to render points manually

Moderator
Posts: 365
Joined: 2002.04
Post: #1
Does anyone know a sensible way of rendering points with a textured quad instead of using GL_POINTS? I particularly want the points to be at the correct Z depth and to diminish in size with perspective. Any code snippets or references would be appreciated.

In case you're wondering, I'm trying to work around what I think is a bug in the Mac OS 9 ATI drivers for the Radeon 8500. After calling glPointSize() with a number other than 1.0, textured quads which get clipped by the edge of the view get randomly distorted UV coordinates. This doesn't happen under Mac OS X and didn't happen on my old Rage 128 Pro.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #2
I guess you could render little quads which face the camera. If they are not anti-aliased, they should at least be of 1 pixel size when you render them. You would only have to make sure they face the right way, but could otherwise put them wherever you put your points.

- D.G
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #3
Quote:Originally posted by DoooG
I guess you could render little quads which face the camera.

Yes, that's what I have in mind - my problem is how to do it! Smile

How would I actually transform the quads so they appear head on? Do I actually rotate the quads so they face the camera, or do I somehow draw them in screen space?

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
Quote:Originally posted by NCarter
Yes, that's what I have in mind - my problem is how to do it! Smile

How would I actually transform the quads so they appear head on? Do I actually rotate the quads so they face the camera, or do I somehow draw them in screen space?


ehh...hehe...good one.

Well, I have all my graphic stuff in objects, and every frame I call a predraw function, which has the current (global) position of the camera, so I would simple recode the predraw function to rotate the quads' matrices accordingly.

Actually, you just need to do it once, and there may be a simpler way for you. You could (somehow) determine the normal vector of the screen in your world's coordinates, and then create one rotation matrix which rotates the quads to face in that direction. You would not need to change the quads themselves every time, just multiply the modelview matrix with this rotation matrix (for each single quad, but since this is done by opengl for you, it should not be a slowdown). Note that this only works if the modelview matrix is before set in a way that the quads are drawn around its center, since the rot. matrix rotates in local coordinates around the center of the local world (I hope you can understand).

I hope the above makes sense to you. I am basically sure about finding the normal of the screen and making the quads face that way, but maybe not so clear on the how.

- D.G
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
http://nate.scuzzy.net/gltut/

You want the billboarding tutorial.
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #6
Quote:Originally posted by OneSadCookie
You want the billboarding tutorial.

Thanks, that's exactly what I wanted. I'll try implementing that tonight.

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
I haven't seen the algorithm run, but I think you will get majorly distored quads on the edges of the screen with a high FOV. You should get no distortion, however, if the quads point the same direction (actually opposite) as the camera looks. If you use gluLookAt() to point your camera, you already know the screen normal.

-D.G
Quote this message in a reply
Moderator
Posts: 365
Joined: 2002.04
Post: #8
Done! It worked perfectly once I managed to get my axes the right way round!

DoooG, I didn't see any distortion using this technique. I think it's because OpenGL (like most computer graphic systems) uses one-point perspective, which causes anything which is aligned with the viewing plane to appear flat. I'm not sure, but I think your suggestion is effectively the same thing calculated in a different way (provided you align the quads' normals with the camera direction vector rather than pointing it straight at the camera). It looked like it would require more calculation, though, so I decided to go with the billboarding code.

Thanks guys!

Neil Carter
Nether - Mac games and comic art
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #9
Quote:Originally posted by NCarter
Done! It worked perfectly once I managed to get my axes the right way round!

DoooG, I didn't see any distortion using this technique. I think it's because OpenGL (like most computer graphic systems) uses one-point perspective, which causes anything which is aligned with the viewing plane to appear flat. I'm not sure, but I think your suggestion is effectively the same thing calculated in a different way (provided you align the quads' normals with the camera direction vector rather than pointing it straight at the camera). It looked like it would require more calculation, though, so I decided to go with the billboarding code.

Thanks guys!


What I thought was that only the quad in the center of view would be aligned to the viewing plane if it pointed to the camera, but one lets say 30∞ off would also point 30∞ off. Or is it that the billboarding code simply gets the direction the camera points, and not the actual vector from the camera to the quad? probably, now that I think about it... oh well, my bad, I should read more carefully.

- D.G
Quote this message in a reply
henryj
Unregistered
 
Post: #10
Nate Millers algorithm returns billboards that are aligned to the inverse of the camera view direction. This usually gives the nicest result.

Another method is to rotate the billboard to point at the camera. This looks weird in my opnion.

Fortunately the former is cheaper to do.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Two gluProject points? mikey 5 5,052 Jan 5, 2012 01:03 PM
Last Post: mikey
  surface rendering from data points mc1961 6 5,049 Nov 15, 2007 03:37 PM
Last Post: TomorrowPlusX
  ordering of control points in glMap1f(...data) WhatMeWorry 10 6,914 Mar 11, 2006 08:36 PM
Last Post: WhatMeWorry
  Manually antialiased primitives using texturing arekkusu 18 6,550 Jan 16, 2004 12:39 AM
Last Post: kelvin
  Cocoa and OpenGL entry points? napthali 5 3,983 Dec 31, 2003 06:22 PM
Last Post: AnotherJake