Skip to content

Instantly share code, notes, and snippets.

View FredericBriolet's full-sized avatar
🛰️

Fred Briolet FredericBriolet

🛰️
View GitHub Profile
magick convert T_Ceramic_M.png T_Ceramic_R.png T_Ceramic_M.png -channel RGB -combine T_Ceramic_MR.png
@m4n1ok
m4n1ok / autoplay.js
Last active January 10, 2023 09:35
Detect autoplay inline video
export const isAutoplaySupported = () => {
// Detect if user can autoplay inline video
// Works when user is on low-battery mode on IOS
// Return promise from video.play
const video = document.createElement('video')
video.src = 'data:video/mp4;base64,AAAAIGZ0eXBtcDQyAAAAAG1wNDJtcDQxaXNvbWF2YzEAAATKbW9vdgAAAGxtdmhkAAAAANLEP5XSxD+VAAB1MAAAdU4AAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAACFpb2RzAAAAABCAgIAQAE////9//w6AgIAEAAAAAQAABDV0cmFrAAAAXHRraGQAAAAH0sQ/ldLEP5UAAAABAAAAAAAAdU4AAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAoAAAAFoAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAHVOAAAH0gABAAAAAAOtbWRpYQAAACBtZGhkAAAAANLEP5XSxD+VAAB1MAAAdU5VxAAAAAAANmhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABMLVNNQVNIIFZpZGVvIEhhbmRsZXIAAAADT21pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAw9zdGJsAAAAwXN0c2QAAAAAAAAAAQAAALFhdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAoABaABIAAAASAAAAAAAAAABCkFWQyBDb2RpbmcAAAAAAAAAAAAAAAA
@Erkaman
Erkaman / taa.frag
Last active April 25, 2023 02:32
rudimentary temporal anti-aliasing solution, that is good as a starting point for more advanced TAA techniques.
/*
The MIT License (MIT)
Copyright (c) 2018 Eric Arnebäck
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@m4n1ok
m4n1ok / videos.js
Last active September 18, 2021 08:45
Encode video directory into mp4 and webm
/**
* Generate web videos mp4 + webm from given folder
* You can pass options by file in videos.json
* Options are crop size
* NODE and FFMEPG is required. On mac brew install node && brew install ffmpeg
* FFMPEG command are inspired by https://gist.github.com/Vestride/278e13915894821e1d6f
* eg: node videos.js --input=../inputDir --output=../dir/outputDir --prefix=compressed --r-audio
* if missing outputDir, inputDir will be use
*/
@baptistebriel
baptistebriel / gist:29e761fbc7cc5923cf6b99444a2935c4
Created August 9, 2017 17:44
compress mp4 video using ffmpeg
// http://ericholsinger.com/install-ffmpeg-on-a-mac
ffmpeg -i input.mp4 -vcodec h264 -acodec mp3 output.mp4
@patrickheng
patrickheng / Damping
Last active November 19, 2019 11:27
Formula
current -= ( target + current ) * friction
current += ( target - current ) * friction
@unitycoder
unitycoder / if-branchless.shader
Last active April 3, 2024 11:20
Avoiding Branching / Conditionals in Shaders Fast No If
"The common wisdom of "don't use conditionals in shaders" is one of my biggest frustrations with how shaders are taught.
step(y, x) _is_ a conditional! It compiles to identical code as:
float val = (x >= y ? 1.0 : 0.0)
or
float val = 0.0;
if (x >= y) val = 1.0;"
https://twitter.com/bgolus/status/1235254923819802626
// Performing shader divisions without diving *rcp = approximation of 1/x
float myDividedVal = myValToDivide * rcp(myDivider);
@Vestride
Vestride / encoding-video.md
Last active June 5, 2024 14:38
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
@floz
floz / gist:53ad2765cc846187cdd3
Created December 18, 2014 18:47
PhotoshopMath.glsl
/*
** 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
@garyharan
garyharan / _mixins.scss
Created May 5, 2011 15:46
Useful scss mixins (rounded corners, gradients, text-field, button)
@mixin box-shadow($top, $left, $blur, $color, $inset: false) {
@if $inset {
-webkit-box-shadow:inset $top $left $blur $color;
-moz-box-shadow:inset $top $left $blur $color;
box-shadow:inset $top $left $blur $color;
} @else {
-webkit-box-shadow: $top $left $blur $color;
-moz-box-shadow: $top $left $blur $color;
box-shadow: $top $left $blur $color;
}