pretty crazy organic mandelbrot
This commit is contained in:
1 parent
986d37148a
commit
6da13bac1c
5 files changed
+66
-51
No files matched your search
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 24f077503be6ae942a1e1245dbd53ea9, type: 3}
|
||||
m_Name: Bloom
|
||||
m_EditorClassIdentifier:
|
||||
active: 0
|
||||
active: 1
|
||||
quality:
|
||||
m_OverrideState: 1
|
||||
m_Value: 1
|
||||
|
||||
@@ -194,7 +194,7 @@ Material:
|
||||
- _EnableFogOnTransparent: 1
|
||||
- _EnableGeometricSpecularAA: 0
|
||||
- _EnergyConservingSpecularColor: 1
|
||||
- _EscapeRadius: 20
|
||||
- _EscapeRadius: 83.2
|
||||
- _HeightAmplitude: 0.02
|
||||
- _HeightCenter: 0.5
|
||||
- _HeightMapParametrization: 0
|
||||
@@ -230,7 +230,7 @@ Material:
|
||||
- _ReceivesSSR: 1
|
||||
- _ReceivesSSRTransparent: 0
|
||||
- _RefractionModel: 0
|
||||
- _Repeat: 13.11
|
||||
- _Repeat: 34.44
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessRemapMax: 1
|
||||
- _SmoothnessRemapMin: 0
|
||||
@@ -238,7 +238,7 @@ Material:
|
||||
- _SpecularAAScreenSpaceVariance: 0.1
|
||||
- _SpecularAAThreshold: 0.2
|
||||
- _SpecularOcclusionMode: 1
|
||||
- _Speed: 0
|
||||
- _Speed: 0.367
|
||||
- _SrcBlend: 1
|
||||
- _StencilRef: 0
|
||||
- _StencilRefDepth: 8
|
||||
@@ -254,6 +254,7 @@ Material:
|
||||
- _Symmetry: 0
|
||||
- _TexWorldScale: 1
|
||||
- _TexWorldScaleEmissive: 1
|
||||
- _ThemeSize: 128
|
||||
- _Thickness: 1
|
||||
- _TransmissionEnable: 1
|
||||
- _TransparentBackfaceEnable: 0
|
||||
@@ -274,11 +275,11 @@ Material:
|
||||
- _ZWrite: 1
|
||||
- _Zoom: 3
|
||||
m_Colors:
|
||||
- _Area: {r: -0.5405251, g: 0.10383208, b: 4.09617, a: 1.8463168}
|
||||
- _Area: {r: -1.0452415, g: 0.329197, b: 0.5696741, a: 0.28194416}
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _BaseColorMap_MipInfo: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Colors: {r: 3, g: 4, b: 5, a: 0}
|
||||
- _Colors: {r: 6.7, g: 4, b: 5, a: 0}
|
||||
- _DiffusionProfileAsset: {r: 0, g: 0, b: 0, a: 0}
|
||||
- _DoubleSidedConstants: {r: 1, g: 1, b: -1, a: 0}
|
||||
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
|
||||
@@ -7,13 +7,12 @@ Shader "Explorer/Mandelbrot"
|
||||
_Area("Area", vector) = (0, 0, 4 ,4)
|
||||
_Angle("Angle", range(-3.1415, 3.1415)) = 0
|
||||
_MaxIter("Max Iterations", range(0, 555)) = 255
|
||||
_Color("Color", range(0,1)) = 0.5
|
||||
_Repeat("Repeat", float) = 1
|
||||
_Speed("Speed", range(0, 1)) = 0.1
|
||||
_Symmetry("Symmetry", range(0, 1)) = 0
|
||||
_EscapeRadius("EscapeRadius", range(2, 200)) = 50
|
||||
|
||||
_SpectrumTexture("SpectrumTexture", 2D) = "white" {}
|
||||
_ThemeTexture("ThemeTexture", 2D) = "white" {}
|
||||
_SpectrumSize("SpectrumSize", float) = 16
|
||||
|
||||
}
|
||||
@@ -52,14 +51,13 @@ Shader "Explorer/Mandelbrot"
|
||||
|
||||
float4 _Area;
|
||||
float _Angle;
|
||||
float _Color;
|
||||
float _Repeat;
|
||||
float _Speed;
|
||||
float _Symmetry;
|
||||
float _EscapeRadius;
|
||||
int _MaxIter;
|
||||
sampler2D _MainTex;
|
||||
sampler2D _SpectrumTexture;
|
||||
sampler2D _ThemeTexture;
|
||||
|
||||
float2 rot(float2 p, float2 pivot, float a) {
|
||||
float s = sin(a);
|
||||
@@ -78,18 +76,33 @@ Shader "Explorer/Mandelbrot"
|
||||
uv = lerp(i.uv - 0.5, uv, _Symmetry);
|
||||
float2 c = _Area.xy + uv * _Area.zw;
|
||||
c = rot(c, _Area.xy, _Angle);
|
||||
|
||||
// cool modulation
|
||||
float time = _Time.y;
|
||||
float sub = tex2D(_SpectrumTexture, 0.0);
|
||||
float bass = tex2D(_SpectrumTexture, 0.25);
|
||||
float mids = tex2D(_SpectrumTexture, 0.50);
|
||||
float highs = tex2D(_SpectrumTexture, 0.75);
|
||||
|
||||
float r = lerp(2.0, 200, bass);
|
||||
// float maxIterations = lerp(2.0, 500, sub);
|
||||
// float maxIterations = lerp(2.0, 500, sub);
|
||||
// float speed = sub * -scale;
|
||||
|
||||
float maxIterations = _MaxIter;
|
||||
// float r = _EscapeRadius;
|
||||
float speed = _Speed;
|
||||
|
||||
float2 z; // track pixel jumping across screen
|
||||
float2 zPrev;
|
||||
// float r = _EscapeRadius;
|
||||
float r = lerp(2.0f, 50.0f, tex2D(_SpectrumTexture, 1.0f));
|
||||
float r2 = r*r;
|
||||
|
||||
float iter; // track current iteration
|
||||
for (iter = 0; iter < _MaxIter; iter++) {
|
||||
// update z based on previous z value and add original starting position
|
||||
// zPrev = z;
|
||||
zPrev = rot(z, 0, _Time.y);
|
||||
// zPrev = rot(z, 0, clamp(tex2D(_SpectrumTexture, 0.1f) * 6.28, 1, 6.28));
|
||||
float rotation = sin(time);
|
||||
zPrev = rot(z, 0, rotation);
|
||||
|
||||
z = float2(z.x*z.x-z.y*z.y, 2*z.x*z.y) + c;
|
||||
if (dot(z, zPrev) > r2) {
|
||||
@@ -100,18 +113,20 @@ Shader "Explorer/Mandelbrot"
|
||||
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;
|
||||
// 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));
|
||||
// float4 col = tex2D(_ThemeTexture, m + abs(sin(time)) * speed);
|
||||
float4 col = tex2D(_ThemeTexture, m + time * speed);
|
||||
col *= smoothstep(3, 0, fracIter);
|
||||
|
||||
// dark bands
|
||||
float angle = atan2(z.x, z.y);
|
||||
col *= 1 + sin(angle*2 + time*4)*.2;
|
||||
|
||||
col *= 1 + sin(angle*2 + _Time.y*4)*.2;
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
|
||||
Reference in new issue
Block a user