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:
authorTon Roosendaal <ton@blender.org>2004-04-28 22:08:34 +0400
committerTon Roosendaal <ton@blender.org>2004-04-28 22:08:34 +0400
commit02ba73aaade72fbef292c59505a5b4e9e01f44f5 (patch)
tree290d5f39017827a0264ab86542f60cb159b112b2
parent0da09b4299e8af299621ac049dfb94c7bdd9f69e (diff)
Sneaked in new feature (request samo):
The Image texture repeat options, now allow a "Checker" repeat. With odd and even tiles set separately, and a size button to set a 'Mortar' inbetween tiles. http://www.blender3d.org/cms/Render_engine_features.215.0.html Also fixed bug: using 'CalcAlpha' option for image textures didn't give antialised edges for image.
-rw-r--r--source/blender/blenkernel/intern/image.c91
-rw-r--r--source/blender/blenkernel/intern/texture.c1
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/makesdna/DNA_texture_types.h10
-rw-r--r--source/blender/render/intern/source/texture.c50
-rw-r--r--source/blender/src/buttons_shading.c27
-rw-r--r--source/blender/src/previewrender.c17
7 files changed, 146 insertions, 53 deletions
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index a87b01a1b8f..d3f0d3b72af 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -602,17 +602,15 @@ int imagewrap(Tex *tex, float *texvec)
int ofs, x, y;
char *rect;
+ Tin= Ta= Tr= Tg= Tb= 0.0;
ima= tex->ima;
-
if(ima==0 || ima->ok== 0) {
- Tin= Ta= Tr= Tg= Tb= 0.0;
return 0;
}
if(ima->ibuf==0) ima_ibuf_is_nul(tex);
if (ima->ok) {
-
ibuf = ima->ibuf;
if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
@@ -628,18 +626,37 @@ int imagewrap(Tex *tex, float *texvec)
fy= texvec[1];
}
+ if(tex->extend == TEX_CHECKER) {
+ int xs, ys;
+
+ xs= (int)floor(fx);
+ ys= (int)floor(fy);
+ fx-= xs;
+ fy-= ys;
+
+ if( (tex->flag & TEX_CHECKER_ODD)==0) {
+ if((xs+ys) & 1);else return 0;
+ }
+ if( (tex->flag & TEX_CHECKER_EVEN)==0) {
+ if((xs+ys) & 1) return 0;
+ }
+ /* scale around center, (0.5, 0.5) */
+ if(tex->checkerdist<1.0) {
+ fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5;
+ fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5;
+ }
+ }
+
x = (int)(fx*ibuf->x);
y = (int)(fy*ibuf->y);
if(tex->extend == TEX_CLIPCUBE) {
if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y || texvec[2]<-1.0 || texvec[2]>1.0) {
- Tin= 0;
return 0;
}
}
- else if(tex->extend == TEX_CLIP) {
+ else if( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) {
- Tin= 0;
return 0;
}
}
@@ -1308,16 +1325,70 @@ int imagewraposa(Tex *tex, float *texvec, float *dxt, float *dyt)
imaprepeat= (tex->extend==TEX_REPEAT);
imapextend= (tex->extend==TEX_EXTEND);
+ if(tex->extend == TEX_CHECKER) {
+ int xs, ys, xs1, ys1, xs2, ys2, boundary;
+
+ xs= (int)floor(fx);
+ ys= (int)floor(fy);
+
+ // both checkers available, no boundary exceptions, checkerdist will eat aliasing
+ if( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) {
+ fx-= xs;
+ fy-= ys;
+ }
+ else {
+
+ xs1= (int)floor(fx-minx);
+ ys1= (int)floor(fy-miny);
+ xs2= (int)floor(fx+minx);
+ ys2= (int)floor(fy+miny);
+ boundary= (xs1!=xs2) || (ys1!=ys2);
+
+ if(boundary==0) {
+ if( (tex->flag & TEX_CHECKER_ODD)==0) {
+ if((xs+ys) & 1);
+ else return 0;
+ }
+ if( (tex->flag & TEX_CHECKER_EVEN)==0) {
+ if((xs+ys) & 1) return 0;
+ }
+ fx-= xs;
+ fy-= ys;
+ }
+ else {
+ if(tex->flag & TEX_CHECKER_ODD) {
+ if((xs1+ys) & 1) fx-= xs2;
+ else fx-= xs1;
+
+ if((ys1+xs) & 1) fy-= ys2;
+ else fy-= ys1;
+ }
+ if(tex->flag & TEX_CHECKER_EVEN) {
+ if((xs1+ys) & 1) fx-= xs1;
+ else fx-= xs2;
+
+ if((ys1+xs) & 1) fy-= ys1;
+ else fy-= ys2;
+ }
+ }
+ }
+
+ /* scale around center, (0.5, 0.5) */
+ if(tex->checkerdist<1.0) {
+ fx= (fx-0.5)/(1.0-tex->checkerdist) +0.5;
+ fy= (fy-0.5)/(1.0-tex->checkerdist) +0.5;
+ minx/= (1.0-tex->checkerdist);
+ miny/= (1.0-tex->checkerdist);
+ }
+ }
if(tex->extend == TEX_CLIPCUBE) {
if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0 || texvec[2]<-1.0 || texvec[2]>1.0) {
- Tin= 0;
return 0;
}
}
- else if(tex->extend == TEX_CLIP) {
+ else if(tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
if(fx+minx<0.0 || fy+miny<0.0 || fx-minx>1.0 || fy-miny>1.0) {
- Tin= 0.0;
return 0;
}
}
@@ -1471,7 +1542,7 @@ int imagewraposa(Tex *tex, float *texvec, float *dxt, float *dyt)
BRICONRGB;
if(tex->imaflag & TEX_CALCALPHA) {
- Ta= Tin= MAX3(Tr, Tg, Tb);
+ Ta= Tin= Ta*MAX3(Tr, Tg, Tb);
}
else Tin= Ta;
if(tex->flag & TEX_NEGALPHA) Ta= 1.0f-Ta;
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 0d472f278de..a1dc9dec3d0 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -329,6 +329,7 @@ void default_tex(Tex *tex)
int a;
tex->stype= 0;
+ tex->flag= TEX_CHECKER_ODD;
tex->imaflag= TEX_INTERPOL+TEX_MIPMAP;
tex->extend= TEX_REPEAT;
tex->cropxmin= tex->cropymin= 0.0;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2a2ca1c7f2b..c5ac1a7bce8 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -4155,6 +4155,9 @@ static void do_versions(Main *main)
Scene *sce;
while(tex) {
+ if((tex->flag & (TEX_CHECKER_ODD+TEX_CHECKER_EVEN))==0) {
+ tex->flag |= TEX_CHECKER_ODD;
+ }
/* copied from kernel texture.c */
if(tex->ns_outscale==0.0) {
/* musgrave */
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index a60c4f117d6..88f25f9c0a5 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -149,6 +149,7 @@ typedef struct Tex {
float cropxmin, cropymin, cropxmax, cropymax;
short xrepeat, yrepeat;
short extend, len;
+ float checkerdist, pad;
short frames, offset, sfra, fie_ima;
float norfac, *nor;
@@ -224,15 +225,18 @@ typedef struct Tex {
#define TEX_MORKPATCH 16384
/* flag */
-#define TEX_COLORBAND 1
-#define TEX_FLIPBLEND 2
-#define TEX_NEGALPHA 4
+#define TEX_COLORBAND 1
+#define TEX_FLIPBLEND 2
+#define TEX_NEGALPHA 4
+#define TEX_CHECKER_ODD 8
+#define TEX_CHECKER_EVEN 16
/* extend (starts with 1 because of backward comp.) */
#define TEX_EXTEND 1
#define TEX_CLIP 2
#define TEX_REPEAT 3
#define TEX_CLIPCUBE 4
+#define TEX_CHECKER 5
/* noisetype */
#define TEX_NOISESOFT 0
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c
index 47a12627bf0..762e00073c2 100644
--- a/source/blender/render/intern/source/texture.c
+++ b/source/blender/render/intern/source/texture.c
@@ -895,17 +895,18 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *dxt, float
}
/* repeat */
- if(tex->xrepeat>1) {
- fx *= tex->xrepeat;
- if(fx>1.0) fx -= (int)(fx);
- else if(fx<0.0) fx+= 1-(int)(fx);
- }
- if(tex->yrepeat>1) {
- fy *= tex->yrepeat;
- if(fy>1.0) fy -= (int)(fy);
- else if(fy<0.0) fy+= 1-(int)(fy);
+ if(tex->extend==TEX_REPEAT) {
+ if(tex->xrepeat>1) {
+ fx *= tex->xrepeat;
+ if(fx>1.0) fx -= (int)(fx);
+ else if(fx<0.0) fx+= 1-(int)(fx);
+ }
+ if(tex->yrepeat>1) {
+ fy *= tex->yrepeat;
+ if(fy>1.0) fy -= (int)(fy);
+ else if(fy<0.0) fy+= 1-(int)(fy);
+ }
}
-
/* crop */
if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) {
fac1= tex->cropxmax - tex->cropxmin;
@@ -994,21 +995,22 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, float *dxt, float
}
/* repeat */
- if(tex->xrepeat>1) {
- fx *= tex->xrepeat;
- dxt[0]*= tex->xrepeat;
- dyt[0]*= tex->xrepeat;
- if(fx>1.0) fx -= (int)(fx);
- else if(fx<0.0) fx+= 1-(int)(fx);
- }
- if(tex->yrepeat>1) {
- fy *= tex->yrepeat;
- dxt[1]*= tex->yrepeat;
- dyt[1]*= tex->yrepeat;
- if(fy>1.0) fy -= (int)(fy);
- else if(fy<0.0) fy+= 1-(int)(fy);
+ if(tex->extend==TEX_REPEAT) {
+ if(tex->xrepeat>1) {
+ fx *= tex->xrepeat;
+ dxt[0]*= tex->xrepeat;
+ dyt[0]*= tex->xrepeat;
+ if(fx>1.0) fx -= (int)(fx);
+ else if(fx<0.0) fx+= 1-(int)(fx);
+ }
+ if(tex->yrepeat>1) {
+ fy *= tex->yrepeat;
+ dxt[1]*= tex->yrepeat;
+ dyt[1]*= tex->yrepeat;
+ if(fy>1.0) fy -= (int)(fy);
+ else if(fy<0.0) fy+= 1-(int)(fy);
+ }
}
-
/* crop */
if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) {
fac1= tex->cropxmax - tex->cropxmin;
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 45c908d46ff..bd0f094ae69 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -1098,16 +1098,27 @@ static void texture_panel_image(Tex *tex)
uiDefButF(block, NUM, B_TEXPRV, "Filter :", 10,92,150,19, &tex->filtersize, 0.1, 25.0, 0, 0, "Sets the filter size used by mipmap and interpol");
uiBlockBeginAlign(block);
- uiDefButS(block, ROW, 0, "Extend", 10,70,75,19, &tex->extend, 4.0, 1.0, 0, 0, "Extends the colour of the edge pixels");
- uiDefButS(block, ROW, 0, "Clip", 85,70,75,19, &tex->extend, 4.0, 2.0, 0, 0, "Sets alpha 0.0 outside Image edges");
- uiDefButS(block, ROW, 0, "ClipCube", 160,70,75,19, &tex->extend, 4.0, 4.0, 0, 0, "Sets alpha to 0.0 outside cubeshaped area around Image");
- uiDefButS(block, ROW, 0, "Repeat", 235,70,75,19, &tex->extend, 4.0, 3.0, 0, 0, "Causes Image to repeat horizontally and vertically");
- uiBlockBeginAlign(block);
- uiDefButS(block, NUM, B_TEXPRV, "Xrepeat:", 10,50,150,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the X direction");
- uiDefButS(block, NUM, B_TEXPRV, "Yrepeat:", 160,50,150,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the Y direction");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Extend", 10,70,63,19, &tex->extend, 4.0, 1.0, 0, 0, "Extends the colour of the edge pixels");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Clip", 73,70,48,19, &tex->extend, 4.0, 2.0, 0, 0, "Sets alpha 0.0 outside Image edges");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "ClipCube", 121,70,63,19, &tex->extend, 4.0, 4.0, 0, 0, "Sets alpha to 0.0 outside cubeshaped area around Image");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Repeat", 184,70,63,19, &tex->extend, 4.0, 3.0, 0, 0, "Causes Image to repeat horizontally and vertically");
+ uiDefButS(block, ROW, B_TEXREDR_PRV, "Checker", 247,70,63,19, &tex->extend, 4.0, 5.0, 0, 0, "Causes Image to repeat in checker pattern");
+
+ if(tex->extend==TEX_REPEAT) {
+ uiBlockBeginAlign(block);
+ uiDefButS(block, NUM, B_TEXPRV, "Xrepeat:", 10,50,150,19, &tex->xrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the X direction");
+ uiDefButS(block, NUM, B_TEXPRV, "Yrepeat:", 160,50,150,19, &tex->yrepeat, 1.0, 512.0, 0, 0, "Sets a repetition multiplier in the Y direction");
+ }
+ else if(tex->extend==TEX_CHECKER) {
+ uiBlockBeginAlign(block);
+ uiDefButS(block, TOG|BIT|3, B_TEXPRV, "Odd", 10,50,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets odd checker tiles");
+ uiDefButS(block, TOG|BIT|4, B_TEXPRV, "Even", 110,50,100,19, &tex->flag, 0.0, 0.0, 0, 0, "Sets even checker tiles");
+ uiDefButF(block, NUM, B_TEXPRV, "Mortar:", 210,50,100,19, &tex->checkerdist, 0.0, 0.99, 0, 0, "Set checkers distance (like mortar)");
+ }
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_REDR, "MinX ", 10,28,150,19, &tex->cropxmin, -10.0, 10.0, 10, 0, "Sets minimum X value to crop Image");
uiDefButF(block, NUM, B_REDR, "MinY ", 10,8,150,19, &tex->cropymin, -10.0, 10.0, 10, 0, "Sets minimum Y value to crop Image");
+
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_REDR, "MaxX ", 160,28,150,19, &tex->cropxmax, -10.0, 10.0, 10, 0, "Sets maximum X value to crop Image");
uiDefButF(block, NUM, B_REDR, "MaxY ", 160,8,150,19, &tex->cropymax, -10.0, 10.0, 10, 0, "Sets maximum Y value to crop Image");
@@ -2121,7 +2132,7 @@ static void lamp_panel_lamp(Object *ob, Lamp *la)
uiBlockBeginAlign(block);
if ELEM(la->type, LA_LOCAL, LA_SPOT) {
uiDefButF(block, NUMSLI,B_MATPRV,"Quad1 ", 120,30,180,19,&la->att1, 0.0, 1.0, 0, 0, "Set the linear distance attenuatation for a quad lamp");
- uiDefButF(block, NUMSLI,B_MATPRV,"Quad2 ", 120,10,180,19,&la->att2, 0.0, 1.0, 0, 0, "Set the qudratic distance attenuatation for a quad lamp");
+ uiDefButF(block, NUMSLI,B_MATPRV,"Quad2 ", 120,10,180,19,&la->att2, 0.0, 1.0, 0, 0, "Set the quadratic distance attenuatation for a quad lamp");
}
else if(la->type==LA_AREA) {
if(la->k==0.0) la->k= 1.0;
diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c
index 214161e53fd..92821b11aa7 100644
--- a/source/blender/src/previewrender.c
+++ b/source/blender/src/previewrender.c
@@ -588,15 +588,16 @@ static void texture_preview_pixel(Tex *tex, int x, int y, char *rect)
texvec[1]= 0.5+v1*y;
/* no coordinate mapping, exception: repeat */
- if(tex->xrepeat>1) {
- texvec[0] *= tex->xrepeat;
- if(texvec[0]>1.0) texvec[0] -= (int)(texvec[0]);
- }
- if(tex->yrepeat>1) {
- texvec[1] *= tex->yrepeat;
- if(texvec[1]>1.0) texvec[1] -= (int)(texvec[1]);
+ if(tex->extend==TEX_REPEAT) {
+ if(tex->xrepeat>1) {
+ texvec[0] *= tex->xrepeat;
+ if(texvec[0]>1.0) texvec[0] -= (int)(texvec[0]);
+ }
+ if(tex->yrepeat>1) {
+ texvec[1] *= tex->yrepeat;
+ if(texvec[1]>1.0) texvec[1] -= (int)(texvec[1]);
+ }
}
-
}
else if(tex->type==TEX_ENVMAP) {
if(tex->env) {