Different levels of tessellation. |

I ended up creating an procedurally created and animated landscape using the image.

To create the landscape I tesselated a simple plain to have enough vertecies available for the displacement later on. I wanted the scene to have a retro-wavy style, with synthy music and 3D wireframe models. Luckily Unreal Engine 4 comes with wireframe shading capabilties right out of the box.

Based on the image by Abe Pazos, we get two masks. The Glow mask indicateds where we want the terrain to be animated (unfortunate naming xD). The Terrain Mask indicates where we want the terrain to be extruded but not animated. We actually use these two mask to indicate where the terrain should glow as well. Additionally we sample noise from a noise texture. Different noise texture will yield different effects. You could also use procedural noise.

Material settings. | Texture setup. |

The material focuses on three values, calculating the base color for the wireframe edges, figuring out which part of the mesh should glow and where the mesh should be deformed. Below you'll find the shader formulated in Unreal's node based shader graph.

Material graph / shader. |

First we move a noise texture via uv panning. Then I mask the noise values with the red and the blue channels [_{1}] of the glow map.

These mapped noise values give us the overall shape of the animated part of the terrain. To add height variance in the animation we sample the game time and use it generate a sine wave. Because we are only interested in values between 0 and 1 we mirror the negative part of the sine wave along the x axis. The tricky part now is to extrude the terrain in relation to the planes surface. This is archived by scaling the product of the sine wave and masked noise values for red and blue channel with the normal vector of the vertices of our surface in world space. For the static terrain we basically do the same, only difference being that the terrain mask is sampled instead of the animated noise. Those three values will then be added together and used as information on how much the mesh should be displaced at any give uv coordinate. To allow for maximum effect, we use a tessellation factor of 16. In the video below you see the impact different levels of tessellation have on the terrain.

Different levels of tesselation. |

To emphazise the retro-wavy style a bit more, we simply work with the lighting to change the base colors appearance in the scene. This then later gets combined with the emissive / glowing values and results in the final color. For an extra bit of detail, we position the light so that the animated parts of terrain self-shadow other parts of the terrain. In my opinion, this gives the effect much more impact.

Glowing parts (blue is not glowing). | Base color. | Everything combined + lighting. |

After setting up the scene and material, we now just have to tweak the values a bit to fit the aesthetic and music [_{2}]. Now when the sphere is moving through the game world, you'll actually be able to figure out the direction from which the audio is originating. This works both in the VR and non-VR version - if you wear headphones.

Actually values for the material. |

As you can see in the preview of the material instance editor, the material looks rather interesting when mapped on a sphere. We simply place a sphere into the world, assigning it the same material as the plane and attach an audio source to it [_{3}]. Now when moving the sphere through the scene, we will actually be able to figure out from where the sound is originating. This works with both the VR and non-VR verions - if you wear headphones.

Head over to ich.io to download and try the experience for yourself. |

I would love to hear your thoughts! If you want to get in touch, consider following me on twitter @blurryroots or sent me an e-mail.

You might also be interested in these posts:

Also have a look at this project, using Unreal Engine to create a music video.

In this setup I am using 4 textures to archive this effect. Because the glow mask is only using the red and blue channel, we could pack the terrain mask into the green channel and the noise map into the alpha channel - effectively reducing the texture count to two.

I did actually not use any form of beat detection (just the moving noise and the sine wave) to animate the terrain. I was curious how much I could get away with and still convey the feeling of synchronicity (and maybe a teensy bit of lazyness xD).

This project uses binaural audio after the cutscene part. It basically approximates how human hearing works to play back audio placed within the 3D world.

]]>There is no reference implementation as of yet, so the concept is pretty much hypothetical.

Preview of the paper | Download |

The initial version has been written in September of 2016 as part of a one of my studies subjects. In early 2017, I revised the paper and decided to submit it to a journal or conference, to see what the community had to say about it. In May, I submitted the paper to be considered for the 2017 conference of computational intelligence and games (CIG). Although the paper has not been accepted, getting feedback from experts in the field was very helpful. Below you can read what the assigned reviewers had to say about the content of the paper.

The review has been single blinded. So the reviewers have been anonymized, but they had my name. Personally I was expecting a double-blind review. Although some effects based on the authors prestige have been observed when using single-blind reviews, I guess there are arguments to be made for either system. To come to a conclusion after the reviews are made, each evaluation is given a score - negative for rejection, positive for acceptance. My score came out at a total sum of zero.

*This paper describes an agent architecture that essentially is a large conglomerate of components like many known agent architectures (although missing components like a learner, relying instead only on memory without analysing it). There is no report on any implementation of this architecture and therefore naturally also no evaluation of its usefulness.*

