Skip to content

09. Tutorials

3Dickulus edited this page Dec 25, 2021 · 2 revisions

Tutorials

00 - Simple 2D system.frag
// The simplest way to draw something in Fragmentarium,
// is to include the "2D.frag" header.
//
// Now, we can implement a simple 'color' function,
// which for each point in the plane returns a RGB color.
//
// Notice, that you can zoom using the mouse or the keyboard.
// (A,S,D,W,Q,E,1,3)

vec3 color(vec2 c) {
	return vec3(cos(c.x),sin(c.y),sin(c.x*c.y));
}
01 - Simple 2D Escape Time Fractal.frag
// Escape time fractals iterate a functions for each point
// in the plane, and check if the sequence generated converges.
// 
// The "2DJulia.frag" helper file makes it easy to generate
// these kind of systems.
//
// Just implement the 'formula' function below.
// It is possible to draw Mandelbrots and Julias
// and customize the coloring.
//
// Here is an example of a Mandelbrot:

vec2 formula(vec2 z, vec2 offset) {
	z = cMul(z,z)+offset;
	return z;
}
02 - User Variables and Presets.frag
// It is easy to create custom variables,
// and tie them to sliders in the user interface.
//
// Hint: use the context menu to quickly
// insert templates for different variable types.
// Here you can also see the different types 
// of variables.

// Organize controls by grouping them 
#group MySystem

// Creates a floating point variable,
// with a slider with minimum = 0,
// default = 1, and maximum 10.
uniform float X; slider[0,1,10]
uniform float Y; slider[0,1,10]

// Use the variable like any other in the code
// (But don't assign to them)
vec3 color(vec2 c) {
	return vec3(cos(c.x*X)+sin(c.y*Y),
		sin(c.x*Y)+cos(c.y*X),
		sin(c.x*c.y));
}

// It is possible to store one or more user variable
// settings in a Preset.
//
// Preset are parsed at build time, and will
// appear in the drop-down box in the Parameter 
// window, where they can be quickly applied.

// Presets with the name 'Default'
// will be automatically assigned,
// when the system is built the first time.
#preset Default
Center = -0.221053,0.488189
Zoom = 0.186907
AntiAliasScale = 1
AntiAlias = 1
X = 1.2977
#endpreset

// Create presets by using the
// 'Copy to Clipboard' button in the 
// Parameter window.
#preset Preset 2
Center = -0.221053,0.488189
Zoom = 0.335658
AntiAliasScale = 1
AntiAlias = 1
X = 6.8702
Y = 0.3053
Y = 6.3359
#endpreset
03 - Dynamic Systems.frag
// It is possible to change variables
// based on a special uniform 'time' variable.
//
// To see this in action, you must
// change the Render mode to 'Animation (time)' - 
// otherwise the system will only render changes 
// when something changes.

#group MySystem

uniform float X; slider[0,1,10]
uniform float Y; slider[0,1,10]
uniform float time;

vec3 color(vec2 c) {
	return vec3(cos(c.x*X+time)+sin(c.y*Y+time*2.0),
		sin(c.x*Y)+cos(c.y*X+time),
		sin(c.x*c.y+time));
}

#preset Default
Center = -1.87816,-0.786641
Zoom = 0.214943
AntiAliasScale = 1
AntiAlias = 1
X = 5.0382
Y = 3.0534
#endpreset
04 - Textures.frag
04 - Textures.frag
// It is possible to read from external bitmaps
// from Fragmentarium using textures.
// Set up a sampler2D as below,
// and read using the texture2D command.
#group MySystem

uniform float T ;slider[0,4,10]
uniform float R; slider[0,2,10]
uniform float step; slider[0,0.004,0.01]
uniform float time;

// Here we read from a texture
// Files locations are resolved relative to the current file,
// and to the include path set in the settings.
uniform sampler2D texture; file[texture2.jpg]

// You can set texture parameters directly:
#TexParameter texture GL_TEXTURE_MAG_FILTER GL_LINEAR
#TexParameter texture GL_TEXTURE_WRAP_S GL_REPEAT
#TexParameter texture GL_TEXTURE_WRAP_T GL_REPEAT

// A simple system based on the 'tunnel' system by Inigo Quilez:
// http://www.iquilezles.org/apps/shadertoy/
vec3 color(vec2 c) {
	c*= 1.3+cos(time*2.0);
	vec2 uv;
	
	float a = atan(c.y,c.x);
	float r = length(c);
	
	uv.x = .5*time+.1/r;
	uv.y = a/3.1416 + time*0.1;
	vec2 dd = vec2(step,0.0);
	vec2 d =uv;
	vec3 col = texture2D(texture,d).xyz;
	vec3 colX = texture2D(texture,d+dd.xy).xyz;
	vec3 colMX = texture2D(texture,d-dd.xy).xyz;
	vec2 g;
	g.x = length(colMX)-length(colX);
	vec3 colY = texture2D(texture,d+dd.yx).xyz;
	vec3 colMY = texture2D(texture,d-dd.yx).xyz;
	g.y = length(colMY)-length(colY);
	g = normalize(g);
	vec2 light = vec2(cos(time*T),sin(time*T))*R;
	return mix(col,r*col* max(-1.0,dot(light,g)),0.9);
}

#preset Default
Center = -0.0214904,-0.00195827
Zoom = 2.34384
AntiAliasScale = 1
AntiAlias = 1
T = 4.3511
R = 2.2308
step = 0.0041
#endpreset
10 - Simple Distance Estimated 3D system.frag
// This is an example of 
// a simple distance estimated system.
//
// The function "DE" must return 
// the distance to the closest 
// point on any objects in any direction.
vec3 baseColor(vec3 p, vec3 n) {
	if (mod(length(p*10.0),2.0)<1.0) return vec3(1.0);
   return vec3(0.0);
}

float  DE(vec3 z) {
	float d = (length(z-vec3(1.0,0.0,0.0))-1.0); // A sphere
	d = max(d,- (length(z.xy-vec2(1.,0.0))-0.4)); // minus a tube
	d = max(d,- (length(z.yz-vec2(0.,0.0))-0.4)); // minus a tube
	d = max(d,- (length(z.xz-vec2(1.,0.0))-0.4)); // minus a tube
	d = min(d, z.x); // plus a ground plane
       d = min(d, length(z.yz-vec2(1.,1.0))-0.3); // plus a  tube
	return d;
}

#preset Default
FOV = 0.4
Eye = 4.76415,-4.09381,3.08941
Target = -1.17452,2.39263,-1.67067
Up = 0.803593,0.507247,-0.311349
#endpreset
11 - Simple Distance Estimated 3D fractal.frag
// Here one of the simplest fractals,
// a distance estimated Menger cube.
#group Menger
uniform int Iterations;  slider[0,8,100]
uniform int ColorIterations;  slider[0,8,100]
uniform float Scale; slider[0.00,3.0,4.00]
uniform vec3 Offset; slider[(0,0,0),(1,1,1),(1,1,1)]

float DE(vec3 z)
{
	int n = 0;
	while (n < Iterations) {
		z = abs(z);
		if (z.x<z.y){ z.xy = z.yx;}
		if (z.x< z.z){ z.xz = z.zx;}
		if (z.y<z.z){ z.yz = z.zy;}
		z = Scale*z-Offset*(Scale-1.0);
		if( z.z<-0.5*Offset.z*(Scale-1.0))  z.z+=Offset.z*(Scale-1.0);
		if (n<ColorIterations) orbitTrap = min(orbitTrap, (vec4(abs(z),dot(z,z))));		
		n++;
	}
	
	return abs(length(z)-0.0 ) * pow(Scale, float(-n));
}

