Realike: the bendy engine
December 31, 2012 at 11:13 am | Posted in Computer path | Leave a commentTags: 3D, 3D video, C++, engine, fabric, game, indie, maths, programming, realtime, render
Realike is a holistic simulation engine based upon the idea of atom that unifies what you see with what is detected (What You See Is What You Touch (WYSIWYT)) and let physic interactions emerge by themselves. It’s inspired by my previous work from 2004 Pentium IV 3000MHz II: fabric.
The nominal way of making 3D games was and is being explored thoroughly by most developers, that is: everything in the game is an empty triangle shell controllable through predefined animations. But (and this is a big but) the interactions are performed between invisible bounding volumes. Also if you want something to be breakable you must program it specifically. There’s nothing wrong with this traditional way, several of my all time favourite games fall under this category. But there are another possibilities.
Here is mine: every part of every interactive object in the game behaves as it should by itself. Just put out there your avatar or any interactive part of the scene and attach to it some forces applied to specific parts (= muscles) and you are ready to go. All collision detection will be performed over what you see on screen: What You See Is What You Touch (WYSIWYT). Fracture patterns will appear spontaneously whenever enough stress emerges on some part of the system.
One way to do this is just plagiarism of the way things are done in the real world: everything must be composed of (and exclusively of) atoms. Each atom could have position, size, mass, softness, interactions with other atoms, orientation…
Arising problem: the amount of atoms required to construct anything playable is going to be huge. Very careful design is going to be needed to reduce memory usage. And even more care should be put CPU wise. It could be challenging to animate at 60 fps many thousands of interacting dynamic atoms. Let’s also allow for static atoms used to create non changing parts of the game. Realike has been designed to address this issue. Some of its advantages are:
- Varied material properties arise by themselves from internal specific atom structure (just as in chemical compounds), examples are:
- rubbery materials
- rigid materials
- combination of rubbery and rigid along different axis
- fragile (easily breakable)
- unbreakable
- fabric
- malleable
- fluid
- No need for separate handling of bounding volumes for collision detection and visualization, this just happens by itself whenever something is constructed on the engine.
- New exotic types of avatars are possible, for example real bipeds/quadrupeds. Watch the video for another example of a wrinkled thick-fabric like ball.
- The difficult to rate advantage of an exciting new feeling. Hard to describe how enticing is to control an avatar inside an all atom world. You’ll have to trust me on this one until the game ‘Fathomed dodecahedron’ is released.
- On the game editor front whole new approaches are possible all stemming from the fact you are now dealing with real filled objects with internal structure instead of empty shells.
- Potentially everything can bend and/or break without any extra effort, it will just happen under the right stress.
- If individual atom behaviour is well programmed then 2 natural physic traits will emerge by themselves without having expressly been coded: precession on rotating bodies and angular momentum.
- There’s an oportunity here to innovate also at visual level. How are you going to represent the particles? realtime blobs? individual polygon spheres? using the atoms as the skeleton of an empty traditional triangle shell? are you going to raytrace them? billboarding perhaps? …
Here is gameplay capture of ‘Fathomed dodecahedron’, it runs at 150 fps on my PC:
Raydiant: chasing the rainbow
December 14, 2009 at 7:42 pm | Posted in Computer path | 2 CommentsTags: 3D, C++, density distribution, fractal, game, procedural, ray tracing
This is the first sample render of Raydiant using spectral sensitive materials. In this case some crystal triangular monoliths are responsible for the rainbowish thingy. I’ve developed a spectral pathtracing method, no photons are traced from light sources (no photon mapping), so light sources can be arbitrarily numerous and heterogeneous and render goes just even faster. Total internal reflection is also modeled, hence the secondary rainbows apparently going against the unique light source. I’ve spent long time staring at every different light effect on each zone of this particular render, I like them. So from now on Raydiant is a spectral pathtracer. The monoliths are made of glass with refraction index 1.4 to 1.6 for all the range of visible light. I’m working on speeding it up by a factor of 20 times and it’s looking good. The second image with square monoliths is another test posted for aesthetic reasons.
Raydiant: realtime mutithreaded radiosity
November 8, 2009 at 11:04 am | Posted in Computer path | Leave a commentTags: 3D, C++, density distribution, fractal, game, procedural, ray tracing
The radiosity tracer module has been finally completed/debugged and is working. So the new ideas applied to Raydiant engine about realtime steradian controled stem count to improve performance are now proved to be useful. Also the generic multithreaded tracer than can hold any other tracer inside (like the radiosity one) and transparently clone it and make it work at any number of threads simultaneously without synchronization penalties is completed and debugged. The result is that now you can interactively move yourself around in a synthetic scenario with true realtime radiosity in a i7. This opens far-reaching possibilities: games that look as if you where there is one I’m really attracted to. Also now that Fermi platform from Nvidia is here the Raydiant engine can be compiled at one of those 512 CPU cards and see what happends… . Because there is no precalcs the scene lights can be instantly moved around. And any number of ligths can be put at a secenario with no performance penalty, in fact is the inverse. On some of these screenshots the new light dispersion capability of the Raydiant engine can be clearly appreciated.
Raydiant: custom probability distribution
November 7, 2009 at 11:11 am | Posted in Computer path | 1 CommentTags: 3D, C++, density distribution, fractal, game, procedural, ray tracing
It was very useful to be able to transform a constant normalized random distribution (same probability for every number between 0 and 1) into another one with personalized density distribution. This has been used to create materials choosing photon bouncing directions. Also used on objective depth of field effects of different types. This is the way I did it (and really enjoyed deducing this one):
- Lets suppose we have a random generator with a density probability distribution : D(x)=1 for all 0<=x<1, and lets call ‘r’ the random numbers generated by this distribution.
- We want to get another density probability distribution called E(x), of course definite integral of E(x) between x=0 and x=1 must be exactly 1.
- Lets call ‘t’ to the random numbers generated by E(x) distribution.
- I found the relationship between r and t is: r = definite integral of E(x) between x=0 and x=t. This is to say the area defined between E(x) and the horizontals axis between x=0 and x=t must be exactly r.
- So just substitute your E(x) and solve the equation for t.
- Applied example 1: find a random distribution that applied to a radius and given uniform random angles gives a homogeneous surface distribution at the plane inside a radius 1 circle:
- Solution: t = sqrt(r/pi)
- Applied example 2: find a random distribution that applied to a radius and given uniform random angles gives a homogeneous surface distribution at the plane inside a washer of radius r0 and r1 with r0<r1:
- Solution: t = (-b+sqrt(b^2+2ar))/a with a = (2(r1-r0))/(r0+r1) and b = 1-(r1-r0)/(r0+r1)
- As exercise: can you calculate ‘t’ for a random distribution which is completely lineal between x=0 and x=1?
These are some screen shoots of custom random distributions made by my wife María with the same Raydiant engine:
Raydiant: Random generators
November 7, 2009 at 10:09 am | Posted in Computer path | 3 CommentsTags: 3D, C++, fractal, game, procedural, pseudorandom, random generator, ray tracing
I find delightful the art of pseudorandom number generation. A bunch of generators has been tested before choosing one for the Raydiant engine. Some of them have been found to be not so random by the simple method of drawing random points in an accumulation buffer. These are the bad sheep (see the screen shoots just to be sure):
- Park-Miller “minimal standard” 31 bit pseudo-random number generator, implemented with David G. Carta’s optimization: with 32 bit math and without division.
- Lehmer random number generator. For more details see: “Random Number Generators: Good Ones Are Hard To Find” by Steve Park and Keith Miller, Communications of the ACM, October 1988.
- Concatenation of following two 16-bit multiply with carry generators: x(n) = a*x(n-1)+carry mod 2^16 and y(n) = b*y(n-1)+carry mod 2^16. Number and carry packed within the same 32 bit integer. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests.
- Combination of a Multiply with carry generator and a simple multiplicative generator. Returns x(n) + z(n) where x(n) = x(n-1) + x(n-2) mod 2^32 and z(n) = 30903 * z(n-1) + carry mod 2^16. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests.
On the other hand there were other generators that didn’t show their true predictive nature and insisted on appearing as true random numbers:
- ANSI C pseudorandom number generator.
- Mersenne Twister pseudorandom number generator.
- Robert Jenkins’ IBAA generator. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests.
- Combination of lagged Fibonacci generator and a multiply with carry generator. Returning x(n)+y(n) mod 2^32 where x(n)=x(n-99)*x(n-33)mod2^32, x’s odd and y(n)=30903*y(n-1)+carrymod2^16. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests.
- A Combination of 2 multiple recursive generators. Has parameters for 3 different combos. Source: Pierre
* L’Ecuyer, “Good Parameter Sets for Combined Multiple Recursive Random Number Generators.” Operations Research, vol.47 no.1 (1999), pp.159–164. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests. - Combination of 3 Tausworthe generators — assumes 32-bit integers, Source: Pierre L’Ecuyer, “Maximally
Equidistributed Combined Tausworthe Generators”. Mathematics of Computation, vol.65, no.213(1996), pp203–213. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests. Strong theoretical backing so far. - Combination of 4 tausworth generators — assumes 32-bit integers, Sources: Pierre L’Ecuyer, “Tables of
Maximally-Equidistributed Combined LFSR Generators.” Mathematics of Computation, vol.68, no 225(1999), pp.261–269. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests. Strong theoretical backing so far.
Other merits considered to choose the perfect one were fastness of set seed operation, low memory usage, length of period and of course random number generation performance. And the winner is…
- Combination of a shift-register sequence on a 32-bit vector, a linear congruential generator, and a multiply with carry sequence. Returns y+x+z where y(n) = b xor (b<<5), b = a xor (a>>17), a = y(n-1) xor (y(n-1)<<13)), x(n) = 69069*x(n-1)+1mod2^32 and z(n) = 2*z(n-1)+z(n-2)+carry mod 2^32. The period is > 2^127. Extremely high quality, extremely fast, ultra fast set seed, 32 bit random numbers. Pass all of the tests in Marsaglia’s “Diehard” battery of statistical tests.
These are the bad sheep, to appreciate the defects is imperative you see them at full size and 1 pixel per texel zoom. A couple billion points have been accumulated on each one:
- Park-Miller “minimal standard”
- Lehmer
- Multiply with carry 16
- Multiply with carry
Raydiant IV
November 7, 2009 at 9:54 am | Posted in Computer path | Leave a commentTags: 3D, C++, fractal, game, procedural, ray tracing
Those are the last tests just before starting completing and debugging the HQ render with radiosity. This waiting is killing me but discipline is not a luxury but a necessity when dealing with hundred of thousands of C++ lines. The main components of the engine are the ethers, materials and chromes. Simply put ethers are the shape of things, materials define how light interact with things and chromes define the color of each point. These 3 main elements can be freely combined between them so any new one that is implemented provokes a combinatory explosion of new possibilities. To improve performance an automatic steradian dispersion ray calculator has been included so the optimum child ray count are generated in each photon bouncing.
Raydiant III
November 7, 2009 at 9:27 am | Posted in Computer path | Leave a commentTags: 3D, C++, fractal, game, procedural, ray tracing
OK, after a lot of debugging the Raydiant engine is starting to behave, so much so that even transparent, translucent and diffuse reflective materials look good even on preview mode. And preview mode generates frames at an interactive rate, I’m having so much fun moving around in this test scenario. At this stage of developing only 1 thread is still currently being used. I can’t wait to increase that number to 8, the optimum for my i7. Of course once this mechanism is coded and debugged you will be able to select any number of threads, something appropriate for your particular system.
Raydiant II
November 7, 2009 at 9:18 am | Posted in Computer path | Leave a commentTags: 3D, C++, fractal, game, procedural, ray tracing
The new Raydiant engine will be able to accurately simulate light dispersion and coupling a new architecture several times faster with the new multithreaded ability with no synchronization overhead things are looking good. The ability to visualize the recursive grid spatial partition has been very useful for debugging and intellectual enjoyment also. But all this is still theory because by now only preview mode interactive and static renders had been obtained:
i7 2930MHz 4x2threads: Raydiant
November 6, 2009 at 9:57 pm | Posted in Computer path | Leave a commentTags: 3D, C++, fractal, game, procedural, ray tracing
So after finishing and using the Raydiosity engine I could see some ways to improve the quality and performance of the renders. And with the new true multikernel CPUs may be even realtime true radiosity interactive movement could be achieved, a game can be made… . As with the previous Raydiosity engine a fundamental feature is a strong and easy procedural geometry and texture generation API. This time I linked with Qt library. After 6 months of redesign and heavy coding this are some of the screen shoots of the new Raydiant engine in preview mode (most of them are obtained at interactive rates):
Pentium IV 3000MHz V: Raydiosity fruit
November 5, 2009 at 7:50 pm | Posted in Computer path | Leave a commentTags: 3D, C++, fractal, game, procedural, ray tracing
Many experiments involving procedural generation of geometry were conducted with the Raydiant engine, some of them may be technically interesting or aesthetical. A bunch of them:
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.









































































































