Skip to content

Commit 81f010b

Browse files
committed
[site] new video + Fractals v1.3
- minor changes to the website - different coloring methods for the mandelbulb fractal
1 parent 895445f commit 81f010b

File tree

12 files changed

+46
-27
lines changed

12 files changed

+46
-27
lines changed

Fractals Project/Assets/Scenes/Mandelbox.unity

+1-1
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,7 @@ PrefabInstance:
19701970
- target: {fileID: 4412081284719302609, guid: 1f834fe602c595649a57bd478ffa5942,
19711971
type: 3}
19721972
propertyPath: m_Name
1973-
value: Mix
1973+
value: Color Mix
19741974
objectReference: {fileID: 0}
19751975
m_RemovedComponents: []
19761976
m_SourcePrefab: {fileID: 100100000, guid: 1f834fe602c595649a57bd478ffa5942, type: 3}

Fractals Project/Assets/Scenes/Mandelbulb.unity

+2-2
Original file line numberDiff line numberDiff line change
@@ -2860,12 +2860,12 @@ PrefabInstance:
28602860
- target: {fileID: 4412081284719302609, guid: 1f834fe602c595649a57bd478ffa5942,
28612861
type: 3}
28622862
propertyPath: m_Name
2863-
value: Mix
2863+
value: Mix Trap Coloring
28642864
objectReference: {fileID: 0}
28652865
- target: {fileID: 4412081284719302609, guid: 1f834fe602c595649a57bd478ffa5942,
28662866
type: 3}
28672867
propertyPath: m_IsActive
2868-
value: 0
2868+
value: 1
28692869
objectReference: {fileID: 0}
28702870
m_RemovedComponents: []
28712871
m_SourcePrefab: {fileID: 100100000, guid: 1f834fe602c595649a57bd478ffa5942, type: 3}

Fractals Project/Assets/Scripts/Mandelbulb/Mandelbulb.compute

+35-13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ static const float epsilon = 0.00004;
2626

2727
// structs
2828
struct Ray { float3 origin; float3 direction; };
29+
struct Data { float2 a; float3 b; };
30+
31+
// data contructor
32+
Data DataConstr(float2 a, float3 b) {
33+
Data data;
34+
data.a = a;
35+
data.b = b;
36+
return data;
37+
}
2938

3039
Ray CreateRay(float3 origin, float3 direction) {
3140
Ray ray;
@@ -42,10 +51,16 @@ Ray CreateCameraRay(float2 uv) {
4251
return CreateRay(origin, direction);
4352
}
4453

54+
// orbit trap
55+
void Trap(float3 z, inout float3 trap) {
56+
//z = abs(z);
57+
if (length(z) < length(trap))
58+
trap = z;
59+
}
4560

4661
// mandelbulb distance estimator from http://blog.hvidtfeldts.net/index.php/2011/09/distance-estimated-3d-fractals-v-the-mandelbulb-different-de-approximations/
47-
float2 DE(float3 p) {
48-
float3 z = p;
62+
Data DE(float3 p) {
63+
float3 z = p, trap = p;
4964
float r, dr = 1;
5065
int i;
5166

@@ -68,27 +83,32 @@ float2 DE(float3 p) {
6883
if (Alt) z = zr * float3(cos(theta) * cos(phi), cos(theta) * sin(phi), sin(theta));
6984
else z = zr * float3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta));
7085
z += Julia * C + (1 - Julia) * p;
86+
87+
88+
Trap(z, trap); // trap
7189
}
72-
90+
91+
trap = abs(trap);
7392
float dst = 0.1 * log(r) * r / dr;
74-
return float2(dst, sin(i));
93+
return DataConstr(float2(dst, sin(i)), trap);
7594
}
7695