#preset Default
FOV = 0.4
Eye = -3.55741,0.119991,-2.22946
Target = 4.91261,-0.165702,3.07876
Up = 0.0398762,0.999198,-0.00374516
AntiAlias = 1
Detail = -2.35396
DetailAO = -1.00002
FudgeFactor = 1
MaxRaySteps = 56
BoundingSphere = 3.774
Dither = 0.5
NormalBackStep = 1
AO = 0,0,0,0.7
Specular = 0.1666
SpecularExp = 16
SpotLight = 1,1,1,0.19608
SpotLightDir = 0.37142,0.1
CamLight = 1,1,1,1.13978
CamLightMin = 0.29412
Glow = 1,1,1,0.07895
GlowMax = 20
Fog = 0.4161
HardShadow = 0.33846
ShadowSoft = 2
Reflection = 0
BaseColor = 1,1,1
OrbitStrength = 0.64935
X = 0.5,0.6,0.6,0.2126
Y = 1,0.6,0,0.30708
Z = 0.8,0.78,1,1
R = 0.666667,0.666667,0.498039,0.03174
BackgroundColor = 0.6,0.6,0.45
GradientBackground = 0.3
CycleColors = false
Cycles = 6.95699
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
Iterations = 8
ColorIterations = 5
Scale = 3
Offset = 1,1,1
#endpreset
12 - Faster raytracing of 3D fractals.frag
// Here one of the simplest fractals,
// a distance estimated Menger cube.
#group Menger
uniform int Iterations;  slider[0,8,100]
uniform int ColorIterations;  slider[0,8,100]
uniform float Scale; slider[0.00,3.0,4.00]
uniform vec3 Offset; slider[(0,0,0),(1,1,1),(1,1,1)]

float DE(vec3 z)
{
	int n = 0;
	while (n < Iterations) {
		z = abs(z);
		if (z.x<z.y){ z.xy = z.yx;}
		if (z.x< z.z){ z.xz = z.zx;}
		if (z.y<z.z){ z.yz = z.zy;}
		z = Scale*z-Offset*(Scale-1.0);
		if( z.z<-0.5*Offset.z*(Scale-1.0))  z.z+=Offset.z*(Scale-1.0);
		if (n<ColorIterations) orbitTrap = min(orbitTrap, (vec4(abs(z),dot(z,z))));		
		n++;
	}
	
	return abs(length(z)-0.0 ) * pow(Scale, float(-n));
}

#preset Default
FOV = 0.4
Eye = -3.55741,0.119991,-2.22946
Target = 4.91261,-0.165702,3.07876
Up = 0.0398762,0.999198,-0.00374516
AntiAlias = 1
Detail = -2.35396
DetailAO = -1.00002
FudgeFactor = 1
MaxRaySteps = 56
BoundingSphere = 3.774
Dither = 0.5
NormalBackStep = 1
AO = 0,0,0,0.7
Specular = 0.1666
SpecularExp = 16
SpotLight = 1,1,1,0.19608
SpotLightDir = 0.37142,0.1
CamLight = 1,1,1,1.13978
CamLightMin = 0.29412
Glow = 1,1,1,0.07895
GlowMax = 20
Fog = 0.4161
HardShadow = 0.33846
ShadowSoft = 2
Reflection = 0
BaseColor = 1,1,1
OrbitStrength = 0.64935
X = 0.5,0.6,0.6,0.2126
Y = 1,0.6,0,0.30708
Z = 0.8,0.78,1,1
R = 0.666667,0.666667,0.498039,0.03174
BackgroundColor = 0.6,0.6,0.45
GradientBackground = 0.3
CycleColors = false
Cycles = 6.95699
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
Iterations = 8
ColorIterations = 5
Scale = 3
Offset = 1,1,1
#endpreset
20 - Progressive 2D.frag
// An example of using progressive rendering.
// Bbuffers are set up by the 'Progressive2D' fragment.
//
// Remember to set 'Render mode' to 'Progressive'.
// Progressive rendering, makes very high-quality AA possible.
// Notice, that this is a difficult image to render, due to very high frequency components.

vec3 color(vec2 v) {
	vec2 p = (viewCoord+vec2(1.0))/2.0;
	p=p/pixelSize;
	
	if (p.y<40.0) {
		return vec3(pow(0.5,1.0/Gamma));
	}
	float r = dot(v,v);
	float a = 1.0;
	if (mod(r,1.0)<0.5) a =1.0-a;
	if (v.y>0.0) a = 1.0-a;
	return vec3(a);
}




