Skip to content

Instantly share code, notes, and snippets.

View CodyJasonBennett's full-sized avatar

Cody Bennett CodyJasonBennett

View GitHub Profile
@wiseConst
wiseConst / 3_byte_tangent_frames.txt
Last active April 7, 2025 10:51
3 BYTE TANGENT FRAMES + bitmask array for TBN sign. Doom Eternal 2020
// This is implementation of 3 BYTE TANGENT FRAMES (and additional bitfield tangent sign array)
// I come up with whilst was reading Doom Eternal 2020 presentation.
// Shortly, storing for each 'glm::vec3 normal' and 'glm::vec4 tangent'(w is used for TBN sign) is expensive!
// IDEA: Store only normal + rotation angle for tangent. (bitangent is reconstructed with cross product as usual.)
// https://jcgt.org/published/0003/02/01/paper.pdf
// https://knarkowicz.wordpress.com/2014/04/16/octahedron-normal-vector-encoding/
// 2 bytes for octahedron normal encoding.
// 1 byte for rotation.
@mattdesl
mattdesl / random.wgsl
Last active July 2, 2024 14:30
high quality deterministic PRNG in WebGPU & WGSL (xorshift128) - MIT licensed
// each pixel is assigned 4 random u32 values per frame
@group(0) @binding(1)
var<storage, read> rnd_state: array<u32>;
// the current state within this pixel
var<private> local_rnd_state:vec4u;
fn random_u32(state:ptr<private,vec4u>) -> u32 {
var st:vec4u = *state;
/* Algorithm "xor128" from p. 5 of Marsaglia, "Xorshift RNGs" */
import time
import math
import torch
import taichi as ti
import taichi.math as tm
import tinytex as ttex
from tinycio import fsio
@h3r2tic
h3r2tic / raymarch.hlsl
Last active April 29, 2025 19:17
Depth buffer raymarching for contact shadows, SSGI, SSR, etc.
// Copyright (c) 2023 Tomasz Stachowiak
//
// This contribution is dual licensed under EITHER OF
//
// Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
// MIT license (http://opensource.org/licenses/MIT)
//
// at your option.
#include "/inc/frame_constants.hlsl"
@sketchpunk
sketchpunk / arcball.js
Last active September 30, 2024 16:53
Maths for various camera movement ( Orbit, Arcball, FPS, Zoom, etc )
/** Using a faux sphere in screen space, determine the arc transform to orbit
* the camera around a target position. A continuous orientation will
* be provided for further calls.
*/
function arcBallTransform(
scrSize, // Screen size, vec2
scrPos0, // Starting mouse position, vec2
scrPos1, // Ending Mouse Positiong, vec2
rotOrientation, // Current arc orientation, quaternion
targetPos, // Position to orbit around
@mrdoob
mrdoob / index.html
Created April 23, 2021 15:15
11 years of Three.js
<html>
<head>
<style>
body {
margin: 0;
padding: 10px;
color: #ffffff;
background: #222222;
font-family: sans-serif;
font-size: 7px;
@Popov72
Popov72 / using_pix_with_canary.md
Last active April 12, 2025 19:25
Using PIX with Chrome

In PIX, Select Target Process => Launch Win32 and set the following 2 entries according to where Canary / Chrome is installed:

  • Path to executable: "C:\Users\alexis\AppData\Local\Google\Chrome SxS\Application\chrome.exe"
  • Working directory: "C:\Users\alexis\AppData\Local\Google\Chrome SxS\Application"
  • Command line arguments: --disable-gpu-sandbox --disable-direct-composition
    • You can add those arguments if you want to be able to see the disassembled shader code: --enable-dawn-features=emit_hlsl_debug_symbols,disable_symbol_renaming
  • Launch Suspended unchecked, Launch for GPU capture and Force D3D11On12 checked

Then click on "Launch".

Important: you should close all your Canary / Chrome windows/processes before clicking on the "Launch" button!

@patriciogonzalezvivo
patriciogonzalezvivo / SimpleCameraFollower.md
Last active September 19, 2021 19:20
Simple Camara Follow in OF
cam.setPosition( cam.getPosition()+(targetPos-cam.getPosition())*0.01 );
cam.lookAt(targetPos);
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Math.md
Last active May 20, 2025 00:48
GLSL Math functions

Trigonometry

const float PI = 3.1415926535897932384626433832795;
const float PI_2 = 1.57079632679489661923;
const float PI_4 = 0.785398163397448309616;

float PHI = (1.0+sqrtf(5.0))/2.0;