Added an option "Cast Approximate" to control if a material should cast
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 11 Feb 2010 15:43:31 +0000 (15:43 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 11 Feb 2010 15:43:31 +0000 (15:43 +0000)
shadow when using approximate AO, separate from "Traceable".

release/scripts/ui/properties_material.py
source/blender/blenkernel/BKE_blender.h
source/blender/blenkernel/intern/material.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_material_types.h
source/blender/makesrna/intern/rna_material.c
source/blender/render/intern/source/occlusion.c

index ca7edf1e3ee685ab79395a30ef3f3514b76a2d9e..d63dd932e452ebdadcae417f264b1fb6a0445a6b 100644 (file)
@@ -334,7 +334,7 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
         sub = col.column()
         sub.active = (not mat.ray_shadow_bias)
         sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
-
+        col.prop(mat, "cast_approximate")
 
 class MATERIAL_PT_diffuse(MaterialButtonsPanel):
     bl_label = "Diffuse"
index 666ecf7d65df6a7d3f7be8e1a3624d0e9753191e..c101b8870170bb8074e2fb920ec81e0c5714d590 100644 (file)
@@ -43,7 +43,7 @@ struct bContext;
 struct ReportList;
 
 #define BLENDER_VERSION                        250
-#define BLENDER_SUBVERSION             16
+#define BLENDER_SUBVERSION             17
 
 #define BLENDER_MINVERSION             250
 #define BLENDER_MINSUBVERSION  0
index 038ce6c5d25865bd996fdd563f3251f55370e143..9c56699fa1d47a03e5b249fb89782a7042a34bff 100644 (file)
@@ -188,7 +188,7 @@ void init_material(Material *ma)
        ma->vol.ms_diff = 1.f;
        ma->vol.ms_intensity = 1.f;
        
-       ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP;
+       ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP|MA_APPROX_OCCLUSION;
 
        ma->preview = NULL;
 }
index af9df4b00bade367a625245f630084a890cb4474..175851266edd1d43f00ca67cf44fdac8ccdb4574 100644 (file)
@@ -10563,10 +10563,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
        
-       /* put 2.50 compatibility code here until next subversion bump */
-       {
+       if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) {
                Scene *sce;
                Sequence *seq;
+               Material *ma;
 
                /* initialize to sane default so toggling on border shows something */
                for(sce = main->scene.first; sce; sce = sce->id.next) {
@@ -10587,6 +10587,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                        SEQ_END
                }
 
+               for(ma = main->mat.first; ma; ma=ma->id.next)
+                       if(ma->mode & MA_TRACEBLE)
+                               ma->shade_flag |= MA_APPROX_OCCLUSION;
+
                /* sequencer changes */
                {
                        bScreen *screen;
@@ -10621,6 +10625,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                } /* sequencer changes */
        }
 
+       /* put 2.50 compatibility code here until next subversion bump */
+       {
+       }
+
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
        /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
 
index 7a19262b0cd0f5bf96c3527bf628f0af37568e72..d41c286a93f7eb155539791cdec3df450d65924b 100644 (file)
@@ -234,6 +234,7 @@ typedef struct Material {
 /* shade_flag */
 #define MA_CUBIC                       1
 #define MA_OBCOLOR                     2
+#define MA_APPROX_OCCLUSION    4
 
 /* diff_shader */
 #define MA_DIFF_LAMBERT                0
index 0cfe44c1be64bd34e64a391edcd0c14e4b5046cf..089f9416753272dd3f8e652ef990570cf8ae0914 100644 (file)
@@ -1648,6 +1648,11 @@ void RNA_def_material(BlenderRNA *brna)
        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_update(prop, 0, "rna_Material_update");
+
+       prop= RNA_def_property(srna, "cast_approximate", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_APPROX_OCCLUSION);
+       RNA_def_property_ui_text(prop, "Cast Approximate", "Allow this material to cast shadows when using approximate ambient occlusion.");
+       RNA_def_property_update(prop, 0, "rna_Material_update");
        
        prop= RNA_def_property(srna, "tangent_shading", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V);
index d06339f75cce4f498a044bf0cc99f39c84035345..3f825613d12a8992694273f96ac72e2275d263e2 100644 (file)
@@ -629,6 +629,7 @@ static OcclusionTree *occ_tree_build(Render *re)
        OcclusionTree *tree;
        ObjectInstanceRen *obi;
        ObjectRen *obr;
+       Material *ma;
        VlakRen *vlr= NULL;
        int a, b, c, totface;
 
@@ -640,7 +641,9 @@ static OcclusionTree *occ_tree_build(Render *re)
                        if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
                        else vlr++;
 
-                       if((vlr->mat->mode & MA_TRACEBLE) && (vlr->mat->material_type == MA_TYPE_SURFACE))
+                       ma= vlr->mat;
+
+                       if((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE))
                                totface++;
                }
        }
@@ -677,7 +680,9 @@ static OcclusionTree *occ_tree_build(Render *re)
                        if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
                        else vlr++;
 
-                       if((vlr->mat->mode & MA_TRACEBLE) && (vlr->mat->material_type == MA_TYPE_SURFACE)) {
+                       ma= vlr->mat;
+
+                       if((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) {
                                tree->face[b].obi= c;
                                tree->face[b].facenr= a;
                                tree->occlusion[b]= 1.0f;