#preset Default
Center = 0.0727965,-0.192122
Zoom = 0.141329
Gamma = 2.2
ToneMapping = 1
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
AARange = 4.15701
AAExp = 1.81626
GaussianAA = true
#endpreset
21 - Progressive 2D Escape Time Fractal.frag
// An example of Escape Time Fractals, 
// using progressive rendering.
// Bbuffers are set up by the 'Progressive2DJulia' fragment.
// 
// Remember to set 'Render mode' to 'Continous'.
// Progressive rendering, makes very high-quality AA possible.

//  Fractal by Kali: http://www.fractalforums.com/new-theories-and-research/very-simple-formula-for-fractal-patterns/msg31800/#msg31800

uniform float MinRadius; slider[0,0,10]
uniform float Scaling; slider[-5,0,5]

vec2 formula(vec2 z,vec2 c) {
	float m =dot(z,z);
	if (m<MinRadius) {
		z = abs(z)/(MinRadius*MinRadius);
	}else {
		z = abs(z)/m*Scaling;
	}
	return z+c;
}

#preset Default
Center = -0.118362,0.0108127
Zoom = 10.8053
Gamma = 2.5463
ToneMapping = 3
Exposure = 1.3044
Brightness = 1
Contrast = 1.0396
Saturation = 1.8817
AARange = 1
AAExp = 1
GaussianAA = false
Iterations = 1000
PreIterations = 15
R = 1
G = 0.84034
B = 0.525
C = 0.90756
Julia = true
JuliaX = 1.43649
JuliaY = 2.05404
ShowMap = false
MapZoom = 2.1
EscapeSize = 5
ColoringType = 0
ColorFactor = 0.5
MinRadius = 0
Scaling = -1.9231
#endpreset
22 - Progressive 3D Rendering.frag
#info knot thingy by knighty (2012). Based on an idea by DarkBeam from fractalforums (http://www.fractalforums.com/new-theories-and-research/not-fractal-but-funny-trefoil-knot-routine/30/)
#include "Soft-Raytracer.frag"
#group Trefoil


//Radius of the tubes
uniform float tubeRadius; slider[0,0.1,0.5]

//Radius of the goup of tubes
uniform float groupRadius; slider[0,0.4,0.5]

//Radius of the whole object (because it looks like a torus (-:)
uniform float objectRadius; slider[0,1,1]

//Rotation Numerator X: actually not a rotation. This is frequency in x direction
uniform int    RotNumeratorX; slider[-10,2,10]

//Rotation Numerator Y: actually not a rotation. This is frequency in y direction. (lissajou figure)
uniform int    RotNumeratorY; slider[-10,4,10]

//Rotation Denominator: this is the rotation "speed" in xz plane
uniform int    RotDenominator; slider[1,3,20]

//Rotations number: how many instances to check. related to the period of the knot. Have to find math formula for that. 
uniform int    Rotations; slider[1,1,10]

float Cylinder(vec2 p){
	p.x-=groupRadius;
	return length(p)-tubeRadius;
}

float twist(vec3 p){//seen from above it is a lissajou fugure
	float ra =p.z*float(RotNumeratorX)/float( RotDenominator);
	float raz=p.z*float(RotNumeratorY)/float(RotDenominator);
	return length(p.xy-vec2(groupRadius*cos(ra)+objectRadius,groupRadius*sin(raz)+objectRadius))-tubeRadius;
}

vec3 bend2PI(vec3 p){
	return vec3(length(p.xz),p.y,atan(p.z,p.x));
}

float DE(vec3 p) {
	float r=length(p.xz), ang=atan(p.z,p.x),y=p.y;
	float d=10000.;
	for(int i=0; i<Rotations;i++){
		vec3 p=vec3(r,y,ang+2.*PI*float(i));
		p.x-=objectRadius;
		d=min(d,twist(p));
	}
	return min(d,p.y);
}

