Skip to content

eleniv3d/WebGL-Ray-Marcher

 
 

Repository files navigation

WebGL Ray Marcher

Created WebGL fragment shaders that utilize raymarching and signed distance functions. To create the fragment shaders, I generated a mesh that maps to the canonical screen space coordinates of the viewport. I have created four different fragment shaders for the program.

Spheres.glsl

Spheres

CubeSphereIntersect.glsl

Cube Sphere Intersection

GrayScaleMandelbulb.glsl

Grey Mandelbulb

PurpleGlowMandelbulb.glsl

Purple Mandelbulb

How To Run Project

The best way to run the project is by using a local HTTP server. The steps to run this project will use Python's local web server package.

Navigate to the directory where the project has been cloned. Then, run the following python command:

python3 -m http.server

Once the server is running locally, connect to it via the proper port number:

localhost:<port number>

How To Change Active Shader

To change out the active fragment shader, modify the line below in the index.html file:

<script id="fragShader" type="x-shader/x-fragment" src=<desired fragment shader> ></script>

Replace <desired fragment shader> with one of the specified fragment shaders above. For example:

<script id="fragShader" type="x-shader/x-fragment" src="Spheres.glsl" ></script>

About

WebGL2 Ray Marching Fragment Shader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • GLSL 59.9%
  • JavaScript 34.6%
  • HTML 5.5%