An efficient interactive C++ renderer for ShaderToy-alike demos with 2D/3D/CubeMap/Video/Camera/LightField/Volume textures. (Partially used in my I3D 2018 papers)
Clone or download
Latest commit 8f59bcf Oct 11, 2018
Permalink
Failed to load latest commit information.
Algorithm added various new shaders. Jul 30, 2018
Antialiasing completed texture3d / sampler3d / noise3d Sep 4, 2018
Blur Added various examples Sep 15, 2018
Colors Added submodules and recent shaders. Oct 5, 2018
Compression Shaders added. Apr 23, 2018
DataStructure fix the keyboard bug Dec 11, 2017
Diffusion added thumbnails of demos Apr 25, 2018
Distortion Added various examples Sep 15, 2018
DuEngine completed texture3d / sampler3d / noise3d Sep 4, 2018
DuShaders sketch demo Oct 11, 2018
Edge Shaders added. Apr 23, 2018
ExamplePictures added more examples Feb 13, 2018
FeaturedShaders Added submodules and recent shaders. Oct 5, 2018
FoveatedRendering Added submodules and recent shaders. Oct 5, 2018
Fractal added thumbnails of demos Apr 25, 2018
Gallery Added submodules and recent shaders. Oct 5, 2018
Games Added various examples Sep 15, 2018
ImageQualityCompare @ 4e76ead Added submodules and recent shaders. Oct 5, 2018
Lightfield added more examples. Apr 9, 2018
Lighting Added new shaders. Aug 6, 2018
Math Added submodules and recent shaders. Oct 5, 2018
NeuralNetworks added various new shaders. Jul 30, 2018
Noise Added GaussianNoise.glsl, the NoiseDistribution is a better one... Sep 28, 2018
Physics added thumbnails of demos Apr 25, 2018
RayTracing added TAA demos Aug 30, 2018
Sampling added thumbnails of demos Apr 25, 2018
Scripts remove unused files. Apr 24, 2018
ShaderOfWeek sketch demo Oct 11, 2018
Textures Added more shaders from my ShaderToy profile. Apr 26, 2018
Tutorials Added various examples Sep 15, 2018
UnitTests completed texture3d / sampler3d / noise3d Sep 4, 2018
Volume bonsai done. Apr 6, 2018
.gitattributes update .gitattributes Dec 15, 2017
.gitignore fully implemented dynamic shader linking; volume rendering half done. Apr 5, 2018
.gitmodules Added submodules and recent shaders. Oct 5, 2018
OpenSolution.cmd refactoring of the Texture.cpp Dec 14, 2017
README.md Added submodules and recent shaders. Oct 5, 2018
RunTest.cmd updated README.md Feb 12, 2018
SetEnvironmentVariable.cmd Candlestick.cmd Feb 20, 2018
desktop.ini Adding more favorite demos. Dec 15, 2017

README.md

DuEngine

DuEngine is an efficient and interactive C++ graphics engine for rendering, managing, recording image and video screenshots of ShaderToy-like demos with a variety of textures in real time. It contains algorithms on the GPU such as Poisson Editing, Antialiasing, Bilateral Filtering, Diffusion, Distrotion, Kernel Foveated Rendering, and rich ray marching / tracing demos. It's mostly used for personal references and most source files are located under DuEngine while the my shaders locates under DuShaders; algorithms are categorized under different subfolders. Currently, DuEngine supports 2D (jpg, png), 3D (binary file or grid image), video (mp4 or image sequences), lightfields (grid layout) textures. However, it only supports Windows and requires a graphics card with OpenGL 4.5+. One may mitagate the C++ code to Unix by replacing the OpenCV and Freeglut libraries.

LightFieldSingle

Compilation

Dependencies: OpenGL 4.5+, Glew, OpenCV 3.0+, GLM, Freeglut, and Visual Studio 2015+.

  1. To compile the project, simply run OpenSolution.cmd, or locate the solution file at DuEngine/DuEngine.sln
  2. To test the project, run RunTest.cmd, or UnitTests/debug.cmd, then you will see the renderer with all sorts of input channels.

If the compilation fails, please fix the following five environment variables:

  • OPENCV_INC: Directory to OpenCV include folder.
  • GLEW_INC: Directory to Glew, Freeglut, and GLM headers.
  • OPENCV_LIB: Directory to OpenCV libraries.
  • GLEW_LIB: Directory to Glew and Freeglut libraries.
  • PATH: Add the executable DLLs of OpenCV and GLUT into the PATH variable.