7796
// cast a ray and return the result
78-
float3 March(Ray ray) {
79-
float2 d = 0;
97+
Data March(Ray ray) {
98+
Data d;
8099
float3 eye = ray.origin;
81100

82101
int s = 0;
83102
while (s < steps) {
84103
d = DE(ray.origin); // calculate distance
85104
if (length(eye - ray.origin) > 100) s = steps; // to far away
86-
if (d.x < epsilon) break; // hit
87-
ray.origin += ray.direction * d.x; // march
105+
if (d.a.x < epsilon) break; // hit
106+
ray.origin += ray.direction * d.a.x; // march
88107
s++; // next iteration
89108
}
90-
91-
return float3(1 - s / float(steps), length(eye - ray.origin), d.y);
109+
110+
return DataConstr(float2(1 - s / float(steps), d.a.y), d.b);
111+
//return float3(1 - s / float(steps), length(eye - ray.origin), d.y);
92112
}
93113

94114
// main method
@@ -103,8 +123,10 @@ void CSMain (uint3 id : SV_DispatchThreadID) {
103123
Ray ray = CreateCameraRay(uv);
104124

105125
// render
106-
float3 res = March(ray);
107-
float a = res.x * (2 - Mix * 2) + res.z * (Mix * 2);
126+
Data res = March(ray);
127+
//float a = res.a.x * (2 - Mix * 2) + res.a.y * (Mix * 2);
108128
//Texture[id.xy] = Source[id.xy] + (float4(a, a, a, 0) * float4(0.8, 0.2, 0.2, 0));
109-
Texture[id.xy] = float4(1, 1, 1, 1) * (res.x + 0.1) + float4(0.8, 0.2, 0.2, 0) * res.z;
129+
//float4 a = TrapColoring ? float4(res.b, 0) : float4(0.8, 0.2, 0.2, 0);
130+
float4 a = float4(res.b, 0) * Mix + float4(0.8, 0.2, 0.2, 0) * (1 - Mix);
131+
Texture[id.xy] = float4(1, 1, 1, 1) * (res.a.x + 0.1) + a * res.a.y;
110132
}

Fractals Project/Assets/Scripts/Mandelbulb/Mandelbulb.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class Mandelbulb : App {
66
private int iterations = 30;
77
private float julia;
88
private Vector3 c = Vector3.zero;
9-
private float mix = 0.5f;
9+
private float mix;
1010
private bool alt;
1111

1212
private void Start() { cameraType = CameraType.Orbit; }

Fractals Project/Assets/Scripts/Utils/ControlsHelper.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections;
3-
using UnityEditor;
4-
using UnityEngine;
1+
using UnityEngine;
52
using UnityEngine.EventSystems;
63

74
public class ControlsHelper : MonoBehaviour {

Fractals Project/ProjectSettings/ProjectSettings.asset

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ PlayerSettings:
128128
16:10: 1
129129
16:9: 1
130130
Others: 1
131-
bundleVersion: v1.2
131+
bundleVersion: v1.3
132132
preloadedAssets:
133133
- {fileID: 0}
134134
- {fileID: 0}

Fractals Site/src/css/main.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ body.no-cursor, body.no-cursor * {
101101
height: 100%;
102102
object-fit: cover;
103103
pointer-events: none;
104-
filter: brightness(100%);
104+
filter: brightness(90%);
105105
transition: filter var(--scroll);
106106
}
107107

@@ -186,7 +186,7 @@ span::selection {
186186
}
187187

188188
.blur {
189-
backdrop-filter: blur(2rem) brightness(110%);
189+
backdrop-filter: blur(2rem) brightness(120%);
190190
background-color: rgba(61, 61, 90, 0.1);
191191
}
192192

Fractals Site/src/media/video.mp4

-4.49 MB
Binary file not shown.

Fractals Site/src/scripts/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function onScroll() {
8686

8787
// landing page / other pages
8888
if (Scroll.targetScroll === 0)
89-
vid.style.filter = 'brightness(100%)';
89+
vid.style.filter = 'brightness(90%)';
9090
else
9191
vid.style.filter = 'brightness(75%)';
9292

docs/css/main.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/media/video.mp4

-4.49 MB
Binary file not shown.

0 commit comments

Comments
 (0)