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
diff options
context:
space:
mode:
authorMatt Ebb <matt@mke3.net>2007-11-15 03:11:00 +0300
committerMatt Ebb <matt@mke3.net>2007-11-15 03:11:00 +0300
commitd273ae05712901ef7619219db9864a3734bf4f22 (patch)
tree60ca5c1c584eb60bbc1d06bf1929d942574279a3
parenteedfb86ea57f17445f8f7e5fe9affd620843b70c (diff)
* 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.
-rw-r--r--source/blender/makesdna/DNA_material_types.h1
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h2
-rw-r--r--source/blender/render/intern/source/shadeinput.c4
-rw-r--r--source/blender/render/intern/source/shadeoutput.c8
-rw-r--r--source/blender/render/intern/source/texture.c1
-rw-r--r--source/blender/src/buttons_shading.c8
6 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h
index 252af0ebdb1..3e2197f2d83 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -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 */
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 364535736ae..052e104ee62 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -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];
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index ca661469b36..71b59f7b8be 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -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;
}
}
}
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 24eabffdf6f..56cb226560a 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -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);
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c
index 8c366593034..f541b161e0a 100644
--- a/source/blender/render/intern/source/texture.c
+++ b/source/blender/render/intern/source/texture.c
@@ -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 */
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 67ccf78c5f6..f422a39266a 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -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);