Skip to content

Instantly share code, notes, and snippets.

@qoh
qoh / docker-volume-copy
Last active March 29, 2021 14:43
Create a copy of a Docker volume
#!/bin/sh
src="$1"
dest="$2"
if test "$src" = ""
then
echo "Usage: $0 <source-volume> [new-volume]" >&2
exit 1
fi
Color chars
\c0 (byte 1)
Set color to color 0
\c1 (byte 2)
Set color to color 1
\c2 (byte 3)
Set color to color 2
\c3 (byte 4)
Set color to color 3
\c4 (byte 5)
#version 120
#extension GL_EXT_texture_array : require
#extension GL_EXT_texture_array : enable
vec2 poissonDisk[36] = vec2[](
vec2(-0.412506, -0.505401),
vec2(-0.198678, -0.362386),
vec2(0.0612825, -0.360698),
vec2(-0.680803, -0.662816),
vec2(-0.275453, -0.057909),
#version 120
#extension GL_EXT_texture_array : require
#extension GL_EXT_texture_array : enable
// Configuration: For the adventurous!
// This is blending. Shadows are rendered to separate layers based on distance.
// This may cause shadows to suddenly change appearance. Use this to change
// how long a distance they will "fade" between the two versions over.
float blendAlpha = 0.75f; // bl default is 0.9f
float blendBeta = 1.0f - blendAlpha;
function isInfinity(%value)
{
return strcmp(%value, "-1.#INF") == 0 || strcmp(%value, "1.#INF") == 0;
}
function isNaN(%value)
{
return strcmp(%value, "-1.#IND") == 0;
}
function rotl(%value, %shift)
{
return (%value << %shift) | (%value >> (32 - %value));
}
function blake2(%bytes)
{
if (%bytes.class $= "BitArray")
%bytes = ByteArray(%bytes);
else if (%bytes.class !$= "ByteArray")
function createLightning(%start, %end, %group, %color)
{
if (%color $= "")
%color = "1 0 1";
%normal = vectorNormalize(vectorSub(%end, %start));
%segments = Array::from(Array::from(%start, %end, 1));
%count = 3;
%offset = 0.6 * (vectorDist(%start, %end) / 7);
@qoh
qoh / gist:6779291
Last active May 11, 2020 04:50
renderCsm_frag.glsl file for soft shaders v2 - ultra graphics version.
#version 120
#extension GL_EXT_texture_array : require
#extension GL_EXT_texture_array : enable
// Soft shadows v2
// - Ultra graphics version
// fudgeKey is very hard to get right.
// Try various values to fix weird patterns or "disconnected shadows".
// It depends on your shadow quality, too.
@qoh
qoh / gist:6779282
Last active May 11, 2020 04:50
renderCsm_frag.glsl file for soft shaders v2 - performance optimized version.
#version 120
#extension GL_EXT_texture_array : require
#extension GL_EXT_texture_array : enable
// Soft shadows v2
// - Performance optimized version
float dist = 0.05f;
float step = 0.025f;
@qoh
qoh / gist:6729709
Last active May 11, 2020 04:50
Replace shaders/renderCsm_frag.glsl with this and re-apply your shader settings. Read notes in the code before complaining.
#version 120
#extension GL_EXT_texture_array : require
#extension GL_EXT_texture_array : enable
// NOTE: this is a development release - expect tons of bugs
// this /will/ decrease your fps roughly (soft_distance*2/soft_stepsize+1)³ times,
// depends on cost of individual operations
// soft_distance is the space to spread out shadow blurring samples over