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:

Anonymous Anonymous said...

And you just found out that the code tag doesn't work here. ;)

I know it's hard, but keep on writing.

14 February 2009 at 16:06 
Blogger DiogoNeves said...

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

23 May 2011 at 21:57 

Post a Comment

<< Home


xrl://

Previous Post

Bike crash, oh bike crash.
shading some simplicity
I forgot to delete this...
I'm green

Archives

October 2007
January 2009
February 2009
March 2009
April 2009
May 2009