This is a file from the Wikimedia Commons

File:Lyapunov 2.png

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Original file(1,920 × 1,080 pixels, file size: 164 KB, MIME type: image/png)

Summary

Description
English: MB set rendered using Lyapunov exponent
Date
Source

Own work

Shader "Fractals/Coloring Techniques/Escape-Time"
{
	Properties
	{
		_MainTex ("Texture", 2D) = "white" {}

		_Iter ("Iterations", Range(0, 250)) = 100
		_Dividend ("Dividend", Range (0, 0.5)) = 15
		
		_Zoom ("Zoom", Range (0.1, 1000)) = 0.65
		_Position ("Offset", Vector) = (0.4, 0, 0, 0)

		_Background ("Background", Color) = (0, 0.25, 1, 0)
		_Origin ("Origin", Color) = (0, 0, 0, 0)
	}	
	SubShader
	{
		Cull Off ZWrite Off ZTest Always

		Pass
		{
			CGPROGRAM

			#pragma vertex vert
			#pragma fragment frag
			
			#include "UnityCG.cginc"
			#include "Complex.cginc"
			#include "FractalOperations.cginc"

			struct appdata
			{
				float4 vertex : POSITION;
				float2 uv : TEXCOORD0;
			};

			struct v2f
			{
				float2 uv : TEXCOORD0;
				float4 vertex : SV_POSITION;
			};

			sampler2D _MainTex;

			int _Iter;
			fixed _Zoom;
			fixed _Dividend;
			float2 _Position;
			fixed4 _Background;
			fixed4 _Origin;

			v2f vert (appdata v)
			{
				v2f o;
				o.vertex = UnityObjectToClipPos(v.vertex);
				o.uv = v.uv;
				return o;
			}

			fixed4 frag (v2f i) : SV_Target
			{
				float x0 = (ClampScaleX(i.uv) + _Position.x) / _Zoom;
				float y0 = (ClampScaleY(i.uv) + _Position.y) / _Zoom;
				
				float2 z = float2(x0, y0);
				float2 c = float2(x0, y0);
				
				int iteration = 0;

				float l = 0;

				while (IsBounded(z, 40) && iteration < _Iter)
				{	
					l += log (cabs(2 * z));

					z = cmul(z, z);
					z += c;					

					iteration++;
				}

				l /= iteration;

				if (l > 0)
					return _Background;

                float3 color = tanh(l >= 0 ? 
											float3(0, 0.7 * log(1 + l), log(1 + l)) : 
											3 * float3(_Origin.x-l, _Origin.y-l * 0.1, _Origin.z));

				return float4(color + _Dividend, 1);


			}		    
			ENDCG
		}
	}
	CustomEditor "FractalEditor"
}
Author JPBotelho

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

6 February 2018

image/png

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:41, 6 February 2018Thumbnail for version as of 15:41, 6 February 20181,920 × 1,080 (164 KB)JPBotelhoUser created page with UploadWizard

Global file usage

The following other wikis use this file: