What are the benefits of a wall being as a plane or as a box? Should I use a plane with a box collider instead of mesh collider?
|
There's going to be a couple different things that you'll need to consider. Note: that the benefits from the optimizations described below only really matter with a ton of walls. At that point, it might be wise to consider a different solution like binary space partitioning (BSP) for making your walls in your game. This would make your levels highly optimized for rendering (if designed correctly) and for physics (as you have a very good definition of what collides and what doesn't. RenderingA box is going to take more to render than a plane. It has more vertices and triangles meaning your vertex shader and the rasterizer are going to have to be run over more data. Therefore, only use a box when you need to in terms of visibility. Remove faces as needed for what the player will need to see. PhysicsYou should always use a ProductivityIf you're much faster working with planes with |
|||
|
|
|
Expanding a bit on "Coburn"'s points: Rendering: If you render the wall as only a plane, then the wall will only be visible from one side, as the plane (or more exactly its faces) only has one rendered side. So if the player is able to move around the wall, you would need multiple planes to cover all the sides, which means you end up with a box anyway. Physics: Simple geometry colliders (spheres, boxes, etc.) are always faster to compute compared to full mesh colliders since not all faces of the mesh have to be checked individually. Instead "simple" raycasts can be used or distance calculations (e. g. distance to center of sphere minus sphere size). For other physics engines that have a separate "plane collider" (which Unity doesn't), there is no "better" one. A plane might be slightly faster performance-wise, but you might then run into the issue of fast objects passing through it without actually colliding. Then you are left with either having thicker colliders (so box instead of plane) or move to Continous Collission Detection (CCD), as explained here. |
|||||||||||||||||
|
|
One more thing about Rendering: When you have your own shadow-mapping implementation, walls made out of boxes can be superior to walls made out of planes due to peter-panning that can appear with planes. Here's an explanation of the symptom: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/#peter-panning |
|||||||||||||
|
|
I was always told that if u are going to have shadows that its best to make it solid to help with light bleeding because the difference in depth is to small and it will bleed. I could be wrong, but I make all of my walls and stuff like that two sided, a wall will only be a few verts so it shouldn't be that much of a saving by having it a plane. There are some things that I leave sides of but its mostly the bottom or top of stuff that has lots of stuff around it to help with light bleeding. I do the same for physics, didn't every really think about it but to me it seemed right to use a wall as a wall and a plane as a plane but that is just me |
|||
|
|