Jump to content
  • Advertisement
Sign in to follow this  
McZ

OpenGL how to process the render queue?

This topic is 5172 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I would like to know different ways of how I can process the render queue. I would like to know how I should request a mirror texture, shadow rendering etc. how to set different rendering states I have a generic interface for my rendersystem so I can easy write different plugins for OpenGL or Direct3D. so far I do like something this, not exactly but basicly.. I don't do anything about the materials yet I have only one color and no lights for all objects so far. Render(cCamera *camera) { Rendercore->Begin(); //will clear screen and reset the matrices Rendercore->SetCamera( camera ); for( o = each object in queue ) { Rendercore->PushMatrix(); Rendercore->MultiplyMatrix( o->getmatrix() ); Rendercore->Draw( o ); Rendercore->PopMatrix(); } Rendercore->End(); // flip the buffer etc. } I have been planning to create a shader based system for rendering, altough it would be more dynamic and try to build a list of shaders depending on my material-script and not have a pre-defined shader/effect dependency list. I will have one shader to turn on/off lights, one to set the color(or material color if lights is on) one to set bind texture(s) e.g. I have this shaders in a list: LightShader ColorShader TextureShader if I should display a simple lit object the colorshader and the lightshader would be choosed and put into a list for that object, if the object isn't and has a texture it will only choose the TextureShader. to choose the correct shader I have a bit-field that describes the material so the engine can ask the shader if it can display a part of that bit-field. then before each object I disable shaders that has nothing to do with the new object, and leave the one I can reuse still enabled and then I enable the shaders that I need wich is still disabled. after that I pass in the object to the shader and it will do the magic of building the material. the problem is that I can't figure out how to put in a request for a reflection texture in there somewhere. [Edited by - McZ on August 19, 2004 2:34:50 AM]

Share this post


Link to post
Share on other sites
Advertisement
One approach would be to let the renderer keep a separate list of geometry that uses "dependent" shaders, such as reflective shaders. When such geometry is queued, it goes to that list rather than the main list. When rendering, process this list first. In my engine, steps such as rendering a reflection texture are partly the responsibility of a particular material, so the renderer calls something like mesh->material->preProcess(). That method in turn can do some setup (e.g. preparing an alternate camera), then call back to the renderer - but at that point, the call to the renderer specifies that it should only draw "non-dependent" geometry (only the main list). This way, anything that has not yet had its reflection texture prepared (including the current mesh) does not get drawn yet while rendering this texture. However, after each dependent material has been preprocessed, that material can be flagged as "valid" for the remainder of the frame, and geometry that uses it can be promoted to the main render list. It's a fairly simple scheme, and so will miss some recursive reflections - but for the kinds of scenes I have so far, that's an acceptable compromise.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!