Prevent double multiplication of Fresnel.

This commit is contained in:
Joey de Vries
2016-12-18 11:28:01 +01:00
parent 70f2ec7c1b
commit 0f78bb69ae
3 changed files with 7 additions and 7 deletions

View File

@@ -95,10 +95,10 @@ int main()
glm::vec3( 10.0f, -10.0f, 10.0f),
};
glm::vec3 lightColors[] = {
glm::vec3(5.0f, 5.0f, 5.0f),
glm::vec3(5.0f, 5.0f, 5.0f),
glm::vec3(5.0f, 5.0f, 5.0f),
glm::vec3(5.0f, 5.0f, 5.0f)
glm::vec3(2.0f, 2.0f, 2.0f),
glm::vec3(2.0f, 2.0f, 2.0f),
glm::vec3(2.0f, 2.0f, 2.0f),
glm::vec3(2.0f, 2.0f, 2.0f)
};
int nrRows = 7;
int nrColumns = 7;

View File

@@ -103,7 +103,7 @@ void main()
float NDF = DistributionGGX(N, H, roughness);
float G = GeometrySmith(N, V, L, roughness);
vec3 nominator = NDF * G * F;
vec3 nominator = NDF * G * F;
float denominator = 4 * max(dot(V, N), 0.0) * max(dot(L, N), 0.0) + 0.001; // 0.001 to prevent divide by zero.
vec3 brdf = nominator / denominator;
@@ -111,7 +111,7 @@ void main()
float NdotL = max(dot(N, L), 0.0);
// add to outgoing radiance Lo
Lo += (kD * albedo / PI + kS * brdf) * radiance * NdotL;
Lo += (kD * albedo / PI + brdf) * radiance * NdotL; // note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
}
// ambient lighting (note that the next IBL tutorial will replace

View File

@@ -138,7 +138,7 @@ void main()
float NdotL = max(dot(N, L), 0.0);
// add to outgoing radiance Lo
Lo += (kD * albedo / PI + kS * brdf) * radiance * NdotL;
Lo += (kD * albedo / PI + brdf) * radiance * NdotL; // note that we already multiplied the BRDF by the Fresnel (kS) so we won't multiply by kS again
}
// ambient lighting (note that the next IBL tutorial will replace