Giter VIP home page Giter VIP logo

x-raytracer's Introduction

BabylonJS Ray Tracer

This project implements a basic ray tracer using BabylonJS and WebGL shaders. It renders a scene with spheres, demonstrating basic ray tracing techniques including reflections and simple lighting.

Features

  • Custom WebGL shader implementation of ray tracing
  • Rendering of multiple spheres with different colors and sizes
  • Basic lighting and reflection effects
  • Real-time rendering using BabylonJS

Prerequisites

  • Node.js and npm (Node Package Manager)
  • A modern web browser with WebGL support

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/babylonjs-ray-tracer.git
    cd babylonjs-ray-tracer
    
  2. Install dependencies:

    npm install
    

Usage

  1. Build the project:

    npm run build
    
  2. Start the development server:

    npm start
    
  3. Open your web browser and navigate to http://localhost:8080 (or the port specified by your development server).

Project Structure

  • src/index.ts: Main application file
  • src/shader/rayTracerShader.ts: GLSL shaders for ray tracing
  • dist/index.html: HTML file for rendering the canvas

Customization

  • Modify the createSpheres method in src/index.ts to change the number, size, position, and color of spheres.
  • Adjust the camera position in the createScene method to change the view of the scene.
  • Edit the shader code in src/shader/rayTracerShader.ts to modify the ray tracing algorithm, lighting, or add new effects.

Troubleshooting

If you encounter a white screen or other rendering issues:

  1. Check the browser console for error messages.
  2. Ensure WebGL is enabled and supported in your browser.
  3. Verify that all shader uniforms are being set correctly in the runRenderLoop method.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is open source and available under the MIT License.

x-raytracer's People

Contributors

jh-plask avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.