Cycles: add "Transparent Shadow" option for materials, to disable them per material.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 18 Jun 2013 09:36:00 +0000 (09:36 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 18 Jun 2013 09:36:00 +0000 (09:36 +0000)
12 files changed:
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_shader.cpp
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_types.h
intern/cycles/render/light.cpp
intern/cycles/render/object.cpp
intern/cycles/render/osl.cpp
intern/cycles/render/shader.cpp
intern/cycles/render/shader.h
intern/cycles/render/svm.cpp

index 0c6cf9f513a2dd0f8a3af9e06c6b63ebeb7636b8..b94dd32fad0116536674ebadc725540a065eedf9 100644 (file)
@@ -504,6 +504,12 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
                             "objects that emit little light compared to other light sources",
                 default=True,
                 )
+        cls.use_transparent_shadow = BoolProperty(
+                name="Transparent Shadows",
+                description="Use transparent shadows for this material if it contains a Transparent BSDF"
+                            "disabling will render faster but not give accurate shadows",
+                default=True,
+                )
         cls.homogeneous_volume = BoolProperty(
                 name="Homogeneous Volume",
                 description="When using volume rendering, assume volume has the same density everywhere, "
index a30622a36ac4b542d9ec67c0d37fc0ae7229acf3..e9f8a4f0a8d19d8f42e59ced6e87cf43f9a06e7f 100644 (file)
@@ -919,6 +919,7 @@ class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
 
         col = split.column()
         col.prop(mat, "pass_index")
+        col.prop(cmat, "use_transparent_shadow")
 
         layout.prop(cmat, "sample_as_light")
 
index a9db10b21d77d426a9f6f8f526c1c54d6e51112b..923f9b1e726d2ed3a029f815fcac6ca7fbd4eef9 100644 (file)
@@ -860,7 +860,8 @@ void BlenderSync::sync_materials(bool update_all)
 
                        /* settings */
                        PointerRNA cmat = RNA_pointer_get(&b_mat->ptr, "cycles");
-                       shader->sample_as_light = get_boolean(cmat, "sample_as_light");
+                       shader->use_mis = get_boolean(cmat, "sample_as_light");
+                       shader->use_transparent_shadow = get_boolean(cmat, "use_transparent_shadow");
                        shader->homogeneous_volume = get_boolean(cmat, "homogeneous_volume");
 
                        shader->set_graph(graph);
index c430a40d814f9dfdb9002b34ce1f2b53af8749ce..77dc59d2691fe4fed592e19141fe4007ad35f043 100644 (file)
@@ -168,9 +168,9 @@ __device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, ShaderDa
        float3 L = shader_emissive_eval(kg, sd);
 
 #ifdef __HAIR__
-       if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_SAMPLE_AS_LIGHT) && (sd->segment == ~0)) {
+       if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS) && (sd->segment == ~0)) {
 #else
-       if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_SAMPLE_AS_LIGHT)) {
+       if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS)) {
 #endif
                /* multiple importance sampling, get triangle light pdf,
                 * and compute weight with respect to BSDF pdf */
index 347c066962aa1603024d0731bff3b477f75027ad..7e41ee35ae044f0fcb06adbf5ec6965b62a73441 100644 (file)
@@ -891,7 +891,7 @@ __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
 #endif
        int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*2);
 
-       return (flag & SD_HAS_SURFACE_TRANSPARENT) != 0;
+       return (flag & SD_HAS_TRANSPARENT_SHADOW) != 0;
 }
 #endif
 
