跳轉到內容

分形/fragmentarium

來自華夏公益教科書,開放世界開放書籍
Fragmentarium 的螢幕截圖

Fragmentarium 是 Mikael Hvidtfeldt Christensen [1] 開發的一款開源跨平臺 IDE,用於探索基於 GPU 的畫素圖形。它受到 Adobe Pixel Bender 的啟發,但使用 GLSL,並且專門針對分形和生成系統而建立。

功能

  • 多標籤 IDE,帶有 GLSL 語法高亮
  • 用於操作引數設定的使用者小部件。
  • 不同的“滑鼠到 GLSL”對映方案
  • 模組化 GLSL 程式設計 - 包含其他片段
  • 包含用於距離估計系統的簡單光線追蹤器
  • 許多示例,包括 Mandelbulb、Mandelbox、萬花筒 IFS 和 Julia 四元數。

根據 LPGL 或 GPL 許可證授權和分發。

注意:某些片段(GLSL)著色器受其他作者版權保護,可能附帶其他許可證。在重新分發之前,請檢視片段檔案頭。

在提出問題之前,請閱讀常見問題解答。[2]

有關影像示例,請檢視 FF Fragmentarium 畫廊。[3][4]

更多資訊可以在以下網站找到:FractalForums.com -> Fragmentarium [5] 和 FractalForums.org -> Fragmentarium[6]


這是關於它的非官方維基。


Fragmentarium 有幾種不同的版本。主要區別是...

  • 版本 1.0 只有“時間”變數用於動畫。
  • 版本 1.0.31 引入了基於攝像機位置 Catmull-Rom 樣條線的關鍵幀動畫,帶有緩動曲線的引數變形,目標跟蹤自動對焦,OpenEXR 格式紋理輸入和影像輸出,以及德語、荷蘭語和俄語翻譯。
  • 版本 2.0.0 帶來了 samplerCube 紋理和雙精度統一小部件。

獲取 v1.0

[編輯 | 編輯原始碼]

可以在 syntopia.github[7] 上找到預編譯的 Mac 和 Windows 可執行檔案包

或者在 Ubuntu Linux 上...

先決條件

[編輯 | 編輯原始碼]
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
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

轉到 ~/Fragmentarium-master/Fragmentarium-Source 目錄,然後執行 Gui 程式 

cd ~/Fragmentarium-master/Fragmentarium-Source
./Fragmentarium-Source

注意:此時,最好將 Examples、Icons 和 Misc 資料夾與 Fragmentarium 可執行檔案一起移動到合適的 рабочая папка 中,並更改 Fragmentarium-Source.exe 檔案的名稱。

獲取 v1.0.31

[編輯 | 編輯原始碼]

可以在 Digilanti.org[8] 上找到 Windows 安裝程式

Windows 使用者可以下載 6.0M 的 Fragmentarium 安裝程式,並透過導航到您的下載資料夾並單擊安裝程式圖示來執行它。

這將安裝 Windows 可執行檔案 + 示例 Includes 和 Misc 資料夾 + Qt 5.6.2 執行時 DLL + GUI 翻譯檔案到您主資料夾中的工作資料夾中,並在開始選單中建立指向可執行檔案和維護程式的快捷方式。

原始碼

[編輯 | 編輯原始碼]

下載與 OpenEXR 原始碼捆綁在一起的 Fragmentarium 1.0.31 原始碼,或下載包含預編譯的靜態 OpenEXR 庫的較小歸檔檔案。

對於 windows,編譯指令碼期望在 C: 驅動器的頂層找到原始碼,因此將歸檔檔案解壓縮到那裡,或調整 windows bat 檔案中的路徑名。

注意:從這裡開始,v1.0.31 原始碼可根據要求提供,因為開發在 v2.0 分支中。

先決條件

[編輯 | 編輯原始碼]
CMake 3 + CMake-gui
Qt 5.6
C++ compiler
OpenGL 

上述軟體包應與相應的開發軟體包一起安裝。

Git (if fetching the source directly from the repository)

安裝 Qt v5.6 和 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

這將構建 OpenEXR 和 Fragmentarium 專案,並將可執行檔案與支援檔案安裝到 C:/Fragmentarium-1.0.31-3Dickulus/Fragmentarium 資料夾中,然後可以將此資料夾重新定位到您喜歡的任何位置。

