Deva Drifter

2020-07-07 at 10:07 | Posted in Computer path | 2 Comments
Tags: , , , , , , ,

Deva Drifter is a precise and satisfying top down arcade physics based driving game EXCLUSIVE for the Amstrad CPC with rigid body dynamics and SUB-pixel sprites providing smooth handling at 50 frames per second on overscan. It’s the third entry of the Hidden History Saga game series (after Light Lands) and may be the first CPC game with true rigid body dynamics and SUB-pixel sprite drawing (both in the rotation and displacement of the car). This is what Deva Drifter looks like:

Story

Enki says to you: “Utnapishtim, to avoid Annu’s watery genocidal plans I command you to build a huge boat. Every blueprint piece for the emergency watership is hidden inside your extreme driving lessons trophies, because of reasons. Go get them all before the rain comes! Also be careful of big crashes as they will temporarily shutdown your car while its automatic repairing system takes care of the mess.”

How to get the game

  • Deva Drifter: available for free as a download link at the end of this post.
  • Deva Drifter deluxe: the DELUXE version of the game with lots of extra tracks, available as physical or digital edition:
    • Deva Drifter deluxe (Digital Edition): orders should be directed at alberto.rd.mr@gmail.com with subject “Deva Drifter deluxe (Digital Edition)”. Be sure to write from your PayPal mail as this is the payment method. The cost is 3.9€.
    • Deva Drifter deluxe (Physical Edition): temporarily out of stock (on an original 3 inch Amstrad CPC disk. Orders should be directed at alberto.rd.mr@gmail.com with subject “Deva Drifter deluxe (Physical Edition)” and clearly specifying name and shipping address. Be sure to write from your PayPal mail as this is the payment method. The total cost is 69€ with shipping costs included by registered mail).

System requirements

  • Gameplay is better on original hardware: Amstrad/Schneider CPC 464/464+/472/664/6128/6128+, but you may also play using a compatible emulator.
  • 128K of RAM.
  • 3 inch disc drive.

Inside Deva Drifter

Development of Deva Drifter has revolved around two main challenges:
1. Calculating the physics.
2. Providing adequate user feedback through the restricted graphic output.
As for the first challenge: each wheel has static and dynamic grip physics, also speed is independently calculated for each wheel. This may seem unnecessary but because total speed of one wheel is the sum of linear speed plus angular speed this implies each wheel may have a different speed. Car steering is indirectly derived from front wheels smooth analog turning friction with the ground. Every applied force generates torque and modifies the car lineal and angular momentums, as it should be when using rigid body dynamics. There are four different types of ground (tarmac, dirt, ice and quicksand) which modify how each independent wheel reacts and contributes to the movement of the car. And yes the engine handles well the case when each wheel is on a different ground at the same time.
Addressing the second challenge: what good is going to do calculating fun physics if it’s all lost on low resolution graphics output? this is frequently overlooked (as I did). When I first ported Deva Drifter prototype from Linux (high resolution and subpixel drawn) to Amstrad CPC (pixel precise sprites) the feeling of driving was gone. At first I thought there was a bug in the ported code that ruined it, but after much investigation the situation became clear: even though the physics simulation was working perfectly well the diminished graphic feedback to the user was not transmitting it effectively. So I added subpixel precalculated 2x SSAA drawing achieved with 7 possible colors in mode 1 using epileptic sprites (to enjoy the game to the fullest play it on a CRT monitor as usual on original hardware). Then I added overscan to increase sprite drawing resolution to 368*264 pixels (virtual 736*528 subpixels) and in turn increase realtime visual feed back. Internal car calculated location resolution was higher by a lot so that was not a problem. Also a total of 1024 virtual car sprites are used dynamically modifying 256 precalculated sprites on the fly with 16 separate car drawing routines. Everything at 50 frames per second. After all that, the car driving feeling was back on the Amstrad CPC.
That’s a significant amount of Amstrad CPC CPU power poured into so few pixels. I’ve been told about Deva Drifter: ‘it’s like trying to make a nuclear power plant out of card board’. I still don’t know if that is a good or a bad thing…

Deva Drifter is coded in C, assembler and machine code and has been possible thanks to:

  • GCC: as C++ compiler for several development tools.
  • Inkscape: well thought vector editor.
  • GIMP: allows accurate reproduction of CPC mode 0 for designing Amstrad CPC graphics.
  • Roland Perry: one of the lead designers of the original CPC.
  • Wolfgang Amadeus Mozart: something about music.
  • SDCC: awesome C compiler and assembler.
  • CPCMANIA: useful tech info.
  • WinAPE: CPC & CPC+ emulator.
  • CPCtelera: very comfy way to install and use SDCC and WinAPE. Vector Vaults doesn’t use them, but CPCtelera has nice libraries for the CPC for you to try.
  • Wine: runs WinAPE on Linux.
  • Arimo TTF by Steve Matteson.
  • Raydiant++: 2D renders.
  • ConvImgCpc: image conversion tool.
  • LMMS: music arrangements.
  • Linux: worst OS there is, except all the others.
  • iDSK: easy way of creating Amstrad CPC disk images.
  • KDevelop: as editor of source files and GCC frontend.
  • gedit: as generic text editor.

Hint

Try entering Light Lands winning code into Deva Drifter and see what happens…

Health warning

People sensible to unflashy menus are advised to play this game with caution.

Disclaimer

This product is not affiliated, associated, authorized, endorsed by, or in any way officially connected with AMSTRAD, or any of its subsidiaries or its affiliates.

Download

Light Lands

2018-08-29 at 11:04 | Posted in Computer path | 4 Comments
Tags: , , , , , , , , , , , , , , ,

Light Lands is a peaceful retro inspired exploration and puzzle bedroom coder GAME for PC with procedural algebraic visuals and sounds. Light Lands has CPU pathtraced (raytraced) interactive spectral graphics with full scene realtime global illumination on unlimited dynamic surface/volumetric lights and includes a benchmark option. Has music by Yerzmyey, It’s the second entry of the Hidden History Saga after Vector Vaults and looks like this:

System requirements

The thing to remember is that the CPU core count/speed is what dictates the graphic quality. On the other hand the graphics card has a negligible impact on performance:

  • Operating system: Windows 64 bits.
  • CPU: 4 or more FAST cores, the more the BETTER.
  • RAM: 4 Gigabytes (more RAM may be needed for high core count CPUs).
  • Console style game pad with two analog sticks is HIGHLY recommended (although Light Lands may be played with just mouse and keyboard).
  • Graphics card with OpenGl 3.3 or higher. Does NOT use DirectX, DXR API nor NVIDIA RTX.

Physical copy

The full game is available for free as a download at the end of this post, but if you find yourself compelled to posses a professionally pressed CD physical edition (DRM free) please follow this easy steps:

  1. You are advised to download and play Light Lands before buying it in order for you to asses speed performance on your hardware.
  2. Orders should be directed at alberto.rd.mr@gmail.com with subject ‘Light Lands physical edition’ and clearly specifying name and shipping address. Be sure to write from your PayPal email as this is the payment method. The game costs 38€ with international shipping by registered mail included.

This is how the Light Lands pressed CD physical edition looks like (please note this is a professional injection mold CD):

Inside Light Lands technology

Light Lands is a photon simulation environment which uses Raydiant++ graphic engine through the lightspectering rendering module. It doesn’t draw each frame, instead they emerge as a byproduct of synthetic photons accumulating on a virtual photographic plate. It’s an ongoing interactive Monte Carlo simulation. Representation quality is linearly proportional to CPU power: Raydiant++ will take all cores/threads and max out your CPU. Light Lands is retro itself in the sense that in order to use this graphic technology at 2018 the display resolution is kept low, not unlike 8 bit games. You may think of the low resolution and noise of Light Lands in a similar way as other retro systems anomalies like ZX Spectrum color attribute clash or Amstrad CPC mode 0 ludicrously wide pixels: the result of technology limitations at the moment of making the games. Light Lands feels retro at 2018 because it uses technology for the future?.

