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>2011-01-05 18:10:35 +0300
committerTon Roosendaal <ton@blender.org>2011-01-05 18:10:35 +0300
commitb067a85aa3a67baca561641609b11e9d37f6f228 (patch)
tree05bf4b38e44728c11f91304ab34efc2ee0d1e593 /source
parent01b7299bdb9ac1643a3053b3b6b34ac6c62f10ab (diff)
Todo item:
Object color option now is incorporated in preview render, and in display in 3D window. Note that Object-color is "modulating" the render result, it just multiplies... which is very limited for practical use. This was added for Apricot game project. The original meaning however was to replace diffuse only... so specular and light work still correct. ALso made header for properties editor start on top, to reflect default (report in tracker).
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/render/render_preview.c13
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/gpu/intern/gpu_draw.c9
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_material.c2
5 files changed, 21 insertions, 7 deletions
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index 9589c46d726..10f5ed20b0c 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -151,6 +151,7 @@ typedef struct ShaderPreview {
/* node materials need full copy during preview render, glsl uses it too */
Material *matcopy;
+ float col[4]; /* active object color */
int sizex, sizey;
unsigned int *pr_rect;
@@ -389,6 +390,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
init_render_material(mat, 0, NULL); /* call that retrieves mode_l */
end_render_material(mat);
+
+ /* un-useful option */
+ if(sp->pr_method==PR_ICON_RENDER)
+ mat->shade_flag &= ~MA_OBCOLOR;
/* turn on raytracing if needed */
if(mat->mode_l & MA_RAYMIRROR)
@@ -452,6 +457,9 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
for(base= sce->base.first; base; base= base->next) {
if(base->object->id.name[2]=='p') {
+ /* copy over object color, in case material uses it */
+ copy_v4_v4(base->object->col, sp->col);
+
if(ELEM4(base->object->type, OB_MESH, OB_CURVE, OB_SURF, OB_MBALL)) {
/* don't use assign_material, it changed mat->id.us, which shows in the UI */
Material ***matar= give_matarar(base->object);
@@ -1230,7 +1238,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
{
wmJob *steve;
ShaderPreview *sp;
-
+
/* suspended start means it starts after 1 timer step, see WM_jobs_timer below */
steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER|WM_JOB_SUSPEND);
sp= MEM_callocN(sizeof(ShaderPreview), "shader preview");
@@ -1254,6 +1262,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method)
{
+ Object *ob= CTX_data_active_object(C);
wmJob *steve;
ShaderPreview *sp;
@@ -1269,6 +1278,8 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
sp->id = id;
sp->parent= parent;
sp->slot= slot;
+ if(ob && ob->totcol) copy_v4_v4(sp->col, ob->col);
+ else sp->col[0]= sp->col[1]= sp->col[2]= sp->col[3]= 1.0f;
/* setup job */
WM_jobs_customdata(steve, sp, shader_preview_free);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 90e11e6dc37..171dad4bed9 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -69,7 +69,7 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C))
BLI_addtail(&sbuts->regionbase, ar);
ar->regiontype= RGN_TYPE_HEADER;
- ar->alignment= RGN_ALIGN_BOTTOM;
+ ar->alignment= RGN_ALIGN_TOP;
#if 0
/* context area */
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index e54002a85db..5763cd958d0 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -901,7 +901,7 @@ static struct GPUMaterialState {
} GMS = {NULL};
/* fixed function material, alpha handed by caller */
-static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma)
+static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, const int gamma, const Object *ob)
{
if (bmat->mode & MA_SHLESS) {
copy_v3_v3(smat->diff, &bmat->r);
@@ -915,6 +915,9 @@ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat,
mul_v3_v3fl(smat->diff, &bmat->r, bmat->ref + bmat->emit);
smat->diff[3]= 1.0; /* caller may set this to bmat->alpha */
+ if(bmat->shade_flag & MA_OBCOLOR)
+ mul_v3_v3(smat->diff, ob->col);
+
mul_v3_v3fl(smat->spec, &bmat->specr, bmat->spec);
smat->spec[3]= 1.0; /* always 1 */
smat->hard= CLAMPIS(bmat->har, 0, 128);
@@ -979,7 +982,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
/* no materials assigned? */
if(ob->totcol==0) {
- gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0);
+ gpu_material_to_fixed(&GMS.matbuf[0], &defmaterial, 0, ob);
/* do material 1 too, for displists! */
memcpy(&GMS.matbuf[1], &GMS.matbuf[0], sizeof(GPUMaterialFixed));
@@ -1009,7 +1012,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
}
else {
/* fixed function opengl materials */
- gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma);
+ gpu_material_to_fixed(&GMS.matbuf[a], ma, gamma, ob);
blendmode = (ma->alpha == 1.0f)? GPU_BLEND_SOLID: GPU_BLEND_ALPHA;
if(do_alpha_pass && GMS.alphapass)
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index 87f03aec06a..6d92b1d09a5 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -198,7 +198,7 @@ typedef struct Object {
float bbsize[3];
short index; /* custom index, for renderpasses */
unsigned short actdef; /* current deformation group, note: index starts at 1 */
- float col[4]; /* object color, adjusted via IPO's only */
+ float col[4]; /* object color */
/**
* Settings for game objects
* bit 0: Object has dynamic behaviour
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c
index 43dfd36d516..ba2cea3defd 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -1601,7 +1601,7 @@ void RNA_def_material(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_object_color", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_OBCOLOR);
RNA_def_property_ui_text(prop, "Object Color", "Modulate the result with a per-object color");
- RNA_def_property_update(prop, 0, "rna_Material_update");
+ RNA_def_property_update(prop, 0, "rna_Material_draw_update");
prop= RNA_def_property(srna, "shadow_ray_bias", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "sbias");