Skip to content

Instantly share code, notes, and snippets.

View erichlof's full-sized avatar

Erich Loftis erichlof

View GitHub Profile
@erichlof
erichlof / BVH_Point_Light_Source_Fragment.glsl
Created February 20, 2025 21:22
shader (glsl) file for experimental sphere BVH (as opposed to typical AABB BVH)
precision highp float;
precision highp int;
precision highp sampler2D;
#include <pathtracing_uniforms_and_defines>
uniform sampler2D tTriangleTexture;
uniform sampler2D tAABBTexture;
uniform sampler2D tAlbedoTextures[8]; // 8 = max number of diffuse albedo textures per model
@erichlof
erichlof / BVH_Point_Light_Source.js
Created February 20, 2025 21:20
js file for experimental sphere BVH (as opposed to typical AABB BVH)
// scene/demo-specific variables go here
let modelMesh;
let modelScale = 1.0;
let modelPositionOffset = new THREE.Vector3();
let albedoTexture;
let total_number_of_triangles = 0;
let triangle_array;
let triangleMaterialMarkers = [];
let pathTracingMaterialList = [];
let uniqueMaterialTextures = [];
@erichlof
erichlof / BVH_Quick_Builder.js
Last active February 20, 2025 21:15
BVH_Quick_Builder.js
let buildnodes = [];
let leftWorklist = [];
let rightWorklist = [];
let nodesUsed = 1;
let aabb_array_copy;
let k, value, side0, side1, side2;
let bestSplit, goodSplit, okaySplit;
let bestAxis, goodAxis, okayAxis;
let currentMinCorner = new THREE.Vector3();
let currentMaxCorner = new THREE.Vector3();
@erichlof
erichlof / Ocean_And_Sky_Rendering.js
Created August 7, 2023 05:38
Static scene for Ocean and Sky Rendering demo (time is frozen)
// scene/demo-specific variables go here
let sunAngle = 0;
let sunDirection = new THREE.Vector3();
let tallBoxGeometry, tallBoxMaterial, tallBoxMesh;
let shortBoxGeometry, shortBoxMaterial, shortBoxMesh;
let PerlinNoiseTexture;
// called automatically from within initTHREEjs() function (located in InitCommon.js file)
function initSceneData()
{
@erichlof
erichlof / Geometry_Showcase_Fragment.glsl
Created August 26, 2022 03:05
A simple example of adding UBOs to a demo's fragment shader
precision highp float;
precision highp int;
precision highp sampler2D;
#include <pathtracing_uniforms_and_defines>
uniform mat4 uTorusInvMatrix;
uniform InvMatrices_UniformGroup {
mat4 u_InvMatrices[64];
@erichlof
erichlof / Geometry_Showcase.js
Created August 26, 2022 03:03
A simple example of adding UBOs to a demo's js setup file
// scene/demo-specific variables go here
let torusObject;
let InvMatrices_UniformGroup, TopLevelBVH_UniformGroup;
let u_InvMatrices = [];
let u_AABBData = [];
// called automatically from within initTHREEjs() function (located in InitCommon.js file)
function initSceneData()
{
demoFragmentShaderFileName = 'Geometry_Showcase_Fragment.glsl';
@erichlof
erichlof / Hangman.html
Created August 17, 2022 05:54
A simple Hangman game written in HTML and JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Hangman</title>
</head>
<body>
<h2>Hangman!</h2>
@erichlof
erichlof / HDRI_Environment.js
Last active April 23, 2022 00:30
Implements a three.js OribitControls-style camera with Orthographic projection option
// scene/demo-specific variables go here
let modelMesh;
let modelScale = 1.0;
let modelPositionOffset = new THREE.Vector3();
let albedoTexture;
let total_number_of_triangles = 0;
let triangle_array;
let triangleMaterialMarkers = [];
let pathTracingMaterialList = [];
let uniqueMaterialTextures = [];
@erichlof
erichlof / HDRI_Environment_Fragment.glsl
Last active April 20, 2022 15:03
1-sided Rectangle area lights
precision highp float;
precision highp int;
precision highp sampler2D;
uniform sampler2D tTriangleTexture;
uniform sampler2D tAABBTexture;
#include <pathtracing_uniforms_and_defines>
uniform mat4 uLight0_Matrix;
@erichlof
erichlof / HDRI_Environment_Fragment.glsl
Last active April 8, 2022 22:31
Volumetric Rendering with HDRI
precision highp float;
precision highp int;
precision highp sampler2D;
uniform sampler2D tTriangleTexture;
uniform sampler2D tAABBTexture;
uniform sampler2D tHDRTexture;
#include <pathtracing_uniforms_and_defines>