Fix #33984: cycles shadow pass problem with CUDA.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 30 Jan 2013 17:04:51 +0000 (17:04 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 30 Jan 2013 17:04:51 +0000 (17:04 +0000)
intern/cycles/blender/blender_python.cpp
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_path.h

index 676fba7..a10f3b6 100644 (file)
@@ -54,7 +54,7 @@ static PyObject *create_func(PyObject *self, PyObject *args)
        PyObject *pyengine, *pyuserpref, *pydata, *pyscene, *pyregion, *pyv3d, *pyrv3d;
        int preview_osl;
 
-       if(!PyArg_ParseTuple(args, "OOOOOOOp", &pyengine, &pyuserpref, &pydata, &pyscene, &pyregion, &pyv3d, &pyrv3d, &preview_osl))
+       if(!PyArg_ParseTuple(args, "OOOOOOOi", &pyengine, &pyuserpref, &pydata, &pyscene, &pyregion, &pyv3d, &pyrv3d, &preview_osl))
                return NULL;
 
        /* RNA */
index e234d54..4048bbd 100644 (file)
@@ -76,7 +76,7 @@ __device float3 direct_emissive_eval(KernelGlobals *kg, float rando,
 
 __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
        float randt, float rando, float randu, float randv, Ray *ray, BsdfEval *eval,
-       int *lamp)
+       bool *is_lamp)
 {
        LightSample ls;
 
@@ -92,12 +92,6 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
                light_sample(kg, randt, randu, randv, sd->time, sd->P, &ls);
        }
 
-       /* return lamp index for MIS */
-       if(ls.shader & SHADER_USE_MIS)
-               *lamp = ls.lamp;
-       else
-               *lamp= ~0;
-
        if(ls.pdf == 0.0f)
                return false;
 
@@ -146,6 +140,9 @@ __device bool direct_emission(KernelGlobals *kg, ShaderData *sd, int lindex,
                ray->t = 0.0f;
        }
 
+       /* return if it's a lamp for shadow pass */
+       *is_lamp = (ls.prim == ~0);
+
        return true;
 }
 
index 06276c8..b029acf 100644 (file)
@@ -399,19 +399,18 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
 
                                Ray light_ray;
                                BsdfEval L_light;
-                               int lamp;
+                               bool is_lamp;
 
 #ifdef __OBJECT_MOTION__
                                light_ray.time = sd.time;
 #endif
 
-                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &lamp)) {
+                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
                                        /* trace shadow ray */
                                        float3 shadow;
 
                                        if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
                                                /* accumulate */
-                                               bool is_lamp = (lamp != ~0);
                                                path_radiance_accum_light(&L, throughput, &L_light, shadow, state.bounce, is_lamp);
                                        }
                                }
@@ -612,20 +611,19 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
 
                                Ray light_ray;
                                BsdfEval L_light;
-                               int lamp;
+                               bool is_lamp;
 
 #ifdef __OBJECT_MOTION__
                                light_ray.time = sd.time;
 #endif
 
                                /* sample random light */
-                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &lamp)) {
+                               if(direct_emission(kg, &sd, -1, light_t, light_o, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
                                        /* trace shadow ray */
                                        float3 shadow;
 
                                        if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
                                                /* accumulate */
-                                               bool is_lamp = (lamp != ~0);
                                                path_radiance_accum_light(L, throughput, &L_light, shadow, state.bounce, is_lamp);
                                        }
                                }
@@ -819,7 +817,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
                if(sd.flag & SD_BSDF_HAS_EVAL) {
                        Ray light_ray;
                        BsdfEval L_light;
-                       int lamp;
+                       bool is_lamp;
 
 #ifdef __OBJECT_MOTION__
                        light_ray.time = sd.time;
@@ -837,13 +835,12 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
                                        float light_u = path_rng(kg, rng, sample*num_samples + j, rng_offset + PRNG_LIGHT_U);
                                        float light_v = path_rng(kg, rng, sample*num_samples + j, rng_offset + PRNG_LIGHT_V);
 
-                                       if(direct_emission(kg, &sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &lamp)) {
+                                       if(direct_emission(kg, &sd, i, 0.0f, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
                                                /* trace shadow ray */
                                                float3 shadow;
 
                                                if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
                                                        /* accumulate */
-                                                       bool is_lamp = (lamp != ~0);
                                                        path_radiance_accum_light(&L, throughput*num_samples_inv, &L_light, shadow, state.bounce, is_lamp);
                                                }
                                        }
@@ -867,13 +864,12 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
                                        if(kernel_data.integrator.num_all_lights)
                                                light_t = 0.5f*light_t;
 
-                                       if(direct_emission(kg, &sd, -1, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &lamp)) {
+                                       if(direct_emission(kg, &sd, -1, light_t, 0.0f, light_u, light_v, &light_ray, &L_light, &is_lamp)) {
                                                /* trace shadow ray */
                                                float3 shadow;
 
                                                if(!shadow_blocked(kg, &state, &light_ray, &shadow)) {
                                                        /* accumulate */
-                                                       bool is_lamp = (lamp != ~0);
                                                        path_radiance_accum_light(&L, throughput*num_samples_inv, &L_light, shadow, state.bounce, is_lamp);
                                                }
                                        }