Skip to content

Instantly share code, notes, and snippets.

View CodyJasonBennett's full-sized avatar

Cody Bennett CodyJasonBennett

View GitHub Profile
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Math.md
Last active September 20, 2024 06:11
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;
@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);
@Popov72
Popov72 / using_pix_with_canary.md
Last active June 29, 2024 20:18
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!

@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;
@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
@h3r2tic
h3r2tic / raymarch.hlsl
Last active November 18, 2024 10:24
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"
import time
import math
import torch
import taichi as ti
import taichi.math as tm
import tinytex as ttex
from tinycio import fsio
@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" */