The lightspectering technique has some parallelisms to jpeg compression. The jpeg algorithm recognizes that the lightness (gray scale) information of an image needs far more quality/detail than the color. So it separates both and devotes more resources to represent lightness than to color. Lightspectering is a collection of techniques tweaked to work together to achieve something similar on a interactive stream of images of a live user controlled camera. In this case is proposed that it’s more important to represent in a lagless way the effects of user controlled camera movement on the live image stream than the effects of world change. For world change we mean: lighting conditions change and object movement/morphing. So lightspectering allows for the camera movements to be reflected instantly on the live image stream. Then the lightning and object changes are progressively reflected and updated at a lower rate as allowed by the available CPU power. Thus we can produce interactive 3D games with full scene realtime global illumination on unlimited dynamic surface and volumetric lights on current (2015) hardware. With lightspectering the 3D graphics card is used lightly to keep frame rate constant by artificially increasing inter frame coherence dynamically only when needed depending on the complexity of the scene and the power of the CPU, hence making it possible to raytrace our way trough 30/60/… fps of global illumination game play on an open world without LOD or fog-limit. Lightspectering reduces the computing power needed to real time path trace a scene by orders of magnitude, dynamically. A drawback of lightspectering on not powerful enough CPUs is an added effect similar to motion blur.

Light Lands is tuned to work on an average 2015 i7, so it’s lowres. Still it gives a feel now for what it can be done in the near future. Another way of making this technology available now in HD and without noise would be through a cloud service. Raydiant++ engine is specially suitable for this as its performance grows linearly with server count. Raydiant++ has several rendering modes like global illumination, classic raytracing, preview mode… . The classic raytracer mode is around 30 times faster than the global illumination mode. I considered whether to use classic raytracing for Light Lands because it has no noise, gives realtime good resolution and has good hard shadows. In the end I decided towards global illumination because it’s more of an improvement over traditional hardware accelerated 3D game rendering.

As lightspectering method accurately calculates recursive refraction and reflexion it’s specially suitable for VR. Also lightspectering allows to select image quality on a per pixel basis which may be useful to leverage pupil tracking as a mean to devote more computing power to where the user is looking to on each moment and less to his peripheral vision zone.

On Raydiant++ engine no LOD is needed and light phenomena happen naturally (no need for constant tricks): recursive reflection, recursive refraction, focus, dispersion, caustics, global illumination, iridescence and more. Because of the efficient use of available SMP on current and coming modern powerful CPUs it may be of interest to Intel and AMD for this technology to go mainstream, since it will justify the need to get as many CPU cores as possible thus reversing modern trend to push for better graphics cards and shifting interest to CPU instead.

Raydiant++ is not restricted to drawing triangles, the limit is your imagination. These are some of the graphic specimens currently available:

  • Box.
  • Fractal procedural mountains (with no memory footprint).
  • Superquadric.
  • Superquadric specialized for integer exponents.
  • Solid cylinder.
  • Cylinder surface.
  • Elliptical cylinder.
  • Bit matrix.
  • Solid cone.
  • Cone surface.
  • Elliptical washer.
  • Sphere.
  • Heart.
  • Ellipsoid.
  • Cylindrical helicoid, right handed and left handed.
  • Elliptic cylindrical helicoid, right handed and left handed.
  • Box helicoid, right handed and left handed.
  • Infinite plane.
  • Alberto’s torus box.
  • Triangle mesh.
  • Polygon mesh.
  • Revolution polyline surface.
  • Convex polyhedron.
  • Generic polyhedron (with holes and non connected).
  • Elliptical torus.
  • Alberto’s groove ellipsoid.
  • Alberto’s bumpy sphere.
  • Alberto’s cos ellipsoid.

On the procedural front among the many generation functions the a-maze function family can be heard and seen throughout the game from the menus to the stages.

Development

