Beckmann distribution changed. It's working now, but maybe too good??
This commit is contained in:
parent
ca47d4a84b
commit
aac668b094
1 changed files with 4 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue