I was having a bit of trouble, and made a quick raytracer to see what the problem was. I fixed that problem, but I noticed something that is mildly worrying.
I got a bit of fuzz around cubes. Is this some expected optimization, or a bug somewhere? I'm using the standard trace function with the closest callback.
I've attached a picture of a typical generated image. As you can see, spheres and planes render perfectly.. but cubes get a bit rough in places.
Fuzzy cubes in raytracer
-
- Posts: 10
- Joined: Mon Nov 17, 2008 10:40 pm
Fuzzy cubes in raytracer
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Fuzzy cubes in raytracer
That picture looks very cool.
This 'hitnormal noise' is an approximation in the internal btSubsimplexConvexCast, to speed things up. Can you try to use the more accurate (but slightly slower) btGjkConvexCast and see if that helps.
Please change the following lines in btCollisionWorld::rayTestSingle, around line 240 of Bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
Note that the convexSweepTest uses the slower but more accurate btContinuousConvexCollision by default. The rayTest sweeps a btSphereShape with zero radius/collision margin.
I realize we should provide the option to choose which method is used in the rayTest. And document this (working on that!).
Thanks for the feedback,
Erwin
By the way:
1) You should also check out the Bullet/Demos/Raytracer, it is a bit similar but not as fancy as your ray tracer. Is has several different ways to perform ray tests. It might help you understand the inner workings a bit better.
2) Just for fun, you can also add some extra collision margin to your btBoxShape (boxShape->setMargin(...). You should notice that the box corners become rounded.
3) Can you share a bit more information what kind of project you are working on?
This 'hitnormal noise' is an approximation in the internal btSubsimplexConvexCast, to speed things up. Can you try to use the more accurate (but slightly slower) btGjkConvexCast and see if that helps.
Please change the following lines in btCollisionWorld::rayTestSingle, around line 240 of Bullet/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
Code: Select all
//#define USE_SUBSIMPLEX_CONVEX_CAST 1
#ifdef USE_SUBSIMPLEX_CONVEX_CAST
btSubsimplexConvexCast convexCaster(castShape,convexShape,&simplexSolver);
#else
btGjkConvexCast convexCaster(castShape,convexShape,&simplexSolver);
//btContinuousConvexCollision convexCaster(castShape,convexShape,&simplexSolver,0);
#endif //#USE_SUBSIMPLEX_CONVEX_CAST
I realize we should provide the option to choose which method is used in the rayTest. And document this (working on that!).
Thanks for the feedback,
Erwin
By the way:
1) You should also check out the Bullet/Demos/Raytracer, it is a bit similar but not as fancy as your ray tracer. Is has several different ways to perform ray tests. It might help you understand the inner workings a bit better.
2) Just for fun, you can also add some extra collision margin to your btBoxShape (boxShape->setMargin(...). You should notice that the box corners become rounded.
3) Can you share a bit more information what kind of project you are working on?
-
- Posts: 10
- Joined: Mon Nov 17, 2008 10:40 pm
Re: Fuzzy cubes in raytracer
Ah cool, I just really wanted to make sure that it wasn't a bug (The raytracer isn't a production thing, I just found it useful to accurately visualise the collision environment)
I'm working on a simple game engine to make some indie games on (like so many people on these boards I are I assume). At the moment I'm coding the base components and testing that everything works (Bullet has made the collision component a lot faster to make than it would if I had made it by hand! So thanks!).
I'm working on a simple game engine to make some indie games on (like so many people on these boards I are I assume). At the moment I'm coding the base components and testing that everything works (Bullet has made the collision component a lot faster to make than it would if I had made it by hand! So thanks!).
-
- Posts: 10
- Joined: Mon Nov 17, 2008 10:40 pm
Re: Fuzzy cubes in raytracer
I uploaded my test app if you want to take a look:
http://img.garry.tv/Botch/BenchTest003.zip
Everything under collision on the tree on the right uses Bullet (run bin/benchtest.exe). The balls demo isn't using dynamics, it's using the swept collision then reflecting on the hit normal.
If it crashes with missing render.dll, it's because it requires the latest dx redist..
http://img.garry.tv/Botch/BenchTest003.zip
Everything under collision on the tree on the right uses Bullet (run bin/benchtest.exe). The balls demo isn't using dynamics, it's using the swept collision then reflecting on the hit normal.
If it crashes with missing render.dll, it's because it requires the latest dx redist..