piter pasma
universal rayhatcher
interview
Code is Data: An Interview with Piter Pasma

Code is Data: An Interview with Piter Pasma

written by The Angels' Win...

09 Jun 2023200 EDITIONS
2 TEZ

This article is based on an interview Piter Pasma did with The Angels’ Wing on May 23rd 2023. That episode is available on YouTube, Apple Podcasts, Spotify and the other podcast platforms. By collecting this article you support our ability to produce content and bring you great interviews like this one. Thank you!

project name project name project name

Code is Data and Data is Code

Piter Pasma's latest generative art project, Universal Rayhatcher, leverages the newly launched fx(params) support that give minters more control over the generative art outputs. Discussing the origin of the project, Piter recalled his initial reaction to the fx(params) framework. "I was a little bit frustrated with how everything worked at first, and I wasn't sure whether any of it would be a good idea", he confessed.

The complexity of parameter selection often contains a web of inter-dependencies between different parameters and random distributions. Traditional slider-based systems often fail to capture these nuances, he said, and added "In high-dimensional spaces, the chance that you hit a nonsense part of the space is actually quite big."

Piter's frustrations sparked a quest for a more adaptable approach to fx(params). His solution? Incorporating code as a parameter. In the case of Universal Rayhatcher, the code is the main parameter that the minter has to input. Code is the best kind of parameter because "Code is data and data is code", as Piter put it. This makes it a very flexible project, able to produce any kind of output that can be expressed using the code parameter.

The term 'Universal' in the project title, as Piter revealed, is also a nod to the theoretical 'Universal Turing Machine', which represents an ideal computer in computing science.

The Universal Rayhatcher builds upon Piter's previous work with his rayhatching algorithm, used in his projects Industrial Devolution, Nanopanorama and Geomorphism. The projects shared functional similarities, with differences primarily in the signed distance functions (SDFs) that defined their shapes. This observation motivated Piter to unify and generalize the code in preparation for what became the Universal Rayhatcher project.

project name project name project name

Signed Distance Functions (SDFs)

In Universal Rayhatcher the main parameter is a line of text, up to 512 characters, which is the formula for the SDF to be rendered using the rayhatching framework. This allows artists to create arbitrary 3D scenes based on mathematical formulas. To get started with SDFs, it helps to understand how they work in the rayhatching framework and how to combine them.

Explaining the basics of SDFs, Piter said, "An SDF always gives the closest distance to the nearest surface. And if you have two shapes, two SDFs, and you want to combine them, you have to take the minimum of those two functions to get the closest distance to either of the shapes." Universal Rayhatcher has allowed many in the gen art space to experiment with these core concepts.

On the topic of merging shapes, Piter shared further insights into the use of SDFs. "When you take the maximum of two SDFs, this creates the intersection. This is the space where both shapes overlap. For modeling purposes, you want to take the maximum of one shape and the negative of the other shape. What this does is called a subtraction. You can cut a spherical hole out of a box, for instance, if you want," he added.

project name project name project name

Painting with Math

The Universal Rayhatcher Project, guided by the intricacies of SDFs, has empowered artists to produce a vast spectrum of distinctive and diverse artistic outputs, showcasing an impressive breadth of creativity. In the interview Piter detailed some of the techniques artists have used to make individual pieces. Discussing Elsif's piece "fren", he explained, "I've got a bit of background in cartoon drawing and I immediately spot that the bear head is made out of two ellipses. The main sphere for the head and a flattened sphere for the snout. Plus another little thingy for the nose. I think she makes eye socket holes by first cutting out spheres and then putting spheres into the leftover holes again, so that they're not dark, soulless eyes, but cute little teddy bear eyes." And Piter added, “It's really one of my favorite pieces from the entire set as well. It's definitely the first one that completely blew me away.

project name project name project name

Piter encourages artists to focus on the visual output of these functions rather than becoming overwhelmed by their mathematical details. "I can recommend everybody to use the website graphtoy.com by Inigo Quilez. It's a great website to explore the graphs of functions. And it's got a lot of built-in functions similar to my framework." Piter suggested. "So it's really not that you have to remember, what are all these functions for? It's more that you have to remember, what do they look like?"

Understanding the concept of SDFs offers artists a powerful tool to create complex 3D renderings. As Piter Pasma has shown, through manipulation and combination of these functions, an endless array of shapes, scenes, and objects can be realized.

Arbitrary Code Execution

When allowing a multitude of creators to input code at will, security becomes a paramount consideration. Piter expressed a deep consciousness of these concerns during our discussion.

Yes, I am concerned with this idea and I spent a lot of time preventing this from happening,” he said, directly addressing the issue of potential malicious code. To safeguard the integrity of the project, Piter has implemented a rigorous filtering system that limits user inputs to a strict list of acceptable mathematical functions and variables.

In the process he recalled a challenge from his programming past: "JavaScript is quite a tricky language. I remember that there was a thing called JSFuck, named after the esoteric programming language brainfuck which is a language that consists only of, I think six or eight characters. JSFuck, which is a similar idea, is a way to execute arbitrary JavaScript code using only a limited set of symbols, like eight characters. No letters, just square brackets, braces, plus, minus - just your regular JavaScript symbols. And with that you can construct any code whatsoever.

"Code is data. Data is code," Piter mused again, highlighting the inseparable relationship between the two and how it can be exploited. However, he found a way to avoid this by ensuring that SDFs only deal with numbers and not strings. By disallowing string constructions, he closed the door for arbitrary code. His ingenious solution was to overwrite the `toString()` method in the prototypes of JavaScript's basic types, causing it to throw an error if any object attempts to convert to a string.

"I wouldn't have released Universal Rayhatcher if I wasn't fairly sure about that last trick with overwriting the `toString()` prototype," Piter confessed, demonstrating his commitment to safety. His openness about the coding challenges he faced, and the solutions he found, provide assurances to both artists and collectors that Universal Rayhatcher mints are safe to open and run in the browser. As you would expect, people have tried to find loopholes as well. “Ciphrd, the founder of fx(hash), spent all evening trying to break out and it didn't work”, Piter shared.

Incredible Diversity of Outputs

The reception and creative use of Piters project by the community has been great to observe and take part in. Despite not initially aiming for an educational outcome, the project has taken on a pedagogic role, introducing many to the magic of SDFs. "People are using it in ways I hadn't expected," Piter commented, referring to the fascinatingly diverse and sometimes perplexing ways the community has been engaging with the code. From seemingly nonsensical loops to intricate arrays with an abundance of arguments, the project has birthed a variety of SDF-based art forms, some of which even carry hidden messages.

Piter was especially taken aback when an artist coded his name into their piece. "At first, I was like, 'how did he do that?' Because neither the word Piter nor Pasma is in the allow list and should go through the validator. And then it turned out that you can in fact use arbitrary words in the index of the repeat macro, and that's where he put ‘Piter' and 'Pasma’."

Another heartening experience was when an artist wrote a message of thanks into their code. Piter expressed, "It's not the picture, it was the message that counted there."

While acknowledging the complexity of decoding SDFs not written by him, Piter was quick to appreciate the creations made by other artists, like those by StrangerintheQ: "The stuff made by Stranger was exactly the kind of stuff that I hoped people would be doing with the Universal Rayhatcher."

project name project name project name

Throughout our conversation, it was clear that Piter was both grateful and pleasantly surprised by the inventive ways people have embraced the project. His reflections on their artistry not only showcased the uniqueness of each creator's approach but also underscored the project's wide-ranging impact. The way artists have creatively, effectively, and sometimes unexpectedly leveraged the Universal Rayhatcher project has been amazing to witness.

stay ahead with our newsletter

receive news on exclusive drops, releases, product updates, and more

feedback