Light Lands is coded in C++ through an IBM Model M keyboard on a PC surrounded by 8, 16, 32 and 64 bit retro systems and has been possible thanks to:

  • Bjarne Stroustrup: C++ father.
  • GCC: real C++ compiler.
  • Boost: C++ libraries.
  • SFML: nice portable multimedia libraries.
  • Inno Setup by Jordan Russell.
  • Linux: best OS there is.
  • ‘Texture and modeling: a procedural approach’ by David S. Ebert, F. Kenton Musgrave, Darwyn Peachey, Ken Perlin and Steven Worley.
  • Xolonium fonts: by Severin Meyer.
  • Bfxr: by increpare.
  • WinRun4J: rcedit.exe tool.
  • MinGW-w64: GCC Windows compiler.
  • KDevelop: IDE.
  • Ubuntu: Linux flavor.
  • DejaVu Fonts.
  • GDB.
  • Glew.
  • GLM.
  • GNU.
  • Mate: no nonsense desktop GUI.
  • Gnome classic: no nonsense desktop GUI.
  • OpenGl.
  • GIMP.
  • Stack Overflow.
  • gedit.
  • LMMS.
  • Audacity.
  • and many more…

Troubleshooting

  • If you have difficulty launching the game this is probably because you have ‘.js’ files associated to an action different from executing. Just go to ‘Program Files\Light Lands\multi-soliton\build\’, right click multi-soliton.exe and ‘Run as administrator’ (thanks to fibs111 for pointing this out).

Download the full game

         mirror 1: Light Lands

         mirror 2: Light Lands

Updates

Light Lands update 2020 09 17 – v1.0.23.zip

Vector Vaults

2016-09-26 at 17:57 | Posted in Computer path | 8 Comments
Tags: , , , , , ,

Vector Vaults is an original and addictive fast retro arcade bedroom coder game exclusive for the Amstrad CPC that will test your pilot skills. It’s the first game of the Hidden History Saga and upon completion will give you a secret code to use in Light Lands (the next entry in the series). Game play is based upon vector graphics (100% spriteless) with 25 frames per second, multi directional, analog variable speed, pixel precise scroll (may be the first game to do this four things at the same time on the CPC?). Physics on ship and camera are fine tunned to provide natural and smooth handling throughout the nine stages where gameplay is the main focus. If you want the smoother experience try it on original hardware. Vector Vaults pays homage to the Vectrex video game console and plays like this:

video-cover

Game story

You are Samuel, an human abducted by some ‘dingir’ into Annu’s mother ship in orbit around earth. They make an offer: help us break into the onboard computer SOLOMON using virtual avatar Enoch. They can’t do it themselves as their neural profiles are well known to SOLOMON. Your reward: Galactic Imperium citizenship. Among many other advantages this will extend your lifespan indefinitely. You don’t know yet who’s Annu or why these ‘dingir’ want to break into SOLOMON, but unending life is enough motivation. Just before a dingir called  Samael switches you to virtual mode inside SOLOMON you state: ‘Let’s do this!’ in a loud confident voice.

Instructions

You are in charge of a ship shaped virtual avatar called Enoch. Your job is to penetrate each of the security encryption layers of SOLOMON in order to finally crack the computer and defeat Annu, so Vector Vaults is kind of a digital lock. The ship energy level is located on the bottom left corner of the screen, keep picking up batteries to refill it. Joystick or keyboard (O, P, Q, A and SPACE) may be used to play. The fire button (or SPACE key) activates the turbo speed. A far lenient skill level called ‘child’ is available from the main menu so every one can enjoy the game. Also pressing ESC key at any moment exits current game.

System requirements

  • Amstrad/Schneider CPC 464/464+/472/664/6128/6128+ or compatible emulator (like WinAPE for example).
  • 128K of RAM.
  • 3 inch disc drive.

Editions

There are two ways of obtaining the full game:

  1. Free download of dsk file: Vector Vaults.
  2. Physical edition: temporarily out of stock (3 inch disc physical edition of Vector Vaults available for 69€ (shipping costs by registered mail included). Orders should be directed at alberto.rd.mr@gmail.com with subject ‘Vector Vaults physical edition‘ and clearly specifying shipping address. Be sure to write from your PayPal associated mail as this is the payment method).

   This is how the physical edition looks like:

Vector Vaults technology

