Skip to content

Instantly share code, notes, and snippets.

View superguigui's full-sized avatar

Guillaume Gouessan superguigui

View GitHub Profile
@steveruizok
steveruizok / findCubicControlPoints.ts
Last active April 13, 2022 01:09
Find the control points for a cubic bezier curve segment from point a to point c passing through point b.
/**
* Find the control points for a cubic segment from point a to point c passing through point b.
* @param a The curve's start point
* @param b The point to curve through
* @param c The curve's end point
*/
export function findCubicControlPoints(
a: { x: number; y: number },
b: { x: number; y: number },
c: { x: number; y: number }
@ayamflow
ayamflow / unity-gotchas.md
Last active October 18, 2020 17:10
Unity gotchas

I'm learning unity by redoing old projects or scenes of videogames (coming from a webGL background), and documenting things I get stuck on, as well as findings.

OpenUPM (and other UPM)

Basically npm for Unity. Just need to add dependencies and scopedRegistries to Packages/manifest.json, Unity will detect the change and install the package.

Importing upm packages in a shader (ShaderLab)

Add this line in CGPROGRAM, after #include "UnityCG.cginc":

#include "Packages/jp.keijiro.noiseshader/Shader/SimplexNoise2D.hlsl"

@ayamflow
ayamflow / rotate-uv.glsl
Created January 16, 2018 23:24
Rotate UV in GLSL
vec2 rotateUV(vec2 uv, float rotation)
{
float mid = 0.5;
return vec2(
cos(rotation) * (uv.x - mid) + sin(rotation) * (uv.y - mid) + mid,
cos(rotation) * (uv.y - mid) - sin(rotation) * (uv.x - mid) + mid
);
}
vec2 rotateUV(vec2 uv, float rotation, vec2 mid)
@ayamflow
ayamflow / performance-monitor.js
Created December 8, 2017 00:31
Performance monitor
// Check FPS estimate over an interval of time and trigger callback if it becomes too slow.
// Ideally callback turn quality settings down (canvas dpr, post process, number of particles, ...)
// See also
// https://mrnmnm.com/
// http://findinglove.activetheory.net
const PAST_FRAMES = 60; // Memorize 1s of render time
const BAD_FRAMES = 30; // Max number of slow frame before downgrade
export default class PerformanceMonitor {
@mattdesl
mattdesl / about.md
Last active July 17, 2023 09:20
optimizing & de-duplicating geometry in GLTF files

optimize GLTF file

This optimizes a GLTF file that was exported by blender (or similar) by de-duplicating buffer views (i.e. chunks of bytes) that are equal and removing redundant accessors.

For example, 100 cubes of different scales/materials/rotations/etc should all end up using a single BufferGeometry in ThreeJS, which isn't the case with current GLTF exporters in Blender and parsers for ThreeJS.

In scenes with a lot of instancing, it can dramatically reduce total file size as well as render performance. In one test scene:

Before: 4.8MB file size, 832 THREE.Geometry instances across 832 THREE.Mesh objects
After: 661KB file size, 13 THREE.Geometry instances across 832 THREE.Mesh objects

@floz
floz / MeshCustomMaterial.js
Created July 17, 2017 14:02
MeshPhysicalMaterial custom
import vs from "shaders/physicalcustom.vs"
import fs from "shaders/physicalcustom.fs"
export default class MeshCustomMaterial extends THREE.MeshPhysicalMaterial {
constructor(parameters, uniforms={}){
super(parameters)
this.defines = { 'PHYSICAL': '' };
@dmnsgn
dmnsgn / WebGL-WebGPU-frameworks-libraries.md
Last active July 23, 2024 14:54
A collection of WebGL and WebGPU frameworks and libraries

A non-exhaustive list of WebGL and WebGPU frameworks and libraries. It is mostly for learning purposes as some of the libraries listed are wip/outdated/not maintained anymore.

Engines and libraries ⚙️

Name Stars Last Commit Description
three.js ![GitHub
@mattdesl
mattdesl / MeshCustomMaterial.js
Last active June 4, 2024 08:51
Custom mesh standard material with glslify + ThreeJS r83dev
const glslify = require('glslify');
const path = require('path');
// This is the original source, we will copy + paste it for our own GLSL
// const vertexShader = THREE.ShaderChunk.meshphysical_vert;
// const fragmentShader = THREE.ShaderChunk.meshphysical_frag;
// Our custom shaders
const fragmentShader = glslify(path.resolve(__dirname, 'standard.frag'));
const vertexShader = glslify(path.resolve(__dirname, 'standard.vert'));
@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@protrolium
protrolium / ffmpeg.md
Last active July 23, 2024 06:07
ffmpeg guide

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

You can get the list of installed codecs with: