Fix T43926: Volume scatter: intersecting objects GPU rendering artifacts
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 23 Mar 2015 07:48:33 +0000 (12:48 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 23 Mar 2015 07:48:33 +0000 (12:48 +0500)
Fix T44007: Cycles Volumetrics: block artifacts with overlapping volumes

The issue was caused by uninitialized parameters of some closures, which
lead to unpredictable behavior of shader_merge_closures().

intern/cycles/kernel/closure/bsdf_ashikhmin_velvet.h
intern/cycles/kernel/closure/bsdf_diffuse.h
intern/cycles/kernel/closure/bsdf_diffuse_ramp.h
intern/cycles/kernel/closure/bsdf_phong_ramp.h
intern/cycles/kernel/closure/bsdf_reflection.h
intern/cycles/kernel/closure/bsdf_refraction.h
intern/cycles/kernel/closure/bsdf_transparent.h
intern/cycles/kernel/closure/bssrdf.h
intern/cycles/kernel/closure/volume.h

index 580f50d5dd6b7893032a9659ddc0f8e01c63d03f..98c1159948afc3a67c92bce7e54474da80461743 100644 (file)
@@ -39,6 +39,7 @@ ccl_device int bsdf_ashikhmin_velvet_setup(ShaderClosure *sc)
 {
        float sigma = fmaxf(sc->data0, 0.01f);
        sc->data0 = 1.0f/(sigma * sigma); /* m_invsigma2 */
+       sc->data1 = 0.0f;
        
        sc->type = CLOSURE_BSDF_ASHIKHMIN_VELVET_ID;
 
index 4b29bb096d180c13af894e331b3257385fe931fe..29725c5b5dac34eaabaf75c7c9b23e5c6c292f95 100644 (file)
@@ -40,6 +40,8 @@ CCL_NAMESPACE_BEGIN
 ccl_device int bsdf_diffuse_setup(ShaderClosure *sc)
 {
        sc->type = CLOSURE_BSDF_DIFFUSE_ID;
+       sc->data0 = 0.0f;
+       sc->data1 = 0.0f;
        return SD_BSDF|SD_BSDF_HAS_EVAL;
 }
 
@@ -83,6 +85,8 @@ ccl_device int bsdf_diffuse_sample(const ShaderClosure *sc, float3 Ng, float3 I,
 ccl_device int bsdf_translucent_setup(ShaderClosure *sc)
 {
        sc->type = CLOSURE_BSDF_TRANSLUCENT_ID;
+       sc->data0 = 0.0f;
+       sc->data1 = 0.0f;
        return SD_BSDF|SD_BSDF_HAS_EVAL;
 }
 
index cdaf84f175065abf7030e9642c6ff25c705fd676..e0287e7655aa64d6e8ec8ba0cb802d11798bb7f5 100644 (file)
@@ -52,6 +52,8 @@ ccl_device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const flo
 ccl_device int bsdf_diffuse_ramp_setup(ShaderClosure *sc)
 {
        sc->type = CLOSURE_BSDF_DIFFUSE_RAMP_ID;
+       sc->data0 = 0.0f;
+       sc->data1 = 0.0f;
        return SD_BSDF|SD_BSDF_HAS_EVAL;
 }
 
index f9f263719e992b0a4ed5b6196c76dbb373923138..1ab15eee954c2364d5cc46df045b06f6dd23b6c7 100644 (file)
@@ -51,9 +51,9 @@ ccl_device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float
 
 ccl_device int bsdf_phong_ramp_setup(ShaderClosure *sc)
 {
-       sc->data0 = max(sc->data0, 0.0f);
-       
        sc->type = CLOSURE_BSDF_PHONG_RAMP_ID;
+       sc->data0 = max(sc->data0, 0.0f);
+       sc->data1 = 0.0f;
        return SD_BSDF|SD_BSDF_HAS_EVAL;
 }
 
index 303f4c9ce343899c4ecaa7a8a968b9029d049dd7..d635e734188eea0040ea54d8efd66b9981222393 100644 (file)
@@ -40,6 +40,8 @@ CCL_NAMESPACE_BEGIN
 ccl_device int bsdf_reflection_setup(ShaderClosure *sc)
 {
        sc->type = CLOSURE_BSDF_REFLECTION_ID;
+       sc->data0 = 0.0f;
+       sc->data1 = 0.0f;
        return SD_BSDF;
 }
 
index c78a4b67134deaf83f3d5d466853d897cfc6d8ec..e339778d7d05abf2f9b358485c43d34142696ee5 100644 (file)
@@ -40,6 +40,8 @@ CCL_NAMESPACE_BEGIN
 ccl_device int bsdf_refraction_setup(ShaderClosure *sc)
 {
        sc->type = CLOSURE_BSDF_REFRACTION_ID;
+       sc->data0 = 0.0f;
+       sc->data1 = 0.0f;
        return SD_BSDF;
 }
 
index 3c2fd8004dfb539b3acc90861a0da08094e519a8..78580190f6aa2d0476777e109b0007f9e72b5650 100644 (file)
@@ -38,6 +38,8 @@ CCL_NAMESPACE_BEGIN
 ccl_device int bsdf_transparent_setup(ShaderClosure *sc)
 {
        sc->type = CLOSURE_BSDF_TRANSPARENT_ID;
+       sc->data0 = 0.0f;
+       sc->data1 = 0.0f;
        return SD_BSDF|SD_TRANSPARENT;
 }
 
index b6de2da8c71d3acddb8aaddbb32f9a5fe5f0d950..43de6e529ee33add159158f1d85b83c858561d7c 100644 (file)
@@ -30,6 +30,7 @@ ccl_device int bssrdf_setup(ShaderClosure *sc, ClosureType type)
                return flag;
        }
        else {
+               sc->data0 = 0.0f;
                sc->data1 = clamp(sc->data1, 0.0f, 1.0f); /* texture blur */
                sc->T.x = clamp(sc->T.x, 0.0f, 1.0f); /* sharpness */
                sc->type = type;
index 439610546e5b2a808649955b8296e72bac6c6db1..4143980f2cd3011ad0e61fef0967ff8bc865df6f 100644 (file)
@@ -35,6 +35,7 @@ ccl_device int volume_henyey_greenstein_setup(ShaderClosure *sc)
        
        /* clamp anisotropy to avoid delta function */
        sc->data0 = signf(sc->data0) * min(fabsf(sc->data0), 1.0f - 1e-3f);
+       sc->data1 = 0.0f;
 
        return SD_SCATTER;
 }