diff options
author | Ton Roosendaal <ton@blender.org> | 2003-09-01 00:33:46 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-09-01 00:33:46 +0400 |
commit | 470b5c0366dd31197b7ba39b5c2bc2256a3d8d0f (patch) | |
tree | f08dc5e73c5447a966dcc1b9a6e3203a1dcb60a2 /source/blender | |
parent | b64b5d7b63ff852f3fe210fd8200912538f46bd4 (diff) |
So, for the platform managers to check:
- the link order for Blender has changed, the libradiosity.a has to be moved after the librender.a (obviously for a new dependency!). Check blender/source/Makefile
- there's a new file: blender/source/radiosity/intern/source/radrender.c
Here's what the new code does:
Using the core routines of the Radiosity tool, each renderface with 'emit material' and each renderface with 'radio material flag' set will be used to itterate to a global illumination solution. Per face with high energy (emit) little images are rendered (hemicubes) which makes up lookup tables to 'shoot' its energy to other faces.
In the end this energy - color - then is directly added to the pixel colors while rendering, Gouraud shaded.
Since it's done with renderfaces, it works for all primitives in Blender.
What is doesn't do yet:
- take into account textured color of faces. Currently it uses the material RGB color for filtering distributed energy.
- do some smart pre-subdividing. I don't know yet if this is useful... Right now it means that you'll have to balance the models yourself, to deliver small faces where you want a high accuracy for shadowing.
- unified render (is at my todo list)
User notes:
- per Material you want to have included in radiosity render: set the 'radio' flag. For newly added Materials it is ON by default now.
- the Ambient slider in Material controls the amount of radiosity color.
- for enabling radiosity rendering, set the F10 "Radio" button.
- the Radiosity buttons now only show the relevant radiosity rendering options. Pressing "collect meshes" will show all buttons again.
- for meshes, the faces who use Radio material always call the 'autosmooth' routine, this to make sure sharp angles (like corners in a room) do not have shared vertices. For some smooth models (like the raptor example) you might increase the standard smoothing angle from 30 to 45 degree.
Technical notes:
- I had to expand the renderface and rendervertices for it... shame on me! Faces have one pointer extra, render vertices four floats...
- The size of the hemicubes is now based at the boundbox of the entire scene (0.002 of it). This should be more reliable... to be done
- I fixed a bug in radiosity render, where sometimes backfaces where lit
In general:
I'd like everyone to play a bit with this system. It's not easy to get good results with it. A simple "hit and go" isn't there... maybe some good suggestions?
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 4 | ||||
-rw-r--r-- | source/blender/radiosity/extern/include/radio.h | 5 | ||||
-rw-r--r-- | source/blender/radiosity/intern/source/radfactors.c | 2 | ||||
-rw-r--r-- | source/blender/radiosity/intern/source/radrender.c | 541 | ||||
-rw-r--r-- | source/blender/render/extern/include/render_types.h | 11 | ||||
-rw-r--r-- | source/blender/render/intern/source/initrender.c | 17 | ||||
-rw-r--r-- | source/blender/render/intern/source/renderPreAndPost.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 27 | ||||
-rw-r--r-- | source/blender/render/intern/source/zbuf.c | 81 | ||||
-rw-r--r-- | source/blender/renderconverter/intern/convertBlenderScene.c | 13 | ||||
-rw-r--r-- | source/blender/src/buttons.c | 199 |
13 files changed, 771 insertions, 138 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index a74670dbde9..5d0c1fcc739 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -102,7 +102,7 @@ void init_material(Material *ma) ma->param[3]= 0.1; - ma->mode= MA_TRACEBLE+MA_SHADOW; + ma->mode= MA_TRACEBLE+MA_SHADOW+MA_RADIO; } Material *add_material(char *name) @@ -566,6 +566,8 @@ void init_render_material(Material *ma) } if(ma->mode & MA_VERTEXCOLP) ma->mode |= MA_VERTEXCOL; + if(ma->mode & MA_RADIO) needuv= 1; + if(ma->mode & (MA_VERTEXCOL|MA_FACETEXTURE)) { needuv= 1; if(R.osa) ma->texco |= TEXCO_OSA; /* for texfaces */ diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 36b3e811953..e7639d97d5a 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -122,6 +122,7 @@ typedef struct Material { #define MA_NOMIST 0x4000 #define MA_HALO_SHADE 0x4000 #define MA_HALO_FLARE 0x8000 +#define MA_RADIO 0x10000 /* diff_shader */ #define MA_DIFF_LAMBERT 0 diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 7ce8447da6a..a6241f8d607 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -170,7 +170,7 @@ typedef struct RenderData { * 5: edge shading * 6: field rendering * 7: Disables time difference in field calculations - * 8: Gauss ? is this for sampling? + * 8: radio rendering * 9: borders * 10: panorama * 11: crop @@ -272,7 +272,7 @@ typedef struct Scene { #define R_EDGE 0x0020 #define R_FIELDS 0x0040 #define R_FIELDSTILL 0x0080 -#define R_GAUSS 0x0100 +#define R_RADIO 0x0100 #define R_BORDER 0x0200 #define R_PANORAMA 0x0400 #define R_MOVIECROP 0x0800 diff --git a/source/blender/radiosity/extern/include/radio.h b/source/blender/radiosity/extern/include/radio.h index 23190a02ec2..2f4e1ff5408 100644 --- a/source/blender/radiosity/extern/include/radio.h +++ b/source/blender/radiosity/extern/include/radio.h @@ -164,8 +164,11 @@ extern void setcolNode(RNode *rn, unsigned int *col); extern void pseudoAmb(void); extern void rad_forcedraw(void); extern void drawpatch_ext(RPatch *patch, unsigned int col); - extern void RAD_drawall(int depth_is_on); +/* radrender.c */ +extern void do_radio_render(void); +void end_radio_render(void); + #endif /* RADIO_H */ diff --git a/source/blender/radiosity/intern/source/radfactors.c b/source/blender/radiosity/intern/source/radfactors.c index d0b6a7752a9..5e2812138e2 100644 --- a/source/blender/radiosity/intern/source/radfactors.c +++ b/source/blender/radiosity/intern/source/radfactors.c @@ -479,7 +479,7 @@ void backface_test(RPatch *shoot) if(rp!=shoot) { VecSubf(tvec, shoot->cent, rp->cent); - if( tvec[0]*shoot->norm[0]+ tvec[1]*shoot->norm[1]+ tvec[2]*shoot->norm[2]>0.0) { + if( tvec[0]*rp->norm[0]+ tvec[1]*rp->norm[1]+ tvec[2]*rp->norm[2]<0.0) { setnodeflags(rp->first, RAD_BACKFACE, 1); } } diff --git a/source/blender/radiosity/intern/source/radrender.c b/source/blender/radiosity/intern/source/radrender.c new file mode 100644 index 00000000000..151b5cd40ff --- /dev/null +++ b/source/blender/radiosity/intern/source/radrender.c @@ -0,0 +1,541 @@ +/* *************************************** + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +/* radrender.c, aug 2003 + * + * Most of the code here is copied from radiosity code, to optimize for renderfaces. + * Shared function calls mostly reside in radfactors.c + * No adaptive subdivision takes place + * + * - do_radio_render(); main call, extern + * - initradfaces(); add radface structs in render faces, init radio globals + * - + * - initradiosity(); LUTs + * - inithemiwindows(); + * - progressiverad(); main itteration loop + * - hemi zbuffers + * - calc rad factors + * + * - closehemiwindows(); + * - freeAllRad(); + * - make vertex colors + * + * - during render, materials use totrad as ambient replacement + * - free radfaces + */ + +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_arithb.h" +#include "BLI_rand.h" + +#include "BKE_utildefines.h" +#include "BKE_global.h" +#include "BKE_main.h" + +#include "BIF_screen.h" + +#include "radio.h" +#include "render.h" + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +/* only needed now for a print, if its useful move to RG */ +static float maxenergy; + +/* find the face with maximum energy to become shooter */ +/* nb: _rr means rad-render version of existing radio call */ +VlakRen *findshoot_rr() +{ + RadFace *rf; + VlakRen *vlr=NULL, *shoot; + float energy; + int a; + + shoot= NULL; + maxenergy= 0.0; + + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + if(vlr->radface) { + rf= vlr->radface; + rf->flag &= ~RAD_SHOOT; + + energy= rf->unshot[0]*rf->area; + energy+= rf->unshot[1]*rf->area; + energy+= rf->unshot[2]*rf->area; + + if(energy>maxenergy) { + shoot= vlr; + maxenergy= energy; + } + } + } + + if(shoot) { + maxenergy/= RG.totenergy; + if(maxenergy<RG.convergence) return NULL; + shoot->radface->flag |= RAD_SHOOT; + } + + return shoot; +} + +void backface_test_rr(VlakRen *shoot) +{ + VlakRen *vlr=NULL; + RadFace *rf; + float tvec[3]; + int a; + + /* backface testing */ + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + if(vlr->radface) { + rf= vlr->radface; + if(vlr!=shoot) { + + VecSubf(tvec, shoot->radface->cent, rf->cent); + + if( tvec[0]*rf->norm[0]+ tvec[1]*rf->norm[1]+ tvec[2]*rf->norm[2] < 0.0) { + rf->flag |= RAD_BACKFACE; + } + } + } + } +} + +void clear_backface_test_rr() +{ + VlakRen *vlr=NULL; + RadFace *rf; + int a; + + /* backface flag clear */ + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + rf->flag &= ~RAD_BACKFACE; + } + } +} + +extern RadView hemitop, hemiside; // radfactors.c + +/* hemi-zbuffering, delivers formfactors array */ +void makeformfactors_rr(VlakRen *shoot) +{ + VlakRen *vlr=NULL; + RadFace *rf; + float len, vec[3], up[3], side[3], tar[5][3], *fp; + int a; + + memset(RG.formfactors, 0, sizeof(float)*RG.totelem); + + /* set up hemiview */ + /* first: upvector for hemitop, we use diagonal hemicubes to prevent aliasing */ + + VecSubf(vec, shoot->v1->co, shoot->radface->cent); + Crossf(up, shoot->radface->norm, vec); + len= Normalise(up); + + VECCOPY(hemitop.up, up); + VECCOPY(hemiside.up, shoot->radface->norm); + + Crossf(side, shoot->radface->norm, up); + + /* five targets */ + VecAddf(tar[0], shoot->radface->cent, shoot->radface->norm); + VecAddf(tar[1], shoot->radface->cent, up); + VecSubf(tar[2], shoot->radface->cent, up); + VecAddf(tar[3], shoot->radface->cent, side); + VecSubf(tar[4], shoot->radface->cent, side); + + /* camera */ + VECCOPY(hemiside.cam, shoot->radface->cent); + VECCOPY(hemitop.cam, shoot->radface->cent); + + /* do it! */ + VECCOPY(hemitop.tar, tar[0]); + hemizbuf(&hemitop); + + for(a=1; a<5; a++) { + VECCOPY(hemiside.tar, tar[a]); + hemizbuf(&hemiside); + } + + /* convert factors to real radiosity */ + fp= RG.formfactors; + + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + if(*fp!=0.0 && rf->area!=0.0) { + *fp *= shoot->radface->area/rf->area; + if(*fp>1.0) *fp= 1.0001; + } + fp++; + } + } +} + +/* based at RG.formfactors array, distribute shoot energy over other faces */ +void applyformfactors_rr(VlakRen *shoot) +{ + VlakRen *vlr=NULL; + RadFace *rf; + float *fp, *ref, unr, ung, unb, r, g, b; + int a; + + unr= shoot->radface->unshot[0]; + ung= shoot->radface->unshot[1]; + unb= shoot->radface->unshot[2]; + + fp= RG.formfactors; + + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + if(*fp!= 0.0) { + + ref= &(vlr->mat->r); + + r= (*fp)*unr*ref[0]; + g= (*fp)*ung*ref[1]; + b= (*fp)*unb*ref[2]; + + + rf->totrad[0]+= r; + rf->totrad[1]+= g; + rf->totrad[2]+= b; + + rf->unshot[0]+= r; + rf->unshot[1]+= g; + rf->unshot[2]+= b; + } + fp++; + } + } + /* shoot energy has been shot */ + shoot->radface->unshot[0]= shoot->radface->unshot[1]= shoot->radface->unshot[2]= 0.0; +} + + +/* main loop for itterations */ +void progressiverad_rr() +{ + VlakRen *shoot; + int it= 0; + + shoot= findshoot_rr(); + while( shoot ) { + + /* backfaces receive no energy, but are zbuffered */ + backface_test_rr(shoot); + /* hemi-zbuffers */ + makeformfactors_rr(shoot); + /* based at RG.formfactors array, distribute shoot energy over other faces */ + applyformfactors_rr(shoot); + + it++; + printf("\r Radiostity step %d", it); fflush(stdout); + + clear_backface_test_rr(); + + if(blender_test_break()) break; + if(RG.maxiter && RG.maxiter<=it) break; + + shoot= findshoot_rr(); + } + printf("\n Unshot energy:%f\n", 1000.0*maxenergy); +} + +static RadFace *radfaces=NULL; + +void initradfaces() +{ + VlakRen *vlr= NULL; + RadFace *rf; + int a, b; + + /* globals */ + RG.totenergy= 0.0; + RG.totpatch= 0; // we count initial emittors here + RG.totelem= 0; // total # faces are put here (so we can use radfactors.c calls) + /* size is needed for hemicube clipping */ + RG.min[0]= RG.min[1]= RG.min[2]= 1.0e20; + RG.max[0]= RG.max[1]= RG.max[2]= -1.0e20; + + /* count first for fast malloc */ + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->mat->mode & MA_RADIO) { + if(vlr->mat->emit > 0.0) { + RG.totpatch++; + } + RG.totelem++; + } + } + +printf(" Rad elems: %d emittors %d\n", RG.totelem, RG.totpatch); + if(RG.totelem==0 || RG.totpatch==0) return; + + /* make/init radfaces */ + rf=radfaces= MEM_callocN(RG.totelem*sizeof(RadFace), "radfaces"); + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->mat->mode & MA_RADIO) { + + /* during render, vlr->n gets flipped/corrected, we cannot have that */ + if(vlr->v4) CalcNormFloat4(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co, rf->norm); + else CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, rf->norm); + + rf->totrad[0]= vlr->mat->emit*vlr->mat->r; + rf->totrad[1]= vlr->mat->emit*vlr->mat->g; + rf->totrad[2]= vlr->mat->emit*vlr->mat->b; + VECCOPY(rf->unshot, rf->totrad); + + if(vlr->v4) { + rf->area= AreaQ3Dfl(vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co); + CalcCent4f(rf->cent, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4->co); + } + else { + rf->area= AreaT3Dfl(vlr->v1->co, vlr->v2->co, vlr->v3->co); + CalcCent3f(rf->cent, vlr->v1->co, vlr->v2->co, vlr->v3->co); + } + + RG.totenergy+= rf->unshot[0]*rf->area; + RG.totenergy+= rf->unshot[1]*rf->area; + RG.totenergy+= rf->unshot[2]*rf->area; + + for(b=0; b<3; b++) { + RG.min[b]= MIN2(RG.min[b], rf->cent[b]); + RG.max[b]= MAX2(RG.max[b], rf->cent[b]); + } + + + vlr->radface= rf++; + } + } + RG.size[0]= (RG.max[0]- RG.min[0]); + RG.size[1]= (RG.max[1]- RG.min[1]); + RG.size[2]= (RG.max[2]- RG.min[2]); + RG.maxsize= MAX3(RG.size[0],RG.size[1],RG.size[2]); + + /* formfactor array */ + if(RG.formfactors) MEM_freeN(RG.formfactors); + if(RG.totelem) + RG.formfactors= MEM_mallocN(sizeof(float)*RG.totelem, "formfactors"); + else + RG.formfactors= NULL; + +} + +static void vecaddfac(float *vec, float *v1, float *v2, float fac) +{ + vec[0]= v1[0] + fac*v2[0]; + vec[1]= v1[1] + fac*v2[1]; + vec[2]= v1[2] + fac*v2[2]; + +} + +/* unused now, doesnt work... */ +void filter_rad_values() +{ + VlakRen *vlr=NULL; + VertRen *v1=NULL; + RadFace *rf; + float n1[3], n2[3], n3[4], n4[3], co[4]; + int a; + + /* one filter pass */ + for(a=0; a<R.totvert; a++) { + if((a & 255)==0) v1= R.blove[a>>8]; else v1++; + if(v1->accum>0.0) { + v1->rad[0]= v1->rad[0]/v1->accum; + v1->rad[1]= v1->rad[1]/v1->accum; + v1->rad[2]= v1->rad[2]/v1->accum; + v1->accum= 0.0; + } + } + /* cosines in verts accumulate in faces */ + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + + /* calculate cosines of angles, for weighted add (irregular faces) */ + VecSubf(n1, vlr->v2->co, vlr->v1->co); + VecSubf(n2, vlr->v3->co, vlr->v2->co); + Normalise(n1); + Normalise(n2); + + if(vlr->v4==NULL) { + VecSubf(n3, vlr->v1->co, vlr->v3->co); + Normalise(n3); + + co[0]= saacos(-n3[0]*n1[0]-n3[1]*n1[1]-n3[2]*n1[2])/M_PI; + co[1]= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2])/M_PI; + co[2]= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2])/M_PI; + co[0]= co[1]= co[2]= 1.0/3.0; + } + else { + VecSubf(n3, vlr->v4->co, vlr->v3->co); + VecSubf(n4, vlr->v1->co, vlr->v4->co); + Normalise(n3); + Normalise(n4); + + co[0]= saacos(-n4[0]*n1[0]-n4[1]*n1[1]-n4[2]*n1[2])/M_PI; + co[1]= saacos(-n1[0]*n2[0]-n1[1]*n2[1]-n1[2]*n2[2])/M_PI; + co[2]= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2])/M_PI; + co[3]= saacos(-n3[0]*n4[0]-n3[1]*n4[1]-n3[2]*n4[2])/M_PI; + co[0]= co[1]= co[2]= co[3]= 1.0/4.0; + } + + rf->totrad[0]= rf->totrad[1]= rf->totrad[2]= 0.0; + + vecaddfac(rf->totrad, rf->totrad, vlr->v1->rad, co[0]); + vecaddfac(rf->totrad, rf->totrad, vlr->v2->rad, co[1]); + vecaddfac(rf->totrad, rf->totrad, vlr->v3->rad, co[2]); + if(vlr->v4) { + vecaddfac(rf->totrad, rf->totrad, vlr->v4->rad, co[3]); + } + } + } + + /* accumulate vertexcolors again */ + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + + vecaddfac(vlr->v1->rad, vlr->v1->rad, rf->totrad, rf->area); + vlr->v1->accum+= rf->area; + vecaddfac(vlr->v2->rad, vlr->v2->rad, rf->totrad, rf->area); + vlr->v2->accum+= rf->area; + vecaddfac(vlr->v3->rad, vlr->v3->rad, rf->totrad, rf->area); + vlr->v3->accum+= rf->area; + if(vlr->v4) { + vecaddfac(vlr->v4->rad, vlr->v4->rad, rf->totrad, rf->area); + vlr->v4->accum+= rf->area; + } + } + } + +} + +void make_vertex_rad_values() +{ + VertRen *v1=NULL; + VlakRen *vlr=NULL; + RadFace *rf; + int a; + + /* accumulate vertexcolors */ + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + + vecaddfac(vlr->v1->rad, vlr->v1->rad, rf->totrad, rf->area); + vlr->v1->accum+= rf->area; + vecaddfac(vlr->v2->rad, vlr->v2->rad, rf->totrad, rf->area); + vlr->v2->accum+= rf->area; + vecaddfac(vlr->v3->rad, vlr->v3->rad, rf->totrad, rf->area); + vlr->v3->accum+= rf->area; + if(vlr->v4) { + vecaddfac(vlr->v4->rad, vlr->v4->rad, rf->totrad, rf->area); + vlr->v4->accum+= rf->area; + } + } + } + + /* make vertex colors */ + RG.igamma= 1.0/RG.gamma; + RG.radfactor= RG.radfac*pow(64*64, RG.igamma)/256.0; /* compatible with radio-tool */ + + for(a=0; a<R.totvert; a++) { + if((a & 255)==0) v1= R.blove[a>>8]; else v1++; + if(v1->accum>0.0) { + v1->rad[0]= RG.radfactor*pow( v1->rad[0]/v1->accum, RG.igamma); + v1->rad[1]= RG.radfactor*pow( v1->rad[1]/v1->accum, RG.igamma); + v1->rad[2]= RG.radfactor*pow( v1->rad[2]/v1->accum, RG.igamma); + } + } + +} + +/* main call, extern */ +void do_radio_render(void) +{ + if(G.scene->radio==NULL) add_radio(); + freeAllRad(); /* just in case radio-tool is still used */ + + set_radglobal(); /* init the RG struct */ + + initradfaces(); /* add radface structs to render faces */ + if(RG.totenergy==0.0) return; + + initradiosity(); /* LUT's */ + inithemiwindows(); /* views, need RG.maxsize for clipping */ + + progressiverad_rr(); /* main radio loop */ + + freeAllRad(); /* luts, hemis, sets vars at zero */ + + make_vertex_rad_values(); /* convert face energy to vertex ones */ +} + +/* free call, after rendering, extern */ +void end_radio_render(void) +{ + if(radfaces) MEM_freeN(radfaces); + radfaces= NULL; +} + diff --git a/source/blender/render/extern/include/render_types.h b/source/blender/render/extern/include/render_types.h index 2f33ae686a5..6b790c66936 100644 --- a/source/blender/render/extern/include/render_types.h +++ b/source/blender/render/extern/include/render_types.h @@ -54,7 +54,7 @@ typedef struct RE_Render { float co[3]; - float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3]; + float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3]; float itot, i, ic, rgb, norm; float vn[3], view[3], *vno, refcol[4]; @@ -152,10 +152,12 @@ typedef struct VertRen float co[3]; float n[3]; float ho[4]; + float rad[3]; /* result radio rendering */ float *orco; float *sticky; void *svert; /* smooth vert, only used during initrender */ short clip, texofs; /* texofs= flag */ + float accum; /* accum for radio weighting */ } VertRen; /* ------------------------------------------------------------------------- */ @@ -170,6 +172,12 @@ struct Material; struct MFace; struct TFace; +typedef struct RadFace { + float unshot[3], totrad[3]; + float norm[3], cent[3], area; + int flag; +} RadFace; + typedef struct VlakRen { struct VertRen *v1, *v2, *v3, *v4; @@ -181,6 +189,7 @@ typedef struct VlakRen char snproj, puno; char flag, ec; unsigned int lay; + RadFace *radface; } VlakRen; diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index bd331aa44d8..37e6f4deb56 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -178,15 +178,16 @@ float calc_weight(float *weight, int i, int j) weight[a]= 0.0; - if(R.r.mode & R_GAUSS) { - if(dist<1.5) { - x = dist*1.5; - weight[a]= (1.0/exp(x*x) - 1.0/exp(1.5*1.5*1.5*1.5)); - } - } - else { + /* gaussian weighting has been cancelled */ + //if(R.r.mode & R_GAUSS) { + // if(dist<1.5) { + // x = dist*1.5; + // weight[a]= (1.0/exp(x*x) - 1.0/exp(1.5*1.5*1.5*1.5)); + // } + //} + //else { if(i==0 && j==0) weight[a]= 1.0; - } + //} totw+= weight[a]; diff --git a/source/blender/render/intern/source/renderPreAndPost.c b/source/blender/render/intern/source/renderPreAndPost.c index 678f241a1e2..63a59bc659b 100644 --- a/source/blender/render/intern/source/renderPreAndPost.c +++ b/source/blender/render/intern/source/renderPreAndPost.c @@ -43,6 +43,7 @@ #include "envmap.h" #include "renderHelp.h" #include "shadowBuffer.h" +#include "radio.h" #ifdef HAVE_CONFIG_H #include <config.h> @@ -79,6 +80,9 @@ void prepareScene() } } + /* RADIO */ + if(R.r.mode & R_RADIO) do_radio_render(); + /* ENVIRONMENT MAPS */ make_envmaps(); } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index d9066494284..0153974c370 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1896,26 +1896,33 @@ void shade_lamp_loop() else ma->alpha= (1.0-t)*R.mat->alpha+t; } } + + if( ma->mode & MA_RADIO) { + ir+= ma->amb*R.rad[0]; + ig+= ma->amb*R.rad[1]; + ib+= ma->amb*R.rad[2]; + } + if(R.refcol[0]==0.0) { - a= 65535.0*( ma->r*ir +ma->ambr +isr); + a= 65535.0*( ma->r*ir +ma->ambr +isr +ma->amb*R.rad[0]); if(a>65535) a=65535; else if(a<0) a= 0; shortcol[0]= a; - a= 65535.0*(ma->g*ig +ma->ambg +isg); + a= 65535.0*(ma->g*ig +ma->ambg +isg +ma->amb*R.rad[1]); if(a>65535) a=65535; else if(a<0) a= 0; shortcol[1]= a; - a= 65535*(ma->b*ib +ma->ambb +isb); + a= 65535*(ma->b*ib +ma->ambb +isb + ma->amb*R.rad[2]); if(a>65535) a=65535; else if(a<0) a= 0; shortcol[2]= a; } else { - a= 65535.0*( ma->mirr*R.refcol[1] + (1.0 - ma->mirr*R.refcol[0])*(ma->r*ir +ma->ambr) +isr); + a= 65535.0*( ma->mirr*R.refcol[1] + (1.0 - ma->mirr*R.refcol[0])*(ma->r*ir +ma->ambr +ma->amb*R.rad[0]) +isr); if(a>65535) a=65535; else if(a<0) a= 0; shortcol[0]= a; - a= 65535.0*( ma->mirg*R.refcol[2] + (1.0 - ma->mirg*R.refcol[0])*(ma->g*ig +ma->ambg) +isg); + a= 65535.0*( ma->mirg*R.refcol[2] + (1.0 - ma->mirg*R.refcol[0])*(ma->g*ig +ma->ambg +ma->amb*R.rad[1]) +isg); if(a>65535) a=65535; else if(a<0) a= 0; shortcol[1]= a; - a= 65535.0*( ma->mirb*R.refcol[3] + (1.0 - ma->mirb*R.refcol[0])*(ma->b*ib +ma->ambb) +isb); + a= 65535.0*( ma->mirb*R.refcol[3] + (1.0 - ma->mirb*R.refcol[0])*(ma->b*ib +ma->ambb +ma->amb*R.rad[2]) +isb); if(a>65535) a=65535; else if(a<0) a= 0; shortcol[2]= a; } @@ -2266,6 +2273,14 @@ void shadepixel(float x, float y, int vlaknr) R.vcol[2]= 0.0; } } + if(R.matren->mode & MA_RADIO) { + R.rad[0]= (l*v3->rad[0] - u*v1->rad[0] - v*v2->rad[0]); + R.rad[1]= (l*v3->rad[1] - u*v1->rad[1] - v*v2->rad[1]); + R.rad[2]= (l*v3->rad[2] - u*v1->rad[2] - v*v2->rad[2]); + } + else { + R.rad[0]= R.rad[1]= R.rad[2]= 0.0; + } if(R.matren->mode & MA_FACETEXTURE) { if((R.matren->mode & MA_VERTEXCOL)==0) { R.vcol[0]= 1.0; diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 4b0a8652a68..1cbe015731a 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -1876,10 +1876,9 @@ static int hashlist_projectvert(float *v1, float *hoco) return buck->clip; } - +/* used for booth radio 'tool' as during render */ void RE_zbufferall_radio(struct RadView *vw, RNode **rg_elem, int rg_totelem) { - RNode **re, *rn; float hoco[4][4]; int a; int c1, c2, c3, c4= 0; @@ -1910,31 +1909,67 @@ void RE_zbufferall_radio(struct RadView *vw, RNode **rg_elem, int rg_totelem) fillrect(R.rectot, R.rectx, R.recty, 0xFFFFFF); zbuffunc= zbufinvulGL; - - re= rg_elem; - re+= (rg_totelem-1); - for(a= rg_totelem-1; a>=0; a--, re--) { - rn= *re; - if( (rn->f & RAD_SHOOT)==0 ) { /* no shootelement */ - - if( rn->f & RAD_BACKFACE) Zvlnr= 0xFFFFFF; - else Zvlnr= a; - - c1= hashlist_projectvert(rn->v1, hoco[0]); - c2= hashlist_projectvert(rn->v2, hoco[1]); - c3= hashlist_projectvert(rn->v3, hoco[2]); - - if(rn->v4) { - c4= hashlist_projectvert(rn->v4, hoco[3]); + + if(rg_elem) { /* radio tool */ + RNode **re, *rn; + + re= rg_elem; + re+= (rg_totelem-1); + for(a= rg_totelem-1; a>=0; a--, re--) { + rn= *re; + if( (rn->f & RAD_SHOOT)==0 ) { /* no shootelement */ + + if( rn->f & RAD_BACKFACE) Zvlnr= 0xFFFFFF; + else Zvlnr= a; + + c1= hashlist_projectvert(rn->v1, hoco[0]); + c2= hashlist_projectvert(rn->v2, hoco[1]); + c3= hashlist_projectvert(rn->v3, hoco[2]); + + if(rn->v4) { + c4= hashlist_projectvert(rn->v4, hoco[3]); + } + + zbufclip(hoco[0], hoco[1], hoco[2], c1, c2, c3); + if(rn->v4) { + zbufclip(hoco[0], hoco[2], hoco[3], c1, c3, c4); + } } - - zbufclip(hoco[0], hoco[1], hoco[2], c1, c2, c3); - if(rn->v4) { - zbufclip(hoco[0], hoco[2], hoco[3], c1, c3, c4); + } + } + else { /* radio render */ + VlakRen *vlr=NULL; + RadFace *rf; + int totface=0; + + for(a=0; a<R.totvlak; a++) { + if((a & 255)==0) vlr= R.blovl[a>>8]; else vlr++; + + if(vlr->radface) { + rf= vlr->radface; + if( (rf->flag & RAD_SHOOT)==0 ) { /* no shootelement */ + + if( rf->flag & RAD_BACKFACE) Zvlnr= 0xFFFFFF; /* receives no energy, but is zbuffered */ + else Zvlnr= totface; + + c1= hashlist_projectvert(vlr->v1->co, hoco[0]); + c2= hashlist_projectvert(vlr->v2->co, hoco[1]); + c3= hashlist_projectvert(vlr->v3->co, hoco[2]); + + if(vlr->v4) { + c4= hashlist_projectvert(vlr->v4->co, hoco[3]); + } + + zbufclip(hoco[0], hoco[1], hoco[2], c1, c2, c3); + if(vlr->v4) { + zbufclip(hoco[0], hoco[2], hoco[3], c1, c3, c4); + } + } + totface++; } } } - + /* restore */ R.rectx= rectxo; R.recty= rectyo; diff --git a/source/blender/renderconverter/intern/convertBlenderScene.c b/source/blender/renderconverter/intern/convertBlenderScene.c index 2008236b0ec..b86ed966d5b 100644 --- a/source/blender/renderconverter/intern/convertBlenderScene.c +++ b/source/blender/renderconverter/intern/convertBlenderScene.c @@ -1499,7 +1499,7 @@ static void init_render_mesh(Object *ob) float xn, yn, zn, nor[3], imat[3][3], mat[4][4]; float *extverts=0, *orco; int a, a1, ok, do_puno, need_orco=0, totvlako, totverto, vertofs; - int start, end, flipnorm; + int start, end, flipnorm, do_autosmooth=0; me= ob->data; if (rendermesh_uses_displist(me) && me->subdivr>0) { @@ -1613,7 +1613,7 @@ static void init_render_mesh(Object *ob) ma= give_render_material(ob, a1+1); if(ma==0) ma= &defmaterial; - + /* test for 100% transparant */ ok= 1; if(ma->alpha==0.0 && ma->spectra==0.0) { @@ -1627,7 +1627,9 @@ static void init_render_mesh(Object *ob) } if(ok) { - + /* radio faces need autosmooth, to separate shared vertices in corners */ + if(ma->mode & MA_RADIO) do_autosmooth= 1; + start= 0; end= me->totface; set_buildvars(ob, &start, &end); @@ -1747,7 +1749,7 @@ static void init_render_mesh(Object *ob) } } - if(me->flag & ME_AUTOSMOOTH) { + if(do_autosmooth || (me->flag & ME_AUTOSMOOTH)) { autosmooth(totverto, totvlako, me->smoothresh); do_puno= 1; } @@ -2766,7 +2768,8 @@ void RE_freeRotateBlenderScene(void) end_render_textures(); end_render_materials(); - + end_radio_render(); + R.totvlak=R.totvert=R.totlamp=R.tothalo= 0; } diff --git a/source/blender/src/buttons.c b/source/blender/src/buttons.c index 3a975a4de34..845eff9df26 100644 --- a/source/blender/src/buttons.c +++ b/source/blender/src/buttons.c @@ -2553,102 +2553,119 @@ void radiobuts(void) rad= G.scene->radio; } - flag= rad_phase(); - sprintf(str, "buttonswin %d", curarea->win); block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 10, 30, 190, 100, UI_BLOCK_ROWS); - if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_INIT, "Limit Subdivide", 0, 0, 10, 10, NULL, 0, 0, 0, 0, "Subdivide patches"); + flag= rad_phase(); + + if(flag & RAD_PHASE_PATCHES) { + uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_RAD_INIT, "Limit Subdivide", 10, 70, 190, 40, NULL, 0, 0, 0, 0, "Subdivide patches"); + } if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTPURPLE); else uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_RAD_COLLECT, "Collect Meshes", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert selected and visible meshes to patches"); + uiDefBut(block, BUT, B_RAD_COLLECT, "Collect Meshes", 10, 30, 190, 40, NULL, 0, 0, 0, 0, "Convert selected and visible meshes to patches"); uiDrawBlock(block); - sprintf(str, "buttonswin1 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); - - uiBlockSetCol(block, BUTGREEN); - uiDefButS(block, ROW, B_RAD_DRAW, "Wire", 0, 0, 10, 10, &rad->drawtype, 0.0, 0.0, 0, 0, "Enable wireframe drawmode"); - uiDefButS(block, ROW, B_RAD_DRAW, "Solid", 0, 0, 10, 10, &rad->drawtype, 0.0, 1.0, 0, 0, "Enable solid drawmode"); - uiDefButS(block, ROW, B_RAD_DRAW, "Gour", 0, 0, 10, 10, &rad->drawtype, 0.0, 2.0, 0, 0, "Enable Gourad drawmode"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, TOG|BIT|0, B_RAD_DRAW, "ShowLim", 1, 0, 10, 10, &rad->flag, 0, 0, 0, 0, "Visualize patch and element limits"); - uiDefButS(block, TOG|BIT|1, B_RAD_DRAW, "Z", 1, 0, 3, 10, &rad->flag, 0, 0, 0, 0, "Draw limits different"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, B_RAD_LIMITS, "ElMax:", 2, 0, 10, 10, &rad->elma, 1.0, 500.0, 0, 0, "Set maximum size of an element"); - uiDefButS(block, NUM, B_RAD_LIMITS, "ElMin:", 2, 0, 10, 10, &rad->elmi, 1.0, 100.0, 0, 0, "Set minimum size of an element"); - uiDefButS(block, NUM, B_RAD_LIMITS, "PaMax:", 3, 0, 10, 10, &rad->pama, 10.0, 1000.0, 0, 0, "Set maximum size of a patch"); - uiDefButS(block, NUM, B_RAD_LIMITS, "PaMin:", 3, 0, 10, 10, &rad->pami, 10.0, 1000.0, 0, 0, "Set minimum size of a patch"); - uiDrawBlock(block); - - sprintf(str, "buttonswin2 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 450, 30, 180, 150, UI_BLOCK_ROWS); + if(flag==0) { - if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_SHOOTE, "Subdiv Shoot Element", 0, 0, 12, 10, NULL, 0, 0, 0, 0, ""); - uiDefBut(block, BUT, B_RAD_SHOOTP, "Subdiv Shoot Patch", 1, 0, 12, 10, NULL, 0, 0, 0, 0, "Detect high energy changes"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, 0, "Max Subdiv Shoot:", 2, 0, 10, 10, &rad->maxsublamp, 1.0, 250.0, 0, 0, "Set the maximum number of shoot patches that are evaluated"); - uiDefButI(block, NUM, 0, "MaxEl:", 3, 0, 10, 10, &rad->maxnode, 1.0, 250000.0, 0, 0, "Set the maximum allowed number of elements"); - uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 4, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); - uiDrawBlock(block); + sprintf(str, "buttonswin1 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 0, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); + uiDefButS(block, NUM, 0, "Max Iterations:", 1, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); + uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 2, 0, 50, 10, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); + uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 2, 0, 50, 10, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); + uiDefButF(block, NUM, 0, "Convergence:", 3, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); + uiDrawBlock(block); + } + else { - sprintf(str, "buttonswin3 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 640, 30, 200, 150, UI_BLOCK_ROWS); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, 0, "Max Iterations:", 0, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); - uiDefButF(block, NUM, 0, "Convergence:", 1, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); - uiDefButS(block, NUM, 0, "SubSh P:", 2, 0, 10, 10, &rad->subshootp, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect pathes"); - uiDefButS(block, NUM, 0, "SubSh E:", 2, 0, 10, 10, &rad->subshoote, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect elements"); - if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - uiDefBut(block, BUT, B_RAD_GO, "GO", 3, 0, 10, 15, NULL, 0, 0, 0, 0, "Start the radiosity simulation"); - uiDrawBlock(block); + sprintf(str, "buttonswin1 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 210, 30, 230, 150, UI_BLOCK_ROWS); + + uiBlockSetCol(block, BUTGREEN); + uiDefButS(block, ROW, B_RAD_DRAW, "Wire", 0, 0, 10, 10, &rad->drawtype, 0.0, 0.0, 0, 0, "Enable wireframe drawmode"); + uiDefButS(block, ROW, B_RAD_DRAW, "Solid", 0, 0, 10, 10, &rad->drawtype, 0.0, 1.0, 0, 0, "Enable solid drawmode"); + uiDefButS(block, ROW, B_RAD_DRAW, "Gour", 0, 0, 10, 10, &rad->drawtype, 0.0, 2.0, 0, 0, "Enable Gourad drawmode"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, TOG|BIT|0, B_RAD_DRAW, "ShowLim", 1, 0, 10, 10, &rad->flag, 0, 0, 0, 0, "Visualize patch and element limits"); + uiDefButS(block, TOG|BIT|1, B_RAD_DRAW, "Z", 1, 0, 3, 10, &rad->flag, 0, 0, 0, 0, "Draw limits different"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, B_RAD_LIMITS, "ElMax:", 2, 0, 10, 10, &rad->elma, 1.0, 500.0, 0, 0, "Set maximum size of an element"); + uiDefButS(block, NUM, B_RAD_LIMITS, "ElMin:", 2, 0, 10, 10, &rad->elmi, 1.0, 100.0, 0, 0, "Set minimum size of an element"); + uiDefButS(block, NUM, B_RAD_LIMITS, "PaMax:", 3, 0, 10, 10, &rad->pama, 10.0, 1000.0, 0, 0, "Set maximum size of a patch"); + uiDefButS(block, NUM, B_RAD_LIMITS, "PaMin:", 3, 0, 10, 10, &rad->pami, 10.0, 1000.0, 0, 0, "Set minimum size of a patch"); + uiDrawBlock(block); + + sprintf(str, "buttonswin2 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 450, 30, 180, 150, UI_BLOCK_ROWS); + + if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_SHOOTE, "Subdiv Shoot Element", 0, 0, 12, 10, NULL, 0, 0, 0, 0, ""); + uiDefBut(block, BUT, B_RAD_SHOOTP, "Subdiv Shoot Patch", 1, 0, 12, 10, NULL, 0, 0, 0, 0, "Detect high energy changes"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, 0, "Max Subdiv Shoot:", 2, 0, 10, 10, &rad->maxsublamp, 1.0, 250.0, 0, 0, "Set the maximum number of shoot patches that are evaluated"); + uiDefButI(block, NUM, 0, "MaxEl:", 3, 0, 10, 10, &rad->maxnode, 1.0, 250000.0, 0, 0, "Set the maximum allowed number of elements"); + uiDefButS(block, NUM, B_RAD_LIMITS, "Hemires:", 4, 0, 10, 10, &rad->hemires, 100.0, 1000.0, 100, 0, "Set the size of a hemicube"); + uiDrawBlock(block); + + sprintf(str, "buttonswin3 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 640, 30, 200, 150, UI_BLOCK_ROWS); + + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, 0, "Max Iterations:", 0, 0, 10, 10, &rad->maxiter, 0.0, 10000.0, 0, 0, "Maximum number of radiosity rounds"); + uiDefButF(block, NUM, 0, "Convergence:", 1, 0, 10, 10, &rad->convergence, 0.0, 1.0, 10, 0, "Set the lower threshold of unshot energy"); + uiDefButS(block, NUM, 0, "SubSh P:", 2, 0, 10, 10, &rad->subshootp, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect pathes"); + uiDefButS(block, NUM, 0, "SubSh E:", 2, 0, 10, 10, &rad->subshoote, 0.0, 10.0, 0, 0, "Set the number of times the environment is tested to detect elements"); + if(flag == RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); + uiDefBut(block, BUT, B_RAD_GO, "GO", 3, 0, 10, 15, NULL, 0, 0, 0, 0, "Start the radiosity simulation"); + uiDrawBlock(block); + + sprintf(str, "buttonswin4 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 850, 30, 200, 150, UI_BLOCK_ROWS); - sprintf(str, "buttonswin4 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 850, 30, 200, 150, UI_BLOCK_ROWS); - - uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 0, 0, 50, 17, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); - uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 0, 0, 50, 17, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_FACEFILT, "FaceFilter", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Force an extra smoothing"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_NODELIM, "RemoveDoubles", 2, 0, 30, 10, NULL, 0.0, 50.0, 0, 0, "Join elements which differ less than 'Lim'"); - uiBlockSetCol(block, BUTGREY); - uiDefButS(block, NUM, 0, "Lim:", 2, 0, 10, 10, &rad->nodelim, 0.0, 50.0, 0, 0, "Set the range for removing doubles"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_NODEFILT, "Element Filter", 3, 0, 10, 10, NULL, 0, 0, 0, 0, "Filter elements to remove aliasing artefacts"); - uiDrawBlock(block); - - sprintf(str, "buttonswin5 %d", curarea->win); - block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); - uiAutoBlock(block, 1060, 30, 190, 150, UI_BLOCK_ROWS); - - if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_FREE, "Free Radio Data", 0, 0, 10, 10, NULL, 0, 0, 0, 0, "Release all memory used by Radiosity"); - if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); - else uiBlockSetCol(block, BUTGREY); - uiDefBut(block, BUT, B_RAD_REPLACE, "Replace Meshes", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, changing input-meshes"); - uiDefBut(block, BUT, B_RAD_ADDMESH, "Add new Meshes", 2, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, unchanging input-meshes"); - uiDrawBlock(block); + uiBlockSetCol(block, BUTGREY); + uiDefButF(block, NUM, B_RAD_FAC, "Mult:", 0, 0, 50, 17, &rad->radfac, 0.001, 250.0, 100, 0, "Mulitply the energy values"); + uiDefButF(block, NUM, B_RAD_FAC, "Gamma:", 0, 0, 50, 17, &rad->gamma, 0.2, 10.0, 10, 0, "Change the contrast of the energy values"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_FACEFILT, "FaceFilter", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Force an extra smoothing"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_NODELIM, "RemoveDoubles", 2, 0, 30, 10, NULL, 0.0, 50.0, 0, 0, "Join elements which differ less than 'Lim'"); + uiBlockSetCol(block, BUTGREY); + uiDefButS(block, NUM, 0, "Lim:", 2, 0, 10, 10, &rad->nodelim, 0.0, 50.0, 0, 0, "Set the range for removing doubles"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_NODEFILT, "Element Filter", 3, 0, 10, 10, NULL, 0, 0, 0, 0, "Filter elements to remove aliasing artefacts"); + uiDrawBlock(block); - rad_status_str(str); - cpack(0); - glRasterPos2i(210, 189); - BMF_DrawString(uiBlockGetCurFont(block), str); + sprintf(str, "buttonswin5 %d", curarea->win); + block= uiNewBlock(&curarea->uiblocks, str, UI_EMBOSSX, UI_HELV, curarea->win); + uiAutoBlock(block, 1060, 30, 190, 150, UI_BLOCK_ROWS); + + if(flag & RAD_PHASE_PATCHES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_FREE, "Free Radio Data", 0, 0, 10, 10, NULL, 0, 0, 0, 0, "Release all memory used by Radiosity"); + if(flag & RAD_PHASE_FACES) uiBlockSetCol(block, BUTSALMON); + else uiBlockSetCol(block, BUTGREY); + uiDefBut(block, BUT, B_RAD_REPLACE, "Replace Meshes", 1, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, changing input-meshes"); + uiDefBut(block, BUT, B_RAD_ADDMESH, "Add new Meshes", 2, 0, 10, 10, NULL, 0, 0, 0, 0, "Convert meshes to Mesh objects with vertex colours, unchanging input-meshes"); + uiDrawBlock(block); + + rad_status_str(str); + cpack(0); + glRasterPos2i(210, 189); + BMF_DrawString(uiBlockGetCurFont(block), str); + } } @@ -4272,16 +4289,17 @@ void matbuts(void) uiDefButI(block, TOG|BIT|0, 0, "Traceable", 576,200,77,18, &(ma->mode), 0, 0, 0, 0, "Make material visible for shadow lamps"); uiDefButI(block, TOG|BIT|1, 0, "Shadow", 576,181,77,18, &(ma->mode), 0, 0, 0, 0, "Enable material for shadows"); - uiDefButI(block, TOG|BIT|2, B_MATPRV, "Shadeless", 576, 162, 77, 18, &(ma->mode), 0, 0, 0, 0, "Make material insensitive to light or shadow"); - uiDefButI(block, TOG|BIT|3, 0, "Wire", 576, 143, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render only the edges of faces"); - uiDefButI(block, TOG|BIT|6, 0, "ZTransp", 576, 124, 77, 18, &(ma->mode), 0, 0, 0, 0, "Z-Buffer transparent faces"); - uiDefButI(block, TOG|BIT|8, 0, "ZInvert", 576, 105, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render with inverted Z Buffer"); + uiDefButI(block, TOG|BIT|16, 0, "Radio", 576, 162, 77,18, &(ma->mode), 0, 0, 0, 0, "Set the material insensitive to mist"); + uiDefButI(block, TOG|BIT|2, B_MATPRV, "Shadeless", 576, 143, 77, 18, &(ma->mode), 0, 0, 0, 0, "Make material insensitive to light or shadow"); + uiDefButI(block, TOG|BIT|3, 0, "Wire", 576, 124, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render only the edges of faces"); + uiDefButI(block, TOG|BIT|6, 0, "ZTransp", 576, 105, 77, 18, &(ma->mode), 0, 0, 0, 0, "Z-Buffer transparent faces"); uiDefButI(block, TOG|BIT|5, B_MATPRV_DRAW, "Halo", 576, 86, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render as a halo"); uiDefButI(block, TOG|BIT|9, 0, "Env", 576, 67, 77, 18, &(ma->mode), 0, 0, 0, 0, "Do not render material"); uiDefButI(block, TOG|BIT|10, 0, "OnlyShadow", 576, 48, 77, 18, &(ma->mode), 0, 0, 0, 0, "Let alpha be determined on the degree of shadow"); uiDefButI(block, TOG|BIT|14, 0, "No Mist", 576, 29, 77,18, &(ma->mode), 0, 0, 0, 0, "Set the material insensitive to mist"); + uiDefButI(block, TOG|BIT|8, 0, "ZInvert", 576, 10, 77, 18, &(ma->mode), 0, 0, 0, 0, "Render with inverted Z Buffer"); uiBlockSetCol(block, BUTGREY); - uiDefButF(block, NUM, 0, "Zoffs:", 576, 10, 77,18, &(ma->zoffs), 0.0, 10.0, 0, 0, "Give face an artificial offset"); + uiDefButF(block, NUM, 0, "Zoffs:", 576, -9, 77,18, &(ma->zoffs), 0.0, 10.0, 0, 0, "Give face an artificial offset"); } /* PREVIEW RENDER */ @@ -6605,7 +6623,8 @@ void renderbuts(void) uiBlockSetCol(block, BUTGREY); uiDefButS(block, TOG|BIT|1,0,"Shadows", 565,167,122,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable shadow calculation"); - uiDefButS(block, TOG|BIT|10,0,"Panorama",565,142,122,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)"); + uiDefButS(block, TOG|BIT|10,0,"Pano",565,142,61,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable panorama rendering (output width is multiplied by Xparts)"); + uiDefButS(block, TOG|BIT|8,0,"Radio",626,142,61,22, &G.scene->r.mode, 0, 0, 0, 0, "Enable radiosity rendering"); uiDefButS(block, ROW,B_DIFF,"100%", 565,114,121,20,&G.scene->r.size,1.0,100.0, 0, 0, "Set render size to defined size"); uiDefButS(block, ROW,B_DIFF,"75%", 565,90,36,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size"); |