Skip to content

Instantly share code, notes, and snippets.

View 0beqz's full-sized avatar

0beqz 0beqz

View GitHub Profile
@0beqz
0beqz / MotionBlurPass.js
Created October 13, 2022 14:51
Hacky fix for an issue of the MotionBlurPass from threejs-sandbox
/**
* @author Garrett Johnson / http://gkjohnson.github.io/
*
* Approach from http://john-chapman-graphics.blogspot.com/2013/01/per-object-motion-blur.html
*/
import {
Frustum,
Color,
WebGLRenderTarget,
LinearFilter,
@0beqz
0beqz / MeshReflectorMaterial.js
Created March 5, 2022 14:57
ES5 MeshReflectorMaterial.js
// original implementation is from https://github.com/pmndrs/drei
const {
DepthFormat, DepthTexture, LinearFilter, Matrix4, MeshStandardMaterial,
PerspectiveCamera, Plane, UnsignedShortType, Vector3, Vector4, WebGLRenderTarget
} = THREE
class MeshReflectorMaterial extends MeshStandardMaterial {
constructor(renderer, camera, scene, object, {
mixBlur = 0,
@0beqz
0beqz / BoxProjectedEnvMapHelper.js
Last active February 29, 2024 01:45
Updated code to box-project env-maps in three.js (r137) - credits go to codercat (https://codercat.tk) for the box-projecting code
import * as THREE from "three"
// credits for the box-projecting shader code go to codercat (https://codercat.tk)
const worldposReplace = /* glsl */`
#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )
vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );
#ifdef BOX_PROJECTED_ENV_MAP
vWorldPosition = worldPosition.xyz;