#preset default
FOV = 0.62536
Eye = 0.77939,1.62364,1.44633
Target = -2.86937,-4.53699,-3.77496
Up = -0.312624,0.711048,-0.620502
EquiRectangular = false
FocalPlane = 1.4674
Aperture = 0.02
Gamma = 2.2685
ToneMapping = 2
Exposure = 0.9783
Brightness = 1
Contrast = 1.0891
Saturation = 1.4516
GaussianWeight = 1
AntiAliasScale = 2
Detail = -3
DetailAO = -0.14287
FudgeFactor = 0.66265
MaxRaySteps = 132
BoundingSphere = 4 Locked
Dither = 0 Locked
NormalBackStep = 1
AO = 0,0,0,0.61224
Specular = 0.3797
SpecularExp = 51.389
SpotLight = 0.811765,1,0.819608,2.2222
SpotLightPos = 5,2.676,-0.7042
SpotLightSize = 1.25157
CamLight = 0.0980392,0.713725,1,0.53846
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
Shadow = 0.86364 NotLocked
Sun = 0.84582,1.57
SunSize = 0.01
Reflection = 0
BaseColor = 0.701961,0.701961,0.701961
OrbitStrength = 0
X = 0.411765,0.6,0.560784,0.41748
Y = 0.666667,0.666667,0.498039,-0.16504
Z = 1,0.258824,0.207843,1
R = 0.0823529,0.278431,1,0.82352
BackgroundColor = 0,0,0
GradientBackground = 0.3261
CycleColors = true
Cycles = 4.04901
EnableFloor = false
FloorNormal = 0,0,0
FloorHeight = 0
FloorColor = 1,1,1
tubeRadius = 0.07534
groupRadius = 0.29851
objectRadius = 0.43077
RotNumeratorX = -2
RotNumeratorY = -4
RotDenominator = 3
Rotations = 3
#endpreset
23 - Working with the back buffer.frag
// A 'Game of Life' implementation
// demonstrating how to work with a pixel-accurate 
// back buffer.
// Switch to Continuous mode. Set Subframe max to zero!
// Make sure AntiAlias is off (set to 1).
//

uniform sampler2D backbuffer;
uniform float time;

/*
From Wikipedia:
Any live cell with fewer than two live neighbours dies, as if caused by under-population.
Any live cell with two or three live neighbours lives on to the next generation.
Any live cell with more than three live neighbours dies, as if by overcrowding.
Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
*/

vec2 position = (viewCoord*1.0+vec2(1.0))/2.0;


float rand(vec2 co){
	// implementation found at: lumina.sourceforge.net/Tutorials/Noise.html
	return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}


#define SubframeMax 0
#define IterationsBetweenRedraws 20

#TexParameter backbuffer GL_TEXTURE_MAG_FILTER GL_NEAREST
#TexParameter backbuffer GL_TEXTURE_WRAP_S GL_REPEAT
#TexParameter backbuffer GL_TEXTURE_WRAP_T GL_REPEAT

void  isAlive(float  dx, float  dy, inout int count) {
	 vec4 v1 = texture2D( backbuffer,  position + pixelSize*vec2( dx, dy ) );
      	 if (v1.x==1.0) count++;
}


vec3 color(vec2 z) {
	if (length(z)<0.1 && length(z)>0.08) return (rand(time*z) < 0.5 ? vec3(1.0,0.0,0.0) : vec3(0.0));
	vec4 v1 = texture2D( backbuffer, mod ( position , 1.0 ) );
	int neighbours = 0;
	int alive =0;
	 isAlive(0.0,0.0,alive);
	
	// Count neighbours
	isAlive(1.0,0.0, neighbours);
	isAlive(1.0,1.0, neighbours);
	isAlive(1.0,-1.0, neighbours);
	isAlive(0.0,1.0, neighbours);
	isAlive(0.0,-1.0, neighbours);
	isAlive(-1.0,1.0, neighbours);
	isAlive(-1.0,0.0, neighbours);
	isAlive(-1.0,-1.0, neighbours);
	
	// Rules
	if (alive==1) {
		if (neighbours<2) return vec3(v1.x*0.99,v1.y*0.99,v1.z);
		else if (neighbours<4) return vec3(1.0);
	} else {
		if (neighbours==3) return vec3(1.0);
	}

	return vec3(v1.x*0.95,v1.y*0.98,v1.z*0.999) ;
}


#preset Default
Center = 0,0
Zoom = 6.15279
AntiAliasScale = 1
AntiAlias = 1
#endpreset
24 - Pure 3D.frag
// An example of working with 3D without a distance estimator

// Free HDRI's: http://www.hdrlabs.com/sibl/archive.html

float sphereLine(vec3 pos, vec3 dir, vec3 center, float radius, out vec3 normal) {
	vec3 sd=center-pos;
	float b = dot(dir,sd);
	float temp = b*b+radius*radius-dot(sd,sd);
	if (temp>0.0) {
		temp = b - sqrt(temp); // intersection distance
		normal = normalize((pos+temp*dir)-center);
		return temp;
	}
	normal = vec3(0.0);
	return -1.;
}

#define PI  3.14159265358979323846264

vec3 equirectangularMap(vec3 dir, sampler2D sampler) {
	dir = normalize(dir);
	vec2 longlat = vec2(atan(dir.y,dir.x),acos(dir.z));
 	return texture2D(sampler,longlat/vec2(2.0*PI,PI) ).xyz;
	
}

uniform float Specular; slider[0,1,1]
uniform float Diffuse;slider[0,1,1]

vec3 color(vec3 pos, vec3 dir) {
	
	vec3 normal = vec3(1.0,1.0,1.0);
	float intersect = 10000.0;
	vec3 finalNormal = vec3(0.0);
	for (int j = 0; j < 6; j++) {
		float z = (float(j)-6.0)/2.0;
		float i = sphereLine(pos,normalize(dir),vec3(1.0,0.0+float(j),z),0.5, normal);
		if (i<intersect && i>0.) {
			intersect =i;
			finalNormal = normal;
		}
	}
	
	if (intersect<10000.) {
		vec3 reflected = -2.0*dot(dir,finalNormal)*finalNormal+dir;
		vec3 col = Specular*equirectangularMap(reflected, texture);
		vec3 col2 = Diffuse*equirectangularMap(finalNormal, texture2);
		return col+col2;
	}
	vec3 col =equirectangularMap(dir,texture);
	return col;
}



#preset Default
FOV = 0.4
Eye = 8.42062,8.55686,-1.41974
Target = 0.781867,2.10355,-1.35523
Up = 0.0291443,-0.024509,0.999275
EquiRectangular = false
FocalPlane = 1
Aperture = 0
Gamma = 2.2222
ToneMapping = 3
Exposure = 1
Brightness = 1
Contrast = 1
Saturation = 1
GaussianWeight = 1
AntiAliasScale = 2
texture = Ditch-River_2k.hdr
texture2 = Ditch-River_Env.hdr
Specular = 1,0
Diffuse = 1,0,1
#endpreset
25 - Image Based Lighting.frag
// Just a simple test scene...
float DE(vec3 p)
{
       p.xy=p.yx;
	float d = length(p+vec3(0.0,0.0,-0.25))-0.25;   //  sphere
	d= min(d, udRoundBox(p+vec3(0.2,1.0,-0.25),vec3(0.2),0.05)); // rounded box
	d =min(d, sdCone(p+vec3(1.,1.,-0.5),vec2(0.95,0.45))); // cone
	d = min(d, sdTorus88(p+vec3(-1.4,1.,-0.6),vec2(0.5,0.1))); // torus
	return min(p.z,d);// distance estimate
}

