Added an option "Cast Approximate" to control if a material should cast

shadow when using approximate AO, separate from "Traceable".
This commit is contained in:
Brecht Van Lommel 2010-02-11 15:43:31 +00:00
parent 4746fbd8ce
commit d98603129c
7 changed files with 26 additions and 7 deletions

@ -334,7 +334,7 @@ class MATERIAL_PT_shadow(MaterialButtonsPanel):
sub = col.column() sub = col.column()
sub.active = (not mat.ray_shadow_bias) sub.active = (not mat.ray_shadow_bias)
sub.prop(mat, "shadow_ray_bias", text="Ray Bias") sub.prop(mat, "shadow_ray_bias", text="Ray Bias")
col.prop(mat, "cast_approximate")
class MATERIAL_PT_diffuse(MaterialButtonsPanel): class MATERIAL_PT_diffuse(MaterialButtonsPanel):
bl_label = "Diffuse" bl_label = "Diffuse"

@ -43,7 +43,7 @@ struct bContext;
struct ReportList; struct ReportList;
#define BLENDER_VERSION 250 #define BLENDER_VERSION 250
#define BLENDER_SUBVERSION 16 #define BLENDER_SUBVERSION 17
#define BLENDER_MINVERSION 250 #define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0 #define BLENDER_MINSUBVERSION 0

@ -188,7 +188,7 @@ void init_material(Material *ma)
ma->vol.ms_diff = 1.f; ma->vol.ms_diff = 1.f;
ma->vol.ms_intensity = 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; ma->preview = NULL;
} }

@ -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; Scene *sce;
Sequence *seq; Sequence *seq;
Material *ma;
/* initialize to sane default so toggling on border shows something */ /* initialize to sane default so toggling on border shows something */
for(sce = main->scene.first; sce; sce = sce->id.next) { 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 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 */ /* sequencer changes */
{ {
bScreen *screen; bScreen *screen;
@ -10621,6 +10625,10 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
} /* sequencer changes */ } /* 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!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

@ -234,6 +234,7 @@ typedef struct Material {
/* shade_flag */ /* shade_flag */
#define MA_CUBIC 1 #define MA_CUBIC 1
#define MA_OBCOLOR 2 #define MA_OBCOLOR 2
#define MA_APPROX_OCCLUSION 4
/* diff_shader */ /* diff_shader */
#define MA_DIFF_LAMBERT 0 #define MA_DIFF_LAMBERT 0

@ -1649,6 +1649,11 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Cast Buffer Shadows", "Allow this material to cast shadows from shadow buffer lamps"); 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"); 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); prop= RNA_def_property(srna, "tangent_shading", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V); RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TANGENT_V);
RNA_def_property_ui_text(prop, "Tangent Shading", "Use the material's tangent vector instead of the normal for shading - for anisotropic shading effects"); RNA_def_property_ui_text(prop, "Tangent Shading", "Use the material's tangent vector instead of the normal for shading - for anisotropic shading effects");

@ -629,6 +629,7 @@ static OcclusionTree *occ_tree_build(Render *re)
OcclusionTree *tree; OcclusionTree *tree;
ObjectInstanceRen *obi; ObjectInstanceRen *obi;
ObjectRen *obr; ObjectRen *obr;
Material *ma;
VlakRen *vlr= NULL; VlakRen *vlr= NULL;
int a, b, c, totface; 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; if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
else vlr++; 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++; totface++;
} }
} }
@ -677,7 +680,9 @@ static OcclusionTree *occ_tree_build(Render *re)
if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; if((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak;
else vlr++; 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].obi= c;
tree->face[b].facenr= a; tree->face[b].facenr= a;
tree->occlusion[b]= 1.0f; tree->occlusion[b]= 1.0f;