I need a little help to get me pointed in the right direction. I apologize if this is a common question… I haven’t been able to find answers by searching these forums or the web. I suspect this is because I don’t know exactly what to search for. I am attempting to enhance an OpenGL application that I did not originally write, and I’m far from an OpenGL expert.
I have a number of objects in my scene. Some objects have parts that are translucent, handled by manual back-to-front sorting and GL_BLEND/glBlendFunc()… there is no shader support in this app. Each object is contained in it’s own display list.
At run time, I want to control the translucency of entire objects (as in a ghost car). The degree of an object’s translucency is dynamic, and may change from one frame to the next.
What I would like to do is to leave as much of the existing code in place, but somehow tell OpenGL “draw the entire next object with 0.50 alpha.” I would prefer to use the simplest and most compatible method to do this (some customers that use this software have VERY old hardware).
Here are some specific questions I have:
- Is there a way to apply translucency to a display list?
- If shaders are required, can this be done w/ a vertex shader (modifying each vert’s alpha), or is a pixel shader required?
- Can a pixel shader directly blend into the frame buffer? Something like: gl_FragColor = 0.5 * gl_FragColor + 0.5 * newColor; (I know that gl_FragColor is read-only, but this expresses what I would like to do).
- If I must use shaders, can I leave the existing fixed-pipeline code and just use the shader when I draw the dynamically-translucent objects, or do I need to re-write my code to use shaders for all drawing?