* New material option: TexFace Alpha
This is an additional option for 'TexFace', which uses the alpha of the UV assigned faces as well as the colour. It appears in material buttons as a little 'A' button next to 'TexFace', when 'TexFace is switched on. It's a bit horrible, but no point tweaking that layout in isolation at this stage. This image is using texface alpha, with different assigned images, all sharing the one material: http://mke3.net/blender/devel/rendering/texface_alpha.jpg Usually I consider texface (and teaching people to use it for UV mapping) to be pretty evil, but in some cases, when you have lots of separate images that you want to control in the one material, it can be quite handy.
This commit is contained in:
@@ -188,6 +188,7 @@ typedef struct Material {
|
||||
/* qdn: a bit clumsy this, tangents needed for normal maps separated from shading */
|
||||
#define MA_NORMAP_TANG 0x8000000
|
||||
#define MA_GROUP_NOLAY 0x10000000
|
||||
#define MA_FACETEXTURE_ALPHA 0x20000000
|
||||
|
||||
#define MA_MODE_MASK 0x1fffffff /* all valid mode bits */
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ typedef struct ShadeInput
|
||||
float layerfac;
|
||||
|
||||
/* texture coordinates */
|
||||
float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3];
|
||||
float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4], rad[3];
|
||||
float refcol[4], displace[3];
|
||||
float strand, tang[3], stress, winspeed[4];
|
||||
|
||||
|
||||
@@ -675,11 +675,13 @@ void shade_input_set_shade_texco(ShadeInput *shi)
|
||||
shi->vcol[0]= shi->col[0].col[0];
|
||||
shi->vcol[1]= shi->col[0].col[1];
|
||||
shi->vcol[2]= shi->col[0].col[2];
|
||||
shi->vcol[3]= 1.0f;
|
||||
}
|
||||
else {
|
||||
shi->vcol[0]= 0.0f;
|
||||
shi->vcol[1]= 0.0f;
|
||||
shi->vcol[2]= 0.0f;
|
||||
shi->vcol[3]= 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,6 +723,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
|
||||
shi->vcol[0]= 1.0f;
|
||||
shi->vcol[1]= 1.0f;
|
||||
shi->vcol[2]= 1.0f;
|
||||
shi->vcol[3]= 1.0f;
|
||||
}
|
||||
if(tface && tface->tpage)
|
||||
render_realtime_texture(shi, tface->tpage);
|
||||
@@ -739,6 +742,7 @@ void shade_input_set_shade_texco(ShadeInput *shi)
|
||||
shi->vcol[0]= 1.0f;
|
||||
shi->vcol[1]= 1.0f;
|
||||
shi->vcol[2]= 1.0f;
|
||||
shi->vcol[3]= 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -829,6 +829,8 @@ void shade_color(ShadeInput *shi, ShadeResult *shr)
|
||||
shi->r= shi->vcol[0];
|
||||
shi->g= shi->vcol[1];
|
||||
shi->b= shi->vcol[2];
|
||||
if(ma->mode & (MA_FACETEXTURE_ALPHA))
|
||||
shi->alpha= shi->vcol[3];
|
||||
}
|
||||
|
||||
if(ma->texco)
|
||||
@@ -1149,6 +1151,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
|
||||
|
||||
if (lar->energy == 0.0) return;
|
||||
|
||||
/* optimisation, don't render fully black lamps */
|
||||
if (!(lar->mode & LA_TEXTURE) && (lar->r + lar->g + lar->b == 0.0f))
|
||||
return;
|
||||
|
||||
/* lampdist, spot angle, area side, ... */
|
||||
visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist);
|
||||
if(visifac==0.0f)
|
||||
@@ -1471,6 +1477,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
|
||||
shi->r= shi->vcol[0];
|
||||
shi->g= shi->vcol[1];
|
||||
shi->b= shi->vcol[2];
|
||||
if(ma->mode & (MA_FACETEXTURE_ALPHA))
|
||||
shi->alpha= shi->vcol[3];
|
||||
}
|
||||
if(ma->texco)
|
||||
do_material_tex(shi);
|
||||
|
||||
@@ -2450,6 +2450,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
|
||||
shi->vcol[0]*= texr.tr;
|
||||
shi->vcol[1]*= texr.tg;
|
||||
shi->vcol[2]*= texr.tb;
|
||||
shi->vcol[3]*= texr.ta;
|
||||
}
|
||||
|
||||
/* eof */
|
||||
|
||||
@@ -3785,8 +3785,9 @@ static void material_panel_material(Material *ma)
|
||||
uiBlockSetCol(block, TH_BUT_SETTING1);
|
||||
uiDefButBitI(block, TOG, MA_VERTEXCOL, B_MAT_VCOL_LIGHT, "VCol Light", 8,166,74,20, &(ma->mode), 0, 0, 0, 0, "Adds vertex colors as extra light");
|
||||
uiDefButBitI(block, TOG, MA_VERTEXCOLP, B_MAT_VCOL_PAINT, "VCol Paint", 82,166,74,20, &(ma->mode), 0, 0, 0, 0, "Replaces material's colors with vertex colors");
|
||||
uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace", 156,166,74,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
|
||||
uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 230,166,73,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
|
||||
uiDefButBitI(block, TOG, MA_FACETEXTURE, B_REDR, "TexFace", 156,166,64,20, &(ma->mode), 0, 0, 0, 0, "Sets UV-Editor assigned texture as color and texture info for faces");
|
||||
if (ma->mode & MA_FACETEXTURE) uiDefButBitI(block, TOG, MA_FACETEXTURE_ALPHA, B_REDR, "A", 220,166,20,20, &(ma->mode), 0, 0, 0, 0, "Use alpha channel in 'TexFace' assigned images");
|
||||
uiDefButBitI(block, TOG, MA_SHLESS, B_MATPRV, "Shadeless", 240,166,63,20, &(ma->mode), 0, 0, 0, 0, "Makes material insensitive to light or shadow");
|
||||
|
||||
uiDefButBitI(block, TOG, MA_NOMIST, B_NOP, "No Mist", 8,146,74,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values");
|
||||
uiDefButBitI(block, TOG, MA_ENV, B_MATPRV, "Env", 82,146,74,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through (only for solid faces)");
|
||||
@@ -3830,7 +3831,8 @@ static void material_panel_material(Material *ma)
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "B ", 128,57,175,19, colpoin+2, 0.0, 1.0, rgbsel, 0, "");
|
||||
}
|
||||
uiBlockEndAlign(block);
|
||||
uiDefButF(block, NUMSLI, B_MATPRV, "A ", 128,30,175,19, &ma->alpha, 0.0, 1.0, 0, 0, "Alpha");
|
||||
if (ma->mode & (MA_FACETEXTURE) && ma->mode & (MA_FACETEXTURE_ALPHA)) ;
|
||||
else uiDefButF(block, NUMSLI, B_MATPRV, "A ", 128,30,175,19, &ma->alpha, 0.0, 1.0, 0, 0, "Alpha");
|
||||
|
||||
}
|
||||
uiBlockBeginAlign(block);
|
||||
|
||||
Reference in New Issue
Block a user