• Advertisement
Sign in to follow this  

VBSP Map file rendering

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

Hello , I recently started working on implementing maps into my engine and I chose using the Valve bsp format used in Half-life2 DM. (I'm using D3D9) Anyway , I managed to write something that loads the map nicely the only problem is that it renders perfectly only with Line-list primitive type. The cause is basicly because how the vertex indices are saved in the VBSP file , instead of a triangle(3 vert indices) it is saved as a line(2 vert indices), a face is a quad that can be consturcted from a various number of lines. There are for example faces that are constructed from 6 lines , 5 lines , 4 lines and so forth. This is problematic because as far as I know (I'm fairly new to D3D) to get a solid primitive you must have an array of triangles and not lines. So what I ask is , is there a way to somehow fill the line-made quads with something , or if someone worked with this format before could give me some tips on how to convert a randomed lined-quad to 2 triangles.

Share this post


Link to post
Share on other sites
Advertisement
Unfortunately I don't have any solution to offer, but a few comments instead...

You are correct that to get a solid primitive you must use triangles - these are either in fan, strip or list form, but ultimately it must be a triangle of 3 vertices. Points, lines and triangles are the only things D3D knows how to render.

BSP trees were really nice in the old days, but they mostly suck for any hardware in the last 5 or so years. They're far too "involved" for efficient GPU rendering - the geometry manipulation of splitting/combining and potentially large number of draw calls just aren't efficient anymore. This algorithm really needs to stay with the rasterization-only hardware or the pure CPU software renderers.

That aside, you'll need to learn the VBSP format inside-out and backwards and find a way to tesselate/triangulate it for consumption by Direct3D. Given that Valve have had D3D renderers for all their engines I should imagine this won't be too hard!

My guess is some sort of algorithm that traverses the graph of vertices/lines and groups by coplanarity and then splits into triangles. I should also imagine you can implement it as some sort of streaming algorithm - either streaming to statically generate all triangles up-front, or streaming with a visibility predicate whenever the camera moves.


hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by jollyjeffers
Unfortunately I don't have any solution to offer, but a few comments instead...

You are correct that to get a solid primitive you must use triangles - these are either in fan, strip or list form, but ultimately it must be a triangle of 3 vertices. Points, lines and triangles are the only things D3D knows how to render.

BSP trees were really nice in the old days, but they mostly suck for any hardware in the last 5 or so years. They're far too "involved" for efficient GPU rendering - the geometry manipulation of splitting/combining and potentially large number of draw calls just aren't efficient anymore. This algorithm really needs to stay with the rasterization-only hardware or the pure CPU software renderers.

That aside, you'll need to learn the VBSP format inside-out and backwards and find a way to tesselate/triangulate it for consumption by Direct3D. Given that Valve have had D3D renderers for all their engines I should imagine this won't be too hard!

My guess is some sort of algorithm that traverses the graph of vertices/lines and groups by coplanarity and then splits into triangles. I should also imagine you can implement it as some sort of streaming algorithm - either streaming to statically generate all triangles up-front, or streaming with a visibility predicate whenever the camera moves.


hth
Jack


Thank's alot for your comment.
It seems quite a hassle to try and further investigate this format if you say it's out-dated , although I dont like quiting work in the middle of it , I guess i'll try a different map format.


[Edited by - Xsy on January 13, 2009 2:43:40 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Xsy
It seems quite a hassle to try and further investigate this format if you say it's out-dated
Well I don't know enough about the map format as a whole to say its out-dated, just that if it does indeed uses a conventional BSP-type algorithm that it doesn't map so well to modern hardware/API's.

Thus you could be investing a bunch of time implementing what, in my opinion, is a "dead" algorithm in the context of current hardware rendering.

As an aside, things like BSP/Quadtree/Octree and other spacial partitioning algorithms can be quite fun to code even if they aren't so useful [smile]

hth
Jack

Share this post


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

  • Advertisement