Beckmann distribution changed. It's working now, but maybe too good??

This commit is contained in:
Tobias 2022-12-01 11:43:10 +01:00
parent ca47d4a84b
commit aac668b094

View file

@ -38,21 +38,15 @@ Color CookTorranceShader::shade(Scene const &scene, Ray const &ray) const {
}
float CookTorranceShader::D(float NdotH) const {
float divisor = 4.0f * m * m * std::pow(cos(NdotH), 4);
float exponent = std::pow(tan(NdotH) / m, 2);
return 1 / divisor * std::exp(- 1.0f * exponent);
float divisor = 4.0f * m * m * std::pow(NdotH, 4.0f);
float exponent = (NdotH * NdotH - 1.0f) / (m * m * NdotH * NdotH);
return 1 / divisor * std::exp(exponent);
}
float CookTorranceShader::F(float VdotH) const {
return F0 + (1 - F0) * std::pow(1 - VdotH, 5);
return F0 + (1.0f - F0) * std::pow(1.0f - VdotH, 5.0f);
}
float CookTorranceShader::G(float NdotH, float NdotV, float VdotH, float NdotL) const {
if (std::abs(NdotL) < 0.1f) {
return std::min(1.0f, std::min(2 * NdotH * NdotV / VdotH, 2 * NdotH * NdotL / VdotH));
} else if (std::abs(NdotV) < 0.1f) {
return 2 * NdotH * NdotL / VdotH;
} else {
return 1;
}
}