Skip to content

TravorLZH/shader-tester

Repository files navigation

Shader Tester

Shader Tester is a program that allows users to customize the fragment shader for a specific object. The synopsis of this program is as follows:

$ ./build/shader object [shader]
  • object specifies the preset shape the program will be rendering. (cube, square, and polygon are currently available, you can make more by yourselves)

  • shader is an optional argument that allows you to customize the coloring of the rendered object. Without this argument, the program will use default.frag as its fragment shader.

For example, if you type ./build/shader cube in the terminal, you will get this result:

default-shader

To use a custom shader, run the program with a second argument that specifies the shader file.

$ ./build/shader cube examples/mouselight.frag

With issuing the above command, we obtain this result:

mouselight-shader

By using this shader, you can change the light source position by moving your mouse.

Building

To increase portability, this project is built by cmake. Before running cmake, you need to have glfw3 installed and OpenGL 3 configured. Then, type the following command will help you.

$ mkdir build && cd build/
$ cmake ..
$ cmake --build .

Uniforms

The current version of this program supports three uniforms.

  • time: This is a float variable that stores the seconds elapsed since the program started running.
  • mouse: is a two-dimensional vector storing the normalized coordinates of mouse pointer.
  • has_mouse: determines whether the mouse is in the render region.

About

A GLFW-based program written in pure C dedicated to shader learners (including me!)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published