*I have many problems with the architecture and the paper. First, the amount of citations of non-peerreviewed "sources" is the largest I have ever seen in a paper (and this includes full papers). Just looking at the introduction reveals viewpoints that for sure are not shared by the AI community (at least by anyone who ever looked at automated theorem proving) and, rather frankly, made me question myself if I should continue reading this paper. Since it is my duty to continue I did and was "rewarded" by many other pieces that never were seriously evaluated (like [23] and [24]). On the other side, there are many (real) papers that would have been of relevance that are not mentioned. An example is*

*Donaldson T., Park A., Lin IL. (2004) Emotional Pathfinding.
In: Tawfik A.Y., Goodwin S.D. (eds) Advances in Artificial Intelligence.
AI 2004. Lecture Notes in Computer Science, vol 3060. Springer, Berlin, Heidelberg*

*which represents a much more reasonable way how to integrate emotions into the decision making of an agent.*

*This highlights another big problem of the paper: the title claims that the paper is about moral behavior, but it addresses morality only as a component of the architecture that is mentioned in one sentence. There is much more fuss about emotions (hence my selection of the above citation). I also do not see a precise description of the utility system
(by the way, utility is usually at the core of every rational decision making, but there are many different functions that can be used to measure utility, so that a precise definition is always needed when this term is used). And, naturally, there was no exploring of anything going on in this paper. So, the title is highly misleading.*

*If we add to that obvious problems with citations in the text (often the placeholder "Author" is used) then this is a paper that should not be accepted, even as poster.*

*This paper outlines a framework to create behaviour, particularly moral behaviour, with a model that takes context, experience, emotions and relationships into account. The work makes reasonable references back to appropriate literature, and provides a sketch of how such a framework should be set up. Figure 1. looks understandable, but the brevity of the paper results in a lack of implementation details. (which is to be expected from a short paper).*

*It is a bit unclear if this framework is a design proposal, or has actually been implemented. It would definitely be nice to see something like that in action, or interact with. It would be interesting to hear a talk about this.*

*I am a bit doubtful though, if this kind of approach can overcome the framing problem. There is a lot of talk about context here, and emotions and relationships, but are these actually generically grounded in experience, or are they all based on predefined rules. In other words, is there a list of situations where the agent feels anger, a list of criteria, or is this something that somehow derives from its perception. The question basically comes back to how this approach would deal with previously unseen experience, or an interaction not anticipated by the game designer. But this is more a comment, than a critique of the current paper, as this seems to be a rather general problem.*

*This is a solid conference paper. The paper is well-written. The work is rather incremental. Comparison against other similar works is limited. The paper is borderline to weak accept and thus i propose weak accept.*

*This paper presents a very generic agent architecture that includes an affective layer. The paper clearly attempts to do a whole lot of different things - the related work, while extensive for a short paper, covers a number of different areas. It is not entirely clear what specific problem this architecture attempts to solve, or which new capability it tries to provide that is not covered by existing architectures. On top of this, it seems that the architecture is not implemented yet, and certainly not evaluated. While short can report on work that's not quite finished yet, it would be expected that the work is a bit better motivated and more specific. As it is, I don't think this paper is of publishable quality.*

The Superformula is based on the the concept of superellipses. The original form is in polar coordinate. The snippet below shows how you convert those into points to

]]>The Superformula is based on the the concept of superellipses. The original form is in polar coordinate. The snippet below shows how you convert those into points to use on a 2D canvas.

```
var rpart = (this.m * angle) / 4;
var apart = Math.abs (Math.cos (rpart) / this.a);
var bpart = Math.abs (Math.sin (rpart) / this.b);
var r = Math.pow (
Math.pow (apart, this.n2) + Math.pow (bpart, this.n3),
-1 / this.n1
)
var x = Math.cos (angle) * r;
var y = Math.sin (angle) * r;
```

- a (m=3, n1=14, n2=6, n3=21)
- b (m=8, n1=-12, n2=52, n3=4)
- c (m=10, n1=-6, n2=6, n3=-1)
- d (m=21, n1=9, n2=5, n3=16)

Each of the numbers corresponds to a parameter fed into the formula, called (in order left to right) *m*, *n1*, *n2* and *n3*. The first parameter *m* is used to give the shape edges. So if you set it to 0 you basically get a circle. The outer parameter *n1* inceases the shape a general *roundness*. Lastly *n2* increase the weight of the cosine part of the formula, while *n3* increase the the weight of the sine part. There are also two additional parameter *a* and *b*. These are used to change the symmetry of the shape. In the example above they are both set to 1.

I also wrote a little web tool to generate supershapes. You can download it here.

If you're interested in how it works, you can stare at some code here.

Want to see some supershapes in action? I wrote a little shader over at shadertoy.

]]>The code and a demo project can be found on github. You can read the abstract and summary here or take a closer look for yourself. I included a copy of the thesis in the repository.

