Skip to content

Instantly share code, notes, and snippets.

View neurolabusc's full-sized avatar

Chris Rorden neurolabusc

View GitHub Profile
<!--
Go to Line 153 for the start of Uniform Buffer Object related code and intro
Prerequsite:
You at least know what uniforms are in the context of WebGL
and mininally understand the concepts involved in creating a square in WebGL
-->
<html>
@mhamilt
mhamilt / Notes.md
Last active February 19, 2023 20:17
Metal Compute Shader Example in Swift and Objective C

Notes

Create a command line target in xcode either in Swift or Obj-C. add a metal file to the project and copy and paste the respective code into each file.

@DomNomNom
DomNomNom / intersectAABB.glsl
Last active May 22, 2024 02:59
Ray-AABB (Axis Aligned Bounding Box) intersection.
// adapted from intersectCube in https://github.com/evanw/webgl-path-tracing/blob/master/webgl-path-tracing.js
// compute the near and far intersections of the cube (stored in the x and y components) using the slab method
// no intersection means vec.x > vec.y (really tNear > tFar)
vec2 intersectAABB(vec3 rayOrigin, vec3 rayDir, vec3 boxMin, vec3 boxMax) {
vec3 tMin = (boxMin - rayOrigin) / rayDir;
vec3 tMax = (boxMax - rayOrigin) / rayDir;
vec3 t1 = min(tMin, tMax);
vec3 t2 = max(tMin, tMax);
float tNear = max(max(t1.x, t1.y), t1.z);
@dannysmith
dannysmith / osx_setup.sh
Last active October 17, 2023 08:20
Sensible defaults for New Mac
#!/usr/bin/env bash
# ~/.osx — http://mths.be/osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &