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).
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user