index 6ae3b10595c505499c59e4115e6bd6fb219207c0..a9f1831fc7dbdf4b07d9017d2c6ee939e69e866f 100644 (file)
@@ -492,8 +492,8 @@ enum ShaderDataFlag {
        SD_CLOSURE_FLAGS = (SD_EMISSION|SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY|SD_BSSRDF|SD_HOLDOUT|SD_VOLUME|SD_AO),
 
        /* shader flags */
-       SD_SAMPLE_AS_LIGHT = 512,                       /* direct light sample */
-       SD_HAS_SURFACE_TRANSPARENT = 1024,      /* has surface transparency */
+       SD_USE_MIS = 512,                                       /* direct light sample */
+       SD_HAS_TRANSPARENT_SHADOW = 1024,       /* has transparent shadow */
        SD_HAS_VOLUME = 2048,                           /* has volume shader */
        SD_HOMOGENEOUS_VOLUME = 4096,           /* has homogeneous volume */
 
index 1d48ae8f87d098fd3887eb973e65c4431049486b..2f92b957929fb3c30350ff7927d50281e498a57f 100644 (file)
@@ -164,7 +164,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                foreach(uint sindex, mesh->used_shaders) {
                        Shader *shader = scene->shaders[sindex];
 
-                       if(shader->sample_as_light && shader->has_surface_emission) {
+                       if(shader->use_mis && shader->has_surface_emission) {
                                have_emission = true;
                                break;
                        }
@@ -175,7 +175,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                        for(size_t i = 0; i < mesh->triangles.size(); i++) {
                                Shader *shader = scene->shaders[mesh->shader[i]];
 
-                               if(shader->sample_as_light && shader->has_surface_emission)
+                               if(shader->use_mis && shader->has_surface_emission)
                                        num_triangles++;
                        }
 
@@ -184,7 +184,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                        foreach(Mesh::Curve& curve, mesh->curves) {
                                Shader *shader = scene->shaders[curve.shader];
 
-                               if(shader->sample_as_light && shader->has_surface_emission)
+                               if(shader->use_mis && shader->has_surface_emission)
                                        num_curve_segments += curve.num_segments();
 #endif
                }
@@ -215,7 +215,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                foreach(uint sindex, mesh->used_shaders) {
                        Shader *shader = scene->shaders[sindex];
 
-                       if(shader->sample_as_light && shader->has_surface_emission) {
+                       if(shader->use_mis && shader->has_surface_emission) {
                                have_emission = true;
                                break;
                        }
@@ -247,7 +247,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                        for(size_t i = 0; i < mesh->triangles.size(); i++) {
                                Shader *shader = scene->shaders[mesh->shader[i]];
 
-                               if(shader->sample_as_light && shader->has_surface_emission) {
+                               if(shader->use_mis && shader->has_surface_emission) {
                                        distribution[offset].x = totarea;
                                        distribution[offset].y = __int_as_float(i + mesh->tri_offset);
                                        distribution[offset].z = __int_as_float(shader_id);
@@ -277,7 +277,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
                                Shader *shader = scene->shaders[curve.shader];
                                int first_key = curve.first_key;
 
-                               if(shader->sample_as_light && shader->has_surface_emission) {
+                               if(shader->use_mis && shader->has_surface_emission) {
                                        for(int j = 0; j < curve.num_segments(); j++) {
                                                distribution[offset].x = totarea;
                                                distribution[offset].y = __int_as_float(i + mesh->curve_offset); // XXX fix kernel code
index 1a2780995e3dc0b7bdb370decc1137a46e2a637a..7931a51b99d94dfe1faa659dc0a56a2f47182dd5 100644 (file)
@@ -127,7 +127,7 @@ void Object::tag_update(Scene *scene)
                foreach(uint sindex, mesh->used_shaders) {
                        Shader *shader = scene->shaders[sindex];
 
-                       if(shader->sample_as_light && shader->has_surface_emission)
+                       if(shader->use_mis && shader->has_surface_emission)
                                scene->light_manager->need_update = true;
                }
        }
index 8efc6b553e01bf31f72885e216b9823cc840adf0..52e4c697ba800968e2492d269022f8549095d24e 100644 (file)
@@ -100,7 +100,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
                compiler.background = (shader == scene->shaders[scene->default_background]);
                compiler.compile(og, shader);
 
-               if(shader->sample_as_light && shader->has_surface_emission)
+               if(shader->use_mis && shader->has_surface_emission)
                        scene->light_manager->need_update = true;
        }
 
index b061e869e2f34682a8c51c7aed3e444ea3fbde16..da6c3566f6990dca8cc6814a438cfa69b5bf3640 100644 (file)
@@ -42,7 +42,8 @@ Shader::Shader()
        graph = NULL;
        graph_bump = NULL;
 
-       sample_as_light = true;
+       use_mis = true;
+       use_transparent_shadow = true;
        homogeneous_volume = false;
 
        has_surface = false;
@@ -88,7 +89,7 @@ void Shader::tag_update(Scene *scene)
        /* if the shader previously was emissive, update light distribution,
         * if the new shader is emissive, a light manager update tag will be
         * done in the shader manager device update. */
-       if(sample_as_light && has_surface_emission)
+       if(use_mis && has_surface_emission)
                scene->light_manager->need_update = true;
 
        /* get requested attributes. this could be optimized by pruning unused
@@ -220,10 +221,10 @@ void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Sc
        foreach(Shader *shader, scene->shaders) {
                uint flag = 0;
 
-               if(shader->sample_as_light)
-                       flag |= SD_SAMPLE_AS_LIGHT;
-               if(shader->has_surface_transparent)
-                       flag |= SD_HAS_SURFACE_TRANSPARENT;
+               if(shader->use_mis)
+                       flag |= SD_USE_MIS;
+               if(shader->has_surface_transparent && shader->use_transparent_shadow)
+                       flag |= SD_HAS_TRANSPARENT_SHADOW;
                if(shader->has_volume)
                        flag |= SD_HAS_VOLUME;
                if(shader->homogeneous_volume)
index 2a9f119846754d1a935e5f4341ee6b5c492028ea..8810017068bff577f6354b12cb933caf73a1af0a 100644 (file)
@@ -62,7 +62,8 @@ public:
        ShaderGraph *graph_bump;
 
        /* sampling */
-       bool sample_as_light;
+       bool use_mis;
+       bool use_transparent_shadow;
        bool homogeneous_volume;
 
        /* synchronization */
index f61f9ca0fe381d7c84b5e27bbfccef0a2b1e9670..3e211a3ee24f723aab7a4a2172518fe094f8af11 100644 (file)
@@ -74,7 +74,7 @@ void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
 
                assert(shader->graph);
 
-               if(shader->sample_as_light && shader->has_surface_emission)
+               if(shader->use_mis && shader->has_surface_emission)
                        scene->light_manager->need_update = true;
 
                SVMCompiler compiler(scene->shader_manager, scene->image_manager,