Skip to content

bfxdev/glslsandbox

Repository files navigation

glslsandbox

My creations on the fantastic GLSL Sandbox by mrdoob (this site is not moderated so you will find good, bad and ugly things there). Coding in GLSL in the browser thanks to WebGL is just pure recreation and mathematical art!

The principle is simple: write a main function setting the color of each pixel on the screen given its coordinates. Because the calls to the main function are done in parallel, no data can be stored or shared between the calls.

The variables are defined as:

  • gl_FragCoord: vector of 2 integers containing the pixel coordinates
  • gl_FragColor: vector of 4 floats containing the RGBA components of the color to compute
  • resolution: size in pixels of the rendered rectangle
  • time: time (in seconds?) since reload/modification of the page
  • mouse: virtual position of the mouse pointer inside the rendered rectangle (between 0 and 1)
  • backbuffer: 2D texture containing the previously rendered frame (type sampler2D)

Check as well the superb but heavy Shadertoy by iq for similar, more complex shaders (with input data).

Basic calculation of a ray-tracer with mouse-controlled rotations:

checker

Full ray-tracer with recursive reflections and lighting based on the Phong reflection model:

ray-tracer

It only supports 4 kinds of objects: checker, sky drawn wih Perlin noise, light and mirror-ball.

This is my first attempt at simulating the wave equation but with an inappropriate propagation speed, such that the computation is not stable:

diverging

The result is interesting: it processes the current picture, including the circles drawn under the mouse pointer, into slowly moving lines.

It is difficult to explain what happens there, give it a try!

Simulation of the wave equation on two medias with different speeds (slower in the ellipse at the center of the rendered rectangle):

water

The computation principle is comparable to the explicit finite-difference method.

A fake lighting is computed with the mouse pointer as light source.

Classical Mandelbrot set with wide-range zoom and rotation:

mandelbrot

The fractal is rendered with circular orbit traps.

Superposition of a Julia set on top of the Mandelbrot set, where the reference point on the Julia set corresponds to the position of the mouse pointer on the Mandelbrot set:

fractal-sequence

The dots represent the sequence of complex numbers used in the iterations on the Mandelbrot set at the mouse pointer position.

This shader is very useful to understand how the computation evolves in different areas of the Mandelbrot set. Give it a try!

Skeleton implementation of the display of a character string (only the character "O" is implemented):

font

The code is particularly strange here.

About

My creations on the site glslsandbox.com

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages