Skip to content

Instantly share code, notes, and snippets.

//from http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/
//1d
g = 1.6180339887498948482 //golden ratio
a1 = 1.0/g
x[n] = (0.5+a1*n) %1
//2d
g = 1.32471795724474602596 //plastic constant
a1 = 1.0/g
//from https://learnopengl.com/PBR/IBL/Specular-IBL
float RadicalInverse_VdC(uint bits)
{
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
@BattleAngelAlita
BattleAngelAlita / gist:b27252674288cf5403086425f45af215
Created November 22, 2018 11:39 — forked from renaudbedard/gist:7a90ec4a5a7359712202
Billboarding for Unity surface shaders
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
// get the camera basis vectors
float3 forward = -normalize(UNITY_MATRIX_V._m20_m21_m22);
float3 up = float3(0, 1, 0); //normalize(UNITY_MATRIX_V._m10_m11_m12);
float3 right = normalize(UNITY_MATRIX_V._m00_m01_m02);
// rotate to face camera