Featuring: Fractals
Featuring: Fractals is a installation that contains an exploratory project used to display fractals. Fractal scenes are explored and interacted with using gamification unique to VR.
My goal is to push forward the progression of which the user experiences fractals in unique ways via wearable technology and educate people on the beautiful nature of fractals: geometric, natural
It is my goal to pioneer wearable technologies that enable users to experience fractals in unique ways and to educate them about the beauty of fractals: geometric, natural, and ethereal.
The aspect of Virtual Reality as a wearable, immersive tool, has incalculable potential to give artists and game developers unlimited ways to express themselves creatively inside a 3D space. In this project, the user will experience and interact with a variety of fractals in a 3D space using immersive mechanics such as: climbing, picking up objects, and shooting bow and arrows.
The Mandelbrot Set
The Mandelbrot fractal is a famous mathematical object that is named after the mathematician Benoit Mandelbrot. It is created by iterating a complex mathematical function over a set of complex numbers. The resulting pattern is a set of points in the complex plane, where the points that remain bounded under the iteration of the function are part of the fractal. The Mandelbrot fractal is known for its intricate and infinitely complex structure, which has been studied extensively in the field of mathematics. It is also widely used in computer graphics and other applications.
Creation tutorials
I created in unity the Mandelbrot set and this is the code that I used to make the shader.
Shader "Explorer/mandelbrot"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Area("Area", vector) = (0, 0, 4, 4)
_MaxIter("Iterations", range(4, 1000)) = 255
_Angle ("Angle", range(-3.1415, 3.1415)) = 0
_Color("Color", range(0,1)) = .5
_Repeat("Repeat", float) = 1
_Speed("Speed", float) = 1
_Symmetry("Symmetry", range(0,1)) = 1
}
SubShader
{
// No culling or depth
Tags {"RenderType" = "Opaque"}
Cull Off ZWrite Off //ZTest Always - zhan removed this line
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
float4 _Area;
float _Angle, _MaxIter, _Color, _Repeat, _Speed, _Symmetry;
sampler2D _MainTex;
float2 rot(float2 p, float2 pivot, float a) {
float s = sin(a);
float c = cos(a);
p -= pivot;
p = float2(p.x*c - p.y*s, p.x*s + p.y*c);
p += pivot;
return p;
}
fixed4 frag (v2f i) : SV_Target
{
float2 uv = i.uv - .5;
uv = abs(uv);
uv = rot(uv, 0, .25*3.1415);
uv = abs(uv);
uv = lerp(i.uv - .5, uv, _Symmetry);
float2 c = _Area.xy + +uv * _Area.zw;
//xyzw bringsa the original area to -2 and 2..m makes the whole mandelbrot fractal visible
c = rot(c, _Area.xy, _Angle);
float r = 20;//escape radius
float r2 = r * r;
float2 z, zPrevious;
float iter;
for (iter = 0; iter < _MaxIter; iter++) {
zPrevious = rot(z, 0, _Time.y);
z = float2(z.x*z.x - z.y*z.y, 2 * z.x*z.y) + c;
if (dot(z, zPrevious) > r2) break;
}
if (iter > _MaxIter) return 0;
float dist = length(z); //distance from origin
float fracIter = (dist - r) / (r2 - r); //linear interpolation
fracIter = log2(log(dist) / log(r));//double exponential interpolation
//iter -= fracIter;
float m = sqrt(iter / _MaxIter);
float4 col = sin(float4(.3, .45, .65, 1)*m*20)*.5+.5; // procedural colors
col = tex2D(_MainTex, float2(m*_Repeat +_Time.y* _Speed, _Color)); // used this line of code to choose from the rain bow texture that i added
float angle = atan2(z.x, z.y); // -pi and pi
col *= smoothstep(3, 0, fracIter);
col *= 1 + sin(angle * 2 + _Time.y * 4)*.2;
return col;
}
ENDCG
}
}
}
Variables can be adjusted within Unity
Code for Mandelbrot zoom and interaction mechanics
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Explorer : MonoBehaviour
{
public Material mat;
public Vector2 pos;
public float scale, angle;
private Vector2 smoothPos;
private float smoothScale, smoothAngle;
private void UpdateShader()
{
smoothPos = Vector2.Lerp(smoothPos, pos, .03f);// each time it gets to hree, itll update smoothpos to be 50% closer to non smoothpause. will go half way towards distance. smooth pos will follow remaining pos
smoothScale = Mathf.Lerp(smoothScale, scale, .03f);
smoothAngle = Mathf.Lerp(smoothAngle, angle, .03f);
smoothScale = Mathf.Lerp(smoothScale, scale, .03f);
float aspect = (float)Screen.width / (float)Screen.height; //changes variable based on the size of the viewport. this keeps the fractal from straching and disforming.
float scaleX = smoothScale;
float scaleY = smoothScale;
if (aspect > 1f)
scaleY /= aspect;
else
scaleX *= aspect;
mat.SetVector("_Area", new Vector4(smoothPos.x, smoothPos.y, scaleX, scaleY));
mat.SetFloat("_Angle", smoothAngle);
}
private void HandleInputs()
{
if (Input.GetKey(KeyCode.UpArrow))
scale *= .99f; //makes the scaling reduce by percentage. scale can never get to zero or the other side of zero.
Debug.Log(scale); // debug scale rotation... set fixed values to three / four different spots
if (Input.GetKey(KeyCode.DownArrow))
scale *= 1.01f;
if (Input.GetKey(KeyCode.E))
angle -= .01f;
Debug.Log(angle); // debug angle rotation... set fixed values to three/four different spots
if (Input.GetKey(KeyCode.Q))
angle += .01f;
Vector2 dir = new Vector2(.01f * scale, 0);
float s = Mathf.Sin(angle);
float c = Mathf.Cos(angle);
dir = new Vector2(dir.x * c, dir.x * s);
if (Input.GetKey(KeyCode.A))
pos -= dir;
if (Input.GetKey(KeyCode.D))
pos += dir;
dir = new Vector2(-dir.y, dir.x);
if (Input.GetKey(KeyCode.S))
pos -= dir;
if (Input.GetKey(KeyCode.W))
pos += dir;
}
void FixedUpdate ()
{
HandleInputs();
UpdateShader();
}
}
3D Fractal Creations
Hurricane VR Physics Interaction Toolkit
I used this physics toolkit to set up my VR rig, locomotion, and interactions.
I used the climbing and bow and arrow interactions.
Respawn Watch
I used the follow fractals, The Menger Sponge to create my main hub.
Koch Snowflake
The Koch snowflake is a unique fractal because it is created by starting with a triangle and then adding smaller triangles to the middle of each side. This process is repeated indefinitely, resulting in a shape that has an infinitely complex boundary and a finite area. The Koch snowflake is also interesting because it is self-similar, meaning that a smaller version of the snowflake can be found within the larger one.
Pythagoras Tree
The Pythagoras tree is a fractal that is created using the Pythagorean theorem to generate a series of squares that are arranged in a specific way. The fractal is created by starting with a square and then adding two smaller squares to the sides of the original square. The sides of the new squares are perpendicular to the sides of the original square, and the length of the sides of the new squares is determined by the Pythagorean theorem. This process is then repeated indefinitely, resulting in a tree-like structure with branches that get smaller and smaller as they get further from the center. The Pythagoras tree is named after the famous Greek mathematician Pythagoras, who is known for his work on geometry, including the theorem that bears his name.
Pythagoras was a famous Greek mathematician known for his work on geometry, including the famous theorem that bears his name. This theorem states that in a right triangle, the square of the length of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the lengths of the other two sides. It is not clear how this theorem would be related to a fractal.
Menger Sponge
The Menger sponge is a fractal that is named after the mathematician Karl Menger. It is created by starting with a cube and then dividing it into 27 smaller cubes, removing the cube in the middle and the six cubes that touch it, and then repeating this process on each of the remaining 20 cubes. This process is repeated indefinitely, resulting in a sponge-like shape with an infinitely complex structure. The Menger sponge has the interesting property that it has a finite volume but an infinite surface area. It is also a self-similar fractal, meaning that a smaller version of the sponge can be found within the larger one. The Menger sponge has been studied extensively in the field of mathematics and is also used in computer graphics and other applications.
Romanesco broccoli
A variant of cauliflower, is the ultimate fractal vegetable. Its pattern is a natural representation of the Fibonacci or golden spiral, a logarithmic spiral where every quarter turn is farther from the origin by a factor of phi, the golden ratio. The Fibonacci sequence, a common and beautiful numeric pattern in nature, creates the Golden Ratio.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Broc : MonoBehaviour
{
public GameObject Broccoli;
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Mouth")
{
other.gameObject.GetComponent<AudioSource>().Play();
Broccoli.SetActive(false);
}
}
}
Sirpinski triangle
(Iterated fractal)
The Sierpiński triangle (sometimes spelled Sierpinski), also called the Sierpiński gasket or Sierpiński sieve, is a fractal attractive fixed set with the overall shape of an equilateral triangle, subdivided recursively into smaller equilateral triangles.
Pentagram
The pentagram is more famous as a magical or holy symbol. It has the Golden Ratio in it:
- a/b = 1.618…
- b/c = 1.618…
- c/d = 1.618…
“Chaos is the science of surprises, of the nonlinear and the unpredictable.” (Fractalfoundation.org, 2018).
Chaos theory teaches us to expect the unexpected. Chaos theory approaches nonlinear concepts or situations that are adequately uncontrollable or predictable. Examples of chaos theory include; weather, turbulence, the stock market, our brain state, etc. Fractal mathematics is often used to describe these phenomena and capture the infinite complexity which is found in nature.
“Many natural objects exhibit fractal properties, including landscapes, clouds, trees, organs, rivers, etc, and many of the systems in which we live exhibit complex, chaotic behavior “ (Fractalfoundation.org, 2018).
The theme of my project will be Chaos Theory in the sense that the scenes are connected in a way that is not connected and unexpected and the user will be able to explore these scenes while learning about fractals (2D, 3D, Natural, and geometric).
Climbing Interaction
I chose to use the climbing interaction because I liked how this used hand tracking to get users physical involved in my Experience.
GitKraken
I used GitKraken for Version Control. Thank you Anson for teaching me to use this program.
Future Work:
Archery scene
I used this archery scene to demonstrate fractal iterations using a fun mechanic (bow and arrow). I started by
My original idea came from shooting dragons since they are immortal and that went with my infinity theme. however, later on I changed the mechanic to spawn three iterations of each fractal and on the fourth hit, plan animation. This was more comprehendible and even educational for the users.
<iframe src="https://artslondon-my.sharepoint.com/personal/l_descher0620211_arts_ac_uk/_layouts/15/Doc.aspx?sourcedoc={a0fe78af-e5a7-4ac9-a056-ea5d48175877}&action=embedview&wdAr=1.7777777777777777" width="476px" height="288px" frameborder="0">This is an embedded <a target="_blank" href="https://office.com">Microsoft Office</a> presentation, powered by <a target="_blank" href="https://office.com/webapps">Office</a>.</iframe>
Infinity
The concept of infinity refers to the idea of something that has no end or limit. It is often used to describe things that are infinitely large, infinitely small, or infinitely complex. For example, the universe is considered to be infinitely large, as it is believed to be constantly expanding and never-ending. The concept of infinity is also used to describe things that are infinitely small, such as the particles that make up atoms, or the infinitely complex patterns that can be found in nature.
In mathematics, infinity is represented by the symbol ∞, and it is used in a variety of contexts. For example, it is used to represent the result of dividing a number by zero, or the limit of a function as the input value approaches infinity. Despite its widespread use, the concept of infinity remains a topic of debate and disagreement among philosophers and mathematicians. Some people argue that infinity is a real and meaningful concept, while others argue that it is a meaningless or impossible concept.
Appendix
Social VR – Museum of other Realities and VRChat