In the context of video games Procedrual Content Generation (PCG) has shown interesting, useful and impressive capabilities to aid developers and designers bring their vision to life. In this thesis I will take a look at some examples of video games and how they made used of PCG . I also discuss how PCG can be defined and what misconceptions there might be. After this I will introduce a concept for a modular PCG workflow. The concept will be implemented as a Unity plugin called Velvet. This plugin will then be used to create a set of example applications showing what the system is capable of.

The basic idea for Velvet has been heavily inspired by an article by Dejobaan Games on gamasutra. It describes the concepts and systems they used to generate content within their series of AaaaaAAaaaAAAaaAAAAaAAAAA!!! base jumping games.

I guess you could best compare the concept to Unix pipelines. You create modules with specific responsibilities. Each module then accepts data and returns data in the same way. This allows modules to be arranged in a sequential order. This is called a chain in Velvet. The special thing here is, that a chain is also considered to be a module, which allows for a tree-like structure of modules. This idea is based on the composite design pattern.

For the prototype I made use of Unitys scene graph. A chain is basically represented by a game object and the modules would be the components associated with this object. You can then nest game objects creating your recipe for what ever content you want to generate. The type of data processed by modules can be any type (generically typed). Although the examples only use a list of game objects as the basic type of data processed by modules.

I would love to hear your thoughts. If you want to get in touch and talk about PCG, consider following me on twitter @blurryroots or sent me an e-mail!

You might also be interested in these posts:

]]>Disclaimer ^{1}

The relation of two things is, such that the ratio of A plus B to A is the same as A to B.

```
function isGoldenRatio (a, b) {
var x = (a + b) / a;
var y = a / b;
// check if 'almost' equal, avoids floating point errors
```

]]>Disclaimer ^{1}

The relation of two things is, such that the ratio of A plus B to A is the same as A to B.

```
function isGoldenRatio (a, b) {
var x = (a + b) / a;
var y = a / b;
// check if 'almost' equal, avoids floating point errors
return (x - y) < Number.EPSILON;
}
```

Well, if I were to construct a rectangle, such that its length is 1, which height value would be necessary to result in a golden ration?

Let's start by solving the equation describing the golden ration for b.

In order to get rid of a, I assume it to be equal to 1.

```
// when assuming a = 1
((1 + b) / 1) == (1 / b)
// we're able to simplify this to
(1 + b) == (1 / b)
```

To find a value for b, I try to rearrange the equation so it can be solved as a quadratic equation.

Because b is in the denominator, I have to assume it is never 0.

```
// assume b != 0
b * (1 + b) == 1
// expanded
b + (b * b) == 1
// and subtracted by 1
b + (b * b) - 1 == 0
// and flipped
0 == (b * b) + b - 1
```

Now I determine the p and q values of the equation.

```
0 == p * (b * b) + q * b - 1
```

This gives me p = 1 and q = -1

Now I can start solving the equation to find its root.^{2}

```
// base equation
x1 = -1 * (p / 2) + sqrt(pow((p / 2), 2) + 1)
// with my values I get
x1 = -1 * (1 / 2) + sqrt(pow((1 / 2), 2) + 1)
x1 = -1 * (1 / 2) + sqrt((1 / 4) + (4 / 4))
x1 = -1 * (1 / 2) + sqrt(5 / 4)
x1 = -1 * (1 / 2) + sqrt(5) / 2
x1 = (sqrt(5) - 1) / 2
```

So b turns out to be defined as:

```
b = (sqrt(5) - 1) / 2
```

Assuming a = 1 and b ~ 0.618, I now have a valid set of values to meet the rules of the golden ration.

But what is the actual ration between a and b in this case?

Let's have a look.

Assuming my values are:

```
a = 1
b = (sqrt(5) - 1) / 2
```

I now search for the ratio phi, between a and b.

```
phi = 1 / ((sqrt(5) - 1) / 2)
```

I could now try to simplify this. But let's have a look again with what I actually started.

Because of my inital assumption of a = 1 I got:

```
(1 + b) == (1 / b)
```

So I could write phi like that.

```
phi = 1 + ((sqrt(5) - 1) / 2)
```

Which is much nicer in my opinion.

If I now try to simplify this, I get:

```
phi = (2 / 2) + ((sqrt(5) - 1) / 2)
phi = (sqrt(5) - 1 + 2) / 2
phi = (sqrt(5) + 1) / 2
```

And there I have it.

The golden ratio is `(sqrt(5) + 1) / 2`

or roughly `1.618`

So this yields an interesting relation.

If I subtract the one I just added I get the same value described by the inverse of phi, which is the same value we calculated for b.

