Batches for BSP+PVS engine

Started by
0 comments, last by duhroach 19 years, 3 months ago
Currently I am moving my engine from simple vertex arrays to vertex buffer objects. The idea is to get the engine to render in batches instead of rendering each surface as its encountered. I am not currently using materials, but eventually I want to move over to that. It seems pretty commonplace to setup batches by material by building render lists and rendering things at the end. Most examples seem to build the main vertex buffers during map load and then generate index buffers during rendering. I'm trying to figure out how I should setup the main vertex buffers for the surfaces in my engine. it seems logical to setup the vertex buffers in the same fashion as the index buffers. since the idea is to render a bunch of the same material/textures seperating the surfaces into bins and then building a vbo for each bin should work. but i am also planning on using per pixel lighting for surfaces that are near light sources. during the ambient pass, my original vbo creation should work fine. its for the lighting passes that I am stuck. i want to get the lighting pass optimized as much as possible. the surfaces that are to be drawn in the lighting pass are basically the intersection of two or more visibility sets. the simplest case is the cameras vis set and the lights vis set. since i am currently using a BSP+PVS system I have also considered setting up the VBOs using leaves. Obviously there are way too many leaves to make a bin for each one. Plus I gathered some statistics on my test maps and found that each leaf only contained a handful of surfaces, many leaves had only one or two surfaces. Often, different leaves contained the same surface (duplicates). i thought out some practical algorithms to consolidate the leaves and sort their materials to produce better buffer sizes, but i still don't know if it will produce the results I am looking for. Using this second system in creating VBOs based on leaf, it might also be possible to create the index buffers during map load using this method, however index buffers will need to be concatenated at render time. Any thoughts or suggestions on which path I should take? I really would like each lighting pass be in a batch. perhaps there is some way of using both methods?
Advertisement
Your bins should be set up according to shader, then materials of the shader.

Lights are just an external plugin for shaders, and shouldn't be a seperate bin sort.
for example:
Rendering Opaque Pass
For each geometry that has shader A
Bind closest 4 lights to the current geometry to the shader
Render Geometry


Infact, if you're setting up an offline compiler for everything, you can minimize the bins even more by batching even larger amounts of your BSP nodes by combining their textures into an atlas. That way, an entire BSP leaf is rendered in one call, with 1 texture, and it won't have to be computed during runtime. This is also especially handy if you're doing lightmapping. So the entire lightmap for a single leaf is in an atlas as well.


~Main
==Colt "MainRoach" McAnlisGraphics Engineer - http://mainroach.blogspot.com

This topic is closed to new replies.

Advertisement