• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    TypeScript
  • License
    Other
  • Created about 2 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Screen-space raymarched godrays for three.js using the pmndrs postprocessing library

three-good-godrays

CI Version

Good godrays effect for three.js using the pmndrs postprocessing library

Adapted from original implementation by @n8python

Demo: https://three-good-godrays.ameo.design

A screenshot showing the three-good-godrays effect in action within the sponza demo scene. A white sphere in the middle of a terrace with pillars has white godrays emanating from it along with prominent shadows.

Install

npm install three-good-godrays

Or import from unpkg as a module:

import { GodraysPass } from 'https://unpkg.com/[email protected]/build/three-good-godrays.esm.js';

Usage

import { EffectComposer, RenderPass } from 'postprocessing';
import * as THREE from 'three';
import { GodraysPass } from 'three-good-godrays';

const { scene, camera, renderer } = initYourScene();

// shadowmaps are needed for this effect
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.shadowMap.autoUpdate = true;

// Make sure to set applicable objects in your scene to cast + receive shadows
// so that this effect will work
scene.traverse(obj => {
  if (obj instanceof THREE.Mesh) {
    obj.castShadow = true;
    obj.receiveShadow = true;
  }
});

// godrays can be cast from either `PointLight`s or `DirectionalLight`s
const lightPos = new THREE.Vector3(0, 20, 0);
const pointLight = new THREE.PointLight(0xffffff, 1, 10000);
pointLight.castShadow = true;
pointLight.shadow.mapSize.width = 1024;
pointLight.shadow.mapSize.height = 1024;
pointLight.shadow.autoUpdate = true;
pointLight.shadow.camera.near = 0.1;
pointLight.shadow.camera.far = 1000;
pointLight.shadow.camera.updateProjectionMatrix();
pointLight.position.copy(lightPos);
scene.add(pointLight);

// set up rendering pipeline and add godrays pass at the end
const composer = new EffectComposer(renderer);

const renderPass = new RenderPass(scene, camera);
renderPass.renderToScreen = false;
composer.addPass(renderPass);

const godraysPass = new GodraysPass(pointLight, camera);
// If this is the last pass in your pipeline, set `renderToScreen` to `true`
godraysPass.renderToScreen = true;
composer.addPass(godraysPass);

function animate() {
  requestAnimationFrame(animate);
  composer.render();
}
requestAnimationFrame(animate);

Develop + Run Demos Locally

  • Clone repo
  • npm install
  • npm run prepublishOnly to run initial builds
  • npm install -g serve
  • Run node esbuild.mjs -w in one terminal tab to automatically re-build JS when files are updated
  • Run serve public/demo -p 5001 and visit http://localhost:5001 in your browser

More Repositories

1

robintrack

Scrapes the Robinhood API to retrieve + store popularity and price data.
JavaScript
683
star
2

tickgrinder

Low-latency algorithmic trading platform written in Rust
Rust
522
star
3

web-synth

A web-based sound synthesis, music production, and audio experimentation platform
TypeScript
350
star
4

neural-network-from-scratch

A neural network library written from scratch in Rust along with a web-based application for building + training neural networks + visualizing their outputs
Rust
110
star
5

cryptoviz

A web-based Depth-Of-Market visualization for data of the Poloniex cryptocurrency exchange.
JavaScript
73
star
6

spotifytrack

A personal homepage showing users' top songs and artists, providing a shareable link that they can use to show it off to friends.
TypeScript
65
star
7

rust-cloud-run-demo

A demo project showing off a Google Cloud Run-compatible web server using Rust, Rocket, Diesel, and MySQL
Rust
34
star
8

svelte-todo

Full-stack to-do app to try out SvelteKit. Minimal with SQLite database + HTTP basic auth
TypeScript
25
star
9

osutrack-api

API for osu!track https://ameobea.me/osutrack/
TypeScript
21
star
10

sketches

Various coding experiments and artsy things
Rust
17
star
11

phost

Small project hoster. Can deploy static websites + Dockerfiles and provide a management TUI client.
Python
17
star
12

polotrack

A web-based dashboard for analyzing Poloniex portfolio holdings + trade history to provide useful insights
JavaScript
15
star
13

io-game

A .io game written using Elixir/Phoenix and WebAssembly
Rust
12
star
14

rocket_async_compression

Implements response compression with gzip and brotli via the `async-compression` crate
Rust
11
star
15

noise-asmjs

Uses `noise-rs` library rendered to render noise to a canvas, allowing users to select and configure the utilized noise functions.
JavaScript
11
star
16

rnn-viz

Interactive visualizations and demos that are used in a blog post I wrote about logic in the context of neural networks
Jupyter Notebook
11
star
17

minutiae

Simulation engine involving a 2D universe populated by cells and entities
Rust
10
star
18

osutrack_irc_v2

Utility to provide osu! players with access to osu!track via in the in-game chat system.
JavaScript
7
star
19

FXCMDataDownloader

A Node/Java utility that downloads and stores historical price data from the FXCM API
Java
6
star
20

homepage

My personal website
JavaScript
6
star
21

algobot3

Third iteration of the algorithmic trading bot I've been working on.
JavaScript
5
star
22

ameotrack

Personal data storage and utility platform.
JavaScript
5
star
23

sprout

AI-powered anime recommendation website for MyAnimeList + AniList with other tools, visualizations, and profile analytics
Jupyter Notebook
5
star
24

sketches-3d

Experiments and demos of 3D game-like things. Mostly using Blender + Three.JS with custom shaders and interactive bits.
TypeScript
5
star
25

jantix

A fully-featured TypeScript library defining a modular, self-contained, 100% type-safe Redux architecture
TypeScript
4
star
26

GAWTrack

Events history tracker for GAW cloud miners.
PHP
4
star
27

algobot_elixir

Second iteration of the forex trader bot implemented in elixir
Elixir
4
star
28

advent-of-code-2018

https://adventofcode.com/
Rust
3
star
29

bot4

REPOSITORY MOVED -> https://github.com/ameobea/tickgrinder
2
star
30

paper_parser

Processes scientific papers and determines regions of interest in them.
Python
2
star
31

rust-stackdriver-logging-utils

Utilities and functions that make logging to Google Stackdriver from Rust using fern easier.
Rust
2
star
32

network_research

Misc. files and scripts used for network research
Python
2
star
33

snapmeo

A screenshotter and image uploader for my personal file hosting platform.
Rust
1
star
34

kouffee-bot

Bot for the discord server
TypeScript
1
star
35

hazbin

Website that randomly picks images from my personal collection of screenshots from the pilot episode of Hazbin Hotel. I have hundreds.
JavaScript
1
star
36

amc-web-ui

Main repository for the AutoMultipleChoice-based application being built for CS358
Python
1
star
37

bittrex-orderbook-importer

imports orderbook updates from bittrex
JavaScript
1
star
38

mysql-log-visualization

Tool for creating a live, web-based visualization of a MySQL server's activity.
Rust
1
star
39

Calculator-Programs

A collection of TI graphing calculator programs made by me during my early years of programming.
1
star
40

quavertrack

Quavertrack is a tool for tracking your stats progression in the rhythm game Quaver, allowing you to see how you and other players improve over time.
TypeScript
1
star
41

algobot

Algorithmic trading platform
JavaScript
1
star