Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Fractals/fragmentarium

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

thumbnail|right|Screen shot of Fragmentarium Fragmentarium is an open source, cross-platform IDE by Mikael Hvidtfeldt Christensen Mikael Hvidtfeldt Christensen for exploring pixel based graphics on the GPU. It is inspired by Adobe's Pixel Bender, but uses GLSL, and is created specifically with fractals and generative systems in mind." Features: Multi-tabbed IDE, with GLSL syntax highlighting User widgets to manipulate parameter settings. Different 'mouse to GLSL' mapping schemes Modular GLSL programming - include other fragments Includes simple raytracer for distance estimated systems Many examples including Mandelbulb, Mandelbox, Kaleidoscopic IFS, and Julia Quaternion. Licensed and distributed under the LPGL or GPL license. Notice: some fragment (GLSL) shaders are copyright by other authors, and may carry other licenses. Please check the fragment file header before redistributing. Please read the FAQ, before asking questions. Fragmentarium FAQ by Mikael Hvidtfeldt Christensen December 30, 2011 For examples of images take a look at the FF Fragmentarium galleries.FractalForums.com -> GalleryFractalForums.org -> Gallery More information can be found at: FractalForums.com -> Fragmentarium FractalForums.com -> Fragmentarium and FractalForums.org -> FragmentariumFractalForums.org -> Fragmentarium This the unofficial wiki about it. Intro Fragmentarium comes in a few different flavors. The major differences are... Version 1.0 has only the "time" variable for animating. Version 1.0.31 introduces camera position Catmull-Rom spline based keyframing, parameter morphing with easing curves, target tracking auto focus, OpenEXR format input for textures and output for images, along with German, Dutch and Russian translations. Version 2.0.0 brings samplerCube textures and double precision uniform widgets. Get v1.0 Precompiled Mac and Windows executable packages can be found at syntopia.githubv1.0 github or on Ubuntu Linux... Prerequisites cmake 3 Qt 4 C++ compiler OpenGL development libs Git (if fetching the source directly from the repository) sudo apt-get install build-essential libx11-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libxext-dev libqt4-opengl-dev git clone https://github.com/Syntopia/Fragmentarium Build cd Fragmentarium-master cd Fragmentarium-Source cd "Build - Linux" ( there are also build folders for Mac OSX, Windows and QCreator with build scripts. ) sh build.sh Run Go to the ~/Fragmentarium-master/Fragmentarium-Source directory, then run Gui program : cd ~/Fragmentarium-master/Fragmentarium-Source ./Fragmentarium-Source Note: at this point it would be a good idea to move the Examples, Icons and Misc folders with the Fragmentarium executable into a suitable working folder and change the name of the Fragmentarium-Source.exe file. Get v1.0.31 Windows installer can be found at Digilanti.orgv1.0.31 Digilanti.org Windows users can download the 6.0M Fragmentarium Installer and run it by navigating to your Downloads folder and clicking the installer icon. This will install the Windows Executable + Examples Includes and Misc folders + Qt 5.6.2 runtime DLLs + GUI translation files into a working folder in your home folder with startmenu shortcuts to the executable and the Maintenance program. Source Code Download Fragmentarium 1.0.31 sources bundled with OpenEXR sources or the smaller archive with precompiled static OpenEXR libs. For windows the compile scripts expect to find the source in top level of C: drive so extract the archive there or adjust the pathnames in the windows bat file. Note: the v1.0.31 sources are available on request as development is in the v2.0 branch from here on. Prerequisites CMake 3 + CMake-gui Qt 5.6 C++ compiler OpenGL The above packages should be installed along with their corresponding development packages. Git (if fetching the source directly from the repository) Build Windows After installing Qt v5.6 and MinGW v4.9.2 Start Menu/Programs/Qt Tools/5.6/MinGW 4.9.2 (32-bit)/Qt 5.6 for Desktop (MinGW 4.9.2 32 bit) cd C:/Fragmentarium-1.0.31-3Dickulus/ mkmingw This will build OpenEXR and the Fragmentarium project and install the executable with support files to C:/Fragmentarium-1.0.31-3Dickulus/Fragmentarium folder, this folder can then be relocated to wherever you like. Linux The archive can be extracted anywhere and the standard development environment with Qt5 OpenGL and OpenEXR should suffice. cd <wherever>/Fragmentarium-1.0.31-3Dickulus/ sh ./mklinux.sh This will build OpenEXR and the Fragmentarium project and install the executable and support files to <wherever>/Fragmentarium-1.0.31-3Dickulus/Fragmentarium folder, this folder can then be relocated to wherever you like. To build Fragmentarium only, after running one of the scripts... cd <wherever>/Fragmentarium-1.0.31-3Dickulus/Fragmentarium-Source/build cmake-gui .. ( to change any paths or precompile flags like the install prefix ) cmake-gui->configure cmake-gui->generate cmake-gui->quit make install Get v2.0.0 Ubuntu Precompiled Ubuntu 14.04.5 package at github.com Ubuntu github.com requires Qt v5.7 or to compile from source on Ubuntu "trusty" Install gcc-4.8 sudo add-apt-repository -y ppa:ubuntu-sdk-team/ppa sudo apt-get update -qq sudo apt-get -qq install g++-4.8 libc6-i386 Install Qt-5.7 sudo apt-add-repository -y ppa:beineri/opt-qt571-trusty sudo apt-get update -qq sudo apt-get install qtcreator-latest Install openexr-2.2 development + runtime sudo apt-add-repository -y ppa:thomas-schiex/blender sudo apt-get update -qq sudo apt-get install libilmbase-dev sudo apt-get install libopenexr-dev sudo apt-get install libilmbase12 sudo apt-get install libopenexr22 Install Extra-CMake-Modules for FindOpenEXR() sudo apt-get install extra-cmake-modules source /opt/qt57/bin/qt57-env.sh Grab the source git clone https://github.com/3Dickulus/FragM Build and install cd FragM/Fragmentarium-Source mkdir build cd build cmake -DNVIDIAGL4PLUS=ON -DUSE_OPEN_EXR=ON -DCMAKE_INSTALL_PREFIX=~/ .. make install The above will install in /home/username/Fragmentarium folder with includes and support files. To install for all users change -DCMAKE_INSTALL_PREFIX=~/ to -DCMAKE_INSTALL_PREFIX=/usr/local and use sudo make install SuSE Leap 42.2 Prerequisites for Linux SuSE Leap 42.2 rpm package at github.com SuSE github.com System Desktop OpenEXR 2.1 Qt 5.6 Build Install git and the latest CMake and CMake-GUI programs along with ECM (Extra CMake Modules) and the standard development environment for Qt5 and OpenEXR git clone https://github.com/3Dickulus/FragM cd FragM/Fragmentarium-Source mkdir build cd build cmake-gui .. (note: set USE_OPEN_EXR=OFF when OpenEXR is not available/desired) make -j4 make install (note: set the install prefix in cmake-gui before running make install, it will install to /usr/local by default, user home folder is OK.) Mac OSX dmg Prerequisites for Mac OSX (this is what was required to build on travis-ci.org) brew update brew tab homebrew/versions brew unlink gcc brew install gcc48 brew install qt5 brew install ilmbase openexr brew unlink openexr brew link --overwrite openexr brew unlink ilmbase brew link --overwrite ilmbase brew unlink cmake brew install cmake brew install git Before calling cmake these env vars need to be set... export PATH="$QTDIR/bin:$PATH" export PATH=/usr/local/bin:$PATH export CC=/usr/local/bin/gcc-4.8 export CXX=/usr/local/bin/g++-4.8 export QTDIR="/usr/local/opt/qt" export LDFLAGS="-L/usr/local/opt/qt/lib" export CPPFLAGS="-I/usr/local/opt/qt/include" Grab the source... git clone https://github.com/3Dickulus/FragM Then to build, execute the following... cd FragM/Fragmentarium-Source mkdir build cd build cmake -DNVIDIAGL4PLUS=ON -DUSE_OPEN_EXR=ON -DCMAKE_INSTALL_PREFIX=../../ .. make install And to build a dmg archive... cd ../../Fragmentarium-2.0.b macdeployqt ./Fragmentarium-2.0.b.app -dmg mv ./Fragmentarium-2.0.b.dmg ../Fragmentarium-Source/build/Fragmentarium-2.0.b-my_build.dmg cd ../Fragmentarium-Source/build ...this should create a file named Fragmentarium-2.0.b-my_build.dmg in the build folder. Now that you have it installed ;) Open syntopia.githubFragmentarium usage in your browser to learn about preprocessor commands, magical uniforms and GUI elements. Open blog.hvidtfeldtsFragmentarium blog in your browser to learn about the math behind path tracing 3D fractals and the GLSL code. The information found at the v1.0 Syntopia links is valid for all versions of Fragmentarium. GUI Usage Run from the desktop by clicking the icon for the executable file. You can drag and drop .frag , .fragparams and .png screenshot files onto the main window and Fragmentarium will open a new tab for a .frag file or apply the parameter settings to the current fragment. Settings are stored in screen shot png files in a chunk named "frAg" and are automatically recognized by Fragmentarium. Commandline Usage ./Fragmentarium-2.0.b [options] [filename.frag] <enter> Output: Fragmentarium is a cross-platform IDE for exploring pixel based GPU graphics. Options: -h, --help Displays this help. -v, --version Displays version information. --style <style> sets the application GUI style. Possible values are 'Breeze','Windows','GTK+','Fusion'. -l, --language <language> sets the application language. Possible values are 'en','de','ru','nl'. -s, --script <script> Fragmentarium command script file to load. Arguments: filename.frag initial fragment to open. Troubleshooting OpenGL version mismatch FragM 2 expects an OpenGL 4.1 Compatibility Profile context. Some drivers provide a lower version in Compatibility Profile, reserving higher versions for Core Profile. Check it : glxinfo | grep "core profile" Unfortunately if FragM gets a lower version, it can crash on startup with a segmentation fault. Mesa Check if you are using MESA: glxinfo | grep version If using Mesa for OpenGL (most commonly on Linux with Free/Libre Open Source drivers) you can force Mesa to lie about its capabilities by setting an environment variable in the shell before launching FragM: export MESA_GL_VERSION_OVERRIDE="4.6COMPAT" This may however merely postpone crashes until unsupported features are invoked. Use at your own risk. Files & Folders Examples Contains 233 files in 16 sub-folders, this tree is duplicated in the Examples menu, just select one and it will be loaded into a new tab. Examples/Tutorials Contains 19 tutorial frags that demonstrate specific features or techniques. The rest of the folders in Examples/ contain frags from a number of contributors, see Acknowledgements fqScript Contains some example Fragmentarium Qt Script files that can be loaded, edited, executed and saved from within Fragmentarium. Misc Contains options files for the video encoders, this folder is also intended for tool scripts like mkcombined.sh and the glsl.xml that describes highlighting for the code editor, at the end of glsl.xml there are places for user selectable colors and style hints so one can customize the highlighting to their own tastes. Languages Contains GUI translation files for Dutch, German and Russian contributed by Sabine, Crist-JRoger and SCORPION. Main Window thumb|Screenshot Top , Program Menus and dynamic menus Tool Bar , Buffer size, Build, Progressive/Animation stop start rewind, Subframe setting and readout, Current time setting and readout. Left , Fragment editor, hide by dragging the splitter bar all the way to the left Middle , GL rendering area Right , Variable widgets (uniforms) dock window, can float or be hidden Bottom , Log dock window, can float or be hidden Status Bar , relays info messages, has XYZ readout for cursor pos, rendered frames per second. Menus File New : Creates a new tab with a simple DE function. Open : Creates a new tab and loads the selected fragment file. Save : Writes the currently active tab to file. Save As : Writes the currently active tab to filename selected by user. Recent files list : History. Close Tab : Closes the currently active tab and associated windows. Exit Application : Quits Framentarium, user will be prompted if there are unsaved changes. Edit Cut : Cuts selected text to clipboard. Copy : Copies selected text to clipboard. Paste : Pastes current clipboard contents. Find : Locate selected text, if no selected text request user input. Shader Asm : Displays GPU assembler code for currently active shaders. (nVidia only) Indent Script : Indent selected text. Insert Command -> Preprocessor Commands : Inserts the selected preprocessor command at the cursor or replaces selected text. Special Uniforms : Inserts the selected uniform variable at the cursor or replaces selected text. Include File (from Preferences Path) : Creates an #include fileName statement at the current cursor position. Insert Preset (from Current Settings) : Appends a new named preset to the text editor. Add Easing Curve : Creates easingcurve settings for the currently selected slider. Add Key Frame : Appends a preset with only camera position information. Select Key Frame : Highlights the text associated with the currently listed keyframe from the variable editor pulldown menu. Preferencess : Global program settings. Render Build Systems : Compiles the shaders. High Resolution and Animation Render : Opens the rendering dialog. Output Preprocessed Script (debug) : Creates a new tab with the main fragment script after parsing all included files. Full Screen (ESC key toggle) : Switch to full screen mode. Save Screen Shot : Saves the current GL area. When image format is png the settings are saved in the "fRAg" chunk, Fragmentarium will recognize this chunk if the screen shot png file is dragged and dropped onto the main window and will attempt to apply those settings to the current fragment. Edit Command Script : Opens a simple editor and allows creating, loading and running a .fqs file, see fqScript folder for examples. Video Encoding : Opens a dialog where the user can select mencoder or ffmpeg to create videos from a folder of generated images. Parameters Reset All : Resets all uniforms to their specified default values. Copy Settings : Copies all variable settings to the clipboard. Copy Group : Copies a single group (variable editor tab) to the clipboard. Paste from Clipboard : Pastes clipbaord contents into variable editor. Paste Selected Text : Pastes the selected text (usually from a preset in the code window) into the variable editor. Save to File : Creates a parameters file. Load from File : Loads a parameters file. Examples This menu is populated dynamically at runtime from the contents of the currently active Examples folder. Selecting a fragment will load the file into a new tab and execute build. Windows These are parts of the main window that can be displayed or hidden. Right mouse button click in the empty part of the menu bar will show this menu as a popup. Log Variable Editor (uniforms) File Toolbar Edit Toolbar Buffer Dimensions Render Toolbar Rendering Mode Zappa Tools Time Help These should be self explanitory. About Show Welcome Note Mouse and Keyboard Help Scripting General Help Scripting Parameter Help Scripting Image Anim Dialog Help Scripting Control Help Clear Texture Cache Project Homepage (web link) Fragmentarium@FractalForums (web link) Fragmentarium 3Dickulus (web link) Flickr Fragmentarium Group (web link) GLSL Specifications (web link) Introduction to Distance Estimated Fractals (web link) Fragmentarium FAQ (web link) EXR Tools When OpenEXR is installed on your system this menu should be populated with these commands. Selecting a command from this menu will display a usage help dialog, these are all commandline programs and only information about the command is shown here. exrenvmap exrheader exrmakepreview exrmaketiled exrmultipart exrmultiview exrstdattr If the EXR Tools menu exists but shows no entries you can set the EXR binaries path via Preferences... from the Edit menu. Main Window Dialogs High Resolution and Animation Render : Opens the render dialog. Here you can render a single image or a range of images for animation. thumb|High Resolution and Animation Dialog Easing Curves : This dialog represents the easing options available for the currently selected slider. thumb|Easing Curve Dialog Timeline : A crude representation of keframes and easing curves, still under development. thumb|Timeline Dialog Preferences : Main program global options. thumb|Preferences Dialog Video Encoding : To setup mencoder or ffmpeg, some example options files are in the Misc folder. thumb|Video Encoding Dialog Scripting Fragmentarium can be controlled via scripting commands available in fqscript files. General commands void setFrame(int); Sets the current frame number. int getFrame(); Returns the current frame number. void loadFragFile(String); Opens a new editor tab, loads the named fragment file, initializes default preset, initializes keyframes and easing curves if the file contains these settings. bool initializeFragment(); Returns success or fail. Must be called after altering a locked variable before rendering an image. Parameter commands void setParameter(String); Set a parameter from String in the form of "parameter = value" also accepts parameter file formatted string. void setParameter(String, bool); Sets a boolean parameter where String is the parameter name and bool is TRUE or FALSE void setParameter(String, int); Sets an integer parameter where String is the parameter name and int is any integer. void setParameter(String, x); Sets a float parameter where String is the parameter name and x is any floating point number. void setParameter(String, x, y); Sets a float2 parameter where String is the parameter name and x,y are any floating point numbers. void setParameter(String, x, y, z); Sets a float3 parameter where String is the parameter name and x,y,z are any floating point numbers. void setParameter(String, x, y, z, w); Sets a float4 parameter where String is the parameter name and x,y,z,w are any floating point numbers. String getParameter(String); Returns a string representing the value(s) for the named parameter, user must parse this into usable values. void applyPresetByName(String); Applies the named preset. Hires image and animation dialog commands void setAnimationLength(int); Sets the total animation duration in seconds. void setTileWidth(int); void setTileHeight(int); Sets the tile width and height. void setTileMax(int); Sets the number of row and column tiles, this value squared = total tiles. void setSubFrames(int); Sets the number of frames to accumulate. void setOutputBaseFileName(String); Sets the filename for saved image, if script has total control this must be set by the script for every frame, if animation is using frag file settings, keyframes etc., then this only needs to be set once to basename and Fragmentarium will add an index padded to 5 digits. void setFps(int); Sets the frames per second for rendering. void setStartFrame(int); Sets the start frame number for rendering a range of frames. void setEndFrame(int); Sets the end frame number for rendering a range of frames. void setAnimation(bool); FALSE sets animation to script control exclusively. TRUE enables control from keyframes and easing curves. void setPreview(bool); TRUE will preview frames in a window on the desktop instead of saving image files. Control commands bool scriptRunning(); Returns FALSE when the user selects the [Stop] button in the script editor. For user implemented test in script to break out of the script control loop. void stopScript(); For user implemented test in script to break out of the script control loop or error like file not found, initialization fail etc. void tileBasedRender(); Begins rendering the current frame or range of frames applying the current state for keyframes and active easing settings. Preprocessor Commands (from syntopia.github.io) Fragmentarium adds a few additional preprocessor commands. #include "some.frag" Simply includes the referenced file. If the filename is a relative filename, Fragmentarium first searches for the file relative to the location of the current executing file (if it is saved), otherwise the paths specified in the 'include path' preference are searched. #camera 3D Tells Fragmentarium to setup a 3D camera model, making it possible to adjust the camera using the mouse on the canvas. #camera 2D Tells Fragmentarium to setup a 2D camera model. #group parameter group name Makes it possible to order GUI elements in groups. #info "hello there" Outputs info when compiling the fragment. Useful for attributions. #includeonly "some.frag" Experimental. Includes 'some.frag', but will ignore any 'include' commands in that file. #replace "before" "after" Experimental. Replaces the given patterns in all subsequent read lines (not in previously parsed lines). #donotrun Tells Fragmentarium that it should not attempt to run this file - it is meant be included from another file. #preset name Marks the beginning of a section with parameter settings. These will appear in a drop-down combobox in the parameter editor window. #endpreset Marks the end of a section with parameter settings. Uniform Widgets The line: uniform float Angle; slider[45.00,0,360] in the GLSL editor will make a simple variable editor widget appear. To create widgets for other types of uniforms... uniform type name ; widget[min,default,max] locktype The keyword uniform must always be present at the beginning of the line. locktype can be one of locked notlocked notlockable alwayslocked defaults to notlocked In the Menu/Edit/Preferences dialog you can select the behavior of lock handling. "Locked" uniforms can be interpreted as "#define"s or as "const"s in the final GLSL code that gets sent to the GPU. type and widget can be one of these GLSL valid types and corresponding Fragmentarium widgets... v1.0 - v1.0.31 Type Widget uniform int name; slider[min,default,max] uniform bool name; checkbox[true or false] uniform float name; slider[min,default,max] uniform vec2 name; slider[(min,min),(default,default),(max,max)] uniform vec3 name; slider[(min,min,min),(default,default,default),(max,max,max)] uniform vec4 name; slider[(min,min,min,min),(default,default,default,default),(max,max,max,max)] uniform vec3 name; color[R,G,B] color selector only uniform vec4 name; color[min,default,max, R, G, B] slider with color selector uniform sampler2D name; file[imageFileName] can be any supported format v2.0 All of v1.0 - v1.0.31 plus these... Type Widget uniform samplerCube name; file[cubemap.png] uniform double name; slider[min,default,max] uniform dvec2 name; slider[(min,min),(default,default),(max,max)] uniform dvec3 name; slider[(min,min,min),(default,default,default),(max,max,max)] uniform dvec4 name; slider[(min,min,min,min),(default,default,default,default),(max,max,max,max)] uniform dvec3 name; color[R,G,B] color selector only uniform dvec4 name; color[min,default,max, R, G, B] slider with color selector All float type sliders have 7 decimal places while double types have 14. Tutorials 00 - Simple 2D system.frag 00 - Simple 2D system.frag #include "2D.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.frag01 - Simple 2D Escape Time Fractal.frag #include "2DJulia.frag" #include "Complex.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 02 - User Variables and Presets.frag #include "2D.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 03 - Dynamic Systems.frag #include "2D.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 #include "2D.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 10 - Simple Distance Estimated 3D system.frag #define providesColor #include "Soft-Raytracer.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 11 - Simple Distance Estimated 3D fractal.frag #include "DE-Raytracer.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 12 - Faster raytracing of 3D fractals.frag // There are different ways to speedup // raytracing. // // 1) Using the 'Preview' sliders to render at lower resolution. // 2) Locking parameters, you do not want to change dynamically, by clicking the padlock next to them, and recompiling // 3) Using another raytracer: // // In this example the 'Fast-Raytracer' is used, // it is faster then the default one, but does // not offer as much flexibility. // // Subblue's raytracer is another faster option. #include "Fast-Raytracer.frag" //#include "Subblue-Raytracer.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 20 - Progressive 2D.frag #include "Progressive2D.frag" #include "Complex.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 21 - Progressive 2D Escape Time Fractal.frag #include "Progressive2DJulia.frag" #include "Complex.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 22 - Progressive 3D Rendering.frag // An example of rendering using the progressive 3D ray tracer, // which makes it possible to use effects like real soft shadows, // better anti-alias, better ambient-occlusion and depth-of-field. // Rendering is much slower, though. // // To use it, just include "Soft-Raytracer" instead of "DE-Raytracer" // // Remember to set 'Render mode' to 'Continous'! #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 23 - Working with the back buffer.frag #buffer RGBA16 #include "2D.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 24 - Pure 3D.frag #include "3D.frag" uniform sampler2D texture; file[Ditch-River_2k.hdr] uniform sampler2D texture2; file[Ditch-River_Env.hdr] // 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 25 - Image Based Lighting.frag // An example of Image Based Lighting. // // NOTICE: // The Ditch-River Panorama HDR is authored by 'Blotchi' and copyrighted by http://www.hdrlabs.com/sibl/archive.html // It is licensed under a CC3.0 license: http://creativecommons.org/licenses/by-nc-sa/3.0/us/ #include "IBL-Raytracer.frag" #include "QuilezLib.frag" #group TestScene uniform float TextureScale; slider[0,1,40] // 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 26 - 3D fractals without a DE.frag #info Mandelbulb without Distance Estimator #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 30 - Simple Keyframe Animation.frag 30 - Simple Keyframe Animation.frag How-To create a KeyFrame Animation: Select Menu Item... Edit->Insert Command->Presets->Insert Preset From Current Settings or Push the "F8" key. This will give you the opportunity to choose a name or use the one provided. For a NON-KeyFrame preset change the name to whatever you like. Leave it as is to add this as a KeyFrame, must be named "KeyFrame.nnn" and it will auto increment as you add new ones. Must have at least 2 KeyFrames to begin animating. Suggest starting with only a default Preset. After adding a few keyframes select the "Animation" button then select "Play". You should see your animation playing. If you already have keyframes and want to adjust one... Apply KeyFrame.nnn you want to edit as current view (from the Preset selection in the Parameters area) Make changes to your view, where you look at, location etc. Press the "F9" key to block mark the current keyframe in the text editor. ("Apply" does this for you) In the menu select "Edit->Insert Command->Presets->Insert Preset From Current Settings" or press the "F8" key. You will be shown "KeyFrame.nnn" where nnn is the same number as the currently selected frame. New camera coordinates will replace the block marked keyframe. That is it, done! this is how tutorial 30 was created Camera path KeyFrame presets are only saved to a file when you save the GLSL script you create them in. CTRL+S will save the current frag to file with no dialog. #info Mandelbulb Anim Fragment #info http://www.fractalforums.com/index.php?topic=16405.0 #define providesInit #group Raytracer // Sets focal plane to Target location uniform bool AutoFocus; checkbox[false] #include "DE-Raytracer-v0.9.10.frag" #include "MathUtils.frag" #group Mandelbulb // Number of fractal iterations. uniform int Iterations; slider[0,9,100] // Number of color iterations. uniform int ColorIterations; slider[0,9,100] // Mandelbulb exponent (8 is standard) uniform float Power; slider[0,8,16] // Bailout radius uniform float Bailout; slider[0,5,30] // Alternate is slightly different, but looks more like a Mandelbrot for Power=2 uniform bool AlternateVersion; checkbox[false] uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)] uniform float RotAngle; slider[0.00,0,180] #group Translation uniform vec3 TransVector; slider[(-1,-1,-1),(1,0,0),(1,1,1)] uniform float TransSpeed; slider[0,0,1] uniform float ImpulseStrength; slider[0,0,10] uniform float ImpulseRate; slider[0,0,10] uniform float ImpulseOffset; slider[0,0,10] uniform vec3 TRotVector; slider[(-1,-1,-1),(1,0,0),(1,1,1)] uniform float TRotSpeed; slider[0,0,45] mat3 rot; uniform float time; void init() { rot = rotationMatrix3(normalize(RotVector), RotAngle); } // This is my power function, based on the standard spherical coordinates as defined here: // http://en.wikipedia.org/wiki/Spherical_coordinate_system // // It seems to be similar to the one Quilez uses: // http://www.iquilezles.org/www/articles/mandelbulb/mandelbulb.htm // // Notice the north and south poles are different here. void powN1(inout vec3 z, float r, inout float dr) { // extract polar coordinates float theta = acos(z.z/r); float phi = atan(z.y,z.x); dr = pow( r, Power-1.0)*Power*dr + 1.0; // scale and rotate the point float zr = pow( r,Power); theta = theta*Power; phi = phi*Power; // convert back to cartesian coordinates z = zr*vec3(sin(theta)*cos(phi), sin(phi)*sin(theta), cos(theta)); } // This is a power function taken from the implementation by Enforcer: // http://www.fractalforums.com/mandelbulb-implementation/realtime-renderingoptimisations/ // // I cannot follow its derivation from spherical coordinates, // but it does give a nice mandelbrot like object for Power=2 void powN2(inout vec3 z, float zr0, inout float dr) { 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; dr = zr*dr*Power + 1.0; zr *= zr0; z = zr*vec3( cos(zo)*cos(zi), cos(zo)*sin(zi), sin(zo) ); } uniform bool Julia; checkbox[false] uniform vec3 JuliaC; slider[(-2,-2,-2),(0,0,0),(2,2,2)] // Compute the distance from `pos` to the Mandelbox. float DE(vec3 pos) { vec3 z=pos; float r; float dr=1.0; int i=0; if (TRotSpeed>0.0) { rot=rotationMatrix3(normalize(TRotVector),TRotSpeed*time); z*=rot; } if (TransSpeed>0.0) { z+=normalize(TransVector)*time*TransSpeed*10.0; } if (ImpulseStrength>0.0) { z+=normalize(TransVector)*(0.8+sin(time*ImpulseRate+ImpulseOffset))*ImpulseStrength; } r=length(z); while(r<Bailout && (i<Iterations)) { if (AlternateVersion) { powN2(z,r,dr); } else { powN1(z,r,dr); } z+=(Julia ? JuliaC : pos); r=length(z); z*=rot; if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r))); i++; } // if ((type==1) && r<Bailout) return 0.0; return 0.5*log(r)*r/dr; /* Use this code for some nice intersections (Power=2) float a = max(0.5*log(r)*r/dr, abs(pos.y)); float b = 1000; if (pos.y>0) b = 0.5*log(r)*r/dr; return min(min(a, b), max(0.5*log(r)*r/dr, abs(pos.z))); */ } float dummy(vec3 p){ p*=time; return time; } #preset Default FOV = 0.62536 Eye = 1.65826,-1.22975,0.277736 Target = -5.2432,4.25801,-0.607125 Up = 0.401286,0.369883,-0.83588 EquiRectangular = false FocalPlane = 1 AutoFocus = false Aperture = 0 Gamma = 2.08335 ToneMapping = 3 Exposure = 0.6522 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 Detail = -2.84956 DetailAO = -1.35716 FudgeFactor = 1 MaxRaySteps = 164 BoundingSphere = 10 Dither = 0.51754 NormalBackStep = 1 AO = 0,0,0,0.85185 Specular = 1.6456 SpecularExp = 16.364 SpecularMax = 10 SpotLight = 1,1,1,1 SpotLightDir = -0.22666,0.5 CamLight = 1,1,1,1.53846 CamLightMin = 0.12121 Glow = 1,1,1,0.43836 GlowMax = 52 Fog = 0 HardShadow = 0.35385 ShadowSoft = 12.5806 Reflection = 0 BaseColor = 1,1,1 OrbitStrength = 0.14286 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.3261 CycleColors = false Cycles = 4.04901 EnableFloor = true FloorNormal = 0,1,0 FloorHeight = -2 FloorColor = 1,1,1 Iterations = 12 ColorIterations = 8 Power = 8 Bailout = 6.279 AlternateVersion = true RotVector = 1,1,1 RotAngle = 0 Julia = false JuliaC = 0,0,0 #endpreset #preset KeyFrame.001 FOV = 0.62536 Eye = 1.65826,-1.22975,0.277736 Target = -5.2432,4.25801,-0.607125 Up = 0.401286,0.369883,-0.83588 #endpreset #preset KeyFrame.002 FOV = 0.62536 Eye = 3.96463,0.917888,0.279432 Target = -4.74042,-0.257782,-0.320685 Up = -0.709039,0.700838,-0.0780331 #endpreset #preset KeyFrame.003 FOV = 0.62536 Eye = 1.33376,0.978975,2.81437 Target = -2.37223,0.395544,-5.15089 Up = 0.0655203,0.994792,0.0780753 #endpreset #preset KeyFrame.004 FOV = 0.62536 Eye = -0.146262,0.991041,-0.550259 Target = -7.41034,2.09513,-5.36868 Up = 0.0484982,0.797152,0.601827 #endpreset 31 - Simple Focal Plane Tracking Target.frag 31 - Simple Focal Plane Tracking Target.frag How-To Enable Auto Focus Add this line to your frag code, preferably in the "Camera" group if the AutoFocus widget doesn't already exist... uniform bool AutoFocus; checkbox[false] Now you can enable/disable focal plane target tracking, the focal plane default maximum distance is 5, if you need more than that open the .frag file that contains the "FocalPlane" widget and edit the maximum... uniform float FocalPlane; slider[0,1,5] to what ever you need like... uniform float FocalPlane; slider[0,1,50] keep in mind that the target floats around at some distance from the camera, dynamically adjusted (sometimes a lot) as you navigate, it is generally beyond what you are looking at and will need to be set before you create a keyframe or they will need to be adjusted by hand in the keyframe presets. NOTE:Mid Mouse Button Click on the fractal object should set the target at the surface of the fractal where you click. #info Mandelbulb Anim Fragment #info http://www.fractalforums.com/index.php?topic=16405.0 #define providesInit #group Raytracer // Sets focal plane to Target location //uniform bool AutoFocus; checkbox[false] #include "DE-Raytracer-v0.9.10.frag" #include "MathUtils.frag" #group Mandelbulb // Number of fractal iterations. uniform int Iterations; slider[0,9,100] // Number of color iterations. uniform int ColorIterations; slider[0,9,100] // Mandelbulb exponent (8 is standard) uniform float Power; slider[0,8,16] // Bailout radius uniform float Bailout; slider[0,5,30] // Alternate is slightly different, but looks more like a Mandelbrot for Power=2 uniform bool AlternateVersion; checkbox[false] uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)] uniform float RotAngle; slider[0.00,0,180] #group Translation uniform vec3 TransVector; slider[(-1,-1,-1),(1,0,0),(1,1,1)] uniform float TransSpeed; slider[0,0,1] uniform float ImpulseStrength; slider[0,0,10] uniform float ImpulseRate; slider[0,0,10] uniform float ImpulseOffset; slider[0,0,10] uniform vec3 TRotVector; slider[(-1,-1,-1),(1,0,0),(1,1,1)] uniform float TRotSpeed; slider[0,0,45] mat3 rot; uniform float time; void init() { rot = rotationMatrix3(normalize(RotVector), RotAngle); } // This is my power function, based on the standard spherical coordinates as defined here: // http://en.wikipedia.org/wiki/Spherical_coordinate_system // // It seems to be similar to the one Quilez uses: // http://www.iquilezles.org/www/articles/mandelbulb/mandelbulb.htm // // Notice the north and south poles are different here. void powN1(inout vec3 z, float r, inout float dr) { // extract polar coordinates float theta = acos(z.z/r); float phi = atan(z.y,z.x); dr = pow( r, Power-1.0)*Power*dr + 1.0; // scale and rotate the point float zr = pow( r,Power); theta = theta*Power; phi = phi*Power; // convert back to cartesian coordinates z = zr*vec3(sin(theta)*cos(phi), sin(phi)*sin(theta), cos(theta)); } // This is a power function taken from the implementation by Enforcer: // http://www.fractalforums.com/mandelbulb-implementation/realtime-renderingoptimisations/ // // I cannot follow its derivation from spherical coordinates, // but it does give a nice mandelbrot like object for Power=2 void powN2(inout vec3 z, float zr0, inout float dr) { 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; dr = zr*dr*Power + 1.0; zr *= zr0; z = zr*vec3( cos(zo)*cos(zi), cos(zo)*sin(zi), sin(zo) ); } uniform bool Julia; checkbox[false] uniform vec3 JuliaC; slider[(-2,-2,-2),(0,0,0),(2,2,2)] // Compute the distance from `pos` to the Mandelbox. float DE(vec3 pos) { vec3 z=pos; float r; float dr=1.0; int i=0; if (TRotSpeed>0.0) { rot=rotationMatrix3(normalize(TRotVector),TRotSpeed*time); z*=rot; } if (TransSpeed>0.0) { z+=normalize(TransVector)*time*TransSpeed*10.0; } if (ImpulseStrength>0.0) { z+=normalize(TransVector)*(0.8+sin(time*ImpulseRate+ImpulseOffset))*ImpulseStrength; } r=length(z); while(r<Bailout && (i<Iterations)) { if (AlternateVersion) { powN2(z,r,dr); } else { powN1(z,r,dr); } z+=(Julia ? JuliaC : pos); r=length(z); z*=rot; if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r))); i++; } // if ((type==1) && r<Bailout) return 0.0; return 0.5*log(r)*r/dr; /* Use this code for some nice intersections (Power=2) float a = max(0.5*log(r)*r/dr, abs(pos.y)); float b = 1000; if (pos.y>0) b = 0.5*log(r)*r/dr; return min(min(a, b), max(0.5*log(r)*r/dr, abs(pos.z))); */ } float dummy(vec3 p){ p*=time; return time; } #preset Default FOV = 0.62536 Eye = 1.65826,-1.22975,0.277736 Target = -5.2432,4.25801,-0.607125 Up = 0,1,0 EquiRectangular = false AutoFocus = true FocalPlane = 1 Aperture = 0.05 Gamma = 2.08335 ToneMapping = 3 Exposure = 0.6522 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 Detail = -2.84956 DetailAO = -1.35716 FudgeFactor = 1 MaxRaySteps = 164 BoundingSphere = 10 Dither = 0.51754 NormalBackStep = 1 AO = 0,0,0,0.85185 Specular = 1.6456 SpecularExp = 16.364 SpecularMax = 10 SpotLight = 1,1,1,1 SpotLightDir = -0.22666,0.5 CamLight = 1,1,1,1.53846 CamLightMin = 0.12121 Glow = 1,1,1,0.43836 GlowMax = 52 Fog = 0 HardShadow = 0.35385 ShadowSoft = 12.5806 Reflection = 0 BaseColor = 1,1,1 OrbitStrength = 0.14286 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.3261 CycleColors = false Cycles = 4.04901 EnableFloor = true FloorNormal = 0,1,0 FloorHeight = -2 FloorColor = 1,1,1 Iterations = 12 ColorIterations = 8 Power = 8 Bailout = 6.279 AlternateVersion = true RotVector = 1,1,1 RotAngle = 0 TransVector = 1,0,0 TransSpeed = 0 ImpulseStrength = 0 ImpulseRate = 0 ImpulseOffset = 0 TRotVector = 1,0,0 TRotSpeed = 0 Julia = false JuliaC = 0,0,0 #endpreset #preset KeyFrame.001 FOV = 0.62536 Eye = 2,0,0 Target = 1,0,0 Up = 0,1,0 #endpreset #preset KeyFrame.002 FOV = 0.62536 Eye = 0.73087,0.0286388,1.42303 Target = 0.31975,-0.0253,0.62258 Up = 0,1,0 #endpreset #preset KeyFrame.003 FOV = 0.62536 Eye = 0.034575,-0.00331298,1.59962 Target = 0.0,0.0,0.0 Up = -0.368,1,0 #endpreset #preset KeyFrame.004 FOV = 0.62536 Eye = 0.034575,-0.00331298,1.59962 Target = 0.05491,-0.00217,0.99997 Up = 0.17544,1,0 #endpreset #preset KeyFrame.005 FOV = 0.62536 Eye = 0.0244074,-0.00388447,1.89945 Target = 0.05491,-0.00217,0.99997 Up = 0,1,0 #endpreset #preset KeyFrame.006 FOV = 0.62536 Eye = 0.0108507,-0.00464646,2.29922 Target = 0.05491,-0.00217,0.99997 Up = 0,1,0 #endpreset #preset KeyFrame.007 FOV = 0.62536 Eye = 0.0108507,-0.00464646,2.29922 Target = 0.02745,-0.0018,0.454545 Up = 0,1,0 #endpreset #preset KeyFrame.008 FOV = 0.62536 Eye = 0.0108507,-0.00464646,2.29922 Target = 0,0,0 Up = 0,1,0 #endpreset #preset KeyFrame.009 FOV = 0.62536 Eye = 0.0108507,-0.00464646,2.29922 Target = 0.05491,-0.00217,0.99997 Up = 0,1,0 #endpreset #preset KeyFrame.010 FOV = 0.62536 Eye = 0.0108507,-0.00464646,2.29922 Target = 0.05491,-0.00217,0.99997 Up = 0,1,0 #endpreset 32 - Simple Multi-Parameter Easing Animation.frag 32 - Simple Multi-Parameter Easing Animation.frag How-To create a Parameter Morph Animation These settings can be saved by using "Range" in the preset name like "#preset Range-100-200", the frame numbers have no impact on the easing curve values and are ignored, they are so the human can be reminded of what this range covers, allows for unique names like "Range-fogIn" "Range-fogOut" etc., these ranges can also be applied via fqScript eg: applyPresetByName("Range-fogIn") These can be placed in the "Default" preset so that when a frag is loaded from cmdline eg:remote machine, they will be active immediately. Cycles1:CosineCurve:44:1:24:1:240:0.3:1:1.7:1:0 Power1:SineCurve:43:1:6:20:220:0.3:1:1.7:1:0 RotAngle1:OutInBack:36:0:360:40:200:0.3:1:1.7:1:0 the items on each line are used as follows... [Variable Name]:[Ease Name]:[Ease Type]:[start frame]:[end frame]:[begin parameter value]:[end parameter value]:[period]:[amplitude]:[overshoot]:[loops]:[pong] yes yes a lot of silly things to remember but fortunately there's a nice little GUI for all that :) load tutorial 32 Select the "Mandelbulb" tab Select the "Power" slider Push "F7" key (or menu item "Edit->Add Easing Curve") Change some settings hit OK that is it, done! Frames before start frame will use start value until start frame is reached. Frames after finish frame will use finish value until end of animation is reached. These become active when the animation is playing. When you do this to a variable that already has a curve you will be prompted "Apply" "Discard" "Cancel" "Apply" will change these settings for this variable (like it, keep it) "Discard" will delete the settings for this variable (clean up, no animating) "Cancel" does nothing This only saves the changes internally!!! if you like the result then... you need to save parameters file or add a new preset with a new name and save the GLSL script or render a highres or anim to create "<frag-name>_Files" this folder will have all of your var morph settings in a single default preset and campath keyframes Parameter morph settings should all be in one named (not keyframe) preset. #info Mandelbulb Anim Fragment #info http://www.fractalforums.com/index.php?topic=16405.0 #define providesInit #group Raytracer // Sets focal plane to Target location //uniform bool AutoFocus; checkbox[false] #include "DE-Raytracer.frag" #include "MathUtils.frag" #group Mandelbulb // Number of fractal iterations. uniform int Iterations; slider[0,9,100] // Number of color iterations. uniform int ColorIterations; slider[0,9,100] // Mandelbulb exponent (8 is standard) uniform float Power; slider[0,8,16] // Bailout radius uniform float Bailout; slider[0,5,30] // Alternate is slightly different, but looks more like a Mandelbrot for Power=2 uniform bool AlternateVersion; checkbox[false] uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)] uniform float RotAngle; slider[0.00,0,360] mat3 rot; uniform float time; void init() { rot = rotationMatrix3(normalize(RotVector), RotAngle); } // This is my power function, based on the standard spherical coordinates as defined here: // http://en.wikipedia.org/wiki/Spherical_coordinate_system // // It seems to be similar to the one Quilez uses: // http://www.iquilezles.org/www/articles/mandelbulb/mandelbulb.htm // // Notice the north and south poles are different here. void powN1(inout vec3 z, float r, inout float dr) { // extract polar coordinates float theta = acos(z.z/r); float phi = atan(z.y,z.x); dr = pow( r, Power-1.0)*Power*dr + 1.0; // scale and rotate the point float zr = pow( r,Power); theta = theta*Power; phi = phi*Power; // convert back to cartesian coordinates z = zr*vec3(sin(theta)*cos(phi), sin(phi)*sin(theta), cos(theta)); } // This is a power function taken from the implementation by Enforcer: // http://www.fractalforums.com/mandelbulb-implementation/realtime-renderingoptimisations/ // // I cannot follow its derivation from spherical coordinates, // but it does give a nice mandelbrot like object for Power=2 void powN2(inout vec3 z, float zr0, inout float dr) { 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; dr = zr*dr*Power + 1.0; zr *= zr0; z = zr*vec3( cos(zo)*cos(zi), cos(zo)*sin(zi), sin(zo) ); } uniform bool Julia; checkbox[false] uniform vec3 JuliaC; slider[(-2,-2,-2),(0,0,0),(2,2,2)] // Compute the distance from `pos` to the Mandelbox. float DE(vec3 pos) { vec3 z=pos; float r; float dr=1.0; int i=0; r=length(z); while(r<Bailout && (i<Iterations)) { if (AlternateVersion) { powN2(z,r,dr); } else { powN1(z,r,dr); } z+=(Julia ? JuliaC : pos); r=length(z); z*=rot; if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r))); i++; } // if ((type==1) && r<Bailout) return 0.0; return 0.5*log(r)*r/dr; /* Use this code for some nice intersections (Power=2) float a = max(0.5*log(r)*r/dr, abs(pos.y)); float b = 1000; if (pos.y>0) b = 0.5*log(r)*r/dr; return min(min(a, b), max(0.5*log(r)*r/dr, abs(pos.z))); */ } float dummy(vec3 p){ p*=time; return time; } #preset Default FOV = 0.62536 Eye = 2.42106,0.501576,0.263686 Target = -6.2468,-0.836125,-0.622262 Up = 0,1,0 EquiRectangular = false AutoFocus = false FocalPlane = 1 Aperture = 0 Gamma = 2.08335 ToneMapping = 3 Exposure = 0.6522 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 Detail = -2.84956 DetailAO = -1.35716 FudgeFactor = 1 MaxRaySteps = 164 BoundingSphere = 10 Dither = 0.51754 NormalBackStep = 1 AO = 0,0,0,0.85185 Specular = 1.6456 SpecularExp = 16.364 SpecularMax = 10 SpotLight = 1,1,1,1 SpotLightDir = 0.22666,0.5 CamLight = 1,1,1,1.53846 CamLightMin = 0.12121 Glow = 1,1,1,0.43836 GlowMax = 52 Fog = 0 HardShadow = 0.35385 ShadowSoft = 12.5806 Reflection = 0 BaseColor = 1,1,1 OrbitStrength = 1 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.3261 CycleColors = true Cycles1:CosineCurve:44:1:24:1:240:0.3:1:1.7:1:0 Cycles = 12.4928 EnableFloor = true FloorNormal = 0,1,0 FloorHeight = -2 FloorColor = 1,1,1 Iterations = 12 ColorIterations = 8 Power1:SineCurve:43:1:6:20:220:0.3:1:1.7:1:0 Power = 1 Bailout = 6.279 AlternateVersion = true RotVector = 1,1,1 RotAngle1:OutInBack:36:0:360:40:200:0.3:1:1.7:1:0 RotAngle = 0.0 Julia = false JuliaC = 0,0,0 #endpreset #preset KeyFrame.001 FOV = 0.62536 Eye = 2.42106,0.501576,0.263686 Target = -6.2468,-0.836125,-0.622262 Up = 0,1,0 #endpreset #preset KeyFrame.002 FOV = 0.62536 Eye = 2.42106,0.501576,0.263686 Target = -6.2468,-0.836125,-0.622262 Up = 0,1,0 #endpreset 33 - Simple Skybox.frag 33 - Simple Skybox.frag #info Mandelbulb Distance Estimator #define providesInit #define providesBackground #define providesColor #include "MathUtils.frag" #include "DE-Raytracer.frag" #group Skybox uniform samplerCube skybox; file[cubemap.png] vec3 backgroundColor(vec3 dir) { float t = length(from-dir); dir *= -1.; return mix(textureCube(skybox, dir.xzy).rgb, BackgroundColor, 1.0-exp(-pow(Fog,4.0)*t*t)); } uniform float RefractiveIndex; slider[0,1,10] vec3 baseColor(vec3 point, vec3 N){ float ratio = 1.00 / RefractiveIndex; vec3 I = (point - from); vec3 R = refract(I, -N, ratio); return textureCube(skybox, R.xzy).rgb; } #group Mandelbulb // Number of fractal iterations. uniform int Iterations; slider[0,9,100] // Number of color iterations. uniform int ColorIterations; slider[0,9,100] // Mandelbulb exponent (8 is standard) uniform float Power; slider[0,8,16] // Bailout radius uniform float Bailout; slider[0,5,30] // mermelada's tweak Derivative bias uniform float DerivativeBias; slider[0,1,10] // Alternate is slightly different, but looks more like a Mandelbrot for Power=2 uniform bool AlternateVersion; checkbox[false] 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)] uniform float time; mat3 rot; void init() { rot = rotationMatrix3(normalize(RotVector), RotAngle); } // This is my power function, based on the standard spherical coordinates as defined here: // http://en.wikipedia.org/wiki/Spherical_coordinate_system // // It seems to be similar to the one Quilez uses: // http://www.iquilezles.org/www/articles/mandelbulb/mandelbulb.htm // // Notice the north and south poles are different here. void powN1(inout vec3 z, float r, inout float dr) { // extract polar coordinates float theta = acos(z.z/r); float phi = atan(z.y,z.x); // mermelada's tweak // http://www.fractalforums.com/new-theories-and-research/error-estimation-of-distance-estimators/msg102670/?topicseen#msg102670 dr = max(dr*DerivativeBias,pow( r, Power-1.0)*Power*dr + 1.0); // scale and rotate the point float zr = pow( r,Power); theta = theta*Power; phi = phi*Power; // convert back to cartesian coordinates z = zr*vec3(sin(theta)*cos(phi), sin(phi)*sin(theta), cos(theta)); } // This is a power function taken from the implementation by Enforcer: // http://www.fractalforums.com/mandelbulb-implementation/realtime-renderingoptimisations/ // // I cannot follow its derivation from spherical coordinates, // but it does give a nice mandelbrot like object for Power=2 void powN2(inout vec3 z, float zr0, inout float dr) { 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; // mermelada's tweak // http://www.fractalforums.com/new-theories-and-research/error-estimation-of-distance-estimators/msg102670/?topicseen#msg102670 dr = max(dr*DerivativeBias,zr*dr*Power + 1.0); zr *= zr0; z = zr*vec3( cos(zo)*cos(zi), cos(zo)*sin(zi), sin(zo) ); } // Compute the distance from `pos` to the Mandelbox. float DE(vec3 pos) { vec3 z=pos; float r; float dr=1.0; int i=0; r=length(z); while(r<Bailout && (i<Iterations)) { if (AlternateVersion) { powN2(z,r,dr); } else { powN1(z,r,dr); } z+=(Julia ? JuliaC : pos); r=length(z); z*=rot; if (i<ColorIterations) orbitTrap = min(orbitTrap, abs(vec4(z.x,z.y,z.z,r*r))); i++; } // if ((type==1) && r<Bailout) return 0.0; return 0.5*log(r)*r/dr; /* Use this code for some nice intersections (Power=2) float a = max(0.5*log(r)*r/dr, abs(pos.y)); float b = 1000; if (pos.y>0) b = 0.5*log(r)*r/dr; return min(min(a, b), max(0.5*log(r)*r/dr, abs(pos.z))); */ } #preset Default FOV = 0.62536 Eye = 1.578295,-2.374888,-0.1754925 Target = -2.237496,5.621949,-0.038792 Up = 0.0250519,0.0290368,-0.9993381 EquiRectangular = false AutoFocus = false FocalPlane = 1 Aperture = 0 Gamma = 2.08335 ToneMapping = 3 Exposure = 0.6522 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 DepthToAlpha = false ShowDepth = false DepthMagnitude = 1 Detail = -2.84956 DetailAO = -1.35716 FudgeFactor = 1 MaxDistance = 1000 MaxRaySteps = 164 Dither = 0.51754 NormalBackStep = 1 AO = 0,0,0,0.85185 Specular = 0.336 SpecularExp = 16.364 SpecularMax = 10 SpotLight = 1,1,1,1 SpotLightDir = 0.7,-0.42 CamLight = 1,1,1,1.53846 CamLightMin = 0.12121 Glow = 1,1,1,0.43836 GlowMax = 52 Fog = 0 HardShadow = 0.35385 ShadowSoft = 12.5806 QualityShadows = false Reflection = 0 DebugSun = 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.9701493 CycleColors = false Cycles = 4.04901 EnableFloor = false FloorNormal = 0,0,-1 FloorHeight = -3.095238 FloorColor = 1,1,1 Iterations = 12 ColorIterations = 8 Power = 8 Bailout = 6.279 AlternateVersion = true RotVector = 1,1,1 RotAngle = 0 Julia = false JuliaC = 0,0,0 skybox = cubemap.png RefractiveIndex = 5.604396 DerivativeBias = 1 #endpreset #preset Octobulb FOV = 0.62536 Eye = -0.184126,0.843469,1.32991 Target = 1.48674,-5.55709,-4.56665 Up = 0,1,0 AntiAlias = 1 Detail = -2.47786 DetailAO = -0.21074 FudgeFactor = 1 MaxRaySteps = 164 BoundingSphere = 2 Dither = 0.5 AO = 0,0,0,0.7 Specular = 1 SpecularExp = 27.082 SpotLight = 1,1,1,0.94565 SpotLightDir = 0.5619,0.18096 CamLight = 1,1,1,0.23656 CamLightMin = 0.15151 Glow = 0.415686,1,0.101961,0.18421 Fog = 0.60402 HardShadow = 0.7230800 Reflection = 0.0 BaseColor = 1,1,1 OrbitStrength = 0.62376 X = 0.411765,0.6,0.560784,-0.37008 Y = 0.666667,0.666667,0.498039,0.86886 Z = 0.666667,0.333333,1,-0.25984 R = 0.4,0.7,1,0.36508 BackgroundColor = 0.666667,0.666667,0.498039 GradientBackground = 0.5 CycleColors = true Cycles = 7.03524 FloorNormal = 0,0,0 FloorHeight = 0 FloorColor = 1,1,1 Iterations = 14 ColorIterations = 6 Power = 8.18304 Bailout = 6.279 AlternateVersion = true RotVector = 1,0,0 RotAngle = 77.8374 #endpreset #preset Refraction FOV = 0.807947 Eye = 1.49337,-0.0604384,-1.459009 Target = -4.526366,-0.2098799,5.042469 Up = -0.02031,0.9980528,0.0041359 EquiRectangular = false AutoFocus = false FocalPlane = 1 Aperture = 0 Gamma = 2 ToneMapping = 5 Exposure = 1 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 DepthToAlpha = false ShowDepth = false DepthMagnitude = 1 Detail = -3.601449 DetailAO = -1.35716 FudgeFactor = 1 MaxDistance = 1000 MaxRaySteps = 1185 Dither = 0.51754 NormalBackStep = 1 AO = 0,0,0,0 Specular = 0 SpecularExp = 0 SpecularMax = 0 SpotLight = 1,1,1,1 SpotLightDir = 0.63626,0.5 CamLight = 1,1,1,1.53846 CamLightMin = 0.12121 Glow = 1,1,1,1 GlowMax = 1000 Fog = 0 HardShadow = 0.35385 ShadowSoft = 12.5806 QualityShadows = false Reflection = 0 DebugSun = false BaseColor = 1,1,1 OrbitStrength = 1 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.3261 CycleColors = false Cycles = 4.04901 EnableFloor = false FloorNormal = 0,0,0 FloorHeight = 0 FloorColor = 1,1,1 Iterations = 0 ColorIterations = 10 Power = 8 Bailout = 6.279 DerivativeBias = 1 AlternateVersion = false RotVector = 1,1,1 RotAngle = 0 Julia = false JuliaC = 1,1,1 skybox = cubemap.png RefractiveIndex = 1.52 #endpreset #preset Reflection FOV = 1 Eye = 2.193986,2.218407,0.2322807 Target = -5.850334,-1.498805,0.2174372 Up = -0.0086972,0.021624,-0.7018754 EquiRectangular = false AutoFocus = false FocalPlane = 1 Aperture = 0 Gamma = 2 ToneMapping = 5 Exposure = 0.6522 Brightness = 1 Contrast = 1 Saturation = 1 GaussianWeight = 1 AntiAliasScale = 2 DepthToAlpha = false ShowDepth = false DepthMagnitude = 1 Detail = -1.318841 DetailAO = -1.35716 FudgeFactor = 1 MaxDistance = 1000 MaxRaySteps = 164 Dither = 0.51754 NormalBackStep = 1 AO = 0,0,0,0.85185 Specular = 1 SpecularExp = 16.364 SpecularMax = 10 SpotLight = 1,1,1,1 SpotLightDir = 0.7,-0.42 CamLight = 1,1,1,1.53846 CamLightMin = 0.12121 Glow = 1,1,1,0.43836 GlowMax = 52 Fog = 0 HardShadow = 0.35385 ShadowSoft = 12.5806 QualityShadows = false Reflection = 1 DebugSun = false BaseColor = 1,1,1 OrbitStrength = 0.14286 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.3261 CycleColors = false Cycles = 4.04901 EnableFloor = false FloorNormal = 0,0,0 FloorHeight = 0 FloorColor = 1,1,1 Iterations = 0 ColorIterations = 8 Power = 8 Bailout = 6.279 AlternateVersion = true RotVector = 1,1,1 RotAngle = 0 Julia = true JuliaC = 0,0,0 skybox = cubemap.png RefractiveIndex = 1.52 DerivativeBias = 0 #endpreset Acknowledgements Much of the inspiration and formulas for Fragmentarium came from the community at FractalForums.com, including Tom Beddard, Jan Kadlec, Iñigo Quilez, Buddhi, Jesse, and others. Special thanks goes out to Knighty and Kali for their great fragments. All fragments should include information about their origins - please notify me, if I made any mis-attributions. The icons used are part of the Everaldo: Crystal project. Fragmentarium is built using the Qt cross-platform GUI framework. Translations by Fractal Forums users: Russian SCORPION Russian Crist-JRoger German Sabine Dutch Sabine Contributors, This means allmost everyone at FractalForums.com over the last 7 years? This list is not complete. 3Dickulus Adam Majewski bermarte Buddhi cKleinhuis Claude Crist-JRodger DarkBeam Eiffie Íñigo Quílez Jesse Kali Knighty M Benesi mclarekin Patryk Kizny Stefan Gustavson Sabine SCORPION Syntopia SubBlue tglad Tryptophan Vinz _revers_ ...just to name a few, if anyone can add to this list it would be a great help. If you contributed an idea or fix to the GUI or source code then I think your user/name deserves mention here too. Other Docs official pages : home page Fragmentarium home page github Syntopia page github page blog Fragmentarium blog faq Fragmentarium official FAQ FragM wiki3Dickulus: FragM wiki on github Fractalforums : program page Fractal Forums page programming pageprogramming page gallery FF gallery flicker group flicker group deviantart search deviantart search Fragmentarium group Fragmentarium deviantart group commons : Category:Fragmentarium git forks github by Claude : Fragmentarium References