Cycles: Fix difference in Ashikhmin Shirley shader between CPU and GPU

The issue was caused by some NaN appearing in calculations.

Visible with scifi_armor_concept.blend from the cloud.
This commit is contained in:
Sergey Sharybin 2016-07-28 18:46:29 +02:00
parent 85ccdf37c0
commit d834759423
1 changed files with 8 additions and 2 deletions

View File

@ -101,8 +101,14 @@ ccl_device float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderClosure *sc, c
float HdotX = dot(H, X);
float HdotY = dot(H, Y);
float e = (n_x * HdotX*HdotX + n_y * HdotY*HdotY) / (1.0f - HdotN*HdotN);
float lobe = powf(HdotN, e);
float lobe;
if(HdotN < 1.0f) {
float e = (n_x * HdotX*HdotX + n_y * HdotY*HdotY) / (1.0f - HdotN*HdotN);
lobe = powf(HdotN, e);
}
else {
lobe = 1.0f;
}
float norm = sqrtf((n_x + 1.0f)*(n_y + 1.0f)) / (8.0f * M_PI_F);
out = NdotO * norm * lobe * pump;