diff options
author | Ton Roosendaal <ton@blender.org> | 2006-03-19 20:50:53 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2006-03-19 20:50:53 +0300 |
commit | cf0408a4f6cbbe326616c93969f8588cf45e76ab (patch) | |
tree | a1f6966fe86d1c74456a1bc45e88f4220e78bfed /source/blender | |
parent | 652bf89985cb16a24b9da04b9dd6ce1c407b8a5c (diff) |
More environment map stuff:
- added a zoom factor for Planar Environment Map, allowing to zoom in or
out on the reflected object. The zoom is corrected when rendering, so it
just gives control over the resolution.
- Planar maps don't cycle anymore, but only render the front plane, using
standard image texture extend mode.
- threaded rendering is back in envmap render
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_texture_types.h | 1 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/envmap.c | 95 | ||||
-rw-r--r-- | source/blender/render/intern/source/initrender.c | 15 | ||||
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/texture.c | 5 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 7 |
8 files changed, 78 insertions, 61 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 6ab68122d5d..ccfb8afedd4 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -5293,7 +5293,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } if(main->versionfile <= 241) { -// Tex *tex; + Tex *tex; Scene *sce; Lamp *la; bArmature *arm; @@ -5359,9 +5359,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if(la->buffers==0) la->buffers= 1; -// for(tex= main->tex.first; tex; tex= tex->id.next) + for(tex= main->tex.first; tex; tex= tex->id.next) { + if(tex->env && tex->env->viewscale==0.0f) + tex->env->viewscale= 1.0f; // tex->imaflag |= TEX_GAUSS_MIP; - + } //Object *ob; /* for empty drawsize and drawtype */ diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index ea49e7d0e6b..47e89dbd1c0 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -115,6 +115,7 @@ typedef struct EnvMap { float obimat[3][3]; short type, stype; float clipsta, clipend; + float viewscale, pad; /* viewscale is for planar envmaps to zoom in or out */ unsigned int notlay; short cuberes, depth; short ok, lastframe; diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 504fc228a1a..0e405af8298 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -116,8 +116,8 @@ struct Render partx*xparts can be larger than rectx, in that case last part is smaller */ int partx, party; - /* correction values for pixels or view */ - float ycor, viewfac; + /* values for viewing */ + float lens, ycor, viewfac; float bluroffsx, bluroffsy; float panophi, panosi, panoco, panodxp, panodxv; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 9826c2fde51..c5425eed90c 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -138,6 +138,7 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->scene= re->scene; /* unsure about this... */ /* view stuff in env render */ + envre->lens= env->viewscale*16.0f; envre->ycor= 1.0; envre->clipsta= env->clipsta; /* render_scene_set_window() respects this for now */ envre->clipend= env->clipend; @@ -512,48 +513,58 @@ void make_envmaps(Render *re) /* ------------------------------------------------------------------------- */ -static int envcube_isect(float *vec, float *answ) +static int envcube_isect(EnvMap *env, float *vec, float *answ) { float labda; int face; - /* which face */ - if( vec[2]<=-fabs(vec[0]) && vec[2]<=-fabs(vec[1]) ) { - face= 0; - labda= -1.0/vec[2]; - answ[0]= labda*vec[0]; - answ[1]= labda*vec[1]; - } - else if( vec[2]>=fabs(vec[0]) && vec[2]>=fabs(vec[1]) ) { + if(env->type==ENV_PLANE) { face= 1; + labda= 1.0/vec[2]; - answ[0]= labda*vec[0]; - answ[1]= -labda*vec[1]; - } - else if( vec[1]>=fabs(vec[0]) ) { - face= 2; - labda= 1.0/vec[1]; - answ[0]= labda*vec[0]; - answ[1]= labda*vec[2]; - } - else if( vec[0]<=-fabs(vec[1]) ) { - face= 3; - labda= -1.0/vec[0]; - answ[0]= labda*vec[1]; - answ[1]= labda*vec[2]; - } - else if( vec[1]<=-fabs(vec[0]) ) { - face= 4; - labda= -1.0/vec[1]; - answ[0]= -labda*vec[0]; - answ[1]= labda*vec[2]; + answ[0]= env->viewscale*labda*vec[0]; + answ[1]= -env->viewscale*labda*vec[1]; } else { - face= 5; - labda= 1.0/vec[0]; - answ[0]= -labda*vec[1]; - answ[1]= labda*vec[2]; + /* which face */ + if( vec[2]<=-fabs(vec[0]) && vec[2]<=-fabs(vec[1]) ) { + face= 0; + labda= -1.0/vec[2]; + answ[0]= labda*vec[0]; + answ[1]= labda*vec[1]; + } + else if( vec[2]>=fabs(vec[0]) && vec[2]>=fabs(vec[1]) ) { + face= 1; + labda= 1.0/vec[2]; + answ[0]= labda*vec[0]; + answ[1]= -labda*vec[1]; + } + else if( vec[1]>=fabs(vec[0]) ) { + face= 2; + labda= 1.0/vec[1]; + answ[0]= labda*vec[0]; + answ[1]= labda*vec[2]; + } + else if( vec[0]<=-fabs(vec[1]) ) { + face= 3; + labda= -1.0/vec[0]; + answ[0]= labda*vec[1]; + answ[1]= labda*vec[2]; + } + else if( vec[1]<=-fabs(vec[0]) ) { + face= 4; + labda= -1.0/vec[1]; + answ[0]= -labda*vec[0]; + answ[1]= labda*vec[2]; + } + else { + face= 5; + labda= 1.0/vec[0]; + answ[0]= -labda*vec[1]; + answ[1]= labda*vec[2]; + } } + answ[0]= 0.5+0.5*answ[0]; answ[1]= 0.5+0.5*answ[1]; return face; @@ -621,11 +632,8 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe if(env->object) MTC_Mat3MulVecfl(env->obimat, vec); else MTC_Mat4Mul3Vecfl(R.viewinv, vec); - face= envcube_isect(vec, sco); - if(env->type==ENV_PLANE) - ima= env->cube[1]; - else - ima= env->cube[face]; + face= envcube_isect(env, vec, sco); + ima= env->cube[face]; if(osatex) { if(env->object) { @@ -647,13 +655,11 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe texr1.nor= texr2.nor= NULL; VecAddf(vec, vec, dxt); - face1= envcube_isect(vec, sco); + face1= envcube_isect(env, vec, sco); VecSubf(vec, vec, dxt); if(face!=face1) { - if(env->type==ENV_CUBE) - ima= env->cube[face1]; - + ima= env->cube[face1]; set_dxtdyt(dxts, dyts, dxt, dyt, face1); imagewraposa(tex, ima, sco, dxts, dyts, &texr1); } @@ -662,12 +668,11 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe /* here was the nasty bug! results were not zero-ed. FPE! */ VecAddf(vec, vec, dyt); - face1= envcube_isect(vec, sco); + face1= envcube_isect(env, vec, sco); VecSubf(vec, vec, dyt); if(face!=face1) { - if(env->type==ENV_CUBE) - ima= env->cube[face1]; + ima= env->cube[face1]; set_dxtdyt(dxts, dyts, dxt, dyt, face1); imagewraposa(tex, ima, sco, dxts, dyts, &texr2); } diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index 8506a565409..520378a9d86 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -485,17 +485,22 @@ void RE_SetCamera(Render *re, Object *camera) /* phi= acos(fac); */ /* lens= 16.0*fac/sin(phi); */ - lens= 35.0; + lens= re->lens; + if(lens==0.0f) + lens= 35.0; clipsta= 0.1; clipend= 1000.0; } - else { /* envmap exception, can be done better... */ - lens= 16.0; + else { /* envmap exception... */ + lens= re->lens; + if(lens==0.0f) + lens= 16.0; + clipsta= re->clipsta; clipend= re->clipend; if(clipsta==0.0f || clipend==0.0f) { - clipsta= 0.1; - clipend= 1000.0; + clipsta= 0.1f; + clipend= 1000.0f; } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 79ec6bb3c5a..8ab916e27f9 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1176,10 +1176,10 @@ static void threaded_tile_processor(Render *re) freeparts(re); } -/* currently only called by preview renders */ +/* currently only called by preview renders and envmap */ void RE_TileProcessor(Render *re, int firsttile) { - if(0) + if(re->r.mode & R_THREADS) threaded_tile_processor(re); else render_tile_processor(re, firsttile); diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 5c2610e45f4..8f5c0d5cecb 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -185,7 +185,10 @@ void init_render_texture(Render *re, Tex *tex) tex->extend= TEX_CLIP; if(tex->env) { - /* only free envmap when rendermode has set to render envmaps, for previewrender */ + if(tex->env->type==ENV_PLANE) + tex->extend= TEX_EXTEND; + + /* only free envmap when rendermode was set to render envmaps, for previewrender */ if(G.rendering) { if (re->r.mode & R_ENVMAP) if(tex->env->stype==ENV_ANIM) diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index d203de55ac3..e07027cf06c 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -904,8 +904,9 @@ static void texture_panel_envmap(Tex *tex) uiDefBut(block, BUT, B_ENV_FREE_ALL, "Free all EnvMaps", 210,145,100,20, 0, 0, 0, 0, 0, "Frees all rendered environment maps for all materials"); uiBlockBeginAlign(block); - uiDefButS(block, ROW, B_REDR, "Cube", 10,120,100,20, &env->type, 3.0f, 0.0f, 0, 0, "Use environment map with six cube sides"); - uiDefButS(block, ROW, B_REDR, "Plane", 110,120,100,20, &env->type, 3.0f, 1.0f, 0, 0, "Only one side is rendered, with Z axis pointing in direction of image"); + uiDefButS(block, ROW, B_NOP, "Cube", 10,120,100,20, &env->type, 3.0f, 0.0f, 0, 0, "Use environment map with six cube sides"); + uiDefButS(block, ROW, B_NOP, "Plane", 110,120,100,20, &env->type, 3.0f, 1.0f, 0, 0, "Only one side is rendered, with Z axis pointing in direction of image"); + uiDefButF(block, NUM, B_NOP, "Zoom: ", 210,120,100,20, &env->viewscale, 0.5f, 5.0f, 100, 2, "Zoom factor for planar environment map"); uiBlockEndAlign(block); } @@ -2469,7 +2470,7 @@ void do_matbuts(unsigned short event) /* when halo is disabled, clear star flag, this is the same as MA_FACETEXTURE <blush> */ /* same for 'xtreme alpha' which is 'only shadow' */ if((ma->mode & MA_HALO)==0) { - ma->mode &= ~(MA_STAR|MA_HALO_XALPHA|MA_ZINV); + ma->mode &= ~(MA_STAR|MA_HALO_XALPHA|MA_ZINV|MA_ENV); } BIF_preview_changed(ID_MA); allqueue(REDRAWBUTSSHADING, 0); |