#preset Default
FOV = 0.58536
Eye = 0.246321,-1.72201,0.434156
Target = -5.5875,6.37903,-0.148662
Up = -0.00420879,0.0687221,0.997349
EquiRectangular = false
FocalPlane = 1
Aperture = 0
Gamma = 2.2685
ToneMapping = 3
Exposure = 0.82653
Brightness = 1
Contrast = 1
Saturation = 1
GaussianWeight = 1
AntiAliasScale = 2
Detail = -3.65484
DetailAO = -1.14289
FudgeFactor = 1
MaxRaySteps = 198
BoundingSphere = 4.3373
Dither = 0.5
NormalBackStep = 1
AO = 0,0,0,1
CamLight = 1,1,1,0
CamLightMin = 0
Glow = 1,1,1,0
GlowMax = 20
Fog = 0
Shadow = 0.70455
Background = Ditch-River_2k.hdr
Specular = Ditch-River_Env.hdr
Diffuse = Ditch-River_Env.hdr
EnvSpecular = 1.8
EnvDiffuse = 0
SpecularMax = 100
Sun = 1.38949,1.02653
SunSize = 0.0045
DebugSun = true
BaseColor = 1,1,1
OrbitStrength = 0
X = 0.5,0.6,0.6,0.2126
Y = 1,0.6,0,0.30708
Z = 0.8,0.78,1,0.35434
R = 0.666667,0.666667,0.498039,0.03174
BackgroundColor = 1,1,1
GradientBackground = 0.4348
CycleColors = false
Cycles = 1.1
EnableFloor = true
FloorNormal = 0,0,0.17074
FloorHeight = 0
FloorColor = 1,1,1
ShowFloor = false
TextureScale = 1
#endpreset
26 - 3D fractals without a DE.frag
#define providesInside

#define providesColor

#include "Brute-Raytracer.frag"
#group Mandelbulb
//#define IterationsBetweenRedraws 5

// Number of fractal iterations.
uniform int Iterations;  slider[0,9,100]

// Mandelbulb exponent (8 is standard)
uniform float Power; slider[-10,8,10]

// Bailout radius
uniform float Bailout; slider[0,5,30]

uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)]

uniform float RotAngle; slider[0.00,0,180]

uniform bool Julia; checkbox[false]
uniform vec3 JuliaC; slider[(-2,-2,-2),(0,0,0),(2,2,2)]

vec3 color(vec3 p) {
	return abs(vec3(p));
}

void powN2(inout vec3 z, float zr0) {
	float zo0 = asin( z.z/zr0 );
	float zi0 = atan( z.y,z.x );
	float zr = pow( zr0, Power-1.0 );
	float zo = zo0 * Power;
	float zi = zi0 * Power;
	zr *= zr0;
	z  = zr*vec3( cos(zo)*cos(zi), cos(zo)*sin(zi), sin(zo) );
}


bool inside(vec3 pos) {
	vec3 z=pos;
	float r;
	int i=0;
	r=length(z);
	while(r<Bailout && (i<Iterations)) {
		powN2(z,r);
		z+=(Julia ? JuliaC : pos);
		r=length(z);
		i++;
	}
	return (r<Bailout);
	
}

#preset Default
FOV = 0.62536
Eye = 0.137861,0.380908,-1.90454
Target = -1.05894,-1.3684,6.69989
Up = -0.970103,0.225702,-0.0892076
EquiRectangular = false
Gamma = 2.5
ToneMapping = 3
Exposure = 1.34694
Brightness = 1
Contrast = 0.9901
Saturation = 1
Near = 0.7368
Far = 2.45904
NormalScale = 0.58825
AOScale = 1.0194
Glow = 0.34167
AOStrength = 0.86047
Samples = 100
Stratify = true
DebugInside = false
SampleNeighbors = true
Specular = 0
SpecularExp = 5.455
SpotLight = 1,0.678431,0.494118,0.78431
SpotLightDir = 1,0.78126
CamLight = 1,1,1,0.38462
CamLightMin = 0
Fog = 0
ShowDepth = false
DebugNormals = false
BaseColor = 1,1,1
OrbitStrength = 0
X = 1,1,1,1
Y = 0.345098,0.666667,0,0.02912
Z = 1,0.666667,0,1
R = 0.0784314,1,0.941176,-0.0194
BackgroundColor = 0.607843,0.866667,0.560784
GradientBackground = 0.86955
CycleColors = false
Cycles = 1.1
Iterations = 9
Power = 8
Bailout = 5
RotVector = 1,1,1
RotAngle = 0
Julia = false
JuliaC = 0,0,0
#endpreset

Clone this wiki locally