mad fractal action
This commit is contained in:
1 parent
55bc4aaa89
commit
9fea0bdab6
60 files changed
+30775
-3747
No files matched your search
@@ -0,0 +1,15 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
|
||||
m_Name: Global Volume Profile
|
||||
m_EditorClassIdentifier:
|
||||
components: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40548eb39c839cf408f1d70849380a53
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,70 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GradientExplorer : MonoBehaviour {
|
||||
|
||||
[SerializeField] private Material mat;
|
||||
[SerializeField] private Vector2 pos;
|
||||
[SerializeField] private float scale;
|
||||
[SerializeField] private float angle;
|
||||
|
||||
private Vector2 smoothPos;
|
||||
private float smoothScale;
|
||||
private float smoothAngle;
|
||||
|
||||
void FixedUpdate() {
|
||||
HandleUserInput();
|
||||
UpdateShader();
|
||||
}
|
||||
|
||||
private void HandleUserInput() {
|
||||
float scroll = Input.GetAxis("Mouse ScrollWheel");
|
||||
|
||||
if (scroll > 0f) {
|
||||
scale = Mathf.Max(scale *= 0.9f, 0.0002f);
|
||||
} else if (scroll < 0f) {
|
||||
scale *= 1.1f;
|
||||
scale = Mathf.Min(scale *= 1.1f, 10.0f);
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.Q)) {
|
||||
angle -= 0.01f;
|
||||
} else if (Input.GetKey(KeyCode.E)) {
|
||||
angle += 0.01f;
|
||||
}
|
||||
|
||||
Vector2 dir = new Vector2(0.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;
|
||||
|
||||
} else if (Input.GetKey(KeyCode.D)) {
|
||||
pos += dir;
|
||||
}
|
||||
|
||||
dir = new Vector2(-dir.y, dir.x);
|
||||
if (Input.GetKey(KeyCode.W)) {
|
||||
pos += dir;
|
||||
} else if (Input.GetKey(KeyCode.S)) {
|
||||
pos -= dir;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateShader() {
|
||||
smoothPos = Vector2.Lerp(smoothPos, pos, 0.03f);
|
||||
smoothScale = Mathf.Lerp(smoothScale, scale, 0.03f);
|
||||
smoothAngle = Mathf.Lerp(smoothAngle, angle, 0.03f);
|
||||
float aspect = (float) Screen.width / Screen.height;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52c0dfe22724326418ca290bf64ea1b7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,269 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-5396277793910816254
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: da692e001514ec24dbc4cca1949ff7e8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 12
|
||||
hdPluginSubTargetMaterialVersions:
|
||||
m_Keys: []
|
||||
m_Values:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Julia
|
||||
m_Shader: {fileID: 4800000, guid: ee8d9969094915f43867d728cbd4ff93, type: 3}
|
||||
m_ShaderKeywords: _DISABLE_SSR_TRANSPARENT _NORMALMAP_TANGENT_SPACE
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses:
|
||||
- TransparentDepthPrepass
|
||||
- TransparentDepthPostpass
|
||||
- TransparentBackface
|
||||
- RayTracingPrepass
|
||||
- MOTIONVECTORS
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _AnisotropyMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BaseColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BentNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BentNormalMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _CoatMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissiveColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _HeightMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _IridescenceMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _IridescenceThicknessMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecularColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SubsurfaceMaskMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TangentMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TangentMapOS:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ThicknessMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TransmittanceColorMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AORemapMax: 1
|
||||
- _AORemapMin: 0
|
||||
- _ATDistance: 1
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlbedoAffectEmissive: 0
|
||||
- _AlphaCutoff: 0.5
|
||||
- _AlphaCutoffEnable: 0
|
||||
- _AlphaCutoffPostpass: 0.5
|
||||
- _AlphaCutoffPrepass: 0.5
|
||||
- _AlphaCutoffShadow: 0.5
|
||||
- _AlphaDstBlend: 0
|
||||
- _AlphaSrcBlend: 1
|
||||
- _AlphaToMask: 0
|
||||
- _AlphaToMaskInspectorValue: 0
|
||||
- _Anisotropy: 0
|
||||
- _Aspect: 1
|
||||
- _BlendMode: 0
|
||||
- _CoatMask: 0
|
||||
- _CullMode: 2
|
||||
- _CullModeForward: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DepthOffsetEnable: 0
|
||||
- _DetailAlbedoScale: 1
|
||||
- _DetailNormalScale: 1
|
||||
- _DetailSmoothnessScale: 1
|
||||
- _DiffusionProfile: 0
|
||||
- _DiffusionProfileHash: 0
|
||||
- _DisplacementLockObjectScale: 1
|
||||
- _DisplacementLockTilingScale: 1
|
||||
- _DisplacementMode: 0
|
||||
- _DoubleSidedEnable: 0
|
||||
- _DoubleSidedGIMode: 0
|
||||
- _DoubleSidedNormalMode: 1
|
||||
- _DstBlend: 0
|
||||
- _EmissiveColorMode: 1
|
||||
- _EmissiveExposureWeight: 1
|
||||
- _EmissiveIntensity: 1
|
||||
- _EmissiveIntensityUnit: 0
|
||||
- _EnableBlendModePreserveSpecularLighting: 1
|
||||
- _EnableFogOnTransparent: 1
|
||||
- _EnableGeometricSpecularAA: 0
|
||||
- _EnergyConservingSpecularColor: 1
|
||||
- _HeightAmplitude: 0.02
|
||||
- _HeightCenter: 0.5
|
||||
- _HeightMapParametrization: 0
|
||||
- _HeightMax: 1
|
||||
- _HeightMin: -1
|
||||
- _HeightOffset: 0
|
||||
- _HeightPoMAmplitude: 2
|
||||
- _HeightTessAmplitude: 2
|
||||
- _HeightTessCenter: 0.5
|
||||
- _InvTilingScale: 1
|
||||
- _Ior: 1.5
|
||||
- _IridescenceMask: 1
|
||||
- _IridescenceThickness: 1
|
||||
- _Iterations: 229
|
||||
- _LinkDetailsWithBase: 1
|
||||
- _MaterialID: 1
|
||||
- _Metallic: 0
|
||||
- _MetallicRemapMax: 1
|
||||
- _MetallicRemapMin: 0
|
||||
- _NormalMapSpace: 0
|
||||
- _NormalScale: 1
|
||||
- _OpaqueCullMode: 2
|
||||
- _PPDLodThreshold: 5
|
||||
- _PPDMaxSamples: 15
|
||||
- _PPDMinSamples: 5
|
||||
- _PPDPrimitiveLength: 1
|
||||
- _PPDPrimitiveWidth: 1
|
||||
- _RayTracing: 0
|
||||
- _ReceivesSSR: 1
|
||||
- _ReceivesSSRTransparent: 0
|
||||
- _RefractionModel: 0
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessRemapMax: 1
|
||||
- _SmoothnessRemapMin: 0
|
||||
- _SpecularAAScreenSpaceVariance: 0.1
|
||||
- _SpecularAAThreshold: 0.2
|
||||
- _SpecularOcclusionMode: 1
|
||||
- _SrcBlend: 1
|
||||
- _StencilRef: 0
|
||||
- _StencilRefDepth: 8
|
||||
- _StencilRefGBuffer: 10
|
||||
- _StencilRefMV: 40
|
||||
- _StencilWriteMask: 6
|
||||
- _StencilWriteMaskDepth: 8
|
||||
- _StencilWriteMaskGBuffer: 14
|
||||
- _StencilWriteMaskMV: 40
|
||||
- _SubsurfaceMask: 1
|
||||
- _SupportDecals: 1
|
||||
- _SurfaceType: 0
|
||||
- _TexWorldScale: 1
|
||||
- _TexWorldScaleEmissive: 1
|
||||
- _Thickness: 1
|
||||
- _TransmissionEnable: 1
|
||||
- _TransparentBackfaceEnable: 0
|
||||
- _TransparentCullMode: 2
|
||||
- _TransparentDepthPostpassEnable: 0
|
||||
- _TransparentDepthPrepassEnable: 0
|
||||
- _TransparentSortPriority: 0
|
||||
- _TransparentWritingMotionVec: 0
|
||||
- _TransparentZWrite: 0
|
||||
- _UVBase: 0
|
||||
- _UVDetail: 0
|
||||
- _UVEmissive: 0
|
||||
- _UseEmissiveIntensity: 0
|
||||
- _UseShadowThreshold: 0
|
||||
- _ZTestDepthEqualForOpaque: 3
|
||||
- _ZTestGBuffer: 4
|
||||
- _ZTestTransparent: 4
|
||||
- _ZWrite: 1
|
||||
- _Zoom: 4
|
||||
m_Colors:
|
||||
- _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: 4, g: 5, b: 6, 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}
|
||||
- _EmissiveColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissiveColorLDR: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _InvPrimScale: {r: 1, g: 1, b: 0, a: 0}
|
||||
- _IridescenceThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
|
||||
- _JuliaSeed: {r: 0.39, g: -0.2, b: 0, a: 0}
|
||||
- _Pan: {r: 0.75, g: 0, b: 0, a: 0}
|
||||
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _ThicknessRemap: {r: 0, g: 1, b: 0, a: 0}
|
||||
- _TransmittanceColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _UVDetailsMappingMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _UVMappingMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _UVMappingMaskEmissive: {r: 1, g: 0, b: 0, a: 0}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e72888f9a1be07242a433eaf527e7772
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
Shader "Kaiju/Julia"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_Iterations("Iterations", range(0, 555)) = 255
|
||||
_Pan("Pan", vector) = (0.5, 0.0, 0.0, 0.0)
|
||||
_Zoom("Zoom", range(0, 4)) = 3
|
||||
_Aspect("Aspect", range(0, 4)) = 1
|
||||
_JuliaSeed("JuliaSeed", vector) = (0.39, -0.2, 0.0, 0.0)
|
||||
_Colors("Colors", vector) = (3.0, 4.0, 5.0, 0.0)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
// #pragma enable_d3d11_debug_symbols
|
||||
#pragma target 3.0
|
||||
#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;
|
||||
}
|
||||
|
||||
float _Iterations;
|
||||
float2 _Pan;
|
||||
float _Zoom;
|
||||
float _Aspect;
|
||||
float2 _JuliaSeed;
|
||||
float3 _Colors;
|
||||
|
||||
float ComputeValue(float2 v, float2 offset) {
|
||||
float vxsquare = 0;
|
||||
float vysquare = 0;
|
||||
|
||||
float iteration = 0;
|
||||
float lastIteration = _Iterations;
|
||||
|
||||
do {
|
||||
vxsquare = v.x * v.x;
|
||||
vysquare = v.y * v.y;
|
||||
|
||||
v = float2(vxsquare - vysquare, v.x * v.y * 2) + offset;
|
||||
|
||||
iteration++;
|
||||
|
||||
if ((lastIteration == _Iterations) && (vxsquare + vysquare) > 4.0) {
|
||||
lastIteration = iteration + 1;
|
||||
}
|
||||
} while (iteration < lastIteration);
|
||||
|
||||
return (float(iteration) - (log(log(sqrt(vxsquare + vysquare))) / log(2.0))) / float(_Iterations);
|
||||
}
|
||||
|
||||
float4 Mandelbrot_PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 {
|
||||
float2 v = (texCoord - 0.5) * _Zoom * float2(1, _Aspect) - _Pan;
|
||||
float val = ComputeValue(v, v);
|
||||
return float4(sin(val * _Colors.x), sin(val * _Colors.y), sin(val * _Colors.z), 1);
|
||||
}
|
||||
|
||||
float4 Julia_PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 {
|
||||
_JuliaSeed = float2(sin(_Time.y), cos(_Time.y));
|
||||
float2 v = (texCoord - 0.5) * _Zoom * float2(1, _Aspect) - _Pan;
|
||||
float val = ComputeValue(v, _JuliaSeed);
|
||||
return float4(sin(val * _Colors.x), sin(val * _Colors.y), sin(val * _Colors.z), 1);
|
||||
}
|
||||
|
||||
float4 frag (v2f i) : SV_Target {
|
||||
// return Julia_PixelShader(i.uv);
|
||||
return Mandelbrot_PixelShader(i.uv);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee8d9969094915f43867d728cbd4ff93
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,133 @@
|
||||
Shader "Kaiju/Julia"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_MaxIterations("Max Iterations", range(0, 555)) = 255
|
||||
_Pan("Pan", vector) = (0.5, 0.0, 0.0, 0.0)
|
||||
_Zoom("Zoom", range(0, 4)) = 3
|
||||
_Aspect("Aspect", range(0, 4)) = 1
|
||||
_JuliaSeed("JuliaSeed", vector) = (0.39, -0.2, 0.0, 0.0)
|
||||
_Colors("Colors", vector) = (3.0, 3.0, 3.0, 0.0)
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
// No culling or depth
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
// #pragma enable_d3d11_debug_symbols
|
||||
#pragma target 3.0
|
||||
#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;
|
||||
}
|
||||
|
||||
float _MaxIterations;
|
||||
float2 _Pan;
|
||||
float _Zoom;
|
||||
float _Aspect;
|
||||
float2 _JuliaSeed;
|
||||
float3 _Colors;
|
||||
|
||||
float ComputeValue(float2 v, float2 offset) {
|
||||
float vxsquare = 0;
|
||||
float vysquare = 0;
|
||||
|
||||
float iteration;
|
||||
for (iteration = 0; iteration < _MaxIterations; iter++) {
|
||||
|
||||
}
|
||||
|
||||
// do {
|
||||
// vxsquare = v.x * v.x;
|
||||
// vysquare = v.y * v.y;
|
||||
|
||||
// v = float2(vxsquare - vysquare, v.x * v.y * 2) + offset;
|
||||
|
||||
// iteration++;
|
||||
|
||||
// if ((lastIteration == _MaxIterations) && (vxsquare + vysquare) > 4.0) {
|
||||
// lastIteration = iteration + 1;
|
||||
// }
|
||||
// } while (iteration < lastIteration);
|
||||
|
||||
// return (float(iteration) - (log(log(sqrt(vxsquare + vysquare))) / log(2.0))) / float(_MaxIterations);
|
||||
}
|
||||
|
||||
// for each pixel (Px, Py) on the screen do
|
||||
// x0 := scaled x coordinate of pixel (scaled to lie in the Mandelbrot X scale (-2.5, 1))
|
||||
// y0 := scaled y coordinate of pixel (scaled to lie in the Mandelbrot Y scale (-1, 1))
|
||||
// x := 0.0
|
||||
// y := 0.0
|
||||
// iteration := 0
|
||||
// max_iteration := 1000
|
||||
// // Here N = 2^8 is chosen as a reasonable bailout radius.
|
||||
|
||||
// while x*x + y*y ≤ (1 << 16) and iteration < max_iteration do
|
||||
// xtemp := x*x - y*y + x0
|
||||
// y := 2*x*y + y0
|
||||
// x := xtemp
|
||||
// iteration := iteration + 1
|
||||
|
||||
// // Used to avoid floating point issues with points inside the set.
|
||||
// if iteration < max_iteration then
|
||||
// // sqrt of inner term removed using log simplification rules.
|
||||
// log_zn := log(x*x + y*y) / 2
|
||||
// nu := log(log_zn / log(2)) / log(2)
|
||||
// // Rearranging the potential function.
|
||||
// // Dividing log_zn by log(2) instead of log(N = 1<<8)
|
||||
// // because we want the entire palette to range from the
|
||||
// // center to radius 2, NOT our bailout radius.
|
||||
// iteration := iteration + 1 - nu
|
||||
|
||||
// color1 := palette[floor(iteration)]
|
||||
// color2 := palette[floor(iteration) + 1]
|
||||
// // iteration % 1 = fractional part of iteration.
|
||||
// color := linear_interpolate(color1, color2, iteration % 1)
|
||||
// plot(Px, Py, color)
|
||||
|
||||
float4 Mandelbrot_PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 {
|
||||
float2 v = (texCoord - 0.5) * _Zoom * float2(1, _Aspect) - _Pan;
|
||||
float val = ComputeValue(v, v);
|
||||
return float4(sin(val * _Colors.x), sin(val * _Colors.y), sin(val * _Colors.z), 1);
|
||||
}
|
||||
|
||||
float4 Julia_PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 {
|
||||
_JuliaSeed = float2(sin(_Time.y), cos(_Time.y));
|
||||
float2 v = (texCoord - 0.5) * _Zoom * float2(1, _Aspect) - _Pan;
|
||||
float val = ComputeValue(v, _JuliaSeed);
|
||||
return float4(sin(val * _Colors.x), sin(val * _Colors.y), sin(val * _Colors.z), 1);
|
||||
}
|
||||
|
||||
float4 frag (v2f i) : SV_Target {
|
||||
// return Julia_PixelShader(i.uv);
|
||||
return Mandelbrot_PixelShader(i.uv);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78081ff9d4e002f459e8f2f4f31a48fd
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user