A few issues with InstanceManager

Problems building or running the engine, queries about how to use features etc.
AusSkiller
Gremlin
Posts: 158
Joined: Wed Nov 28, 2012 1:38 am
x 13

A few issues with InstanceManager

Post by AusSkiller »

I finally finished setting up deferred rendering for my game, originally I had been using a geometry buffer I wrote to render all my point light spheres, but obviously that meant copying a lot of vertex data around that really didn't need to change and wasting a heap of CPU cycles, so I switched over to using the InstanceManager (using HWInstancingBasic) and just setting some per instance data for each light instead which works quite well :). However I came up against a few unexpected problems when doing this and just wanted to find out if there is anything that can be done about them:


First is setting the render order. I have a full screen quad with a shader that does the lighting for ambient and a directional light that, and it also sets up the depth buffer for rendering things that aren't rendered to the GBuffer (particles and the like) and so that the depth testing on other lights works correctly. That makes it very important that everything else gets rendered after the full screen quad, including the point lights. However I found that setting the render queue ID for the instances does not work per instance, only per batch, which does make sense, but I also found there's no way to just tell the InstanceManager to set all batches to a render queue ID, instead I have to iterate through through the map batches then the actual batches and set the render queue there, every frame, in case a new batch was created, which seems really wasteful when I just want them all to be initialized with the same render queue ID. Is there a better way to do it that I missed or is this the only way?


Second is screen based object culling. I noticed that it seems to cull the instances based on a bounding box, but obviously my lights vary in size, originally I scaled them in the shader since I was already passing the radius to it, but the lights would disappear whenever the center of them left the view frustum :(. I ended up working around it by setting the scale on the instances which seems to scale the bounding box too (which works really much better for point lights anyway), but I plan to have some beam lights that will vary from very skinny and long to fat and short and scaling is just not going to work properly for that. So is there some way to change the bounding box per instance or perhaps turn off/disable the culling so they wont disappear?


Thanks.