Skip to content

Instantly share code, notes, and snippets.

View but0n's full-sized avatar

JMA but0n

  • NSW, Australia
  • 09:15 (UTC +10:00)
View GitHub Profile

SCD5584 HCMS-2904

@but0n
but0n / _GJK.md
Created March 23, 2019 09:36 — forked from vurtun/_GJK.md
3D Gilbert–Johnson–Keerthi (GJK) distance algorithm

Gilbert–Johnson–Keerthi (GJK) 3D distance algorithm

The Gilbert–Johnson–Keerthi (GJK) distance algorithm is a method of determining the minimum distance between two convex sets. The algorithm's stability, speed which operates in near-constant time, and small storage footprint make it popular for realtime collision detection.

Unlike many other distance algorithms, it has no requirments on geometry data to be stored in any specific format, but instead relies solely on a support function to iteratively generate closer simplices to the correct answer using the Minkowski sum (CSO) of two convex shapes.

// uniform vec3 iResolution;// viewport resolution (in pixels)
// uniform float iTime;// shader playback time (in seconds)
// uniform float iTimeDelta;// render time (in seconds)
// uniform int iFrame;// shader playback frame
// uniform float iChannelTime[4];// channel playback time (in seconds)
// uniform vec3 iChannelResolution[4];// channel resolution (in pixels)
// uniform vec4 iMouse;// mouse pixel coords. xy: current (if MLB down), zw: click
// uniform samplerXX iChannel0..3;// input channel. XX = 2D/Cube
// uniform vec4 iDate;// (year, month, day, time in seconds)
// uniform float iSampleRate;// sound sample rate (i.e., 44100)
https://cs.stanford.edu/people/karpathy/convnetjs/demo/rldemo.html
https://github.com/pissang/claygl/blob/master/src/util/shader/integrateBRDF.glsl
https://github.com/mrdoob/three.js/blob/dev/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+shift+b",
"command": "cursorLeftSelect",
"when": "textInputFocus"
},
{
"key": "shift+left",
"command": "-cursorLeftSelect",
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - lights - spotlight</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
background-color: #000;
margin: 0px;
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - transform controls</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
margin: 0px;
background-color: #000000;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vulkan/vulkan.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_Vulkan.h>
typedef struct {
SDL_Window *SDLWindow;
SDL_Renderer *SDLRenderer;