adrian's soapbox

Tag: Technical Writeup

Raymarching Distance Fields: Concepts and Implementation in Unity

Raymarching is a fairly new technique used to render realtime scenes. The technique is particularly interesting because it is entirely computed in a screen-space shader. In other words, no mesh data is provided to the renderer and the scene is drawn on a single quad that covers the camera’s field of vision. Objects in the scene are defined by an analytic equation that describes the shortest distance between a point and the surface of any object in the scene (hence the full name Raymarching Distance Fields). It turns out that with only this information you can compose some strikingly complicated and beautiful scenes. Further, because you aren’t using polygonal meshes (and are instead using mathematical equations) it is possible to define perfectly smooth surfaces, unlike in a traditional renderer.


Snail by Inigo Quilez was created entirely using raymarching. You can find more examples of raymarched scenes on Shadertoy.

This article will first discuss the fundamental concepts and theory of raymarching. Then it will show how to implement a basic raymarcher in the Unity game engine. Finally it will show how to integrate raymarching practically in a real Unity game by allowing raymarched objects to be occluded by normal Unity GameObjects.

You can find a complete reference implementation at this Github Repository.
» read more


Bunnyhopping from the Programmer's Perspective

"Bunnyhopping" is an exploit of a very popular bug in games like Quake III Arena, Half-Life, and Counter-Strike. Bunnyhopping, or bhopping for short, allows a player to exceed the game-defined speed limit. It has created entirely new methods of play and allows very exciting, fast-paced emergent gameplay. As a decidedly skill-based mechanic, competitive players love bhopping because it is so hard to master. Thus, it may be useful to you as a game developer to "implement" bunnyhopping into your game. The purpose of this article is to define what bunnyhopping is, why it is important to consider as a game developer, and how to implement it mathematically into your FPS movement code. All code examples are open-source and free to use, as always.

This is what bunnyhopping looks like in-game to a skilled player:

One Example of Bunnyhopping in Counter-Strike: Source (Source)


» read more

Implementing Skyward Sword's Timeshift Stones in Unity

Nintendo is well-known for its polish and excellent use of resources, even while using the relatively underpowered Wii hardware. They often develop game mechanics with this in mind, and this limitation brings out some of Nintendo's true genius in game design. One of my favorite mechanics that take advantage of the hardware like this are the so-called timeshift orbs in The Legend of Zelda: Skyward Sword. Essentially the idea behind these is that the timeshift orbs take everything in a radius around it and send it "back in time" like so:

Zelda's Timeshift Orbs

While this effect seems complicated at first, it is actually pretty simple to implement with a shader.
» read more


Understanding Perlin Noise

The objective of this article is to present an easy-to-understand analysis of Ken Perlin's Improved Perlin Noise. The code in this article is written in C# and is free to use. If you would prefer to just look at the final result, you can view the final source here.

Perlin Noise is an extremely powerful algorithm that is used often in procedural content generation. It is especially useful for games and other visual media such as movies. The man who created it, Ken Perlin, won an academy award for the original implementation. In this article I will be exploring his Improved Perlin Noise, published in 2002.
» read more