Skip to content

Instantly share code, notes, and snippets.

View erichlof's full-sized avatar

Erich Loftis erichlof

View GitHub Profile
@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>
@erichlof
erichlof / HDRI_Environment_Fragment.glsl
Created April 2, 2022 06:03
Handling multiple light sources (HDRI, Quad light, Sphere light)
precision highp float;
precision highp int;
precision highp sampler2D;
uniform sampler2D tTriangleTexture;
uniform sampler2D tAABBTexture;
uniform sampler2D tHDRTexture;
#include <pathtracing_uniforms_and_defines>