Commit 8d72757a authored by Kaspar Scharf's avatar Kaspar Scharf

implemented gas planet texture and jupiter material.

also replaced default material on planet creation with jupiter material, only for testing
parent 88491c31
......@@ -39,6 +39,8 @@ uniform mat4 uViewProjectionMatrix;
uniform mat4 uPrevModelMatrix;
uniform mat4 uPrevViewProjectionMatrix;
uniform vec3 cameraPosition;
out vec4 oColor;
out vec4 oEmissive;
out vec3 oNormal;
......
......@@ -14,19 +14,19 @@
// https://github.com/ashima/webgl-noise
//
vec3 mod289(vec3 x) {
vec3 mod289_2d(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec2 mod289(vec2 x) {
vec2 mod289_2d(vec2 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec3 permute(vec3 x) {
return mod289(((x*34.0)+1.0)*x);
vec3 permute_2d(vec3 x) {
return mod289_2d(((x*34.0)+1.0)*x);
}
float snoise(vec2 v)
float snoise_2d(vec2 v)
{
const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
......@@ -48,8 +48,8 @@ float snoise(vec2 v)
x12.xy -= i1;
// Permutations
i = mod289(i); // Avoid truncation effects in permutation
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
i = mod289_2d(i); // Avoid truncation effects in permutation
vec3 p = permute_2d( permute_2d( i.y + vec3(0.0, i1.y, 1.0 ))
+ i.x + vec3(0.0, i1.x, 1.0 ));
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
......@@ -85,7 +85,7 @@ float fbm_2d(vec2 coords, int numberOfOcts, float freq){
float fValue = 0.0;
float weight = 0.5;
for(int i = 0; i < numberOfOcts; i++){
fValue += snoise(freq * coords) * weight;
fValue += snoise_2d(freq * coords) * weight;
weight *= 0.5;
freq *= 2.0;
}
......
......@@ -16,24 +16,24 @@
// https://github.com/ashima/webgl-noise
//
vec3 mod289(vec3 x) {
vec3 mod289_3d(vec3 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 mod289(vec4 x) {
vec4 mod289_3d(vec4 x) {
return x - floor(x * (1.0 / 289.0)) * 289.0;
}
vec4 permute(vec4 x) {
return mod289(((x*34.0)+1.0)*x);
vec4 permute_3d(vec4 x) {
return mod289_3d(((x*34.0)+1.0)*x);
}
vec4 taylorInvSqrt(vec4 r)
vec4 taylorInvSqrt_3d(vec4 r)
{
return 1.79284291400159 - 0.85373472095314 * r;
}
float snoise(vec3 v)
float snoise_3d(vec3 v)
{
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
......@@ -57,8 +57,8 @@ float snoise(vec3 v)
vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
// Permutations
i = mod289(i);
vec4 p = permute( permute( permute(
i = mod289_3d(i);
vec4 p = permute_3d( permute_3d( permute_3d(
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
......@@ -95,7 +95,7 @@ float snoise(vec3 v)
vec3 p3 = vec3(a1.zw,h.w);
//Normalise gradients
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
vec4 norm = taylorInvSqrt_3d(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
p0 *= norm.x;
p1 *= norm.y;
p2 *= norm.z;
......@@ -124,7 +124,7 @@ float fbm_3d(vec3 coords, int numberOfOcts, float freq){
float fValue = 0.0;
float weight = .5;
for(int i = 0; i < numberOfOcts; i++){
fValue += snoise(freq * coords) * weight;
fValue += snoise_3d(freq * coords) * weight;
weight *= 0.5;
freq *= 2.0;
}
......
......@@ -3,6 +3,7 @@
//needed for calculation of modified normal-vector; change until you get a good result for normals:
#define SAMPLE_ANGLE__NORMAL_VECTOR 0.0005
float getHeightNoise(vec3 normalizedPosInModelspace) {
return (fbm_3d( normalizedPosInModelspace , 4, 80.)/2. + 2*fbm_3d (normalizedPosInModelspace , 2, 1.25));
}
......@@ -14,14 +15,30 @@ float getHeightNoise(vec3 normalizedPosInModelspace) {
#define ROCK_SLOPE .6
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized){
float noiseVal1 = fbm_3d( texCoord3d,4, 128.*128.);// * 0.05;
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized, float depth){
//float noiseVal1 = fbm_3d( texCoord3d,4, 128.*128.);// * 0.05;
float noiseOct1 = 0.;
float noiseOct2 = 0.;
float noiseOct3 = 0.;
float noiseOct4 = 0.;
float noiseOct5 = 0.;
if (depth == 1.) {
noiseOct1 = snoise_3d(128.*128. * texCoord3d);
noiseOct2 = snoise_3d(2*128.*128. * texCoord3d);
noiseOct3 = snoise_3d(4*128.*128. * texCoord3d);
noiseOct4 = snoise_3d(8*128.*128. * texCoord3d);
noiseOct5 = snoise_3d(16*128.*128. * texCoord3d);
}
vec3 distortion = vec3 (.1, .1, .1);
float noiseVal2 = fbm_3d( texCoord3d, 4, 8*128.*128.);// * 0.05;
float noiseVal3 = fbm_3d( texCoord3d + distortion, 4, 8*128.*128.);// * 0.05;
//float noiseVal2 = fbm_3d( texCoord3d, 3, 128.*128.);
float noiseVal2 = 1./2.*noiseOct1 + 1./4.*noiseOct2 + 1./8.*noiseOct3;
//float noiseVal3 = fbm_3d( texCoord3d + distortion, 4, 8*128.*128.);// * 0.05;
float noiseVal3 = 1./2.*noiseOct4 + 1./4.*noiseOct5;
vec4 color = vec4(1., 1., 1., 1.);
float height = getHeightNoise(texCoord3d)*.9 + noiseVal2 * .1;
float height = getHeightNoise(texCoord3d)*.8 + noiseVal2 * .2;
//color = vec4(normalNormalized.x,normalNormalized.y, normalNormalized.z, 1.);
......@@ -30,7 +47,7 @@ vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNorma
float cs = dt / (length(normalNormalized) * length(upVectorNormalized));
float phi = acos(dt);
float phiNormalized = 2*phi / M_PI; //scale results from [0, M_PI/2] to [0, 1]
float c = noiseVal1*.3 +.3;
//float c = noiseVal1*.3 +.3;
float phiPert = .9*phiNormalized + .1 * noiseVal3;
......@@ -48,6 +65,10 @@ vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNorma
return color;
}
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized){
return texture_getColor(texCoord3d, upVectorNormalized, normalNormalized, 1.);
}
float texture_getFinalHeight(vec3 normalizedPosInModelspace){
return 0.008 * getHeightNoise(normalizedPosInModelspace);
}
......
#pragma import "../noise/noise3d.glsl"
#pragma import "../noise/noise2d.glsl"
//float getHeightNoise(vec3 normalizedPosInModelspace) {
// return (fbm_3d( normalizedPosInModelspace , 4, 80.)/2. + 2*fbm_3d (normalizedPosInModelspace , 2, 1.25));
//}
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized, float depth){
float noiseColorRingsR = fbm_2d( vec2(texCoord3d.z, .2),6, 16.);
float noiseColorRingsG = fbm_2d( vec2(texCoord3d.z, .5),5, 8.);
float pFlowRings = fbm_2d( vec2(texCoord3d.z, .8),6, 2.);
float pTime = (pFlowRings-.5)*2. * uTime*0.05;
float co= cos(pTime);
float si= sin(pTime);
mat3 flowRotation = mat3x3(co , -si, 0.,
si, co, 0.,
0., 0., 1.);
texCoord3d = texCoord3d * flowRotation;
float noiseFlow = fbm_3d( vec3(texCoord3d.xy, uTime*.05),6, 2.);
return vec4 (noiseFlow * noiseColorRingsR *.7 +.3, noiseFlow * noiseColorRingsG * .8, 0., 1.);
}
//vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized, float depth){
// //float noiseVal1 = fbm_3d( texCoord3d,4, 128.*128.);// * 0.05;
// float noiseOct1 = 0.;
// float noiseOct2 = 0.;
// float noiseOct3 = 0.;
// float noiseOct4 = 0.;
// float noiseOct5 = 0.;
// if (depth == 1.) {
// noiseOct1 = snoise_3d(128.*128. * texCoord3d);
// noiseOct2 = snoise_3d(2*128.*128. * texCoord3d);
// noiseOct3 = snoise_3d(4*128.*128. * texCoord3d);
// noiseOct4 = snoise_3d(8*128.*128. * texCoord3d);
// noiseOct5 = snoise_3d(16*128.*128. * texCoord3d);
// }
// vec3 distortion = vec3 (.1, .1, .1);
// //float noiseVal2 = fbm_3d( texCoord3d, 3, 128.*128.);
// float noiseVal2 = 1./2.*noiseOct1 + 1./4.*noiseOct2 + 1./8.*noiseOct3;
// //float noiseVal3 = fbm_3d( texCoord3d + distortion, 4, 8*128.*128.);// * 0.05;
// float noiseVal3 = 1./2.*noiseOct4 + 1./4.*noiseOct5;
// vec4 color = vec4(1., 1., 1., 1.);
// float height = getHeightNoise(texCoord3d)*.8 + noiseVal2 * .2;
// //color = vec4(normalNormalized.x,normalNormalized.y, normalNormalized.z, 1.);
// //color = vec4(upVectorNormalized.x,upVectorNormalized.y, upVectorNormalized.z, 1.);
// float dt = dot(normalNormalized, upVectorNormalized);
// float cs = dt / (length(normalNormalized) * length(upVectorNormalized));
// float phi = acos(dt);
// float phiNormalized = 2*phi / M_PI; //scale results from [0, M_PI/2] to [0, 1]
// //float c = noiseVal1*.3 +.3;
// float phiPert = .9*phiNormalized + .1 * noiseVal3;
// if (height> SNOW_LEVEL && phiPert <= ROCK_SLOPE) {
// color = vec4(1., 1., 1., 1.);
// } else if (height> ROCK_LEVEL || phiPert > ROCK_SLOPE) {
// color = vec4(.1, .1, .1, 1.);
// } else if (height> PLANT_LEVEL) {
// color = vec4(.2, .5,.15, 1.);
// }else { //"sand""
// color = vec4(1., .8, .55, 1.);
// }
// return color;
//}
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized){
return texture_getColor(texCoord3d, upVectorNormalized, normalNormalized, 1.);
}
//float texture_getFinalHeight(vec3 normalizedPosInModelspace){
// return 0.008 * 1.;
//}
//vec3 texture_getDisplacedPosition_modelspace(vec3 normalizedPosInModelspace, vec3 normalizedNormal) {
// vec3 newPosition = normalizedPosInModelspace + normalizedNormal * texture_getFinalHeight(normalizedPosInModelspace);
// return newPosition;
//}
#version 410 core
#define LAST_SHADER GEOMETRY
#pragma import "../CommonDeferredFrag.glsl"
#pragma import "gas_texture.glsl"
#pragma import "../terrain/plainSphere_fsh.glsl"
#pragma import "../terrain/plainSphere_gsh.glsl"
#pragma import "../terrain/plainSphere_tcsh.glsl"
#pragma import "../terrain/plainSphere_tesh.glsl"
#pragma import "../terrain/plainSphere_vsh.glsl"
......@@ -7,10 +7,14 @@ float getHeight(vec3 normalizedPosInModelspace) {
return (fbm_3d( normalizedPosInModelspace , 4, 80.)/2. + 2*fbm_3d (normalizedPosInModelspace , 2, 1.25));
}
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized){
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized, float depth){
return vec4(.1, .1, .1, .1);
}
vec4 texture_getColor(vec3 texCoord3d, vec3 upVectorNormalized, vec3 normalNormalized){
return texture_getColor(texCoord3d, upVectorNormalized, normalNormalized, 1.);
}
vec3 texture_getDisplacedPosition_modelspace(vec3 normalizedPosInModelspace, vec3 normalizedNormal) {
float noiseValue = getHeight(normalizedPosInModelspace);
vec3 newPosition = normalizedPosInModelspace + normalizedNormal * 0.008 * noiseValue;
......
......@@ -23,7 +23,7 @@ vec4 color() {
approxNormal = approximateTerrainNormal(normalize(gPosInModelspace));
//approxNormal = inNormal;
vec4 color = texture_getColor(gPosInModelspace, gNormal, approxNormal);
vec4 color = texture_getColor(gPosInModelspace, gNormal, approxNormal, length(cameraPosition - inPosition));
/*float d1 = min(min(gTriDistance.x, gTriDistance.y), gTriDistance.z);
float d2 = min(min(gPatchDistance.x, gPatchDistance.y), gPatchDistance.z);
......
in vec3 vPosInModelspace;
vec3 approxNormal;
void initShader(){
approxNormal = inNormal;
};
vec4 color() {
vec4 color = texture_getColor(vPosInModelspace, approxNormal, approxNormal, length(cameraPosition - inPosition));
color.a = 1.0;
return vec4(1.,0.,0.,1.);
return color;
}
vec4 emissive() {
return uEmissiveColor;
}
vec3 normal() {
return approxNormal;
}
vec4 specularSmoothness() {
return vec4(0.2, 0.2, 0.2, 0.1);
}
#pragma import "../CommonDeferredVert.glsl"
out vec3 vPosInModelspace;
vec3 normal() {
return aPosition;
}
vec2 texCoord() {
return aTexCoord;
}
vec3 position() {
vPosInModelspace = aPosition;
vec4 modelPos = vec4(aPosition, 1.0);
vec4 worldPosition = uModelMatrix * modelPos;
return worldPosition.xyz;
}
#define LAST_SHADER GEOMETRY
in vec3 gPosInModelspace;
void initShader(){};
vec4 color() {
vec4 color = texture_getColor(gPosInModelspace, inNormal, inNormal, length(cameraPosition - inPosition));
color.a = 1.0;
return color;
}
vec4 emissive() {
return uEmissiveColor;
}
vec3 normal() {
return inNormal;
}
vec4 specularSmoothness() {
return vec4(0.2, 0.2, 0.2, 0.1);
}
#version 410 core
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
in vec3 tPosition[3];
in vec3 tPatchDistance[3];
in vec3 tNormal[3];
in vec2 tTexCoord[3];
//in float tHeight[3];
//in vec3 tUpVector_normalized[3];
in vec3 tPosInModelspace[3];
out vec3 gNormal;
out vec3 gPosition;
out vec2 gTexCoord;
//out float gHeight;
//out float gSurfaceAngle;
//out vec3 gUpVector_normalized;
out vec3 gPosInModelspace;
out vec3 gPatchDistance;
out vec3 gTriDistance;
void main()
{
//vec3 A = tPosition[2] - tPosition[0];
//vec3 B = tPosition[1] - tPosition[0];
//gNormal = -normalize(cross(A, B));
gPatchDistance = tPatchDistance[0];
gTexCoord = tTexCoord[0];
gPosition = tPosition[0];
//gHeight = tHeight[0];
//gSurfaceAngle = acos(dot(gNormal, tUpVector[0]));
//gUpVector_normalized = tUpVector_normalized[0];
gPosInModelspace = tPosInModelspace[0];
gNormal = tNormal[0];
gTriDistance = vec3(1, 0, 0);
gl_Position = gl_in[0].gl_Position; EmitVertex();
gTexCoord = tTexCoord[1];
gPosition = tPosition[1];
//gHeight = tHeight[1];
//gSurfaceAngle = acos(dot(gNormal, tUpVector[1]));
//gUpVector_normalized = tUpVector_normalized[1];
gPosInModelspace = tPosInModelspace[1];
gNormal = tNormal[1];
gPatchDistance = tPatchDistance[1];
gTriDistance = vec3(0, 1, 0);
gl_Position = gl_in[1].gl_Position; EmitVertex();
gTexCoord = tTexCoord[2];
gPosition = tPosition[2];
//gHeight = tHeight[2];
//gSurfaceAngle = acos(dot(gNormal, tUpVector[2]));
//gUpVector_normalized = tUpVector_normalized[2];
gPosInModelspace = tPosInModelspace[2];
gNormal = tNormal[2];
gPatchDistance = tPatchDistance[2];
gTriDistance = vec3(0, 0, 1);
gl_Position = gl_in[2].gl_Position; EmitVertex();
EndPrimitive();
}
#version 410 core
layout(vertices = 3) out;
in vec3 vNormal[];
in vec3 vPosition[];
in vec2 vTexCoord[];
out vec3 tcNormal[];
out vec2 tcTexCoord[];
out vec3 tcPosition[];
uniform mat4 uModelMatrix;
uniform vec3 cameraPosition;
#define ID gl_InvocationID
float getTessLevel(float d0, float d1){
float avg = (d0 + d1) / 2.0;
if(avg >= 100){
return 1;
}
if(avg >= 80){
return 2;
}
if(avg >= 60){
return 4;
}
if(avg >= 40){
return 8;
}
if(avg >= 20){
return 16;
}
if(avg >= 10){
return 32;
}
if(avg >= 0){
return 64;
}
else return 1;
}
void main(){
tcNormal[ID] = vNormal[ID];
tcTexCoord[ID] = vTexCoord[ID];
tcPosition[ID] = vPosition[ID];
if (ID == 0) {
float d0 = distance(cameraPosition, (uModelMatrix * vec4(tcPosition[0], 1)).xyz );
float d1 = distance(cameraPosition, (uModelMatrix * vec4(tcPosition[1], 1)).xyz );
float d2 = distance(cameraPosition, (uModelMatrix * vec4(tcPosition[2], 1)).xyz );
gl_TessLevelOuter[0] = getTessLevel(d1, d2);
gl_TessLevelOuter[1] = getTessLevel(d2, d0);
gl_TessLevelOuter[2] = getTessLevel(d0, d1);
gl_TessLevelInner[0] = 0.5 * gl_TessLevelOuter[2];
/*
float avgDist = (d0 + d1 + d2)/3.0;
vec3 midPoint;
float fDistance;
midPoint = (tcPosition[2] + tcPosition[0] / 2.0);
fDistance = distance(midPoint, cameraPosition) * 1;
gl_TessLevelOuter[0] = getTessLevel(fDistance, fDistance);
midPoint = (tcPosition[2] + tcPosition[0] / 2.0);
fDistance = distance(midPoint, cameraPosition) * 1;
gl_TessLevelOuter[1] = getTessLevel(fDistance, fDistance);
midPoint = (tcPosition[2] + tcPosition[0] / 2.0);
fDistance = distance(midPoint, cameraPosition) * 1;
gl_TessLevelOuter[2] = getTessLevel(fDistance, fDistance);
gl_TessLevelInner[0] = (gl_TessLevelOuter[0] + gl_TessLevelOuter[1] +gl_TessLevelOuter[2]) /3;
*/
}
}
#version 410 core
//#pragma import "noise/noise3d.glsl"
//#pragma import "terrain/sphereUV.glsl"
//#pragma import "../terrain/mountainTexture.glsl"
layout(triangles, equal_spacing, ccw) in;
in vec2 tcTexCoord[];
in vec3 tcNormal[];
in vec3 tcPosition[];
out vec3 tNormal;
out vec2 tTexCoord;
out vec3 tPosition;
//out float tHeight;
//out vec3 tUpVector_normalized;
out vec3 tPosInModelspace;
out vec3 tPatchDistance;
uniform mat4 uViewProjectionMatrix;
uniform mat4 uModelMatrix;
uniform vec3 cameraPostion;
//vec3 mod289(vec3 x)
//{
// return x - floor(x * (1.0 / 289.0)) * 289.0;
//}
//vec4 mod289(vec4 x)
//{
// return x - floor(x * (1.0 / 289.0)) * 289.0;
//}
//vec4 permute(vec4 x)
//{
// return mod289(((x*34.0)+1.0)*x);
//}
//vec4 taylorInvSqrt(vec4 r)
//{
// return 1.79284291400159 - 0.85373472095314 * r;
//}
//vec3 fade(vec3 t) {
// return t*t*t*(t*(t*6.0-15.0)+10.0);
//}
//// Classic Perlin noise
//float cnoise(vec3 P)
//{
// vec3 Pi0 = floor(P); // Integer part for indexing
// vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
// Pi0 = mod289(Pi0);
// Pi1 = mod289(Pi1);
// vec3 Pf0 = fract(P); // Fractional part for interpolation
// vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
// vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
// vec4 iy = vec4(Pi0.yy, Pi1.yy);
// vec4 iz0 = Pi0.zzzz;
// vec4 iz1 = Pi1.zzzz;
// vec4 ixy = permute(permute(ix) + iy);
// vec4 ixy0 = permute(ixy + iz0);
// vec4 ixy1 = permute(ixy + iz1);
// vec4 gx0 = ixy0 * (1.0 / 7.0);
// vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
// gx0 = fract(gx0);
// vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
// vec4 sz0 = step(gz0, vec4(0.0));
// gx0 -= sz0 * (step(0.0, gx0) - 0.5);
// gy0 -= sz0 * (step(0.0, gy0) - 0.5);
// vec4 gx1 = ixy1 * (1.0 / 7.0);
// vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
// gx1 = fract(gx1);
// vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
// vec4 sz1 = step(gz1, vec4(0.0));
// gx1 -= sz1 * (step(0.0, gx1) - 0.5);
// gy1 -= sz1 * (step(0.0, gy1) - 0.5);
// vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
// vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
// vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
// vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
// vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
// vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
// vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
// vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);
// vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
// g000 *= norm0.x;
// g010 *= norm0.y;
// g100 *= norm0.z;
// g110 *= norm0.w;
// vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
// g001 *= norm1.x;
// g011 *= norm1.y;
// g101 *= norm1.z;
// g111 *= norm1.w;
// float n000 = dot(g000, Pf0);
// float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
// float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
// float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
// float n001 = dot(g001, vec3(