26 January 2009
GLSL and Point Sprites
I survived last week. Good.
I spent the last 3 or 4 days trying to replace a few spheres with a few point sprites hoping they would be faster. I'm not getting the feeling they're faster than using billboards, or even faster than drawing a few spheres. Even on my old machine. Anyway I finally got some point sprites that behave like real spheres on a 3D world. It's strange how hard it is to find any decent information about using gl_FragDepth, or Point Sprites with GLSL.
After doing a few drawings on my new white board I concluded that I need better pens. I also found out that
[code]gl_PointSize = radius * screen_height / (tan(fov/2) * distance);[/code]
is the correct size of a sphere. Start by drawing a frustrum triangle, split it in half and you're almost there. You can probably guess what the variables mean. After that it was a lot harder to find out that after z is normalized to [-1, 1] it still has to fit in the depth buffer that goes from [0, 1]. The OpenGL specificiation is not a very good reference.
Next step?
Labels: depth, glsl, opengl, point sprites
xernobyl @ 22:20
2 Comments:
And you just found out that the code tag doesn't work here. ;)
I know it's hard, but keep on writing.
I was looking at this as well... did you tried profiling and get some hard data? I thought they were faster as well...
Well, I guess billboards with some kind of hardware instances will do the job hehe
Post a Comment
<< Home