![3dprimcity-[2006-10-23-2041]](http://albertordmr.files.wordpress.com/2009/11/3dprimcity-2006-10-23-20411.png?w=150&h=120)
![3dprimcity-[2006-10-27-2356]](http://albertordmr.files.wordpress.com/2009/11/3dprimcity-2006-10-27-23561.png?w=150&h=112)
![3dprimcity-[2006-10-29-1513]](http://albertordmr.files.wordpress.com/2009/11/3dprimcity-2006-10-29-15131.png?w=150&h=112)
![block-[789332658]](http://albertordmr.files.wordpress.com/2009/11/block-7893326581.png?w=150&h=112)
![crystalMaze-[sphereSandwich][HQ]](http://albertordmr.files.wordpress.com/2009/11/crystalmaze-spheresandwichhq1.png?w=150&h=150)
![cubeCoil_[HQ_crystal]](http://albertordmr.files.wordpress.com/2009/11/cubecoil_hq_crystal1.png?w=150&h=112)
![cubeCoil-[HQ-mirror-room]](http://albertordmr.files.wordpress.com/2009/11/cubecoil-hq-mirror-room1.png?w=150&h=112)

![hemisfear-[crystal]](http://albertordmr.files.wordpress.com/2009/11/hemisfear-crystal1.png?w=150&h=112)
![hemisfear-[hacer-un-scene-basado-en-este-sketcht!]](http://albertordmr.files.wordpress.com/2009/11/hemisfear-hacer-un-scene-basado-en-este-sketcht1.png?w=150&h=112)
![hemisfear-[test-inicial-100][HQ]](http://albertordmr.files.wordpress.com/2009/11/hemisfear-test-inicial-100hq1.png?w=150&h=112)
![hemisfear-[test-only-mosaic]](http://albertordmr.files.wordpress.com/2009/11/hemisfear-test-only-mosaic1.png?w=150&h=112)
![hideOut_[final2][HQ]](http://albertordmr.files.wordpress.com/2009/11/hideout_final2hq1.png?w=150&h=112)
![hollowMaze-[crystal-pink-sun-insede]](http://albertordmr.files.wordpress.com/2009/11/hollowmaze-crystal-pink-sun-insede1.png?w=150&h=150)
![hollowMaze-[test-bumpmap-mirror+difuse-snake]](http://albertordmr.files.wordpress.com/2009/11/hollowmaze-test-bumpmap-mirrordifuse-snake1.png?w=150&h=150)
![hollowMaze-[test-bumpmap-mirror+difuse-snake-detailed]](http://albertordmr.files.wordpress.com/2009/11/hollowmaze-test-bumpmap-mirrordifuse-snake-detailed1.png?w=150&h=150)
![idol-[maze-raw][HQ]](http://albertordmr.files.wordpress.com/2009/11/idol-maze-rawhq1.png?w=150&h=150)

![mosaic-[HQ][dark-board]](http://albertordmr.files.wordpress.com/2009/11/mosaic-hqdark-board1.png?w=150&h=112)
![mosaic-[test-rotadas]](http://albertordmr.files.wordpress.com/2009/11/mosaic-test-rotadas1.png?w=150&h=112)
![penumbra-1024[HQ]](http://albertordmr.files.wordpress.com/2009/11/penumbra-1024hq1.png?w=150&h=150)
![primcity-[037822]](http://albertordmr.files.wordpress.com/2009/11/primcity-0378221.png?w=150&h=112)
![primcity-[135698]](http://albertordmr.files.wordpress.com/2009/11/primcity-1356981.png?w=150&h=112)
![primcity-[893645]](http://albertordmr.files.wordpress.com/2009/11/primcity-8936451.png?w=150&h=112)
![primCity-[7869]](http://albertordmr.files.wordpress.com/2009/11/primcity-78691.png?w=150&h=112)
![primCity-[234234]](http://albertordmr.files.wordpress.com/2009/11/primcity-2342341.png?w=150&h=112)
![primCity-[8787451]](http://albertordmr.files.wordpress.com/2009/11/primcity-87874511.png?w=150&h=120)
![primCity-[7897455659844555]](http://albertordmr.files.wordpress.com/2009/11/primcity-78974556598445551.png?w=150&h=112)
![primcity-[tCFPrimeOr]](http://albertordmr.files.wordpress.com/2009/11/primcity-tcfprimeor1.png?w=150&h=112)
![primCity-[test-sat]](http://albertordmr.files.wordpress.com/2009/11/primcity-test-sat1.png?w=150&h=112)
![primcity-[with-corrected-bumpmap-HHQ]](http://albertordmr.files.wordpress.com/2009/11/primcity-with-corrected-bumpmap-hhq1.png?w=150&h=112)
![sceneBasic-[HQ][VRM]](http://albertordmr.files.wordpress.com/2009/11/scenebasic-hqvrm1.png?w=150&h=112)
![theHole-[rayface-shot].tga](http://albertordmr.files.wordpress.com/2009/11/thehole-rayface-shot-tga1.png?w=150&h=112)
![wireFlower-[2007-05-07-1949]](http://albertordmr.files.wordpress.com/2009/11/wireflower-2007-05-07-19491.png?w=150&h=150)
![wireFlower-[2007-05-30-0840]](http://albertordmr.files.wordpress.com/2009/11/wireflower-2007-05-30-08401.png?w=150&h=112)
