Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2010-12-20 16:02:33 +0300
committerTon Roosendaal <ton@blender.org>2010-12-20 16:02:33 +0300
commit6b1258f5b899d9aa0ad4e0c995dd637801b44aba (patch)
treec98e33576461d52270737b4ac8dda74f0d61fee4 /source
parent88b2955564c42359d4367a4da52596c30dda3cd1 (diff)
Bugfix #25301
Material Node trees: SSS wasn't displaying in Nodes. Implementation notes: - Currently copying local data for preview render, only copies the base material. Node materials are re-used. - This causes data to be in 2 "main" databases... complex. - To make it work for preview, I had to add another loop in the SSS code that checks the original Main dbase. That's marked as warning in code to be fixed up. Another bug: - Material properties "SSS presets" copied settings to the active material, not to the displayed one. Added RNA call to retrieve this from Objects. (Next commit will fix preset scripts)
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/render/render_preview.c29
-rw-r--r--source/blender/makesrna/intern/rna_object.c24
-rw-r--r--source/blender/render/intern/source/sss.c8
3 files changed, 60 insertions, 1 deletions
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index f8c8faffc88..2eac7c20350 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -49,6 +49,7 @@
#include "DNA_world_types.h"
#include "DNA_camera_types.h"
#include "DNA_material_types.h"
+#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
#include "DNA_space_types.h"
@@ -309,6 +310,32 @@ static Object *find_object(ListBase *lb, const char *name)
return ob;
}
+static int preview_mat_has_sss(Material *mat, bNodeTree *ntree)
+{
+ if(mat) {
+ if(mat->sss_flag & MA_DIFF_SSS)
+ return 1;
+ if(mat->nodetree)
+ if( preview_mat_has_sss(NULL, mat->nodetree))
+ return 1;
+ }
+ else if(ntree) {
+ bNode *node;
+ for(node= ntree->nodes.first; node; node= node->next) {
+ if(node->type==NODE_GROUP && node->id) {
+ if( preview_mat_has_sss(NULL, (bNodeTree *)node->id))
+ return 1;
+ }
+ else if(node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) {
+ mat= (Material *)node->id;
+ if(mat->sss_flag & MA_DIFF_SSS)
+ return 1;
+ }
+ }
+ }
+ return 0;
+}
+
/* call this with a pointer to initialize preview scene */
/* call this with NULL to restore assigned ID pointers in preview scene */
static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPreview *sp)
@@ -361,7 +388,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
sce->r.mode |= R_RAYTRACE;
if((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP))
sce->r.mode |= R_RAYTRACE;
- if(mat->sss_flag & MA_DIFF_SSS)
+ if(preview_mat_has_sss(mat, NULL))
sce->r.mode |= R_SSS;
/* turn off fake shadows if needed */
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 2c5cddca77f..6031d3e29d9 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -587,12 +587,29 @@ static void rna_Object_active_material_index_range(PointerRNA *ptr, int *min, in
*max= MAX2(ob->totcol-1, 0);
}
+/* returns active base material */
static PointerRNA rna_Object_active_material_get(PointerRNA *ptr)
{
Object *ob= (Object*)ptr->id.data;
Material *ma;
+
+ ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
+ return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
+}
+/* returns (optional) active node material in base material */
+static PointerRNA rna_Object_active_node_material_get(PointerRNA *ptr)
+{
+ Object *ob= (Object*)ptr->id.data;
+ Material *ma;
+
ma= (ob->totcol)? give_current_material(ob, ob->actcol): NULL;
+ if(ma) {
+ Material *manode= give_node_material(ma);
+ if(manode)
+ return rna_pointer_inherit_refine(ptr, &RNA_Material, manode);
+ }
+
return rna_pointer_inherit_refine(ptr, &RNA_Material, ma);
}
@@ -1777,6 +1794,13 @@ static void rna_def_object(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Active Material", "Active material being displayed");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_MaterialSlot_update");
+ prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "Material");
+ RNA_def_property_pointer_funcs(prop, "rna_Object_active_node_material_get", NULL, NULL, NULL);
+ RNA_def_property_ui_text(prop, "Active Material", "Active (node) material being displayed");
+ RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
+
+
prop= RNA_def_property(srna, "active_material_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "actcol");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c
index 993e0aeb9c3..4bccb46d3d8 100644
--- a/source/blender/render/intern/source/sss.c
+++ b/source/blender/render/intern/source/sss.c
@@ -997,6 +997,14 @@ void make_sss_tree(Render *re)
if(mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS))
sss_create_tree_mat(re, mat);
+ /* XXX preview exception */
+ /* localizing preview render data is not fun for node trees :( */
+ if(re->main!=G.main) {
+ for(mat= G.main->mat.first; mat; mat= mat->id.next)
+ if(mat->id.us && (mat->flag & MA_IS_USED) && (mat->sss_flag & MA_DIFF_SSS))
+ sss_create_tree_mat(re, mat);
+ }
+
}
void free_sss(Render *re)