CyberUniverses

Pray

Intro - Images - News

Perl 6 Ray Tracing Engine

Welcome

Pray is a free 3D renderer written in Perl 6. To try it out for yourself, grab the work in progress from GitHub. For more on the what and why, see the initial project announcement.

Images

CSG operations greatly diversify the geometric possibilities.
A few different shapes add some much-needed variety to scenes.
Rotation and scaling transformations put a new spin on the old sphere.
The small circle towards the middle of the green sphere is a reflection of the back of the blue sphere reflecting the green sphere itself.
Simple shadows are the final addition to the lighting model before public release.
Building on recursion, refraction is the first implemented feature not seen in the original Pray.
A time for reflection at the beginning of recursive ray tracing support.
Rays of hope: color lights and materials, and multiple objects loaded from a scene file.
Slow but steady progress: multiple point lights and an improved shading algorithm.
The first high-res render came out looking vaguely like a pearl, which was amusingly unintentional.

News

Feb. 20, 2014
Code Release

Well, so much for keeping this page updated. The code was released about a month and a half ago on GitHub. I suspect most of the interested parties were already aware of this via IRC, but it certainly ought to be advertised here as well. There have been a few revisions in the mean time, like support for anaglyph glasses, though my free time has largely been spent in other ways, both in and out of the Perl 6 community. Performance improvements already in the works include multicore support and a more streamlined, reusable vector and matrix library. Now that the code is available (and advertised), feel free to fork, pull request, and so forth. Any contribution would be a welcome infusion of energy to the one-man project.


Dec. 10, 2013
Still Kicking

There hasn't been a news post here for a while, so I figured I should rectify that. If you've been keeping an eye on this page, though, you may have noticed a few more renderings. Pray features born in the past couple weeks include shadows, reflection, transparency, refraction, scaling, and rotation. So at least I've only been slacking on the news, not the code. Anti-aliasing and/or depth of field may or may not make the cut for the initial code release. More primitives will definitely be included.

Beyond that, most of the remaining work is internal polishing (so developers aren't disappointed) and non-code development like documentation (so users aren't disappointed). If you're one of the people who've been eager to get your hands on the code, fear not! We're nearly there.


Nov. 27, 2013
Happy Thanksgiving!

In the spirit of giving, I'm happy to share another preview rendering. This one is made possible by the patient and welcoming #perl6 crowd ( \o ), whose guidance has been indispensable over the past several days. In terms of features, Pray now has working color, nearly complete scene file support, basic command-line parameters for resolution and file names, and has become well enough structured to support immediate implementation of rudimentary shadows, reflection, refraction, transparency, and anti-aliasing.

For my numerically intense application, a switch to the JVM back end for Rakudo yielded approximately a five-fold performance increase. Though I haven't yet started a formal set of benchmarks, it seems obvious for now that using JVM instead of Parrot is the way to go if you need higher runtime performance (unless you rely heavily on certain string operations, which I'm told is one of Rakudo JVM's remaining soft spots, along with lack of a native call interface). JVM is also the only Rakudo back end to support multithreading at the moment.

I would have saved myself a lot of rendering time over the past couple weeks if I had paid more attention to JVM when I began. I'm hoping these notes prove helpful to anyone else who may attempt heavy math or runtime-intensive algorithms in Perl 6 as it exists today.


Nov. 24, 2013
Progress and Plans

What a week! Pray is off to a somewhat slower start than I had hoped. In trying to accomplish something with my spare time, I have discovered that I don't have as much as I thought I did. In spite of the car breaking repeatedly and an (unrelated) emergency room visit, I have pressed on, albeit not at the intended pace. But enough excuses.

Here is a rendering from last night, mainly showing lighting improvements. Since the last update eight days ago, besides learning much more Perl 6, reporting bugs, submitting a patch to a module, and entirely rewriting the initial Pray proof-of-concept script as a collection of classes and modules, many functional improvements have been made. I hope to be putting it on GitHub in the near future.

Scene description files now exist and use JSON syntax. The camera direction is defined as an objective point and calculates the angles automatically. The lighting model has come a long way towards satisfying some initial definition of "done". It now supports properly positioned light sources, instead of manually hacked-in directional vectors. Multiple lights are supported. Changes to the lighting model improve shading and pave the way for future experiments with HDR, more exotic lighting algorithms, other colorspaces, and more.

Several things are still needed for the initial release. Scene file support is incomplete and command-line parameters don't exist yet. Documentation needs to be at least started in the form of some sparse comments, a README, and --help. Tests would be nice too, but may be added later. Of course an empty toybox doesn't make anyone happy, so a few different primitives to play with, and more lighting improvements including material definitions, color, basic shadows, reflection, transparency and refraction are all on the to-do list before release.

Longer-term ideas include more output formats (PNG), boolean geometry, texture mapping, bump mapping, POV-Ray scene file support, animation, a more extensive API for integrating Pray rendering into other projects, and possibly more ambitious things like a GUI scene designer. I haven't done any real profiling yet, but there's sure to be a lot of room for optimization, too, which I expect to be an ongoing process throughout the life of the project. In the bigger picture beyond Pray, many parts of it will be easily converted into general-purpose Perl 6 modules once they are mature.

In short: lots to look forward to! Stay tuned...


Nov. 16, 2013
Prior Art

thundergnat pointed out that there are also a couple of Perl 6 ray tracings on Rosetta Code here and here, for anyone interested.


Nov. 15, 2013
Pray is Reborn

Pray is a Perl 6 rewrite of a Perl 5 ray tracing engine which I worked on occasionally over the course of several years for education and entertainment. Some renderings from the old version can still be seen.

Whether or not this project will result in a practical, competitive rendering engine is simultaneously debatable and irrelevant. It is meant to serve as not only a personally engaging and rewarding learning process, but also a contribution to the Perl 6 effort in various forms, such as authoring modules, publishing benchmarks, or perhaps documenting the experience in articles or a blog. Not to mention pretty pictures of geometric solids, so everyone can see how shiny Perl 6 is.

Grand schemes in the nebulous future aside, I present the humble first fruits of this labor: what may or may not be the first pure Perl 6 ray traced rendering on the entire Internet.

Pray, like my understanding of Perl 6, is still in its infancy. The code will be released once it has matured enough to do more good than evil in the world.

Last updated on Sun Mar 2 2014. Copyright © 2014 CyberUniverses. All rights reserved.