Making of RiverScape

Introduction

RiverScape is an executable of 3 332 bytes that produce the image above in less than 30 seconds of computing. It was released at Revision 2023 and ranked 2nd in 4kb executable graphics compo.

Since I used some well know tricks by Demosceners, I will try to cover "the original part" in this article. To me the goal here is that you will understand the process easier than by reading the code in ShaderToy :). I assume you know what an SDF is and you know well how to raymarch it.

Path tracing

A few months ago, I began my path tracing journey by conducting various experiments on ShaderToy (see below). Although it can take a considerable amount of time to compute, the quality of rendering achieved through this technique is truly remarkable. It appears to be an ideal choice for a 4kb graphics executable.

If you want to learn more about path tracing, I recommend you the great series of articles by Alan Wolfe and of course the one from Inigo Quilez.

At the beginning, my main motivation was to try the famous ReStir algorithm to get out of noisy results faster. But I finally didn't take the time to go in depth with this technique and enjoyed writting basic path tracer and play with it.

Disney BRDF Disney BSDF

Water

The shape are a basic sums of : abs( sin( noise(p * frequency) ) ) * amp;

With path tracing, creating a realistic water surface is a straightforward process. As a ray touches the surface of the water, its direction is determined by either refracted or reflected rays, depending on the Fresnel effect. Additionally, when the ray travels underwater, it gets absorbed, resulting in the characteristic blue color.

Water schema

Rock

For quite some time now, I've had a strong inclination towards creating realistic renderings of rocks. I've invested significant effort into writing various shaders for this purpose, but unfortunately, none of the results have fully met my expectations.

La Calanque Niolon Malmousque

In 2022, I had the opportunity to live in a van and travel across the breathtaking landscapes of Europe. During my journey, I came across a plethora of distinct rock formations in their natural habitat. It was then that I realized the limitations of using only fbm (fractal brownian motion) for creating compelling rock shapes.

Real rock

I really enjoyed some "sliced rocks" I saw in Sicily, and started to write some code to slice any SDF.

Slice operator

This was nice but you need a good "base shape" to get something interesting. I remembered that I had pretty good results of rocks rendering with a rotated Mandelbox some times ago. So I decided to start here :

WIP0

Then adding details with the "slices operator" at some places.

WIP1

I was pretty happy with the left side of the geometry but definitely not with the right one. So I decided to mix an fbm with the rotated mandelbox to get something more close to rocks.

WIP2

Adding the water described above and bump mapping to the rock:

WIP3

After that I added some "purple moistures" that we can found in nature, at the edge between rocks and water. Kayaking is the key to see this kind of stuff! The last addition was to make the area near the water darker. Because of the ocean waves and the sun, the rocks looks always darker where it's wet.

WIP4

And so, after a lot of tweakings, coloring, rendering, you get this final image.

WIP5

But still, this is far from being photorealistic, I need to find other tricks in the futur!

Greetz

Thanks to Laura Cohen, who has the "artistict vision" that I don't have :).