Sign in to follow this  

Batches for BSP+PVS engine

This topic is 4735 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

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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

This topic is 4735 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this