Vector Vaults draws inspiration from the excellent Amstrad CPC Scrambler clone ‘Killer Cobra’ (which uses hardware scroll). Vector Vaults does not use hardware scroll but a new graphic technique called ‘mode c’ (not mode 3) which I tough of around 29 years ago. This ‘mode c’ provides 3 colors and 160×200 pixel resolution (which is less than ideal) and it’s primary advantage is being able to clear the screen seven times faster (comes very handy for vector graphics). Internally mode ‘c’ is a double buffered mode 0 that works by manipulating the palette between frames cyclically, keeping always 14 of the 16 colors invisible (hence the three usable colors counting background). That way the task of erasing the whole screen may be divided into seven steps, each performed on a consecutive frame. This has to be done alternatively on each of the two video buffers. This technique is made possible thanks to how the Amstrad CPC handles the palette and, of course, may be used for any kind of scroll or other types of movement.

For those of you who are curious, during development I tested using mode c versus erasing only the lines and pixels that were drawn on screen (by redrawing them with background color). The result: mode c was faster, saved memory (less code and data structures) and simpler.

Development

Vector Vaults is coded in C and assembler and has been possible thanks to:

  • Roland Perry: one of the lead designers of the original CPC.
  • CPCWiki: THE Amstrad CPC encyclopedia. Tons of useful examples and great place for the Amstrad CPC enthusiast.
  • Wolfgang Amadeus Mozart: for his underappreciated north Madagascar horned lark studies.
  • SDCC: awesome C compiler and assembler.
  • Grimware: highly useful technical CPC info.
  • CPCMANIA: good tech tips and tricks.
  • Johann Sebastian Bach: decisive neighbor’s mother smoking problem intervention.
  • WinAPE: best CPC and CPC+ emulator.
  • CPCtelera: very comfy way to install and use SDCC and WinAPE. Vector Vaults doesn’t use them, but CPCtelera has nice CPC libraries for you to try.
  • Shining: game box tip, Vector Vaults shares the same box as his excellent CPC game Defence.
  • Wine: runs WinAPE on Linux.
  • Raydiant++: 2D and 3D renders.
  • GIMP: allows accurate reproduction of CPC mode 0 for designing Amstrad graphics.
  • ConvImgCpc: image conversion tool.
  • LMMS: music arrangements.
  • Raywarping: back cover background procedural texture 2D render and avatar 3D render.
  • Wilhelm Richard Wagner: greatly contributed to inline ASM.
  • Linux: best OS there is.
  • GCC: as C++ compiler for several developed tools.
  • iDSK: easy way of creating Amstrad CPC disk images.
  • Antonio Lucio Vivaldi: dolphin saving antarctic mission sponsor acquaintance.
  • KDevelop: as editor of source files and GCC frontend.
  • gedit: as generic editor.
  • Xyphoe: good youtube channel to spread the word.

Side note

Just in case it’s useful to anyone, the formulas for calculating frequency and period of sound portrayed on the following official Amstrad CPC manuals should be corrected:

  • Amstrad CPC 464, 1984, Spanish version.
  • Amstrad CPC 472, 1984, Spanish version (incorrectly titled Amstrad CPC 464 on the cover).
  • Amstrad CPC 6128 Manual del Usuario, 1987, Spanish version.
  • Amstrad CPC 464+, 6128+, 1990, Spanish version.

The right formulas are:

  • frequency = 440*(2^(octave+(N-10)/12))
  • period = round(125000/frequency)

Download

The dsk file: Vector Vaults.

Realike: the bendy engine

2012-12-31 at 11:13 | Posted in Computer path | Leave a comment
Tags: , , , , , , , , , ,

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:

'Fathomed dodecahedron'

‘Fathomed dodecahedron’

Raydiant: chasing the rainbow

2009-12-14 at 19:42 | Posted in Computer path | 2 Comments
Tags: , , , , , ,

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 global illumination

2009-11-08 at 11:04 | Posted in Computer path | Leave a comment
Tags: , , , , , , , ,

The global illumination 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 global illumination 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 global illumination 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

2009-11-07 at 11:11 | Posted in Computer path | 1 Comment
Tags: , , , , , ,

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

2009-11-07 at 10:09 | Posted in Computer path | 3 Comments
Tags: , , , , , , ,

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:

Raydiant IV

2009-11-07 at 09:54 | Posted in Computer path | Leave a comment
Tags: , , , , ,

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

2009-11-07 at 09:27 | Posted in Computer path | Leave a comment
Tags: , , , , ,

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.

Next Page »

Blog at WordPress.com.
Entries and comments feeds.