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>2004-05-07 22:03:40 +0400
committerTon Roosendaal <ton@blender.org>2004-05-07 22:03:40 +0400
commit16c783d950868baceb4b3909dd18ecdf7ee66629 (patch)
tree707d72382b189066b4e74398ab1f6b308e99036c /source
parentd835cc8f1656df8ac3bab150fcf02490d184e10a (diff)
Added two more mapping types to World buttons for sky render.
"Sphere": spherical mapping for a 360 degree panorama "Tube": cylindrical mapping for a 360 degree panorama Both mappings by default do only the sky (upper) hemisphere. The color below is same as regular Horiz and Zenith colors, useful for setting an AO effect. Sample pics: http://www.1000skies.com/fullpanos/index.htm (commercial)
Diffstat (limited to 'source')
-rw-r--r--source/blender/makesdna/DNA_world_types.h2
-rw-r--r--source/blender/render/intern/source/texture.c42
-rw-r--r--source/blender/src/buttons_shading.c10
3 files changed, 42 insertions, 12 deletions
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index cda544df1d1..30cb6071d78 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -140,6 +140,8 @@ typedef struct World {
/* texco (also in DNA_material_types.h) */
#define TEXCO_ANGMAP 64
+#define TEXCO_H_SPHEREMAP 256
+#define TEXCO_H_TUBEMAP 1024
/* mapto */
#define WOMAP_BLEND 1
diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c
index 762e00073c2..b287c14733f 100644
--- a/source/blender/render/intern/source/texture.c
+++ b/source/blender/render/intern/source/texture.c
@@ -1741,20 +1741,46 @@ void do_sky_tex(float *lo)
dyt[0]= dyt[1]= dyt[2]= O.dyview;
/* Grab the mapping settings for this texture */
- if(mtex->texco==TEXCO_ANGMAP) {
+ switch(mtex->texco) {
+ case TEXCO_ANGMAP:
fact= (1.0/M_PI)*acos(lo[2])/(sqrt(lo[0]*lo[0] + lo[1]*lo[1]));
tempvec[0]= lo[0]*fact;
tempvec[1]= lo[1]*fact;
tempvec[2]= 0.0;
co= tempvec;
-
- }
- else if(mtex->texco==TEXCO_OBJECT) {
- Object *ob= mtex->object;
- if(ob) {
+ break;
+
+ case TEXCO_H_SPHEREMAP:
+ case TEXCO_H_TUBEMAP:
+ if(R.wrld.skytype & WO_ZENUP) {
+ if(mtex->texco==TEXCO_H_TUBEMAP) tubemap(lo[0], lo[2], lo[1], tempvec, tempvec+1);
+ else spheremap(lo[0], lo[2], lo[1], tempvec, tempvec+1);
+ /* tube/spheremap maps for outside view, not inside */
+ tempvec[0]= 1.0-tempvec[0];
+ /* only top half */
+ tempvec[1]= 2.0*tempvec[1]-1.0;
+ tempvec[2]= 0.0;
+ /* and correction for do_2d_mapping */
+ tempvec[0]= 2.0*tempvec[0]-1.0;
+ tempvec[1]= 2.0*tempvec[1]-1.0;
+ co= tempvec;
+ }
+ else {
+ /* potentially dangerous... check with multitex! */
+ R.wrld.horr= (wrld_hor->horr);
+ R.wrld.horg= (wrld_hor->horg);
+ R.wrld.horb= (wrld_hor->horb);
+ R.wrld.zenr= (wrld_hor->zenr);
+ R.wrld.zeng= (wrld_hor->zeng);
+ R.wrld.zenb= (wrld_hor->zenb);
+ continue;
+ }
+ break;
+ case TEXCO_OBJECT:
+ if(mtex->object) {
VECCOPY(tempvec, lo);
- MTC_Mat4MulVecfl(ob->imat, tempvec);
+ MTC_Mat4MulVecfl(mtex->object->imat, tempvec);
co= tempvec;
}
}
@@ -1771,7 +1797,7 @@ void do_sky_tex(float *lo)
/* texture */
if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, NULL, dxt, dyt);
-
+
rgb= multitex(mtex->tex, texvec, dxt, dyt, R.osa);
/* texture output */
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index e10727bbcc9..60dfd7164d4 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -1637,10 +1637,12 @@ static void world_panel_texture(World *wrld)
/* TEXCO */
uiBlockBeginAlign(block);
- uiDefButS(block, ROW, B_MATPRV, "View", 100,110,60,20, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Uses global coordinates for the texture coordinates");
- uiDefButS(block, ROW, B_MATPRV, "AngMap", 160,110,70,20, &(mtex->texco), 4.0, (float)TEXCO_ANGMAP, 0, 0, "Uses 360 degree angular coordinates, e.g. for spherical light probes");
- uiDefButS(block, ROW, B_MATPRV, "Object", 230,110,70,20, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates");
- uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 100,90,200,20, &(mtex->object), "");
+ uiDefButS(block, ROW, B_MATPRV, "View", 100,110,45,20, &(mtex->texco), 4.0, (float)TEXCO_VIEW, 0, 0, "Uses global coordinates for the texture coordinates");
+ uiDefButS(block, ROW, B_MATPRV, "AngMap", 145,110,55,20, &(mtex->texco), 4.0, (float)TEXCO_ANGMAP, 0, 0, "Uses 360 degree angular coordinates, e.g. for spherical light probes");
+ uiDefButS(block, ROW, B_MATPRV, "Sphere", 200,110,55,20, &(mtex->texco), 4.0, (float)TEXCO_H_SPHEREMAP, 0, 0, "For 360 degree panorama sky, spherical mapped, only top half");
+ uiDefButS(block, ROW, B_MATPRV, "Tube", 255,110,45,20, &(mtex->texco), 4.0, (float)TEXCO_H_TUBEMAP, 0, 0, "For 360 degree panorama sky, cylindrical mapped, only top half");
+ uiDefButS(block, ROW, B_MATPRV, "Object", 100,90,70,20, &(mtex->texco), 4.0, (float)TEXCO_OBJECT, 0, 0, "Uses linked object's coordinates for texture coordinates");
+ uiDefIDPoinBut(block, test_obpoin_but, B_MATPRV, "", 170,90,130,20, &(mtex->object), "");
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_MATPRV, "dX", 100,50,100,19, mtex->ofs, -20.0, 20.0, 10, 0, "Fine tunes texture mapping X coordinate");