From 66c741e2c509ca3798acbb79a72b3999fe1e6769 Mon Sep 17 00:00:00 2001 From: DavidBluecame Date: Sun, 24 Jan 2016 20:38:55 +0100 Subject: [PATCH] Fix for black dots using HDRI spherical and Coated Glossy Black dots reported in http://www.yafaray.org/community/forum/viewtopic.php?p=31358#p31358 and http://www.yafaray.org/node/705 when using HDRI spherical and Coated Glossy material I've found that the wi vector was sometimes not defined by the Coated Glossy sample function and it caused the next recursive step to use refRay=(0,0,0) which caused a problem in the texture spheremap function to convert 0,0,0 to u,v coordinates (division by zero) I'm not sure why this happens sometimes in the Windows 64 build but not in the Linux 64 build (at least it did not happen to me) or why it happens in v2.0.1 but not in v1.1.0... strange but when dealing with not initialized values anything can happen. So, for now I'll just add a wi assignment in case the sample function ends prematurely, I hope it solves this problem and does not cause any new strange issues. --- src/materials/coatedglossy.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/materials/coatedglossy.cc b/src/materials/coatedglossy.cc index cb203223..24f5adbb 100644 --- a/src/materials/coatedglossy.cc +++ b/src/materials/coatedglossy.cc @@ -288,7 +288,12 @@ color_t coatedGlossyMat_t::sample(const renderState_t &state, const surfacePoint ++nMatch; } } - if(!nMatch || sum < 0.00001){ return color_t(0.f); } + if(!nMatch || sum < 0.00001) + { + wi = reflect_dir(N, wo); //If the sampling is prematurely ended for some reason, we need to give wi a value or it will be undefinded causing unexpected problems as black dots. By default I've chosen wi to be the reflection of wo, but it's an arbitrary choice. + return color_t(0.f); + } + else if(nMatch==1){ pick=0; width[0]=1.f; } else {