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)
This commit is contained in:
Ton Roosendaal 2004-05-07 18:03:40 +00:00
parent d835cc8f16
commit 16c783d950
3 changed files with 42 additions and 12 deletions

@ -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

@ -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 */

@ -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");