Create New Demos

Dependency: Python

To create a new ShaderToy demo, just click _create.cmd in any category folder like "Ray Tracing". In the console, please input your desired shader name, like "Test". The Python script will automatically generate Test.glsl, Test.ini, and Test.cmd files. Note that the GLSL file is the main Shadertoy alike GLSL code, the INI file is the config file which defines the input channels, and the CMD file is a shortcut for you to run the demo.

The detailed input format for _create.cmd is:

_create [FILE_NAME] [NUM_CHANNELS, 1 by default] [NUM_BUFFERS, 0 by default] [LINK_TO_SHADERTOY_FOR_REFERENCE]

Features

Config file

This renderer provides an easy-to-use interface to link any GLSL demos with built-in, and custom 2D, video, 3D, and cubemap textures. It supports most of the preset textures from the ShaderToy, which are located in DuEngine/presets.

To run the engine with a config file, simply run

DuEngine config.ini

The config file reads like as follows:

# This is a comment, $Name corresponds to the file name of the INI file.
shader_frag         =   $Name.glsl

# Specify the number of channels for the main framebuffer. 
channels_count      =   5

# Specify the number of framebuffers for multi-pass rendering
buffers_count       =   4

# Here are some examples of the channel type.
# We pre-define most of the ShaderToy presets. Visit *DuEngine/Texture.cpp* for a glance:
iChannel0_type      =   noise
# iChannel0_type    =   key, font, stpeter, sjtu...

# For a custom texture file, you need to tell the type and filename with extension.
iChannel1_type      =   rgb
iChannel1_tex       =   whatever.png

# The filters and wraps are loaded by default, but you can also change them.
iChannel1_filter        =  mipmap
iChannel1_wrap          =   repeat

# For videos, you can add fps, startFrame, and endFrame.
iChannel2_type          =   video
iChannel2_tex           =   whatever.mp4
iChannel2_fps           =   25
iChannel2_startFrame    =   1
iChannel2_endFrame      =   100

# To read from a frame buffer, use A-Z.
iChannel3_type      =   A

# To read from a video sequence, use %d as the wildcard
iChannel4_type      =   videoseq
iChannel4_tex       =   myfolder/file%d.png

# Each frame buffer can have an arbitrary number of channels.
A_channels_count    =   1
A_iChannel0_type    =   london
B_channels_count    =   1
B_iChannel0_type    =   A
C_channels_count    =   1
C_iChannel0_type    =   B
D_channels_count    =   1
D_iChannel0_type    =   C

# You can ignore the following default parameters starting from this line:
window_width        =   1920
window_height       =   1080

# If your textures are located outside the presets folder, type something like
resources_path      =   ../resources/

Multipass

Full-featured multipass rendering, e.g., see ShaderOfWeek/Goo.cmd for an example.

Screenshots and Recording

Press F2 to take a screen shot. In the configuration file, please add the following lines to record a video / sequences of images:

recording       =   true
record_start    =   1
record_end      =   500
# Use true for generating a single video file; false for generating sequences of images
record_video    =   true

The video will be stored in record by default.

Functional Keys

F1      =   Reset the time and textures;
F2      =   Take screenshot;
F5      =   Recompile the shader;
F6      =   Pause / Play all videos;
F9      =   (Debug) Print iFrame;
F10     =   (Debug) Print iMouse;
F11     =   Toggle the fullscreen mode;

In the end, here stores some of my GLSL code written in Shadertoy.com My ShaderToy Public Profile

Demos and Blog Posts

Interactive Poisson Blending

Unified Gnomonic and Stereographic Projections

Dotted Drawing Sketch

Instgram Brannan Filter

BirthdayCakeNoOcclude

Code Golf: Halftone Image

Artisitc404

LightFieldSingle

  • Light Field Rendering VolumeRendering
  • Volume Rendering

Masterpieces from ShaderToy

  • Please refer to the GLSL code for author names.
  • Most of the shaders is under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.
  • A few of the shaders are under MIT License. Alps LadyBug Venice WindWakerOcean RayTracing Bridge Bidirectional Path Tracing GameOfLife CrossPenguin

Author

Ruofei Du

License

DuEngine, DuShaders Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.

Please refer to GLSL files for License of Third-Party Shaders.