Skip to content

Instantly share code, notes, and snippets.

@Samsy
Samsy / octahedral.shader
Created June 15, 2023 10:03 — forked from pyalot/octahedral.shader
octahedral mapping
#define sectorize(value) step(0.0, (value))*2.0-1.0
#define sum(value) dot(clamp((value), 1.0, 1.0), (value))
#define PI 3.141592653589793
vec2 normalToUvRectOct(vec3 normal){
normal /= sum(abs(normal));
if(normal.y > 0.0){
return normal.xz*0.5+0.5;
}
else{
import {
InstancedBufferGeometry,
InstancedBufferAttribute,
BufferAttribute,
Vector3,
@Samsy
Samsy / encoding-video.md
Created April 13, 2020 19:57 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@Samsy
Samsy / encoding-video.md
Created April 13, 2020 19:57 — forked from Vestride/encoding-video.md
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
float when_fgt(float x, float y) {
return max(sign(x - y), 0.0);
}
vec2 correctRatio(vec2 inUv, float baseratio, float asp){
return mix(
vec2(
inUv.x,
@Samsy
Samsy / TransformationShader.js
Created October 15, 2018 16:23 — forked from jeanlescure/TransformationShader.js
ThreeJS: Vertex shader for translating, scaling, and rotating. Fragment shader for adding texture and controlling opacity.
THREE.TransformationShader = {
defines: {},
uniforms: {
"tDiffuse": { type: "t", value: texture },
"opacity": { type: "f", value: 1.0 },
"translationX": { type: "f", value: 1.0 },
"translationY": { type: "f", value: 1.0 },
"translationZ": { type: "f", value: 1.0 },
"scaleX": { type: "f", value: 1.0 },
@Samsy
Samsy / mic.js
Created October 6, 2018 13:11 — forked from kig/mic.js
Microphone input to MP3
// Uses getUserMedia to record audio from microphone, compresses it to mp3, and throws it away.
// You should change the last step to e.g. pushing the audio to a server over a WebSocket.
// This script uses lame.js for mp3 encoding
// https://github.com/zhuker/lamejs
var audioDataCallback = function(encodedData, originalData) {
console.log("Encoded " + encodedData.byteLength + " bytes. Original: " + originalData.byteLength);
};
@Samsy
Samsy / frag
Created September 26, 2018 16:50
triangle
uniform sampler2D tex;
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( tex, vUv );
}
@Samsy
Samsy / fxaa.glsl
Created July 8, 2018 12:43 — forked from agostbiro/fxaa.glsl
FXAA 3.11 WebGL port
// FXAA 3.11 implementation by NVIDIA (github.com/NVIDIAGameWorks/GraphicsSamples)
// Ported to WebGL by Agost Biro (github.com/abiro)
//----------------------------------------------------------------------------------
// File: es3-kepler\FXAA\assets\shaders/FXAA_DefaultES.frag
// SDK Version: v3.00
// Email: gameworks@nvidia.com
// Site: http://developer.nvidia.com/
//
// Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
/*
** Copyright (c) 2012, Romain Dura romain@shazbits.com
**
** Permission to use, copy, modify, and/or distribute this software for any
** purpose with or without fee is hereby granted, provided that the above
** copyright notice and this permission notice appear in all copies.
**
** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
** WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY