Skip to content
/ DuEngine Public
forked from ruofeidu/DuEngine

An efficient interactive C++ renderer for ShaderToy-alike demos with 2D/CubeMap/Video/Camera/LightField textures. (Partially used in my I3D 2018 papers)

Notifications You must be signed in to change notification settings

HCIL/DuEngine

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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.

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 with 996 ICU clause: 996.ICU

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.

About

An efficient interactive C++ renderer for ShaderToy-alike demos with 2D/CubeMap/Video/Camera/LightField textures. (Partially used in my I3D 2018 papers)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 98.0%
  • C 1.4%
  • Python 0.6%