Blender Internal: Modify material property "Cast Buffer Shadows" to affect ray shadow...
authorIRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Tue, 11 Feb 2014 08:06:21 +0000 (17:06 +0900)
committerIRIE Shinsuke <irieshinsuke@yahoo.co.jp>
Tue, 11 Feb 2014 08:06:21 +0000 (17:06 +0900)
This allows us to make materials that don't cast ray shadows.
Turning off this property can reduce the rendering time slightly.

Note: RNA path is changed to "use_cast_shadows" as well. The older
path "use_cast_buffer_shadows" still can be used as its alias, but
it will be removed after updating some addons.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D272

13 files changed:
release/scripts/startup/bl_ui/properties_material.py
source/blender/blenkernel/intern/material.c
source/blender/blenloader/intern/versioning_legacy.c
source/blender/editors/render/render_preview.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_material_types.h
source/blender/makesrna/intern/rna_material.c
source/blender/render/intern/raytrace/rayobject.cpp
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/shadbuf.c
source/blender/render/intern/source/strand.c
source/blender/render/intern/source/zbuf.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 9e56c269b2b0b425039670c25bbe9d69d6536a55..ee3e90591e706226771433edbb6d3514b887daec 100644 (file)
@@ -222,7 +222,7 @@ class MATERIAL_PT_pipeline(MaterialButtonsPanel, Panel):
 
         col.prop(mat, "use_cast_shadows_only", text="Cast Only")
         col.prop(mat, "shadow_cast_alpha", text="Casting Alpha")
-        col.prop(mat, "use_cast_buffer_shadows")
+        col.prop(mat, "use_cast_shadows")
         col.prop(mat, "use_cast_approximate")
         col.prop(mat, "pass_index")
 
@@ -824,9 +824,9 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel, Panel):
 
         col = split.column()
         if simple_material(base_mat):
-            col.prop(mat, "use_cast_buffer_shadows")
+            col.prop(mat, "use_cast_shadows")
         sub = col.column()
-        sub.active = mat.use_cast_buffer_shadows
+        sub.active = mat.use_cast_shadows
         sub.prop(mat, "shadow_buffer_bias", text="Buffer Bias")
         col.prop(mat, "use_ray_shadow_bias", text="Auto Ray Bias")
         sub = col.column()
index 5f6331315f8ac20bb543b6a6e36dfcb2abd59feb..40257141ffae11ce4bb81fa58737bdffddb17ae3 100644 (file)
@@ -202,7 +202,7 @@ void init_material(Material *ma)
        ma->game.alpha_blend = 0;
        ma->game.face_orientation = 0;
        
-       ma->mode = MA_TRACEBLE | MA_SHADBUF | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP;
+       ma->mode = MA_TRACEBLE | MA_CASTSHADOW | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP;
        ma->shade_flag = MA_APPROX_OCCLUSION;
        ma->preview = NULL;
 }
index 0283d9b04fbfdb628d69c5c45f497d7aa2492a11..e82e5b21e7fcf46e666e8719b836c90d16df0b85 100644 (file)
@@ -2171,7 +2171,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
                                ma->mode |= MA_TANGENT_STR;
                        }
                        if (ma->mode & MA_TRACEBLE)
-                               ma->mode |= MA_SHADBUF;
+                               ma->mode |= MA_CASTSHADOW;
                }
        }
 
index 482c855f06781871727c26d80b963bea2576af78..aecd4e1aa17bbe7744dc9736376f08e97a030ba0 100644 (file)
@@ -350,7 +350,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
                                                if (base->object->id.name[2] == 'c') {
                                                        Material *shadmat = give_current_material(base->object, base->object->actcol);
                                                        if (shadmat) {
-                                                               if (mat->mode & MA_SHADBUF) shadmat->septex = 0;
+                                                               if (mat->mode & MA_CASTSHADOW) shadmat->septex = 0;
                                                                else shadmat->septex |= 1;
                                                        }
                                                }
