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.
Currently only Windows is supported. Please feel free to PR a Linux version. The original code is written in Visual Studio 2017 while I will use VS Code and clang-format with Google style for future commits.
- To compile the project, simply run OpenSolution.cmd, or locate the solution file at DuEngine/DuEngine.sln
- 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
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]
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
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/
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.
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
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.
The above license is only granted to entities that act in concordance with local labor laws. In addition, the following requirements must be observed:
- The licensee must not, explicitly or implicitly, request or schedule their employees to work more than 45 hours in any single week.
- The licensee must not, explicitly or implicitly, request or schedule their employees to be at work consecutively for 10 hours.
Please refer to individual GLSL files (.glsl) for License of Third-Party Shaders.