Blender Internal: Modify material property "Cast Buffer Shadows" to affect ray shadows also, and rename it to "Cast Shadows".

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
This commit is contained in:
Shinsuke Irie 2014-02-11 17:06:21 +09:00
parent 2038eb10d0
commit e2f9afbaab
Notes: blender-bot 2023-02-14 06:00:45 +01:00
Referenced by commit 38e58612ef, Revert own previous commit rBe2f9afbaabbd.
13 changed files with 26 additions and 20 deletions

View 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()

View 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;
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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 */

View 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);

View 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)

View 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;

View 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;
}

View 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;

View 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));
}

View 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;