This means the inverse of phi is the same as phi minus 1.

```
phi - 1 == 1 / phi
```

If you plot those two graphs you get this wonderful graph.

If I now start with this relation, I can deduce other very interesting relations.

Phi minus the inverse of phi is 1.

```
phi - 1 == 1 / phi
1 == phi - (1 / phi)
```

The square of phi minus phi is 1.

```
phi - 1 == 1 / phi
1 == (phi * phi) - phi
```

Or in turn, phi squared minus one, is again phi.

```
1 == phi * (phi - 1)
phi == (phi * phi) - 1
```

From here I can show that the square of phi is equal to phi plus 1.

```
(phi * phi) == phi + 1
```

It is also possible to show that the square root of phi plus 1 is actually just phi. Amazing ;)

```
phi == sqrt(phi + 1)
```

It it also possible to build a 3rd degree polynomial[^3] in a rather pleasing way.

```
1 == (phi * phi) - phi
phi == phi * ((phi * phi) - phi)
phi == (phi * phi * phi) - (phi * phi)
0 == (phi * phi * phi) - (phi * phi) - phi
```

Another nice form would be

```
(phi * phi * phi) == (phi * phi) + phi
```

Which when plotted, looks like this.

I the next post in this series, I will take a closer look at functions which can be build from the rule set of the golden ration and what possible applications there are.

In the mean time, you might want to check out the silver ratio or read about recreational mathematics.

These are just some random thoughts on the golden ration. Why? Just for fun, and because of my strange fondness for this particular number. So please bear with me if my mathematical approaches are not as sophisticated as they possibly could be ;) ↩

Null, or zero point ↩

Also known as cubic equation ↩

- Talk by Grant Duncan (Hello Games) about pcg in No man's sky
- Talk by Sébastien Dubois (Amplitude Studios) about pcg in Dungeon of the Endless
- Article by developers

- Talk by Grant Duncan (Hello Games) about pcg in No man's sky
- Talk by Sébastien Dubois (Amplitude Studios) about pcg in Dungeon of the Endless
- Article by developers at Dejobaan about a modular approach to pcg in their AaaaaAAaaaAAAaaAAAAaAAAAA!!! series
- Tutorial on procedural room/cave generation
- Tutorial on procedural cave generation using cellular automaton
- Talk by Zach Aikman (17-Bit) on procedural dungeon generation in Galak-Z

So far I have found two major factors making

]]>So far I have found two major factors making this concept a considerable problem. Firstly, you obviously want your player to be able to finish your level. It would be no good if you're supposed to open a door with a key, which is unfortunatly placed behind said door and therefore unreachable. Secondly, you want to ensure that your level isn't completely stuffed or looking abandoned and empty. The generator should also produce level designs, which are consistent with the mechanics, asthetics and flair of your game.

Imagine doing all of this in a game which tries to do turn-based stealth combat. There is an awesome talk by one of the developers of Invisible Inc. explaining how they might have done exactly that.

There are quite a few solutions for solving the problem of making a level playable from start to finish. In a blog post by the creator of Jack Benoit, he explains how he generated a level based on perlin noise and filled it with a guaranteed path for the player to find. The path had to satisfy a set of constraints, e.g. the height the player can jump.

If you take this principle and combine it with techniques used in artificial intelligence, namely constraint programming you end up with a very powerful tool, to describe your level generator. There is a paper from 2012 describing an application of said techniques.

I stumbled upon a very interesting approach to ensure a certain 'feeling' for your generated levels. It is called a rhythm based algorithm. With it you can model a certain rhythm in which the player traverses through your level. As far as I understand, you basically model or generate a movement rhythm, consisting of different states like waiting, moving, and jumping. This is then fed into a geometry generator, which in turn calculates a level layout with things like springs, placed according to the 'feel' represented by the movement rhythm.

Another interesting approach is also inspired by rhythm. You generate a start and end platform and let the solver choose a set of patterns, constricted by the physical capabilities of the player's character using a simple hill-climbing algorithm. If you happen to be interested in hill-climbing, or artificial intelligence for that matter, I would recommend checking out the video by computerphile about the basics of this algorithm, as well as some information about artificial intelligence in general.

There is a great paper doing a comparision of different generation algorithms, which also refers to some of the approaches mentioned in this post.

Well I hope you'll enjoy reading the linked material as much as I did. I may update this if I come across more awesomeness which is procedural level generation.

*Further reading*:

Looks promising so far.

More content coming soon*ish*.

You can subscribe to this blog via RSS, if you want to get notified when stuff is happening.

Stay tuned!

]]>Looks promising so far.

More content coming soon*ish*.

You can subscribe to this blog via RSS, if you want to get notified when stuff is happening.

Stay tuned!

]]>