index 8a4714eeded7d8b87fe94b243efeac919319a08b..0a387af7e7e804cef6e6cd3edc6fa9f2e07d4afd 100644 (file)
@@ -3620,7 +3620,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3
        if (v3d->flag2 & V3D_RENDER_SHADOW) {
                for (i = 0; i < ob->totcol; ++i) {
                        Material *ma = give_current_material(ob, i);
-                       if (ma && !(ma->mode & MA_SHADBUF)) {
+                       if (ma && !(ma->mode & MA_CASTSHADOW)) {
                                return true;
                        }
                }
index a6478f2ae69b8372f2b754d4cf60fe3c10c2af34..8dc46ec95d97172e4f9dc23d3beb57d1d0aa8c5f 100644 (file)
@@ -267,7 +267,7 @@ typedef struct Material {
 #define MA_RAYBIAS             0x400000
 #define MA_FULL_OSA            0x800000
 #define MA_TANGENT_STR 0x1000000
-#define MA_SHADBUF             0x2000000
+#define MA_CASTSHADOW          0x2000000
                /* note; we drop MA_TANGENT_STR later to become tangent_u */
 #define MA_TANGENT_V   0x4000000
 /* qdn: a bit clumsy this, tangents needed for normal maps separated from shading */
index 807d9fc35e10e7f668907e70e9b64c53fcbecebb..76c115c93d6e3948925cab37c14c8b5168b14be2 100644 (file)
@@ -1937,10 +1937,16 @@ void RNA_def_material(BlenderRNA *brna)
                                 "Force this material to render full shading/textures for all anti-aliasing samples");
        RNA_def_property_update(prop, 0, "rna_Material_update");
 
+       prop = RNA_def_property(srna, "use_cast_shadows", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_CASTSHADOW);
+       RNA_def_property_ui_text(prop, "Cast Shadows",
+                                "Allow this material to cast shadows");
+       RNA_def_property_update(prop, 0, "rna_Material_update");
+
        prop = RNA_def_property(srna, "use_cast_buffer_shadows", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_SHADBUF);
-       RNA_def_property_ui_text(prop, "Cast Buffer Shadows",
-                                "Allow this material to cast shadows from shadow buffer lamps");
+       RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_CASTSHADOW);
+       RNA_def_property_ui_text(prop, "Cast Shadows",
+                                "This is obsolete RNA path, please use 'use_cast_shadows' instead");
        RNA_def_property_update(prop, 0, "rna_Material_update");
 
        prop = RNA_def_property(srna, "use_cast_approximate", PROP_BOOLEAN, PROP_NONE);
index 9e639501fddf95687c50d49b0ef4b806d4987f22..fd3d2b5083be2266deaa44d117c04a28ad315ca6 100644 (file)
@@ -118,7 +118,7 @@ MALWAYS_INLINE int vlr_check_intersect(Isect *is, ObjectInstanceRen *obi, VlakRe
        if (is->mode == RE_RAY_MIRROR)
                return !(vlr->mat->mode & MA_ONLYCAST);
        else
-               return (is->lay & obi->lay);
+               return (vlr->mat->mode & MA_CASTSHADOW) && (is->lay & obi->lay);
 }
 
 MALWAYS_INLINE int vlr_check_intersect_solid(Isect *UNUSED(is), ObjectInstanceRen *UNUSED(obi), VlakRen *vlr)
index bcde98aea8f4053eeb1fe12ea35405bcf1276653..56080357dce9bc76218e8487c78226633e3ecb64 100644 (file)
@@ -746,7 +746,7 @@ static Material *give_render_material(Render *re, Object *ob, short nr)
        
        if (ma->material_type == MA_TYPE_VOLUME) {
                ma->mode |= MA_TRANSP;
-               ma->mode &= ~MA_SHADBUF;
+               ma->mode &= ~MA_CASTSHADOW;
        }
        if ((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP))
                re->flag |= R_ZTRA;
index 0c3bf85cd241959efc7bb1a7b6c2a8d0213f160c..676e0436bfdc7c580a131a63f575f53e649aa9d4 100644 (file)
@@ -660,7 +660,7 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar)
                        if (vlr->mat!= ma) {
                                ma= vlr->mat;
                                ok= 1;
-                               if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+                               if ((ma->mode & MA_CASTSHADOW)==0) ok= 0;
                        }
                        
                        if (ok && (obi->lay & lay)) {
@@ -2013,7 +2013,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root)
                        if (vlr->mat!= ma) {
                                ma= vlr->mat;
                                ok= 1;
-                               if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+                               if ((ma->mode & MA_CASTSHADOW)==0) ok= 0;
                                if (ma->material_type == MA_TYPE_WIRE) ok= 0;
                                zspanstrand.shad_alpha= zspan.shad_alpha= ma->shad_alpha;
                        }
