tags:

views:

718

answers:

3
+6  A: 

Is it a possibility you cast those rays before you draw the sphere?

Then if Z-buffer is enabled, the sphere's fragments simply won't be rendered, as those parts of rays are closer. When you are drawing something semi-transparent (using blending), you should watch the order you draw things carefully.

In fact I think you cannot use Z-buffer in any sensible way together with ray-tracing process. You'll have to track Z-order manually. While we are at it OpenGL might not be the best API to visualize ray-tracing process. (It will do so possibly much slower than pure software ray-tracer)

EFraim
Well I'll be... just changing the order of my drawing code is all it took; I had no idea that could effect things so much!! Thank you sir! You are a gentleman and a scholar.
puddlesofjoy
Just to clear up my intent for the curious. The actual ray tracing is fully independent of the OpenGL drawing. I have just thrown in a 3d perspective view to help me debug while I get my ray tracer working. It just shows the rays and a copy of the raytraced image textured onto a quad in front of the raytracer eye point.
puddlesofjoy
@puddlesofjoy: any chance you could edit the question and add the result after this fix? It might be instructive for people to see what your intended result looked like. Not a biggie - just a suggestion. Glad this worked out!
Argalatyr
+2  A: 
  1. You dont need the glAlphaFunc, disable it.
  2. Light rays should be blended by adding to the buffer: glBlendFunc(GL_ONE, GL_ONE) (for premultiplied alpha, which you chose.
  3. Turn off depth buffer writing (not testing) when rendering the rays: glDepthMask(GL_FALSE)
  4. Render the rays last.
Nikolai Ruhe
A: 

AlphaTest is only for discarding fragments - not for blending them. Check the spec By using it, you are telling OpenGL that you want it to throw away the pixels instead of drawing them, so you won't can any transparent blending. The most common blending function is glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); You can also check out the OpenGL Transparency FAQ.

wrosecrans