Rendering the scene yourself

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
kevinsbro
Posts: 51
Joined: Fri Nov 05, 2010 8:18 pm

Rendering the scene yourself

Post by kevinsbro »

So in trying to make my own draw call for the scene, but I'm running into problems. When I look at the source for the drawAll function in the sceneManager I dont get where the culling comes in. I really dont mind doing my own culling though.

Also, I read that its faster for the video driver to draw objects with the same materials together so the shader data doesn't keep getting changed in between object renders, but does anyone know how to implement this? I know the driver material switch(driver->setMaterial) happens in the actual render call in meshSceneNodes but is there something special you have to do when setting the driver material to make sure you dont waste time by resetting the material everytime? Or does the setMaterial function check first before changing the data in the gpu shader?

And does anyone know exactly when the onSetConstants function for shaders gets called? I thought it was supposed to be every time the material was set to the video driver but I feel its being called more that once per frame.

And is there anything else I need to keep in mind?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Rendering the scene yourself

Post by CuteAlien »

Culling happens in CSceneManager::isCulled. You can set the culling-type of your node with ISceneNode::setAutomaticCulling. You have to make sure the bounding-boxes of your node are correct.

The drivers care about not switching the material state unless materials are different, see for example COpenGLDriver::setRenderStates3DMode().

I don't know about shaders.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
kevinsbro
Posts: 51
Joined: Fri Nov 05, 2010 8:18 pm

Re: Rendering the scene yourself

Post by kevinsbro »

Thank you for the info. It really helps me out.

In case anyone is just curious, I've run a few tests in my program and have figured that the onSetConstants function gets called every time the material is "set" even if the driver is already set to that material. It still takes place even if there is no actual switch of materials.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Rendering the scene yourself

Post by mongoose7 »

It may be to set uniforms per mesh/meshbuffer.
Post Reply