 float PDF(vec3 H, vec3 N, float roughness)
 {
     float NdotH = dot(N, H);
-	if(u_distribution == cLambertian)
-	{
-		return max(NdotH * (1.0 / MATH_PI), 0.0);
-	}
-	else if(u_distribution == cGGX)
-	{
-		float D = D_GGX(NdotH, roughness);
-		return max(D / 4.0, 0.0);
-	}
-	else if(u_distribution == cCharlie)
-	{
-		float D = D_Charlie(roughness, NdotH);
-		return max(D / 4.0, 0.0);
-	}
-
-	return 0.f;
+    if(u_distribution == cLambertian)
+    {
+        return max(NdotH * (1.0 / MATH_PI), 0.0);
+    }
+    else if(u_distribution == cGGX)
+    {
+        float D = D_GGX(NdotH, roughness);
+        return max(D / 4.0, 0.0);
+    }
+    else if(u_distribution == cCharlie)
+    {
+        float D = D_Charlie(roughness, NdotH);
+        return max(D / 4.0, 0.0);
+    }
+
+    return 0.f;
 }
 
 // getImportanceSample returns an importance sample direction with pdf in the .w component


vec3 uvToXYZ(int face, vec2 uv)
{
	if(face == 0)
		return vec3(     1.f,   uv.y,    -uv.x);

	else if(face == 1)
		return vec3(    -1.f,   uv.y,     uv.x);

	else if(face == 2)
		return vec3(   +uv.x,   -1.f,    +uv.y);

	else if(face == 3)
		return vec3(   +uv.x,    1.f,    -uv.y);

	else if(face == 4)
		return vec3(   +uv.x,   uv.y,      1.f);

	else {//if(face == 5)
		return vec3(    -uv.x,  +uv.y,     -1.f);}
}

vec2 dirToUV(vec3 dir)
{
	return vec2(
		0.5f + 0.5f * atan(dir.z, dir.x) / MATH_PI,
		1.f - acos(dir.y) / MATH_PI);
}

float saturate(float v)
{
	return clamp(v, 0.0f, 1.0f);
}

// Hammersley Points on the Hemisphere

    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
}

// hammersley2d describes a sequence of points in the 2d unit square [0,1)^2
// that can be used for quasi Monte Carlo integration
vec2 hammersley2d(int i, int N) {
    return vec2(float(i)/float(N), radicalInverse_VdC(uint(i)));
}

// Hemisphere Sample