歸檔檔案可以解壓縮到任何位置,標準開發環境(帶有 Qt5 OpenGL 和 OpenEXR)就足夠了。

cd <wherever>/Fragmentarium-1.0.31-3Dickulus/
sh ./mklinux.sh

這將構建 OpenEXR 和 Fragmentarium 專案,並將可執行檔案和支援檔案安裝到 **<wherever>/Fragmentarium-1.0.31-3Dickulus/Fragmentarium** 資料夾中,此資料夾隨後可以重新定位到您喜歡的任何位置。

要僅構建 Fragmentarium,在執行其中一個指令碼後...

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

獲取 v2.0.0

[edit | edit source]

Ubuntu

[edit | edit source]

github.com [9] 上的預編譯 **Ubuntu 14.04.5** 包需要 Qt v5.7

或者從 Ubuntu "trusty" 上的原始碼編譯

安裝 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

安裝 Qt-5.7

     sudo apt-add-repository -y ppa:beineri/opt-qt571-trusty
     sudo apt-get update -qq
     sudo apt-get install qtcreator-latest

安裝 openexr-2.2 開發版 + 執行時

     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

安裝 Extra-CMake-Modules 用於 FindOpenEXR()

     sudo apt-get install extra-cmake-modules
     source /opt/qt57/bin/qt57-env.sh

獲取原始碼

git clone https://github.com/3Dickulus/FragM

構建並安裝

