Some code tweaks

This commit is contained in:
Ray 2020-03-03 01:21:06 +01:00
parent 8724cf2ea5
commit a6297a2be1
6 changed files with 16 additions and 20 deletions

View file

@ -15,7 +15,7 @@ in vec3 fragPosition;
uniform samplerCube environmentMap;
// Constant values
const float PI = 3.14159265359f;
const float PI = 3.14159265359;
// Output fragment color
out vec4 finalColor;
@ -31,8 +31,8 @@ void main()
vec3 right = cross(up, normal);
up = cross(normal, right);
float sampleDelta = 0.025f;
float nrSamples = 0.0f;
float sampleDelta = 0.025;
float nrSamples = 0.0;
for (float phi = 0.0; phi < 2.0*PI; phi += sampleDelta)
{

View file

@ -34,7 +34,7 @@ void main()
mat3 normalMatrix = transpose(inverse(mat3(matModel)));
// Calculate fragment position based on model transformations
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f));
fragPosition = vec3(matModel*vec4(vertexPosition, 1.0));
// Send vertex attributes to fragment shader
fragTexCoord = vertexTexCoord;

View file

@ -18,7 +18,7 @@ uniform samplerCube environmentMap;
uniform float roughness;
// Constant values
const float PI = 3.14159265359f;
const float PI = 3.14159265359;
// Output fragment color
out vec4 finalColor;
@ -35,7 +35,7 @@ float DistributionGGX(vec3 N, vec3 H, float roughness)
float NdotH = max(dot(N, H), 0.0);
float NdotH2 = NdotH*NdotH;
float nom = a2;
float nom = a2;
float denom = (NdotH2*(a2 - 1.0) + 1.0);
denom = PI*denom*denom;
@ -49,7 +49,7 @@ float RadicalInverse_VdC(uint bits)
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
return float(bits)*2.3283064365386963e-10; // / 0x100000000
}
vec2 Hammersley(uint i, uint N)
@ -60,7 +60,7 @@ vec2 Hammersley(uint i, uint N)
vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness)
{
float a = roughness*roughness;
float phi = 2.0 * PI * Xi.x;
float phi = 2.0*PI*Xi.x;
float cosTheta = sqrt((1.0 - Xi.y)/(1.0 + (a*a - 1.0)*Xi.y));
float sinTheta = sqrt(1.0 - cosTheta*cosTheta);