Skip to content

Instantly share code, notes, and snippets.

View shengsword's full-sized avatar
🤒
Out sick

shengsword

🤒
Out sick
View GitHub Profile
@shengsword
shengsword / instructions.md
Created December 14, 2020 16:54 — forked from Bjvanminnen/instructions.md
How to use glslify with create-react-app

Create your app

create-react-app my-app
cd my-app

Eject it, so that we can modify webpack config

npm run eject
y # when prompted
@shengsword
shengsword / GLSL-Noise.md
Created March 1, 2020 16:30 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@shengsword
shengsword / billboard_sao.frag
Created August 28, 2019 04:23 — forked from transitive-bullshit/billboard_sao.frag
WebGL GLSL SAO (Scalable Ambient Obscurance) fragment shader. SAO is a more efficient method for computing SSAO (Screen-Space Ambient Occlusion). Converts the g-buffer to an occlusion buffer which estimates local ambient occlusion at each fragment in screen-space. For details on the technique itself, see: McGuire et al [12] http://graphics.cs.wi…
// total number of samples at each fragment
#define NUM_SAMPLES {{ numSamples }}
#define NUM_SPIRAL_TURNS {{ numSpiralTurns }}
#define USE_ACTUAL_NORMALS {{ useActualNormals }}
#define VARIATION {{ variation }}
uniform sampler2D sGBuffer;
@shengsword
shengsword / noise-rect.clj
Created May 3, 2019 02:54
draw a noise rectangle in quil
(defn noise-rect [r n]
(let [area (g/area r)
bl (bottom-left r)
br (v2 (right r) (bottom r))
tr (top-right r)
tl (v2 (left r) (top r))
add-x #(m/+ %2 (v2 % 0))
add-y #(m/+ %2 (v2 0 %))
vs (map #(apply divide-segment %)
[[bl br n]
[
[
[234, 112, 112],
[253, 196, 182],
[229, 149, 114],
[38, 148, 171]
],
[
[0, 24, 113],
[255, 88, 93],
@shengsword
shengsword / text-pixel.clj
Created March 12, 2019 17:40
Draw text to buffer and read back to detect whether some pixels in text or not
(defn draw-text []
(let [x-interval (x-interval)
h (* 0.1 (q/height))]
(q/text-align :center :center)
(q/push-matrix)
(q/translate x-interval (* 0.12 (q/height)))
(doseq [ch "TEXT"]
(q/text-char ch 0 0)
(q/translate 0 h))
(defn sph [theta r]
[(* r (Math/cos theta))
(* r (Math/sin theta))])