cd FragM/Fragmentarium-Source
mkdir build
cd build
cmake -DNVIDIAGL4PLUS=ON -DUSE_OPEN_EXR=ON -DCMAKE_INSTALL_PREFIX=~/ ..
make install
  1. 以上操作將安裝在 /home/username/Fragmentarium 資料夾中,其中包含標頭檔案和支援檔案。
  2. 要為所有使用者安裝,請將 **-DCMAKE_INSTALL_PREFIX=~/** 更改為 **-DCMAKE_INSTALL_PREFIX=/usr/local** 並使用 **sudo make install**

SuSE Leap 42.2

[edit | edit source]

github.com [10] 上的 Linux **SuSE Leap 42.2** rpm 包的先決條件

**系統** 桌面
OpenEXR 2.1
Qt 5.6

構建

安裝 git 和最新的 CMake 和 CMake-GUI 程式,以及 ECM(**E**xtra **C**Make **M**odules)以及 Qt5 和 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

[edit | edit source]

**Mac OSX** 的先決條件(這是在 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

在呼叫 cmake 之前,需要設定這些環境變數...

     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"

獲取原始碼...

git clone https://github.com/3Dickulus/FragM

然後構建,執行以下命令...

     cd FragM/Fragmentarium-Source
     mkdir build
     cd build
     cmake -DNVIDIAGL4PLUS=ON -DUSE_OPEN_EXR=ON -DCMAKE_INSTALL_PREFIX=../../ ..
     make install

要構建 dmg 存檔,請執行以下命令...

     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

...這將在構建資料夾中建立一個名為 Fragmentarium-2.0.b-my_build.dmg 的檔案。

現在你已經安裝好了 ;)

[edit | edit source]

在瀏覽器中開啟 syntopia.github[11] 以瞭解預處理器命令、神奇的 uniforms 和 GUI 元素。

在瀏覽器中開啟 blog.hvidtfeldts[12] 以瞭解路徑追蹤 3D 分形背後的數學原理和 GLSL 程式碼。

v1.0 Syntopia 連結中找到的資訊對所有版本的 Fragmentarium 都有效。

GUI 使用

[edit | edit source]

透過點選可執行檔案的圖示從桌面執行。您可以將 **.frag**、**。fragparams** 和 **.png** 螢幕截圖檔案拖放到主視窗,Fragmentarium 將為 .frag 檔案開啟一個新標籤,或將引數設定應用到當前片段。設定儲存在螢幕截圖 png 檔案的“frAg”塊中,並由 Fragmentarium 自動識別。

命令列使用

[edit | edit source]
./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.

故障排除

[edit | edit source]

OpenGL 版本不匹配

[edit | edit source]

FragM 2 需要 OpenGL 4.1 Compatibility Profile 上下文。一些驅動程式在 Compatibility Profile 中提供較低版本,將較高版本保留給 Core Profile。

檢查它 

   glxinfo | grep "core profile"

不幸的是,如果 FragM 獲取了較低版本,它可能會在啟動時崩潰並出現段錯誤。

檢查您是否正在使用 MESA

  glxinfo | grep version

如果使用 Mesa 作為 OpenGL(最常見的是在 Linux 上使用 Free/Libre Open Source 驅動程式),您可以在啟動 FragM 之前透過在 shell 中設定環境變數來強制 Mesa 撒謊有關其功能。

export MESA_GL_VERSION_OVERRIDE="4.6COMPAT"

但這可能只是將崩潰推遲,直到呼叫不支援的功能。後果自負。

檔案和資料夾

[edit | edit source]

示例

[edit | edit source]

包含 16 個子資料夾中的 233 個檔案,此樹在 Examples 選單中重複,只需選擇一個,它將被載入到一個新的標籤中。

Examples/Tutorials

[edit | edit source]

包含 19 個教程片段,演示特定功能或技術。

Examples/ 中的其餘資料夾包含來自眾多貢獻者的片段,請參閱致謝

fqScript

[edit | edit source]

包含一些可以在 Fragmentarium 中載入、編輯、執行和儲存的示例 **F**ragmentarium **Q**t **S**cript 檔案。

雜項

[edit | edit source]

包含用於影片編碼器的 **opt**ions 檔案,此資料夾還用於工具指令碼,如 *mkcombined.sh* 和描述程式碼編輯器高亮的 glsl.xml,在 glsl.xml 的末尾,有使用者可選擇顏色和樣式提示的位置,因此可以根據自己的口味定製高亮顯示。

語言

[edit | edit source]

包含 Sabine、Crist-JRoger 和 SCORPION 貢獻的荷蘭語、德語和俄語的 GUI 翻譯檔案。

主視窗

[edit | edit source]
螢幕截圖

**頂部**,程式選單和動態選單
**工具欄**,緩衝區大小、構建、漸進式/動畫停止啟動倒帶、子幀設定和讀出、當前時間設定和讀出。
**左側**,片段編輯器,透過將分隔條一直拖到左側來隱藏
**中間**,GL 渲染區域
**右側**,變數小部件(uniforms)停靠視窗,可以浮動或隱藏
**底部**,日誌停靠視窗,可以浮動或隱藏
**狀態列**,傳遞資訊訊息,具有游標位置的 XYZ 讀出、每秒渲染幀數。

選單

[edit | edit source]

檔案

[edit | edit source]
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 | edit source]
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.

渲染

[edit | edit source]
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.

引數

[edit | edit source]
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.

示例

[edit | edit source]

此選單在執行時從當前活動 示例資料夾 的內容動態填充。選擇一個片段將載入檔案到新標籤並執行構建。

Windows

[edit | edit source]

這些是主視窗中可以顯示或隱藏的部分。在選單欄的空白部分右鍵單擊將顯示此選單作為彈出視窗。

Log
Variable Editor (uniforms)
File Toolbar
Edit Toolbar
Buffer Dimensions
Render Toolbar
Rendering Mode
Zappa Tools
Time

幫助

[edit | edit source]

這些應該是不言自明的。

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 工具

[edit | edit source]

當您的系統上安裝了 OpenEXR 時,此選單應填充這些命令。從此選單中選擇一個命令將顯示一個使用幫助對話方塊,這些都是命令列程式,此處只顯示有關命令的資訊。

exrenvmap
exrheader
exrmakepreview
exrmaketiled
exrmultipart
exrmultiview
exrstdattr

如果 EXR 工具 選單存在但沒有顯示任何條目,您可以透過 編輯 選單中的 偏好設定... 設定 EXR 二進位制路徑

主視窗對話方塊

[edit | edit source]
高解析度和動畫渲染  : 開啟渲染對話方塊。您可以在此處渲染單個影像或一系列動畫影像。
高解析度和動畫對話方塊
緩動曲線 : 此對話方塊表示當前選定滑塊可用的緩動選項。
緩動曲線對話方塊
時間軸 : 關鍵幀和緩動曲線的粗略表示,仍在開發中。
時間軸對話方塊
偏好設定 : 主要程式全域性選項。
偏好設定對話方塊
影片編碼 : 要設定 mencoder 或 ffmpeg,一些示例選項檔案位於 Misc 資料夾中。
影片編碼對話方塊

指令碼

[edit | edit source]

Fragmentarium 可以透過 fqscript 檔案中可用的指令碼命令進行控制。

通用命令

[edit | edit source]
   void setFrame(int);

設定當前幀號。


   int getFrame();

返回當前幀號。


   void loadFragFile(String);

開啟一個新的編輯器選項卡,載入名為 fragment 的檔案,初始化預設預設,如果檔案包含這些設定,則初始化關鍵幀和緩動曲線。


   bool initializeFragment();

返回成功或失敗。在渲染影像之前必須在修改鎖定變數後呼叫。


引數命令

[edit | edit source]
   void setParameter(String);

從字串中設定引數,格式為 "parameter = value",也接受引數檔案格式字串。


   void setParameter(String, bool);

設定布林引數,其中 String 是引數名稱,bool 是 TRUE 或 FALSE


   void setParameter(String, int);

設定整數引數,其中 String 是引數名稱,int 是任何整數。


   void setParameter(String, x);

設定浮點引數,其中 String 是引數名稱,x 是任何浮點數。


   void setParameter(String, x, y);

設定 float2 引數,其中 String 是引數名稱,x,y 是任何浮點數。


   void setParameter(String, x, y, z);

設定 float3 引數,其中 String 是引數名稱,x,y,z 是任何浮點數。


   void setParameter(String, x, y, z, w);

設定 float4 引數,其中 String 是引數名稱,x,y,z,w 是任何浮點數。


   String getParameter(String);

返回表示命名引數的值的字串,使用者必須將其解析為可用的值。


   void applyPresetByName(String);

應用命名預設。


高解析度影像和動畫對話方塊命令

[edit | edit source]
   void setAnimationLength(int);

設定總動畫持續時間(以秒為單位)。


   void setTileWidth(int);
   void setTileHeight(int);

設定圖塊寬度和高度。


   void setTileMax(int);

設定行和列圖塊的數量,此值平方 = 總圖塊。


   void setSubFrames(int);

設定要累積的幀數。


   void setOutputBaseFileName(String);

設定儲存影像的檔名,如果指令碼完全控制,則必須在每幀中由指令碼設定,如果動畫使用 frag 檔案設定、關鍵幀等,則只需設定一次基名,Fragmentarium 將新增一個填充到 5 位的索引。


   void setFps(int);

設定渲染的幀率。


   void setStartFrame(int);

設定渲染一系列幀的起始幀號。


   void setEndFrame(int);

設定渲染一系列幀的結束幀號。


   void setAnimation(bool);

FALSE 將動畫設定為僅由指令碼控制。TRUE 啟用來自關鍵幀和緩動曲線的控制。


   void setPreview(bool);

TRUE 將在桌面上的視窗中預覽幀,而不是儲存影像檔案。


控制命令

[edit | edit source]
   bool scriptRunning();

當用戶在指令碼編輯器中選擇 [停止] 按鈕時返回 FALSE。用於在指令碼中實現使用者測試以退出指令碼控制迴圈。


   void stopScript();

用於在指令碼中實現使用者測試以退出指令碼控制迴圈或錯誤,例如檔案未找到、初始化失敗等。


   void tileBasedRender();

開始渲染當前幀或一系列幀,應用當前的關鍵幀狀態和活動緩動設定。

預處理器命令

[edit | edit source]

(來自 syntopia.github.io) Fragmentarium 添加了一些額外的預處理器命令。


#include "some.frag"

只需包含引用的檔案。如果檔名是相對檔名,Fragmentarium 首先搜尋與當前執行檔案(如果已儲存)的位置相關的檔案,否則搜尋“包含路徑”偏好設定中指定的路徑。


#camera 3D

告訴 Fragmentarium 設定 3D 相機模型,以便使用畫布上的滑鼠調整相機。


#camera 2D

告訴 Fragmentarium 設定 2D 相機模型。


#group parameter group name

可以按組對 GUI 元素進行排序。


#info "hello there"

編譯片段時輸出資訊。對歸屬很有用。


#includeonly "some.frag"

實驗性。包含 'some.frag',但會忽略該檔案中的任何 'include' 命令。


#replace "before" "after"

實驗性。在所有後續讀取行(不在先前解析的行中)中替換給定的模式。


#donotrun

告訴 Fragmentarium 不應嘗試執行此檔案——它旨在從另一個檔案包含。


#preset name

標記具有引數設定的節的開始。這些將顯示在引數編輯器視窗的下拉組合框中。


#endpreset

標記具有引數設定的節的結束。

統一小部件

[edit | edit source]

行:uniform float Angle; slider[45.00,0,360] 在 GLSL 編輯器中將使一個簡單的變數編輯器小部件出現。

要為其他型別的制服建立小部件...

uniform type name ; widget[min,default,max] locktype

關鍵字 uniform 必須始終出現在行的開頭。
locktype 可以是 locked notlocked notlockable alwayslocked 中的其中之一,預設為 notlocked
在選單/編輯/偏好設定對話方塊中,您可以選擇鎖定處理的行為。“鎖定”制服可以解釋為最終傳送到 GPU 的 GLSL 程式碼中的“#define”或“const”。

typewidget 可以是以下 GLSL 有效型別和相應的 Fragmentarium 小部件...

v1.0 - v1.0.31

[編輯 | 編輯原始碼]
型別 小部件
uniform int name; slider[min,default,max]
uniform bool name; checkbox[truefalse]
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] 僅顏色選擇器
uniform vec4 name; color[min,default,max, R, G, B] 帶有顏色選擇器的滑塊
uniform sampler2D name; file[imageFileName] 可以是任何支援的格式

所有 v1.0 - v1.0.31 以及這些...

型別 小部件
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] 僅顏色選擇器
uniform dvec4 name; color[min,default,max, R, G, B] 帶有顏色選擇器的滑塊


所有 float 型別滑塊都有 7 位小數,而 double 型別則有 14 位。

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.frag
01 - 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

如何建立關鍵幀動畫

  1. 選擇選單項... 編輯->插入命令->預設->從當前設定插入預設或按下“F8”鍵。
  2. 這將為您提供選擇名稱或使用提供的名稱的機會。
  3. 對於非關鍵幀預設,將名稱更改為您喜歡的任何名稱。
  4. 保持原樣以將其新增為關鍵幀,必須命名為“KeyFrame.nnn”,並且在您新增新的關鍵幀時會自動遞增。
  5. 必須至少有 2 個關鍵幀才能開始動畫。
  6. 建議只從一個預設預設開始。
  7. 添加了一些關鍵幀後,選擇“動畫”按鈕,然後選擇“播放”。您應該看到動畫正在播放。
  8. 如果您已經有了關鍵幀,並且想調整其中一個...
  9. 將要編輯的 KeyFrame.nnn 應用為當前檢視(從引數區域的預設選擇中)
  10. 更改您的檢視,您的觀看方向、位置等。
  11. 按下“F9”鍵以在文字編輯器中塊標記當前關鍵幀。(“應用”會為您執行此操作)
  12. 在選單中選擇“編輯->插入命令->預設->從當前設定插入預設”,或按下“F8”鍵。
  13. 您將看到“KeyFrame.nnn”,其中 nnn 與當前選定幀的編號相同。
  14. 新的相機座標將替換塊標記的關鍵幀。
  15. 就是這樣,完成了!教程 30 就是這樣建立的
  16. 相機路徑關鍵幀預設只有在您儲存建立它們的 GLSL 指令碼時才會儲存到檔案。
  17. CTRL+S 將儲存當前片段到檔案,無需對話方塊。
#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

如何啟用自動對焦

將此行新增到您的片段程式碼中,最好放在“相機”組中,如果“自動對焦”小部件尚不存在...

uniform bool AutoFocus; checkbox[false]

現在您可以啟用/停用焦平面目標跟蹤,焦平面的預設最大距離為 5,

如果您需要超過此距離,請開啟包含“FocalPlane”小部件的 .frag 檔案,並編輯最大值...

uniform float FocalPlane; slider[0,1,5]

到您需要的任何值,比如...

uniform float FocalPlane; slider[0,1,50]


請記住,目標會以一定距離漂浮在相機周圍,並在您導航時動態調整(有時會很多),它通常超出了您的視線範圍,並且需要在您建立關鍵幀之前設定,或者需要手動調整關鍵幀預設。


注意:在分形物體上單擊滑鼠中鍵應將目標設定在您單擊的分形的表面。

#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

如何建立引數變形動畫

這些設定可以透過在預設名稱中使用“範圍”來儲存,例如“#preset Range-100-200”,幀號對緩動曲線值沒有影響,並且會被忽略,它們是為了讓人類能夠想起此範圍涵蓋的內容,允許使用唯一的名稱,例如“Range-fogIn” “Range-fogOut” 等,這些範圍也可以透過 fqScript 應用,例如:applyPresetByName("Range-fogIn")


這些可以放在“預設”預設中,以便從 cmdline(例如:遠端機器)載入片段時,它們會立即生效。

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


每行上的專案的使用方式如下...

[Variable Name]:[Ease Name]:[Ease Type]:[start frame]:[end frame]:[begin parameter value]:[end parameter value]:[period]:[amplitude]:[overshoot]:[loops]:[pong]


是的,是的,有很多愚蠢的事情需要記住,但幸運的是,有一個非常棒的小 GUI 可以處理所有這些 :)

  1. 載入教程 32
  2. 選擇“Mandelbulb”選項卡
  3. 選擇“Power”滑塊
  4. 按下“F7”鍵(或選單項“編輯->新增緩動曲線”)
  5. 更改一些設定
  6. 點選確定,就是這樣,完成了!

開始幀之前的幀將使用開始值,直到到達開始幀。

結束幀之後的幀將使用結束值,直到動畫結束。

這些在動畫播放時生效。

當您對已經具有曲線的變數執行此操作時,系統會提示您“應用”、“放棄”、“取消”。

“應用”將為此變數更改這些設定(喜歡它,保留它)

“放棄”將刪除此變數的設定(清理,沒有動畫)

“取消”什麼也不做

這隻會將更改儲存到內部!如果您喜歡結果,那麼...

  1. 您需要儲存引數檔案,或者
  2. 使用新名稱新增一個新預設,並儲存 GLSL 指令碼,或者
  3. 渲染高解析度或動畫以建立“<frag-name>_Files”

此資料夾將包含您所有 var 變形設定,在一個預設預設和 campath 關鍵幀中

引數變形設定應該都在一個命名(不是關鍵幀)預設中。

#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

Fragmentarium 的靈感和公式很大程度上來自 FractalForums.com 的社群,包括 Tom Beddard、Jan Kadlec、Iñigo Quilez、Buddhi、Jesse 以及其他成員。特別感謝 Knighty 和 Kali 為我們提供了很棒的片段。所有片段都應包含有關其起源的資訊 - 如果我做錯了歸屬,請通知我。

使用的圖示是 Everaldo: Crystal 專案的一部分。

Fragmentarium 是使用跨平臺 GUI 框架 Qt 構建的。

Fractal Forums 使用者的翻譯

  • 俄語 SCORPION
  • 俄語 Crist-JRoger
  • 德語 Sabine
  • 荷蘭語 Sabine

貢獻者,這意味著過去 7 年來 FractalForums.com 上幾乎所有的人?此列表並不完整。

  1. 3Dickulus
  2. Adam Majewski
  3. bermarte
  4. Buddhi
  5. cKleinhuis
  6. Claude
  7. Crist-JRodger
  8. DarkBeam
  9. Eiffie
  10. Íñigo Quílez
  11. Jesse
  12. Kali
  13. Knighty
  14. M Benesi
  15. mclarekin
  16. Patryk Kizny
  17. Stefan Gustavson
  18. Sabine
  19. SCORPION
  20. Syntopia
  21. SubBlue
  22. tglad
  23. Tryptophan
  24. Vinz
  25. _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.

其他文件

[編輯 | 編輯原始碼]

參考文獻

[編輯 | 編輯原始碼]
  1. Mikael Hvidtfeldt Christensen
  2. Fragmentarium FAQ by Mikael Hvidtfeldt Christensen December 30, 2011
  3. FractalForums.com -> Gallery
  4. FractalForums.org -> Gallery
  5. FractalForums.com -> Fragmentarium
  6. FractalForums.org -> Fragmentarium
  7. v1.0 github
  8. v1.0.31 Digilanti.org
  9. Ubuntu github.com
  10. SuSE github.com
  11. Fragmentarium 使用說明
  12. Fragmentarium 部落格
  13. Fragmentarium 主頁
  14. github 頁面
  15. Fragmentarium 部落格
  16. Fragmentarium 官方常見問題解答
  17. 3Dickulus: FragM wiki 在 github 上
  18. 分形論壇頁面
  19. 程式設計頁面
  20. FF 畫廊
  21. flicker 群組
  22. deviantart 搜尋
  23. Fragmentarium deviantart 群組
華夏公益教科書