index f2d4a7afd946fb8b798e9cebc58544fa86d41f99..6c13bffdd175dacaca04c8d925c29cce54c02296 100644 (file)
@@ -860,7 +860,7 @@ int zbuffer_strands_abuf(Render *re, RenderPart *pa, APixstrand *apixbuf, ListBa
                /* test if we should skip it */
                ma = obr->strandbuf->ma;
 
-               if (shadow && !(ma->mode & MA_SHADBUF))
+               if (shadow && !(ma->mode & MA_CASTSHADOW))
                        continue;
                else if (!shadow && (ma->mode & MA_ONLYCAST))
                        continue;
index a8ccd1f362fd35326f32bd4812692cf1ccf4c728..6885768261ffbdc9d68fe34b66fa350f30ee36be 100644 (file)
@@ -2368,7 +2368,7 @@ void zbuffer_shadow(Render *re, float winmat[4][4], LampRen *lar, int *rectz, in
                        if (vlr->mat!= ma) {
                                ma= vlr->mat;
                                ok= 1;
-                               if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+                               if ((ma->mode & MA_CASTSHADOW)==0) ok= 0;
                        }
 
                        if (ok && (obi->lay & lay) && !(vlr->flag & R_HIDDEN)) {
@@ -2421,7 +2421,7 @@ void zbuffer_shadow(Render *re, float winmat[4][4], LampRen *lar, int *rectz, in
                                        if (sseg.buffer->ma!= ma) {
                                                ma= sseg.buffer->ma;
                                                ok= 1;
-                                               if ((ma->mode & MA_SHADBUF)==0) ok= 0;
+                                               if ((ma->mode & MA_CASTSHADOW)==0) ok= 0;
                                        }
 
                                        if (ok && (sseg.buffer->lay & lay)) {
@@ -3349,7 +3349,7 @@ static int zbuffer_abuf(Render *re, RenderPart *pa, APixstr *APixbuf, ListBase *
                        if (vlr->mat!=ma) {
                                ma= vlr->mat;
                                if (shadow)
-                                       dofill= (ma->mode & MA_SHADBUF);
+                                       dofill= (ma->mode & MA_CASTSHADOW);
                                else
                                        dofill= (((ma->mode & MA_TRANSP) && (ma->mode & MA_ZTRANSP)) && !(ma->mode & MA_ONLYCAST));
                        }
index b5d9c5b01ddff8ad7c5f9f5ceac95bf70e80f967..ebd9430401c2e08eb0e718418c79aa5a39b0d9a9 100644 (file)
@@ -596,7 +596,7 @@ static bool ConvertMaterial(
                material->ras_mode |= ( mat->game.flag & GEMAT_BACKCULL )?0:TWOSIDED;
 
                // cast shadows?
-               material->ras_mode |= ( mat->mode & MA_SHADBUF )?CAST_SHADOW:0;
+               material->ras_mode |= ( mat->mode & MA_CASTSHADOW )?CAST_SHADOW:0;
                MTex *mttmp = 0;
                int valid_index = 0;