|
|
UED2 Tutorial - BSP, Solid/Semi-Solid |
In this 'tutorial' I will explain for you in more detail some of the
'mysteries' of brushes, BSP, collison hulls and so forth...
It seems to me that a certain 'editing' rules have grown into the
map editing community regarding intersecting/deintersecting, brush solidity
and all the "handle with care" or "this side up" warnings.
I will through this tutorial try to go in detail and play around with ideas
rather than comming with facts (if you can call it that) that really can be
questioned.
I would like to thank BitBasher (from Infogram Forums) who put big
question marks regarding the issue of Invisible Collision Hulls and its
limitation, which got me to do some 'research' regarding the entire
consept behind BSP, semi-solids and all that.
Before I start; If you know actual facts I would really like to know.
Mail me if you like, questions and corrections and all that.
Thanks to Mike G for some additional information regarding BSP problems.
Concept, Warming up:
"Do you have a lighter?"
So where did I collect all the information from, regarding BSP?
Well, I don't really know.
Most of it came in bits and pieces from differnet sources, like sites
and people via mail and forums.
By putting all that together I have created a nice little
illusion on what is 'legal' and not.
Until this time, I have accepted that information as valid and created levels
accordingly.
But, even if I do follow all the rules and make sure that the grid is never
below 4, making sure (and even double checking) that my Invisible Collsion Hull
do not touch walls and zone portals I get BSP holes.
I accept these 'faults' as my own editing faults and curse my lack of editing
skills.
Now, to confront certain 'rules' I start defying the 'laws' of level editing
and play around with Invisible Collision Hulls, Semi-Solids, Non-Solids and
let loads of brushes overlap each other with no particular reason.
I did notice a few BSP holes, but would they be there if I followed the
above rules?
BSP, why cutting the geometry:
"I can actually walk here."
BSP, short for Binary Space Partitioning is in simple terms a way to pre-render the
visibility in a level.
To explain BSP you would first need to know how a rendering engine, by default, work.
(Without BSP).
The only way would be to render geometry by drawing all polys (walls) on top of each other,
starting with the polys in the back and end up with the poly closest to the player.
As geometry can become incredible complex, rendering a screen any other way would be
almost impossible.
But, this is as you can imagen, is very resource demanding and will not render crossing
polys correct.
To make things a bit easier for the in-game rendering engine BSP will create a logical
structure of the gemoetry by calculating visibility in any given area.
(Logical structure would mean BSP tree).
What do this tell us then, and how can it help the engine?
By cutting polys into smaller parts the engine can identify the area you are located at and
make sure that you see what you should see by using a logical structure index, (read BSP tree).
In short it means that areas behind walls will not be rendered, preventing huge CPU
usage to build the display.
What is a BSP tree then?
A BSP tree is an index connecting multiple cuts together so the engine know what parts
to render, at any location and direction.
To go more indepth of BSP and what it actually do, you can take a few
look at these screen shots.
(The best way to see BSP cuts is in "Zone/Portal" view").



The first picture show all polys (sides) of a brush and they all are 'intact'.
It means that if you stand where the camera is, all polys will be visible.
In the next picture you can see a cylinder placed on the floor and it have 'caused'
the floor to be cut up in smaller parts.
Each part represent a single index in the BSP tree.
As you can see the cuts are always on the same plane as the poly.
(Plane means polys / sides that share the same axis, X Y or Z).
Logical enough, if you stand on one side of the plane you cannot see the surface of the
other side.
In the last screen shot you can see that the more 'complex' geometry we create the more
complex the BSP cuts get.
All this is indexed in a 'tree'.
You can think of any set of BSP cuts as branches and sub branches where any given
BSP cut area can be located by following the branch and sub branches.
It just means that by using this system, you can prevent areas that is not visible to be
rendered as they would belong to another 'branch' in the BSP tree.
Nodes, in addition to BSP:
"Rats, they are everywhere."
So, you want to get technical again?
Nodes is in a coders perspective almost the same as a vertex as it is used to define
a certeain geometry.
When BSP create cuts it will place nodes and draw a line between them to create a 'new'
surface.
(These surfaces cannot be textured alone or have its own flags, it's just a way
to index the BSP tree).
Actually that is it about the technical part of nodes.
Let's talk more building related, including nodes.
When you start a map you probably created a room with four walls, floor and ceiling
which would be 6 polys / sides.
If this would be just it, each time a player entered the room the rendering would simply
draw all polys on the screen.
If you put an object in the middle of the room, things become a bit different.
First of all the BSP tree would be different and the way the engine draw the polys,
all visible polys, would change.
Not only do it need to calculate how many polys you are able to see, but also how many
surfaces (BSP cuts).
With this in mind, you can imagen a very detailed room that would cause extensive
BSP cuts all over the place.
To be able to draw the correct polys on the screen the engine would have to
calculate the correct BSP cuts you have in view.
As a result, you might have guessed it, a high node count will result in
frame rate drops.
That is why we have something known as semi-solids.
BSP Holes:
"Damn, have anyone seen my wall?"
So now that you know how the BSP tree is built, how do BSP holes fit in all this?
No code can prevent problematics like this.
Not at it's current state anyways.
When you place objects (brushes) around the level the BSP need to cut the surfaces
to get a faster rendering routine.
All this is ofcourse mathematical all the way and in the world of computers,
data can only be used to a certain limit.
In this it is the limit of how many digits a decimal number can have.
If the decimal point get too far away, the particular cut in question cannot
be placed correctly in the BSP tree.
The result is a hole in the wall.
It will ofcourse only be seen in certain angles and directions as the
surface can still be successfully placed in another "branch" of this
BSP tree and therefore look normal from other angles.
Hall Of Mirrors (HOM):
"Hey, Larry... Is that a portal?"
Hall of Mirrors, why do they occure?
Simple, you are able to see into "nothing".
It will happen when you have a wall that do not have any texture,
the texture is masked or transparet or you have BSP hole.
The engine render everything that you are able to see and if you
are able to see into nothing (which is not rendered) a copy
of the last frame will show in the area in question.
A type of HOM can occure if you have sheets/zoneportals that share
not only the same plane but also the same position, to battle
for what poly to be rendered on top.
(You get this shifting texture in that particular area).
What is the "nothing" then?
This is refered to the area that you haven't any placed any solid
(added or subtracted) geometry.
This area is often said to be filled with mass, but that isn't
entierly correct but used to make understanding the add and subtract
functions easier.
The more correct term would be, the void, nothingness or limbo.
Solids and Brush concept, CSG:
"Ouch, I hit my head."
The brush is the corner stone in creating levels with UED.
It is the clay that you shape and then add to the world,
which in the end will, possibly, end up in a playable map.
The brush can in most extrem sense have any shape and size.
But ofcourse, when actually using and adding brushes, common sense
should apply to the result of modifying the brush.
Adding brushes to the world is somewhat incorrect as you can
both add and subtract brushes.
This is what CSG (Constructive Solid Geometry) state means.
It can be either subtractive or additive as it will tell the game
if this brush should add or remove mass from the world.
If a brush is additive or subtractive can be told from the color of the
brush.
If it is yellow it is subtractive and if it is blue it is additive.
But a brush is not only limited to a CSG state.
It can also have a specific solidity.
This would be solid, semi-solid and non-solid.
(Semi-solid and non-solid explained further down).
A brush that is anything else than solid cannot be subtractive.
Meaning that you cannot subtract semi-solid or non-solids.
The color also change.
A semi-solid is pink and a non-solid is green.
When adding a brush, not by the add button but with the add special brush
button, you can change the solidity of the brush, and also other properties.
I will explain the "Add special brush" button a bit even if it will expand into
other parts.
First of all.
The prefabs you select is not a "spcific" type of bush.
It is just a default selection of options in the add special brush window.
This means that "Water" and "Zone portal" is the exact same thing, but with
different options selected.
It is perfectly ok for you to change and select other options.
It also means that (which not alot of people know) Invisible Collision Hulls
is just a semi-solid with the "Invisible" option checked.
The selections you do (execpt for solidity) will 'stick' with the brush.
Meaning that, trying to change this later will not work.
The add special brush is not limited to a certain shape or size of brush.
Sheets and other types of brushes will do perfectly ok.
Semi-Solids and Invisible Collision Hulls (ICH)
"Hmmm, I can't see it, but I know it's there, somewhere."
Now that you know the concept behind brushes, understanding semi-solids
should not be any problem at all.
A semi-solid is solid as it will block players, any actors and light.
The reason it is a semi-solid is because it will not cause additional
bsp cuts.
It will not add to the current bsp tree.
This means that by adding semi-solids you will only increase the amount
of polys seen at once and not the amount of node counts.
However, a slight bi-effect comes from all this.
As the semi-solid is not part of the bsp tree (not adding to it)
it will not block the actual rendered view.
Meaning that if you would use semi-solids in windows (including invisible
collision hulls as this a semi-solid) the view the game engine render will
include everything behind it (doesn't matter if you actually see it or not).
A semi-solid can, itself, be cut by other brushes which means that it will still
be part of the bsp tree.
With this in mind you probably realize that semi-solids will only work
when using in small numbers as decoration or at special places.
The difference between ICH and other brushes?
None!
An ICH is simply a semi-solid but invisible.
Here comes another factor in.
Invisible brushes do not block light and is not affected by light either.
Why can semi-solids be a problem concerning BSP holes?
Now, as a semi-solid do not increase the amount of nodes it is not increasing the
bsp tree at all.
This means that in certain angles (semi-solids that are not straight) and
complex situtations in a given area with alot of bsp cuts it can cause the rendered
view to come out incorrect and thus causing BSP holes.
Unwanted collision hulls is also a problem.
This usually occure of you let solid structure get too complex, close or around
zone portals / non-solids as this will cause the solid geometry to 'leak'
out and cause collision hulls.
Most often you get a graphical problem along with it aswell.
Non-Solids:
"And I actually thought I understood."
I am not sure that I will explain anything about this topic.
I will not say anything like "Do not use non-solids what-so-ever as this will
cause major bsp holes and destroy your level..." as it will not.
The main problem with non-solid is that they have no solidity and might cause
the calculated collision area to be smaller/larger than it should.
This will cause you to die leaving a 'crater' as you try to veture into a solid
area which no longer is solid.
The worst case situation is your level destroyed, leaving you with unwanted
collision hulls and non-solid areas all over the place.
To avoid this you should keep the non-solid bruhes very strict and clean.
But...
In what situation do you defend using non-solids?
You should always use sheets instead.
Well, non-solids will not block light but is affected by light which results in
it to look like a regular wall.
If you just must use them, use them with care and treat them as you treat semi-solids.
Use only in special places and as few as possible.
One important issue when you use both non-solid and semi-solid is to keep them
far apart.
Semi-solids might work as an magnet for the non-solid area as it is not truly
solid.
The reason you get this problem is that the semi-solid, which do not affect the BSP
tree cause the collision area of the non-solid to be calculated incorrect.
(It will only happen if they are close to each other).
Sheets and Zone Portals:
"Please, close the door, it is cold outside."
Sheets, including zone portals, are treated slightly different than regular brushes.
They only have 'one' poly in the sense that if you change it, it will affect
'both' sides of the sheet (including any flags you set).
With this in mind you might also see that a sheet is 0 units wide.
So in practical editing ways, changing the solidity of a sheet is useless
as it will still act the same way.
I do not know if the game engine treat sheets with different solidity
different but that is not worth finding out so always use non-solid for sheets.
Zone portals are slightly different than a regular sheet as it will tell the
engine where to stop adding lighting and zones specific properties.
If you add a brush (not a sheet) as a zone portal all polys / sides of the brush
will be treated as if it was a sheet.
Sheets are always 'non-solid' and do not affect geometry so overlapping is
perfectly ok.
Sheets can not be made to block players, any actors or light.
However, the sheet is affected by light.
The Grid, the default editing tool:
"Maybe if you put that over there?"
What is the grid?
You already know what it is and how it works,
it's the building aid you have to position, move
and align brushes more precisely inside the 'world'.
All brushes can be located (positioned) at very 'detailed' levels.
(Down to 6 decimals, x.xxxxxx)
Knowing that the grid is only an aid, why wouldn't you be able to set
the grid setting you want, or even turn it off?
To answer this you should first know what causes BSP holes.
When you add/sub brushes to the world they cut the current geometry.
When calculating these cuts the position / edges of the brush must be
included and it could cause the bsp cut / nodes to get decimal values.
There is nothing wrong with that, but a computer is only able to
handle decimal values to a certain size and then you get an error
known as "Overflow".
(The min value of a 'double float' is 2.2250738585072014 E – 308
and max 1.7976931348623158 E + 308. I don't think the engine use such
'huge' values though).
If the cut results in a decimal value that range above the valid range,
used by the engine, it will result in 'overflow' and cause BSP holes.
By thinking about this you will probably realize that the best possible way
to avoid getting decimal values is to use positions in the power of 2.
So why can't I use a grid setting below 4?
Who said you couldn't?
There is no real differance between 2 and 4 when it comes to division
Any number that result in 'endless' decimal values that you divide 4 with,
will result in the same 'problem' with 2.
Unless there is a flaw in the game engine or there actually exist a
mathematical formula that create huge gaps in the result when using
either 2 or 4 there should be no problem with a grid of 2.
But then again, it would also cause 4 and 8 to be very different,
which it really isn't.
All this should also alert you.
A brush should have the size in power of 2, to prevent the above problem.
But to turn of the grid is a whole new chapter.
First of all you would start moving it around on the decimal point (x.xxxxxx).
Division and forumals using decimal values are a pain and will often result
in more decimal digits.
Another thing that is important regarding the grid is vertex snap.
If you want to align two polys / walls of two or more brushes you should
always use vertex snap.
If not the points, polys / walls could be unalign by a small fraction,
without you seeing it.
This again will cause the engine to calculate the cuts incorrect and cause
BSP holes.
Brush Order, First and Last:
"No, that goes in there and that goes over there."
As you add and subtract brushes the order in which they are introduced
into the 'world' is indexed.
This is simply because when you rebuild the geometry the engine need to
'create' all brushes in the correct order, as they are indexed.
The natural order of a room and objects inside would be the room (subtracted)
first and the details (added) later.
A subtracted brush will remove all materia inside its borders which means
that the brush order play and important role in how the geometry will take its
shape.
By adjusting the brush order you also adjust when the brush in question will
cut (BSP) the geometry and be cut itself.
Deintersect and Intersect:
"Damn, I really wish I had a better knife."
First I would like to explain what these two functions really do.
They will modify the current brush to fit into the current design.
Meaning what?
Sometimes you end up having brushes that you need to add or remove
in complex situations.
The brush you have might overlap other brushes or you need a specific
type of design on the brush.
By using deintersect or intersect you can easily solve these kinds of
problems.
Deintersect will remove the parts of the brush that overlap into filled
areas while intersect remove the parts that overlap into open space.
In more realistic sense you will probably see that if you intersect a brush
around a table in a room the brush will get the exact same shape as the table.
If you would deintersect the same brush you will see that it not only "'cling"
around the table but still have the same outer size as the room.
In a more logical sense, using the same example, you see that with intersect,
which remove all parts existing in open area, will have the shape of the
table as it is 'mass', which is not removed.
The oposite, deintersect, will still have the shape of the table but simply
because the mass which the table occupy is removed from the brush.
That is also why the brush still have the same size as the room.
Another feature that this have is that all polys / sides that are cut to fit
the current geometry will recieve the same texture and flags as the original
poly / side.
Meaning that if you would intersect that table from the example above,
the new brush would have the same look and flags as the original brush.
This allow you to create complex objects using multiple brushes and then
intersect it to get one complex brush.
So what do all this have to do with BSP then?
A 'clean' design will reduce the chance of getting BSP holes and
unwanted collision hulls.
In theory there should be nothing wrong with brushes overlapping each other.
But there is no reason for you, as a designer, not to keep your
levels nice and tidy.
Preventing and fixing BSP holes (and collision hulls):
"I told you not to play around with the scissors."
It almost seems that no matter what you do, sooner or later a BSP hole will
find its way into your level.
That is nearly impossible to prevent.
What you do is that you focus on laying it all out to keep the chance of
getting a BSP hole reduced to a acceptable level.
If you see a BSP hole from a few nearly impossible angles when your level is
complete should be acceptable and the chance of someone finding it would
be pretty slim.
The best way to keep problems from happening to you would be to keep everything
as simple as possible and as clean as you can.
A straight wall is prefered instead of a rotated one.
Make sure that all brushes fit by using deintersect and intersect.
It might not prevent BSP holes but it sure will not add to it so there is no
reason for you not to.
Use as few semi-solids (ICH) as you can and only as decoration or at places
that you need them.
By 'planning' your level. Building it up from basic structures like rooms,
and hallways first, then add major / larger details and then start on complex
details (adding semi-solids to the end).
This might not actually prevent BSP holes from occuring but it will reduce
the chance of it.
If you have a BSP hole or even lots of them and you want them to go away,
which I think most of you would like to, what to do?
The first thing is to always rebuild the geometry and maybe change how good
the BSP should be calculated (Optimization: Lame, Good or Optimal).
By locating the actual hole and then change to zone/portal view, which
show BSP cuts, you can locate what cuts that hole is connected with.
By deleting the brush that is connected with this/these nodes the hole
might go away.
Another way is to add a brush (or subtract) close or where the bsp hole
is will cause new cuts to be made and maybe the BSP hole will be
'destroyed'.
Moving one or more brushes that is in the close area will also cause new
bsp cuts to be made and might fix the problem.
By changing the brush order of the brush(es) will make the brush cut and
be cut at an earlier or later stage.
The normal procedure here is to make the details, that most likely is the
cause of the BSP hole, have its order changed to last.
Final thoughts:
"Seriously, why are you so angry?"
So, should you really bother with all this that I have told you?
It's really up to you!
But, as with everything else, editing levels for UT with UED2 have it's
possibilites and limits and using or abusing them will give results
accordingly.
One think to keep in mind is that it is not easy to create a fully
functional level.
You could possibly say it is like painting a picture.
There is no sport throwing colors to the canvas but creating a flowing
picture is alot more harder.
But I think that most people need to experience the problems before they
can be dealt with.
You really don't know the limits until you have crossed the line with
huge steps.
In the end I want to say that you should not take information about BSP and
limits of the editor unless you understand the 'why' behind it.
Keep editing as you want to, but take backups at regular basis so that you
do not lose everything you have done.
|
|