pretty crazy organic mandelbrot

This commit is contained in:
ntr committed 2022-05-06 17:34:46 +10:00
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
+2 -2
View File
@@ -30,10 +30,10 @@ EditorUserSettings:
value: 01570c5350030c5f5a5c5f76132506444516492e7e2927367e2a4b63b2b3323c
flags: 0
RecentlyUsedSceneGuid-8:
value: 52015104520c505e5b5e097a15270d4410161e727c2b736879714467e3b0323b
value: 54090452040508595c0d5c7043750e44414e4d2c7b7c25682f704c31bae4353e
flags: 0
RecentlyUsedSceneGuid-9:
value: 54090452040508595c0d5c7043750e44414e4d2c7b7c25682f704c31bae4353e
value: 52015104520c505e5b5e097a15270d4410161e727c2b736879714467e3b0323b
flags: 0
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c723e3b3b270b3e3a2729633c133af6f9
+30 -31
View File
@@ -48,7 +48,7 @@ MonoBehaviour:
x: 252
y: 73
width: 1482
height: 689
height: 901
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -59,7 +59,7 @@ MonoBehaviour:
m_ShowGizmos: 0
m_TargetDisplay: 0
m_ClearColor: {r: 0, g: 0, b: 0, a: 0}
m_TargetSize: {x: 1482, y: 668}
m_TargetSize: {x: 1482, y: 880}
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
@@ -76,8 +76,8 @@ MonoBehaviour:
vZoomLockedByDefault: 0
m_HBaseRangeMin: -741
m_HBaseRangeMax: 741
m_VBaseRangeMin: -334
m_VBaseRangeMax: 334
m_VBaseRangeMin: -440
m_VBaseRangeMax: 440
m_HAllowExceedBaseRangeMin: 1
m_HAllowExceedBaseRangeMax: 1
m_VAllowExceedBaseRangeMin: 1
@@ -86,7 +86,7 @@ MonoBehaviour:
m_HSlider: 0
m_VSlider: 0
m_IgnoreScrollWheelUntilClicked: 0
m_EnableMouseInput: 1
m_EnableMouseInput: 0
m_EnableSliderZoomHorizontal: 0
m_EnableSliderZoomVertical: 0
m_UniformScale: 1
@@ -96,9 +96,9 @@ MonoBehaviour:
x: 0
y: 21
width: 1482
height: 668
height: 880
m_Scale: {x: 1, y: 1}
m_Translation: {x: 741, y: 334}
m_Translation: {x: 741, y: 440}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
@@ -106,12 +106,12 @@ MonoBehaviour:
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -741
y: -334
y: -440
width: 1482
height: 668
height: 880
m_MinimalGUI: 1
m_defaultScale: 1
m_LastWindowPixelSize: {x: 1482, y: 689}
m_LastWindowPixelSize: {x: 1482, y: 901}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
@@ -162,7 +162,7 @@ MonoBehaviour:
x: 0
y: 0
width: 1736
height: 710
height: 922
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 8096}
vertical: 0
@@ -185,7 +185,7 @@ MonoBehaviour:
x: 0
y: 0
width: 252
height: 710
height: 922
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 6}
@@ -216,7 +216,7 @@ MonoBehaviour:
x: 0
y: 73
width: 251
height: 689
height: 901
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -224,9 +224,9 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: f68b0000
m_LastClickedID: 35830
m_ExpandedIDs: c090ffffbe98ffff44e1ffff68e2ffff42e3ffffece3ffff96e4ffff42e5ffffece5ffff96e6ffff40e7ffffeae7ffff94e8ffff3ee9ffffe8e9ffff92eaffff3cebffffe2ebffff8cecffff36edffffe0edffff20fbffffc0610000d87f0000fe8b0000
m_SelectedIDs: f0980000
m_LastClickedID: 39152
m_ExpandedIDs: 3e11ffff4011fffff812ffff9a4effffdc53ffff9255ffffb28dffffc090ffffbe98ffff44e1ffff68e2ffff42e3ffffece3ffff96e4ffff42e5ffffece5ffff96e6ffff40e7ffffeae7ffff94e8ffff3ee9ffffe8e9ffff92eaffff3cebffffe2ebffff8cecffff36edffffe0edffff20fbffffc0610000d87f0000fe8b0000c08c0000b6900000dc980000fe980000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -268,7 +268,7 @@ MonoBehaviour:
x: 252
y: 0
width: 1484
height: 710
height: 922
m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 2}
@@ -297,9 +297,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 294
x: 252
y: 73
width: 1752
width: 1482
height: 689
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@@ -586,7 +586,7 @@ MonoBehaviour:
m_Rotation:
m_Target: {x: 0.14920431, y: 0.39824635, z: -0.0658278, w: 0.9026827}
speed: 2
m_Value: {x: 0.14920431, y: 0.39824632, z: -0.0658278, w: 0.90268266}
m_Value: {x: 0.14920196, y: 0.3982401, z: -0.065826766, w: 0.90266854}
m_Size:
m_Target: 573.8285
speed: 2
@@ -631,9 +631,9 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 710
y: 922
width: 1736
height: 597
height: 385
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 10}
@@ -664,9 +664,9 @@ MonoBehaviour:
m_Pos:
serializedVersion: 2
x: 0
y: 783
y: 995
width: 1735
height: 576
height: 364
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
m_LastAppliedPresetName: Default
@@ -683,8 +683,7 @@ MonoBehaviour:
m_ShowAllHits: 0
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/Scenes
m_Folders: []
m_Globs: []
m_OriginalText:
m_ViewMode: 0
@@ -724,10 +723,10 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_AssetTreeState:
scrollPos: {x: 0, y: 792}
m_SelectedIDs: f68b0000
scrollPos: {x: 0, y: 180}
m_SelectedIDs: f0980000
m_LastClickedID: 0
m_ExpandedIDs: ffffffff00000000c6620000c8620000ca620000cc620000ce620000d0620000d2620000d4620000d6620000d8620000da620000dc620000de620000e0620000e2620000e4620000e6620000e8620000ea620000ec620000ee620000f0620000f2620000
m_ExpandedIDs: ffffffff00000000c6620000c8620000ca620000cc620000ce620000d0620000d2620000d4620000d6620000d8620000da620000dc620000de620000e0620000e2620000f0620000f262000034630000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -752,8 +751,8 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_ListAreaState:
m_SelectedInstanceIDs: f68b0000
m_LastClickedInstanceID: 35830
m_SelectedInstanceIDs: f0980000
m_LastClickedInstanceID: 39152
m_HadKeyboardFocusLastEvent: 0
m_ExpandedInstanceIDs: c6230000
m_RenameOverlay: