Biiig commit! Thanks to 2-3 weeks of cvs freeze...

Render:
- New; support for dual CPU render (SDL thread)
  Currently only works with alternating scanlines, but gives excellent
  performance. For both normal render as unified implemented.
  Note the "mutex" locks on z-transp buffer render and imbuf loads.
- This has been made possible by major cleanups in render code, especially
  getting rid of globals (example Tin Tr Tg Tb Ta for textures) or struct
  OSA or using Materials or Texture data to write to.
- Made normal render fully 4x32 floats too, and removed all old optimizes
  with chars or shorts.
- Made normal render and unified render use same code for sky and halo
  render, giving equal (and better) results for halo render. Old render
  now also uses PostProcess options (brightness, mul, gamma)
- Added option ("FBuf") in F10 Output Panel, this keeps a 4x32 bits buffer
  after render. Using PostProcess menu you will note an immediate re-
  display of image too (32 bits RGBA)
- Added "Hue" and "Saturation" sliders to PostProcess options

- Render module is still not having a "nice" API, but amount of dependencies
  went down a lot. Next todo: remove abusive "previewrender" code.
  The last main global in Render (struct Render) now can be re-used for fully
  controlling a render, to allow multiple "instances" of render to open.

- Renderwindow now displays a smal bar on top with the stats, and keeps the
  stats after render too. Including "spare" page support.
  Not only easier visible that way, but also to remove the awkward code that
  was drawing stats in the Info header (extreme slow on some ATIs too)

- Cleaned up blendef.h and BKE_utildefines.h, these two had overlapping
  defines.

- I might have forgotten stuff... and will write a nice doc on the architecture!
This commit is contained in:
Ton Roosendaal 2004-12-27 19:28:52 +00:00
parent c43c38140d
commit 610cec55c7
119 changed files with 5130 additions and 6689 deletions

@ -1,3 +1,3 @@
Please read over both of the following files:
intern/GPL-license.txt
intern/BL-license.txt
doc/GPL-license.txt
doc/BL-license.txt

@ -1016,6 +1016,7 @@ if bs_globals.enable_clean==0: # only read SConscripts when not cleaning, this t
Export ('extra_includes')
Export ('user_options_dict')
Export ('library_env')
Export ('sdl_env')
BuildDir (bs_globals.root_build_dir+'/extern', 'extern', duplicate=0)
SConscript (bs_globals.root_build_dir+'extern/SConscript')

@ -145,6 +145,7 @@ endif
ifeq ($(OS),darwin)
@echo "----> Move .blender to .app/Contents/MacOS/"
@rm -fr $(DISTDIR)/blender$(EXT0)/Contents/MacOS/.blender
@mv $(DISTDIR)/.blender $(DISTDIR)/blender$(EXT0)/Contents/MacOS/
endif

@ -74,7 +74,7 @@ elif ( test $UNAME = "Darwin" ) then
CC="cc";
CFLAGS="-fPIC -funsigned-char -O2 -fno-common";
LD="cc";
LDFLAGS="-flat_namespace -bundle -bundle_loader ../../blender.app/Contents/MacOS/blender -ldl -lm";
LDFLAGS="-flat_namespace -bundle -bundle_loader ../../blender.app/Contents/MacOS/blender -lm";
EXT="so";
fi

@ -133,12 +133,8 @@ void RE_free_envmap(struct EnvMap *env);
struct EnvMap *RE_copy_envmap(struct EnvMap *env);
void RE_free_envmapdata(struct EnvMap *env);
int RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt);
void RE_calc_R_ref(void);
extern char texstr[20][12]; /* buttons.c */
/* memory for O is declared in the render module... */
#include "BKE_osa_types.h"
extern Osa O;
/* editsca.c */
void make_unique_prop_names(char *str);

@ -42,6 +42,9 @@ struct ListBase;
struct BezTriple;
struct BevList;
#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
int copyintoExtendedArray(float *old, int oldx, int oldy, float *newp, int newx, int newy);
void unlink_curve( struct Curve *cu);

@ -53,6 +53,30 @@
#define DL_FRONT_CURVE 4
#define DL_BACK_CURVE 8
/* This should, of course, become a function */
#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev) \
\
if( (cyclv)==0 && a==(sizev)-1) break; \
if(cyclu) { \
p1= sizeu*a; \
p2= p1+ sizeu-1; \
p3= p1+ sizeu; \
p4= p2+ sizeu; \
b= 0; \
} \
else { \
p2= sizeu*a; \
p1= p2+1; \
p4= p2+ sizeu; \
p3= p1+ sizeu; \
b= 1; \
} \
if( (cyclv) && a==sizev-1) { \
p3-= sizeu*sizev; \
p4-= sizeu*sizev; \
}
/* prototypes */
struct Object;

@ -93,6 +93,8 @@ typedef struct Global {
short machine, afbreek, moving, colact, zbuf;
short qual, background, imagewin, animspeed;
short winpos, displaymode; /* used to be in Render */
/**
* The current version of Blender.
*/

@ -47,18 +47,12 @@ void free_image(struct Image *me);
void free_image_buffers(struct Image *ima);
struct Image *add_image(char *name);
void free_unused_animimages(void);
void makepicstring(char *string, int frame);
struct anim *openanim(char * name, int flags);
int calcimanr(int cfra, struct Tex *tex);
void do_laseroptics_patch(struct ImBuf *ibuf);
void de_interlace_ng(struct ImBuf *ibuf);
void de_interlace_st(struct ImBuf *ibuf);
void load_image(struct Image * ima, int flags, char *relabase, int framenum);
void ima_ibuf_is_nul(struct Tex *tex);
int imagewrap(struct Tex *tex, float *texvec);
int imagewraposa(struct Tex *tex, float *texvec, float *dxt, float *dyt);
void load_image(struct Image * ima, int flags, char *relabase, int framenum);
void converttopremul(struct ImBuf *ibuf);
void makemipmap(struct Image *ima);
#ifdef __cplusplus
}

@ -1,55 +0,0 @@
/**
* blenlib/BKE_osa_types.h (mar-2001 nzc)
*
* $Id$
*
* ***** 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 *****
*/
#ifndef BKE_OSA_TYPES_H
#define BKE_OSA_TYPES_H
/* typedef struct Osa */
typedef struct RE_Osa
{
float dxco[3], dyco[3];
float dxlo[3], dylo[3], dxgl[3], dygl[3], dxuv[3], dyuv[3];
float dxref[3], dyref[3], dxorn[3], dyorn[3];
float dxno[3], dyno[3], dxview, dyview;
float dxlv[3], dylv[3];
float dxwin[3], dywin[3];
float dxsticky[3], dysticky[3];
float dxrefract[3], dyrefract[3];
} Osa;
/* extern Osa O; */
/* This one used to be done in render/extern/include/render.h, because
memory was allocated in that module. (nzc)*/
#endif

@ -34,6 +34,9 @@
#ifndef BKE_PACKEDFILE_H
#define BKE_PACKEDFILE_H
#define RET_OK 0
#define RET_ERROR 1
struct PackedFile;
struct VFont;
struct bSample;

@ -40,6 +40,21 @@ struct Base;
struct AviCodecData;
struct QuicktimeCodecData;
/* sequence related defines */
#define WHILE_SEQ(base) { \
int totseq_, seq_; Sequence **seqar; \
build_seqar( base, &seqar, &totseq_); \
for(seq_ = 0; seq_ < totseq_; seq_++) { \
seq= seqar[seq_];
#define END_SEQ } \
if(seqar) MEM_freeN(seqar); \
}
void free_avicodecdata(struct AviCodecData *acd);
void free_qtcodecdata(struct QuicktimeCodecData *acd);
void free_scene(struct Scene *me);

@ -44,6 +44,12 @@
#define TRUE 1
#endif
/* also fill in structs itself, dna cannot handle defines, duplicate in blendef.h still */
#ifndef FILE_MAXDIR
#define FILE_MAXDIR 160
#define FILE_MAXFILE 80
#endif
#define ELEM(a, b, c) ( (a)==(b) || (a)==(c) )
#define ELEM3(a, b, c, d) ( ELEM(a, b, c) || (a)==(d) )
#define ELEM4(a, b, c, d, e) ( ELEM(a, b, c) || ELEM(a, d, e) )
@ -67,18 +73,6 @@
#define MAX3(x,y,z) MAX2( MAX2((x),(y)) , (z) )
#define MAX4(x,y,z,a) MAX2( MAX2((x),(y)) , MAX2((z),(a)) )
#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
#define INIT_MINMAX(min, max) (min)[0]= (min)[1]= (min)[2]= 1.0e30; (max)[0]= (max)[1]= (max)[2]= -1.0e30;
#define INIT_MINMAX2(min, max) (min)[0]= (min)[1]= 1.0e30; (max)[0]= (max)[1]= -1.0e30;
@ -95,17 +89,32 @@
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];
/* interferes elsewhere */
/* also fill in structs itself, dna cannot handle defines */
#define FILE_MAXDIR 160
#define FILE_MAXFILE 80
#define MINSIZE(val, size) ( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val)))
/* some math and copy defines */
#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
#define ABS(a) ( (a)<0 ? (-(a)) : (a) )
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
#define LONGCOPY(a, b, c) {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
/* some misc stuff.... */
#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a))
#define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);}
#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1)
#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
/* this weirdo pops up in two places ... */
#if !defined(WIN32) && !defined(__BeOS)
@ -146,28 +155,6 @@
#define ENDB MAKE_ID('E','N','D','B')
/* This should, of course, become a function */
#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev) \
\
if( (cyclv)==0 && a==(sizev)-1) break; \
if(cyclu) { \
p1= sizeu*a; \
p2= p1+ sizeu-1; \
p3= p1+ sizeu; \
p4= p2+ sizeu; \
b= 0; \
} \
else { \
p2= sizeu*a; \
p1= p2+1; \
p4= p2+ sizeu; \
p3= p1+ sizeu; \
b= 1; \
} \
if( (cyclv) && a==sizev-1) { \
p3-= sizeu*sizev; \
p4-= sizeu*sizev; \
}
/* This one rotates the bytes in an int */
#define SWITCH_INT(a) { \
@ -176,131 +163,19 @@
s_i=p_i[0]; p_i[0]=p_i[3]; p_i[3]=s_i; \
s_i=p_i[1]; p_i[1]=p_i[2]; p_i[2]=s_i; }
/* More brain damage. Only really used by packedFile.c */
// return values
#define RET_OK 0
#define RET_ERROR 1
/* and these aren't used at all */
/* #define RET_CANCEL 2 */
/* #define RET_YES (1 == 1) */
/* #define RET_NO (1 == 0) */
/* sequence related defines */
#define WHILE_SEQ(base) { \
int totseq_, seq_; Sequence **seqar; \
build_seqar( base, &seqar, &totseq_); \
for(seq_ = 0; seq_ < totseq_; seq_++) { \
seq= seqar[seq_];
#define END_SEQ } \
if(seqar) MEM_freeN(seqar); \
}
/* not really sure about these... some kind of event codes ?*/
/* INFO: 300 */
/* pas op: ook in filesel.c en editobject.c */
#define B_INFOSCR 301
#define B_INFODELSCR 302
#define B_INFOSCE 304
#define B_INFODELSCE 305
#define B_FILEMENU 306
#define B_PACKFILE 307
/* From iff.h, but seemingly detached from anything else... To which
* encoding scheme do they belong? */
#define AMI (1 << 31)
#define CDI (1 << 30)
#define Anim (1 << 29)
#define TGA (1 << 28)
#define JPG (1 << 27)
#define TIM (1 << 26)
#define TIM_CLUT (010)
#define TIM_4 (TIM | TIM_CLUT | 0)
#define TIM_8 (TIM | TIM_CLUT | 1)
#define TIM_16 (TIM | 2)
#define TIM_24 (TIM | 3)
#define RAWTGA (TGA | 1)
#define JPG_STD (JPG | (0 << 8))
#define JPG_VID (JPG | (1 << 8))
#define JPG_JST (JPG | (2 << 8))
#define JPG_MAX (JPG | (3 << 8))
#define JPG_MSK (0xffffff00)
#define AM_ham (0x0800 | AMI)
#define AM_hbrite (0x0080 | AMI)
#define AM_lace (0x0004 | AMI)
#define AM_hires (0x8000 | AMI)
#define AM_hblace (AM_hbrite | AM_lace)
#define AM_hilace (AM_hires | AM_lace)
#define AM_hamlace (AM_ham | AM_lace)
#define RGB888 1
#define RGB555 2
#define DYUV 3
#define CLUT8 4
#define CLUT7 5
#define CLUT4 6
#define CLUT3 7
#define RL7 8
#define RL3 9
#define MPLTE 10
#define DYUV1 0
#define DYUVE 1
#define CD_rgb8 (RGB888 | CDI)
#define CD_rgb5 (RGB555 | CDI)
#define CD_dyuv (DYUV | CDI)
#define CD_clut8 (CLUT8 | CDI)
#define CD_clut7 (CLUT7 | CDI)
#define CD_clut4 (CLUT4 | CDI)
#define CD_clut3 (CLUT3 | CDI)
#define CD_rl7 (RL7 | CDI)
#define CD_rl3 (RL3 | CDI)
#define CD_mplte (MPLTE | CDI)
#define C233 1
#define YUVX 2
#define HAMX 3
#define TANX 4
#define AN_c233 (Anim | C233)
#define AN_yuvx (Anim | YUVX)
#define AN_hamx (Anim | HAMX)
#define AN_tanx (Anim | TANX)
#define IMAGIC 0732
/* This used to reside in render.h. It does some texturing. */
#define BRICON Tin= (Tin-0.5)*tex->contrast+tex->bright-0.5; \
if(Tin<0.0) Tin= 0.0; else if(Tin>1.0) Tin= 1.0;
#define BRICONRGB Tr= tex->rfac*((Tr-0.5)*tex->contrast+tex->bright-0.5); \
if(Tr<0.0) Tr= 0.0; \
Tg= tex->gfac*((Tg-0.5)*tex->contrast+tex->bright-0.5); \
if(Tg<0.0) Tg= 0.0; \
Tb= tex->bfac*((Tb-0.5)*tex->contrast+tex->bright-0.5); \
if(Tb<0.0) Tb= 0.0;
/* mystifying stuff from blendef... */
#define SELECT 1
#define ACTIVE 2
#define NOT_YET 0
/* ???? */
/* Bit operations */
#define BTST(a,b) ( ( (a) & 1<<(b) )!=0 )
#define BSET(a,b) ( (a) | 1<<(b) )
#define BCLR(a,b) ( (a) & ~(1<<(b)) )
/* bit-row */
#define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) )
/* needed for material.c*/
#define REDRAWBUTSMAT 0x4015
/* useless game shit */
#define MA_FH_NOR 2
#ifdef GS
#undef GS
#endif
#define GS(a) (*((short *)(a)))
#endif

@ -195,10 +195,9 @@ int BPY_call_importloader(char *name)
#define INT 96
/* struct EnvMap; */
/* struct Tex; */
float Ta, Tb, Tg, Tin, Tr;
void do_material_tex(ShadeInput *shi){}
void externtex(struct MTex *mtex, float *vec){}
void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta){}
void init_render_textures(void){}
void end_render_textures(void){}
@ -210,9 +209,7 @@ int RE_envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt){
return 0;
}
void RE_calc_R_ref(void){}
char texstr[20][12]; /* buttons.c */
Osa O;
/* editsca.c */
void make_unique_prop_names(char *str) {}

@ -91,6 +91,7 @@
#include "BIF_mainqueue.h" // mainqenter for onload script
#include "mydevice.h"
#include "nla.h"
#include "blendef.h"
Global G;
UserDef U;
@ -318,8 +319,8 @@ static void setup_app_data(BlendFileData *bfd, char *filename)
G.scene= curscene;
}
else {
R.winpos= bfd->winpos;
R.displaymode= bfd->displaymode;
G.winpos= bfd->winpos;
G.displaymode= bfd->displaymode;
G.fileflags= bfd->fileflags;
G.curscreen= bfd->curscreen;
G.scene= G.curscreen->scene;

@ -521,18 +521,24 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
int a, back;
if(ma==0) return;
shi.mat= ma;
shi.matren= ma->ren;
shi.vlr= NULL; // have to do this!
ma= shi.matren;
// copy all relevant material vars, note, keep this synced with render_types.h
memcpy(&shi.r, &shi.mat->r, 23*sizeof(float));
// set special cases:
shi.har= shi.mat->har;
shi.osatex= 0; // also prevents reading vlr
VECCOPY(shi.vn, nor);
if(ma->mode & MA_VERTEXCOLP) {
if(vertcol) {
ma->r= vertcol[3]/255.0;
ma->g= vertcol[2]/255.0;
ma->b= vertcol[1]/255.0;
shi.r= vertcol[3]/255.0;
shi.g= vertcol[2]/255.0;
shi.b= vertcol[1]/255.0;
}
}
@ -565,24 +571,19 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
shi.ref[2]= (-1.0+inp*shi.vn[2]);
}
if(ma->mode & MA_VERTEXCOLP) {
shi.mat->r= ma->r;
shi.mat->g= ma->g;
shi.mat->b= ma->b;
}
do_material_tex(&shi);
}
if(ma->mode & MA_SHLESS) {
if(vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) {
col1[3]= vertcol[3]*ma->r;
col1[2]= vertcol[2]*ma->g;
col1[1]= vertcol[1]*ma->b;
col1[3]= vertcol[3]*shi.r;
col1[2]= vertcol[2]*shi.g;
col1[1]= vertcol[1]*shi.b;
}
else {
col1[3]= (255.0*ma->r);
col1[2]= (255.0*ma->g);
col1[1]= (255.0*ma->b);
col1[3]= (255.0*shi.r);
col1[2]= (255.0*shi.g);
col1[1]= (255.0*shi.b);
}
if(col2) {
col2[3]= col1[3];
@ -593,14 +594,14 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
}
if( vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) {
diff1[0]= diff2[0]= ma->r*(ma->emit+vertcol[3]/255.0);
diff1[1]= diff2[1]= ma->g*(ma->emit+vertcol[2]/255.0);
diff1[2]= diff2[2]= ma->b*(ma->emit+vertcol[1]/255.0);
diff1[0]= diff2[0]= shi.r*(shi.emit+vertcol[3]/255.0);
diff1[1]= diff2[1]= shi.g*(shi.emit+vertcol[2]/255.0);
diff1[2]= diff2[2]= shi.b*(shi.emit+vertcol[1]/255.0);
}
else {
diff1[0]= diff2[0]= ma->r*ma->emit;
diff1[1]= diff2[1]= ma->g*ma->emit;
diff1[2]= diff2[2]= ma->b*ma->emit;
diff1[0]= diff2[0]= shi.r*shi.emit;
diff1[1]= diff2[1]= shi.g*shi.emit;
diff1[2]= diff2[2]= shi.b*shi.emit;
}
shi.view[0]= 0.0;
@ -679,7 +680,7 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
back= 1;
is= -is;
}
inp= is*lampdist*ma->ref;
inp= is*lampdist*shi.refl;
if(back==0) {
add_to_diffuse(diff1, &shi, is, inp*fl->r, inp*fl->g, inp*fl->b);
@ -692,20 +693,20 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
//diff2[1]+= inp*fl->g;
//diff2[2]+= inp*fl->b;
}
if(ma->spec && (fl->mode & LA_NO_SPEC)==0) {
if(shi.spec!=0.0 && (fl->mode & LA_NO_SPEC)==0) {
float specfac;
if(ma->spec_shader==MA_SPEC_PHONG)
specfac= Phong_Spec(nor, lv, shi.view, ma->har);
specfac= Phong_Spec(nor, lv, shi.view, shi.har);
else if(ma->spec_shader==MA_SPEC_COOKTORR)
specfac= CookTorr_Spec(nor, lv, shi.view, ma->har);
specfac= CookTorr_Spec(nor, lv, shi.view, shi.har);
else if(ma->spec_shader==MA_SPEC_BLINN)
specfac= Blinn_Spec(nor, lv, shi.view, ma->refrac, (float)ma->har);
specfac= Blinn_Spec(nor, lv, shi.view, ma->refrac, (float)shi.har);
else
specfac= Toon_Spec(nor, lv, shi.view, ma->param[2], ma->param[3]);
if(specfac>0) {
t= specfac*ma->spec*lampdist;
t= specfac*shi.spec*lampdist;
if(back==0) {
if(ma->mode & MA_RAMP_SPEC) {
float spec[3];
@ -715,9 +716,9 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
isb+= t*(fl->b * spec[2]);
}
else {
isr+= t*(fl->r * ma->specr);
isg+= t*(fl->g * ma->specg);
isb+= t*(fl->b * ma->specb);
isr+= t*(fl->r * shi.specr);
isg+= t*(fl->g * shi.specg);
isb+= t*(fl->b * shi.specb);
}
}
else if(col2) {
@ -729,9 +730,9 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
isb1+= t*(fl->b * spec[2]);
}
else {
isr1+= t*(fl->r * ma->specr);
isg1+= t*(fl->g * ma->specg);
isb1+= t*(fl->b * ma->specb);
isr1+= t*(fl->r * shi.specr);
isg1+= t*(fl->g * shi.specg);
isb1+= t*(fl->b * shi.specb);
}
}
}
@ -742,13 +743,13 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(diff1, &shi);
if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(&isr, &isg, &isb, &shi);
a= 256*(diff1[0] + ma->ambr +isr);
a= 256*(diff1[0] + shi.ambr +isr);
if(a>255) col1[3]= 255;
else col1[3]= a;
a= 256*(diff1[1] + ma->ambg +isg);
a= 256*(diff1[1] + shi.ambg +isg);
if(a>255) col1[2]= 255;
else col1[2]= a;
a= 256*(diff1[2] + ma->ambb +isb);
a= 256*(diff1[2] + shi.ambb +isb);
if(a>255) col1[1]= 255;
else col1[1]= a;
@ -756,13 +757,13 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
if(ma->mode & MA_RAMP_COL) ramp_diffuse_result(diff2, &shi);
if(ma->mode & MA_RAMP_SPEC) ramp_spec_result(&isr1, &isg1, &isb1, &shi);
a= 256*(diff2[0] + ma->ambr +isr1);
a= 256*(diff2[0] + shi.ambr +isr1);
if(a>255) col2[3]= 255;
else col2[3]= a;
a= 256*(diff2[1] + ma->ambg +isg1);
a= 256*(diff2[1] + shi.ambg +isg1);
if(a>255) col2[2]= 255;
else col2[2]= a;
a= 256*(diff2[2] + ma->ambb +isb1);
a= 256*(diff2[2] + shi.ambb +isb1);
if(a>255) col2[1]= 255;
else col2[1]= a;
}
@ -935,7 +936,7 @@ void shadeDispList(Object *ob)
ma= give_current_material(ob, a+1);
if(ma) {
init_render_material(ma);
if(ma->ren->texco & TEXCO_ORCO) need_orco= 1;
if(ma->texco & TEXCO_ORCO) need_orco= 1;
}
}
@ -2263,7 +2264,7 @@ void imagestodisplist(void)
ListBase _wireframe, *wireframe;
DispList *dl;
Segment *seg;
float *data, xfac, yfac, xsi, ysi, vec[3];
float *data, xfac, yfac, xsi, ysi, vec[3], dum;
int tot;
_wireframe.first= 0;
@ -2285,7 +2286,7 @@ void imagestodisplist(void)
tex= ma->mtex[0]->tex;
/* this takes care of correct loading of new imbufs */
externtex(ma->mtex[0], vec);
externtex(ma->mtex[0], vec, &dum, &dum, &dum, &dum, &dum);
if(tex->type==TEX_IMAGE && tex->ima && tex->ima->ibuf) {

@ -35,6 +35,10 @@
#include <math.h>
#include <stdlib.h>
#ifdef WIN32
#include "BLI_winstuff.h"
#endif
#include "MEM_guardedalloc.h"
#include "DNA_listBase.h"
#include "DNA_effect_types.h"
@ -71,6 +75,9 @@
#include "BKE_screen.h"
#include "BKE_utildefines.h"
#include "render.h" // externtex, bad level call (ton)
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@ -311,39 +318,38 @@ void where_is_particle(PartEff *paf, Particle *pa, float ctime, float *vec)
void particle_tex(MTex *mtex, PartEff *paf, float *co, float *no)
{
extern float Tin, Tr, Tg, Tb;
extern void externtex(struct MTex *mtex, float *vec);
float tin, tr, tg, tb, ta;
float old;
externtex(mtex, co);
externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
if(paf->texmap==PAF_TEXINT) {
Tin*= paf->texfac;
no[0]+= Tin*paf->defvec[0];
no[1]+= Tin*paf->defvec[1];
no[2]+= Tin*paf->defvec[2];
tin*= paf->texfac;
no[0]+= tin*paf->defvec[0];
no[1]+= tin*paf->defvec[1];
no[2]+= tin*paf->defvec[2];
}
else if(paf->texmap==PAF_TEXRGB) {
no[0]+= (Tr-0.5f)*paf->texfac;
no[1]+= (Tg-0.5f)*paf->texfac;
no[2]+= (Tb-0.5f)*paf->texfac;
no[0]+= (tr-0.5f)*paf->texfac;
no[1]+= (tg-0.5f)*paf->texfac;
no[2]+= (tb-0.5f)*paf->texfac;
}
else { /* PAF_TEXGRAD */
old= Tin;
old= tin;
co[0]+= paf->nabla;
externtex(mtex, co);
no[0]+= (old-Tin)*paf->texfac;
externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
no[0]+= (old-tin)*paf->texfac;
co[0]-= paf->nabla;
co[1]+= paf->nabla;
externtex(mtex, co);
no[1]+= (old-Tin)*paf->texfac;
externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
no[1]+= (old-tin)*paf->texfac;
co[1]-= paf->nabla;
co[2]+= paf->nabla;
externtex(mtex, co);
no[2]+= (old-Tin)*paf->texfac;
externtex(mtex, co, &tin, &tr, &tg, &tb, &ta);
no[2]+= (old-tin)*paf->texfac;
}
}

@ -123,6 +123,8 @@
#include "BPY_extern.h"
#include "blendef.h"
static int is_dxf(char *str);
static void dxf_read(char *filename);
static int is_stl(char *str);

File diff suppressed because it is too large Load Diff

@ -59,9 +59,7 @@
#include "BPY_extern.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "render.h"
void free_material(Material *ma)
{
@ -70,9 +68,6 @@ void free_material(Material *ma)
BPY_free_scriptlink(&ma->scriptlink);
if(ma->ren) MEM_freeN(ma->ren);
ma->ren= NULL;
for(a=0; a<MAX_MTEX; a++) {
mtex= ma->mtex[a];
if(mtex && mtex->tex) mtex->tex->id.us--;
@ -543,15 +538,9 @@ void init_render_material(Material *ma)
MTex *mtex;
int a, needuv=0;
if(ma->ren) return;
if(ma->flarec==0) ma->flarec= 1;
ma->ren= MEM_mallocN(sizeof(Material), "initrendermaterial");
memcpy(ma->ren, ma, sizeof(Material));
/* add all texcoflags from mtex */
ma= ma->ren;
ma->texco= 0;
ma->mapto= 0;
for(a=0; a<MAX_MTEX; a++) {
@ -584,9 +573,6 @@ void init_render_material(Material *ma)
}
if(needuv) ma->texco |= NEED_UV;
// optimize, render only checks for ray_mirror value */
if((ma->mode & MA_RAYMIRROR)==0) ma->ray_mirror= 0.0;
// since the raytracer doesnt recalc O structs for each ray, we have to preset them all
if(ma->mode & (MA_RAYMIRROR|MA_RAYTRANSP|MA_SHADOW_TRA)) {
ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM;
@ -613,10 +599,7 @@ void init_render_materials()
void end_render_material(Material *ma)
{
if(ma->ren) MEM_freeN(ma->ren);
ma->ren= 0;
/* XXXX obsolete? check! */
if(ma->mode & (MA_VERTEXCOLP|MA_FACETEXTURE)) {
if( !(ma->mode & MA_HALO) ) {
ma->r= ma->g= ma->b= 1.0;
@ -748,8 +731,6 @@ void delete_material_index()
}
obt= obt->id.next;
}
allqueue(REDRAWBUTSMAT, 0);
/* check indices from mesh */

@ -169,16 +169,15 @@ Scene *add_scene(char *name)
sce->r.framelen= 1.0;
sce->r.frs_sec= 25;
sce->r.postgamma= 1.0;
sce->r.posthue= 1.0;
sce->r.postmul= 1.0;
sce->r.xplay= 640;
sce->r.yplay= 480;
sce->r.freqplay= 60;
sce->r.depth= 32;
if (sce->r.avicodecdata) {
printf("this is not good\n");
}
// sce->r.imtype= R_TARGA;
sce->r.stereomode = 1; // no stereo
strcpy(sce->r.backbuf, "//backbuf");

@ -65,7 +65,6 @@
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "BKE_osa_types.h"
#include "BKE_plugin_types.h"
#include "BKE_bad_level_calls.h"
@ -82,8 +81,6 @@
#include "BKE_ipo.h"
/* ------------------------------------------------------------------------- */
/* All support for plugin textures: */
@ -241,14 +238,11 @@ ColorBand *add_colorband()
int do_colorband(ColorBand *coba, float in, float out[4])
{
/* These vars form the texture channel, in render/intern/texture.c */
extern int Talpha;
CBData *cbd1, *cbd2, *cbd0, *cbd3;
float fac, mfac, t[4];
int a;
if(coba->tot==0) return 0;
Talpha= 1;
cbd1= coba->data;
if(coba->tot==1) {

@ -783,6 +783,10 @@ Vec2Addf(
float *v2
);
void tubemap(float x, float y, float z, float *u, float *v);
void spheremap(float x, float y, float z, float *u, float *v);
#ifdef __cplusplus
}
#endif

@ -2492,3 +2492,38 @@ void cpack_to_rgb(unsigned int col, float *r, float *g, float *b)
*b= (float)(((col)>>16)&0xFF);
*b /= 255.0f;
}
/* *************** PROJECTIONS ******************* */
void tubemap(float x, float y, float z, float *u, float *v)
{
float len;
*v = (z + 1.0) / 2.0;
len= sqrt(x*x+y*y);
if(len>0) {
*u = (1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0;
}
}
/* ------------------------------------------------------------------------- */
void spheremap(float x, float y, float z, float *u, float *v)
{
float len;
len= sqrt(x*x+y*y+z*z);
if(len>0.0) {
if(x==0.0 && y==0.0) *u= 0.0; /* othwise domain error */
else *u = (1.0 - atan2(x,y)/M_PI )/2.0;
z/=len;
*v = 1.0- saacos(z)/M_PI;
}
}
/* ------------------------------------------------------------------------- */

@ -106,32 +106,34 @@
#include "BKE_bad_level_calls.h" // for reopen_text build_seqar (from WHILE_SEQ) open_plugin_seq set_rects_butspace check_imasel_copy
#include "BKE_armature.h" // for precalc_bonelist_irestmats
#include "BKE_action.h"
#include "BKE_constraint.h"
#include "BKE_utildefines.h" // SWITCH_INT WHILE_SEQ END_SEQ DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
#include "BKE_main.h" // for Main
#include "BKE_curve.h"
#include "BKE_effect.h" // for give_parteff
#include "BKE_global.h" // for G
#include "BKE_property.h" // for get_property
#include "BKE_library.h" // for wich_libbase
#include "BKE_texture.h" // for open_plugin_tex
#include "BKE_effect.h" // for give_parteff
#include "BKE_sca.h" // for init_actuator
#include "BKE_main.h" // for Main
#include "BKE_mesh.h" // for ME_ defines (patching)
#include "BKE_armature.h" // for precalc_bonelist_irestmats
#include "BKE_action.h"
#include "BKE_object.h"
#include "BKE_sca.h" // for init_actuator
#include "BKE_scene.h"
#include "BKE_texture.h" // for open_plugin_tex
#include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND
#include "BIF_butspace.h" // for do_versions, patching event codes
#include "BLO_readfile.h"
#include "BLO_undofile.h"
#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
#include "readfile.h"
#include "genfile.h"
#include "BLO_readblenfile.h" // streaming read pipe, for BLO_readblenfile BLO_readblenfilememory
#include "mydevice.h"
#include "blendef.h"
/*
Remark: still a weak point is the newadress() function, that doesnt solve reading from
@ -2012,7 +2014,6 @@ static void direct_link_material(FileData *fd, Material *ma)
ma->ramp_col= newdataadr(fd, ma->ramp_col);
ma->ramp_spec= newdataadr(fd, ma->ramp_spec);
ma->ren= NULL; /* should not be needed, nevertheless... */
}
/* ************ READ MESH ***************** */
@ -4594,11 +4595,24 @@ static void do_versions(Main *main)
}
if(main->versionfile <= 235) {
Tex *tex= main->tex.first;
Scene *sce= main->scene.first;
while(tex) {
if(tex->nabla==0.0) tex->nabla= 0.025;
tex= tex->id.next;
}
while(sce) {
sce->r.postsat= 1.0;
sce= sce->id.next;
}
}
if(main->versionfile <= 236) {
Scene *sce= main->scene.first;
while(sce) {
if(sce->r.postsat==0.0) sce->r.postsat= 1.0;
sce= sce->id.next;
}
}
/* don't forget to set version number in blender.c! */

@ -144,15 +144,17 @@ Important to know is that 'streaming' has been added to files, for Blender Publi
#include "BLI_linklist.h"
#include "BKE_action.h"
#include "BKE_utildefines.h" // for KNOTSU KNOTSV WHILE_SEQ END_SEQ defines
#include "BKE_bad_level_calls.h" // build_seqar (from WHILE_SEQ) free_oops error
#include "BKE_curve.h"
#include "BKE_constraint.h"
#include "BKE_main.h" // G.main
#include "BKE_global.h" // for G
#include "BKE_screen.h" // for waitcursor
#include "BKE_packedFile.h" // for packAll
#include "BKE_library.h" // for set_listbasepointers
#include "BKE_main.h" // G.main
#include "BKE_packedFile.h" // for packAll
#include "BKE_screen.h" // for waitcursor
#include "BKE_scene.h" // for do_seq
#include "BKE_sound.h" /* ... and for samples */
#include "BKE_utildefines.h" // for defines
#include "GEN_messaging.h"
@ -1494,8 +1496,8 @@ static void write_global(WriteData *wd)
fg.curscreen= G.curscreen;
fg.curscene= G.scene;
fg.displaymode= R.displaymode;
fg.winpos= R.winpos;
fg.displaymode= G.displaymode;
fg.winpos= G.winpos;
fg.fileflags= (G.fileflags & ~G_FILE_NO_UI); // prevent to save this, is not good convention, and feature with concerns...
fg.globalf= G.f;

@ -34,7 +34,6 @@
#define BIF_MESHTOOLS_H
extern void join_mesh(void);
extern void make_sticky(void);
extern void fasterdraw(void);
extern void slowerdraw(void);

@ -46,6 +46,7 @@ void BIF_do_ogl_render(struct View3D *v3d, int anim);
void BIF_renderwin_set_for_ogl_render(void);
void BIF_renderwin_set_custom_cursor(unsigned char mask[16][2], unsigned char bitmap[16][2]);
void BIF_redraw_render_rect(void);
void BIF_swap_render_rects(void);
void BIF_toggle_render_display(void);

@ -34,6 +34,7 @@
#ifndef BSE_SEQUENCE_H
#define BSE_SEQUENCE_H
struct PluginSeq;
struct StripElem;
struct Strip;

@ -31,12 +31,6 @@
#ifndef BLENDEF_H
#define BLENDEF_H
#ifdef WIN32
#else
#ifndef __BeOS
#define O_BINARY 0
#endif
#endif
/* **************** MAX ********************* */
@ -53,6 +47,13 @@
#define MAXFLOAT ((float)3.40282347e+38)
#endif
/* also fill in structs itself, dna cannot handle defines, duplicate with utildefines.h still */
#ifndef FILE_MAXDIR
#define FILE_MAXDIR 160
#define FILE_MAXFILE 80
#endif
#include <float.h>
@ -60,40 +61,6 @@
/* **************** GENERAL ********************* */
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
#define VECADD(v1,v2,v3) {*(v1)= *(v2) + *(v3); *(v1+1)= *(v2+1) + *(v3+1); *(v1+2)= *(v2+2) + *(v3+2);}
#define VECSUB(v1,v2,v3) {*(v1)= *(v2) - *(v3); *(v1+1)= *(v2+1) - *(v3+1); *(v1+2)= *(v2+2) - *(v3+2);}
#define INPR(v1, v2) ( (v1)[0]*(v2)[0] + (v1)[1]*(v2)[1] + (v1)[2]*(v2)[2] )
#define CLAMP(a, b, c) if((a)<(b)) (a)=(b); else if((a)>(c)) (a)=(c)
#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a))
#define CLAMPTEST(a, b, c) if((b)<(c)) {CLAMP(a, b, c);} else {CLAMP(a, c, b);}
#define IS_EQ(a,b) ((fabs((double)(a)-(b)) >= (double) FLT_EPSILON) ? 0 : 1)
#define INIT_MINMAX(min, max) (min)[0]= (min)[1]= (min)[2]= 1.0e30; (max)[0]= (max)[1]= (max)[2]= -1.0e30;
#define DO_MINMAX(vec, min, max) if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (min)[2]>(vec)[2] ) (min)[2]= (vec)[2]; \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1]; \
if( (max)[2]<(vec)[2] ) (max)[2]= (vec)[2]; \
#define DO_MINMAX2(vec, min, max) if( (min)[0]>(vec)[0] ) (min)[0]= (vec)[0]; \
if( (min)[1]>(vec)[1] ) (min)[1]= (vec)[1]; \
if( (max)[0]<(vec)[0] ) (max)[0]= (vec)[0]; \
if( (max)[1]<(vec)[1] ) (max)[1]= (vec)[1];
#define MINSIZE(val, size) ( ((val)>=0.0) ? (((val)<(size)) ? (size): (val)) : ( ((val)>(-size)) ? (-size) : (val)))
#define BTST(a,b) ( ( (a) & 1<<(b) )!=0 )
#define BCLR(a,b) ( (a) & ~(1<<(b)) )
#define BSET(a,b) ( (a) | 1<<(b) )
/* bit-row */
#define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) )
// return values
#define RET_OK 0
@ -102,8 +69,6 @@
#define RET_YES (1 == 1)
#define RET_NO (1 == 0)
#define LONGCOPY(a, b, c) {int lcpc=c, *lcpa=(int *)a, *lcpb=(int *)b; while(lcpc-->0) *(lcpa++)= *(lcpb++);}
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
/* big endian */
#define MAKE_ID2(c, d) ( (c)<<8 | (d) )
@ -140,9 +105,6 @@
#define ISPOIN4(a, b, c, d, e) ( (a->b) && (a->c) && (a->d) && (a->e) )
#define KNOTSU(nu) ( (nu)->orderu+ (nu)->pntsu+ (nu->orderu-1)*((nu)->flagu & 1) )
#define KNOTSV(nu) ( (nu)->orderv+ (nu)->pntsv+ (nu->orderv-1)*((nu)->flagv & 1) )
/* psfont */
#define FNT_PDRAW 1
#define FNT_HAEBERLI 2
@ -397,64 +359,9 @@
#define B_PERCENTSUBD 0x40
/* ***************** DISPLIST ***************** */
#define DL_POLY 0
#define DL_SEGM 1
#define DL_SURF 2
#define DL_TRIA 3
#define DL_INDEX3 4
#define DL_INDEX4 5
#define DL_VERTCOL 6
#define DL_VERTS 7
#define DL_NORS 8
#define DL_SURFINDEX(cyclu, cyclv, sizeu, sizev) \
\
if( (cyclv)==0 && a==(sizev)-1) break; \
if(cyclu) { \
p1= sizeu*a; \
p2= p1+ sizeu-1; \
p3= p1+ sizeu; \
p4= p2+ sizeu; \
b= 0; \
} \
else { \
p2= sizeu*a; \
p1= p2+1; \
p4= p2+ sizeu; \
p3= p1+ sizeu; \
b= 1; \
} \
if( (cyclv) && a==sizev-1) { \
p3-= sizeu*sizev; \
p4-= sizeu*sizev; \
}
/* DISPLAYMODE */
#define R_DISPLAYVIEW 0
#define R_DISPLAYWIN 1
#define R_DISPLAYAUTO 2
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
#define RCOMP 3
#define GCOMP 2
#define BCOMP 1
#define ACOMP 0
#else
#define RCOMP 0
#define GCOMP 1
#define BCOMP 2
#define ACOMP 3
#endif
#ifdef GS
#undef GS
#endif
#define GS(a) (*((short *)(a)))
#endif

@ -274,6 +274,7 @@ void test_idbutton_cb(void *namev, void *arg2_unused);
#define B_SELECTCODEC 1639
#define B_RTCHANGED 1640
#define B_SWITCHRENDER 1641
#define B_FBUF_REDO 1642
#ifdef __NLA
/* *********************** */

@ -93,7 +93,6 @@ typedef struct Material {
struct MTex *mtex[10];
struct Ipo *ipo;
struct Material *ren;
/* dynamic properties */
float friction, fh, reflect;

@ -178,6 +178,8 @@ typedef struct RenderData {
* 14: motion blur
* 15: use unified renderer for this pic
* 16: enable raytracing
* 17: gauss sampling for subpixels
* 18: keep float buffer after render
*/
int mode;
@ -208,9 +210,9 @@ typedef struct RenderData {
* The gamma for the normal rendering. Used when doing
* oversampling, to correctly blend subpixels to pixels. */
float gamma, gauss;
/** post-production settings. Don't really belong here */
float postmul, postgamma, postadd, postigamma;
/** post-production settings. */
float postmul, postgamma, postadd, postigamma, posthue, postsat;
/* Dither noise intensity */
float dither_intensity;
float pad_dither;
@ -298,6 +300,8 @@ typedef struct Scene {
#define R_UNIFIED 0x8000
#define R_RAYTRACE 0x10000
#define R_GAUSS 0x20000
#define R_FBUF 0x40000
#define R_THREADS 0x80000
/* yafray: renderer flag (not only exclusive to yafray) */
#define R_INTERN 0
@ -347,6 +351,7 @@ typedef struct Scene {
#define R_LAMPHALO 8
#define R_RENDERING 16
#define R_ANIMRENDER 32
#define R_REDRAW_PRV 64
/* vlakren->flag (vlak = face in dutch) char!!! */
#define R_SMOOTH 1

@ -151,7 +151,7 @@ typedef struct Tex {
short extend, len;
float checkerdist, nabla;
short frames, offset, sfra, fie_ima;
float norfac, *nor;
float norfac;
struct Ipo *ipo;
struct Image *ima;

@ -44,7 +44,6 @@
#include <butspace.h>
#include <BKE_bad_level_calls.h>
#include "sceneRender.h"
#include "render_types.h"
#include "blendef.h"
#include "Scene.h"
#include "gen_utils.h"
@ -792,30 +791,30 @@ PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected a list" ) );
R.winpos = 0;
G.winpos = 0;
for( x = 0; x < PyList_Size( list ); x++ ) {
if( !PyArg_Parse( PyList_GetItem( list, x ), "s", &loc ) ) {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"python list not parseable\n" );
}
if( strcmp( loc, "SW" ) == 0 || strcmp( loc, "sw" ) == 0 )
R.winpos |= 1;
G.winpos |= 1;
else if( strcmp( loc, "S" ) == 0 || strcmp( loc, "s" ) == 0 )
R.winpos |= 2;
G.winpos |= 2;
else if( strcmp( loc, "SE" ) == 0 || strcmp( loc, "se" ) == 0 )
R.winpos |= 4;
G.winpos |= 4;
else if( strcmp( loc, "W" ) == 0 || strcmp( loc, "w" ) == 0 )
R.winpos |= 8;
G.winpos |= 8;
else if( strcmp( loc, "C" ) == 0 || strcmp( loc, "c" ) == 0 )
R.winpos |= 16;
G.winpos |= 16;
else if( strcmp( loc, "E" ) == 0 || strcmp( loc, "e" ) == 0 )
R.winpos |= 32;
G.winpos |= 32;
else if( strcmp( loc, "NW" ) == 0 || strcmp( loc, "nw" ) == 0 )
R.winpos |= 64;
G.winpos |= 64;
else if( strcmp( loc, "N" ) == 0 || strcmp( loc, "n" ) == 0 )
R.winpos |= 128;
G.winpos |= 128;
else if( strcmp( loc, "NE" ) == 0 || strcmp( loc, "ne" ) == 0 )
R.winpos |= 256;
G.winpos |= 256;
else
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"list contains unknown string\n" );
@ -828,7 +827,7 @@ PyObject *M_Render_SetRenderWinPos( PyObject * self, PyObject * args )
//------------------------------------Render.EnableDispView() -----------
PyObject *M_Render_EnableDispView( PyObject * self )
{
R.displaymode = R_DISPLAYVIEW;
G.displaymode = R_DISPLAYVIEW;
allqueue( REDRAWBUTSSCENE, 0 );
return EXPP_incr_ret( Py_None );
@ -837,7 +836,7 @@ PyObject *M_Render_EnableDispView( PyObject * self )
//------------------------------------Render.EnableDispWin() ------------
PyObject *M_Render_EnableDispWin( PyObject * self )
{
R.displaymode = R_DISPLAYWIN;
G.displaymode = R_DISPLAYWIN;
allqueue( REDRAWBUTSSCENE, 0 );
return EXPP_incr_ret( Py_None );
@ -919,14 +918,14 @@ PyObject *RenderData_Play( BPy_RenderData * self )
}
}
if( BLI_exist( file ) ) {
calc_renderwin_rectangle( R.winpos, pos, size );
calc_renderwin_rectangle( G.winpos, pos, size );
sprintf( str, "%s -a -p %d %d \"%s\"", bprogname, pos[0],
pos[1], file );
system( str );
} else {
makepicstring( file, self->renderContext->sfra );
if( BLI_exist( file ) ) {
calc_renderwin_rectangle( R.winpos, pos, size );
calc_renderwin_rectangle( G.winpos, pos, size );
sprintf( str, "%s -a -p %d %d \"%s\"", bprogname,
pos[0], pos[1], file );
system( str );

@ -1,6 +1,7 @@
#!/usr/bin/python
Import ('user_options_dict')
Import ('library_env')
Import ('sdl_env')
render_env = library_env.Copy ()
@ -9,6 +10,7 @@ source_files = ['intern/source/RE_callbacks.c',
'intern/source/envmap.c',
'intern/source/errorHandler.c',
'intern/source/gammaCorrectionTables.c',
'intern/source/imagetexture.c',
'intern/source/initrender.c',
'intern/source/jitter.c',
'intern/source/pixelblending.c',
@ -36,6 +38,7 @@ render_env.Append (CPPPATH = ['intern/include',
'../quicktime',
'../include',
'../../kernel/gen_messaging',
'../yafray'])
'../yafray'] +
sdl_env['CPPPATH'])
render_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/blender_render', source=source_files)

@ -40,9 +40,6 @@
/* fixes. I think it is risky to always include it... */
/* ------------------------------------------------------------------------- */
/* fix for OSA and defmaterial extern */
#include "BKE_osa_types.h"
#include "DNA_material_types.h"
#ifdef __cplusplus
extern "C" {
@ -69,8 +66,6 @@ extern "C" {
/* ------------------------------------------------------------------------- */
extern RE_Render R; /* rendercore.c */
extern Osa O; /* rendercore.c */
extern Material defmaterial; /* initrender.c */
extern unsigned short *igamtab1; /* initrender.c */
extern unsigned short *gamtab; /* initrender.c */
@ -80,7 +75,7 @@ struct View3D;
/* Function definitions */
/* */
/* All functions that need to be externally visible must be declared here. */
/* Currently, this interface contains 29 functions and 11 callbacks. */
/* Currently, this interface contains 38 functions and 11 callbacks. */
/* ------------------------------------------------------------------------- */
@ -88,11 +83,12 @@ struct View3D;
/* shadbuf.c (1) */
/* ------------------------------------------------------------------------- */
/* only for renderconvertor */
void RE_initshadowbuf(struct LampRen *lar, float mat[][4]);
/* ------------------------------------------------------------------------- */
/* initrender (14) */
/* initrender (9) */
/* ------------------------------------------------------------------------- */
struct View3D;
@ -107,7 +103,7 @@ struct View3D;
void RE_initrender(struct View3D *ogl_render_view3d);
/**
*
* only for renderconvertor
*/
void RE_setwindowclip(int mode, int jmode);
@ -117,12 +113,12 @@ void RE_setwindowclip(int mode, int jmode);
*/
void RE_animrender(struct View3D *ogl_render_view3d);
void RE_free_render_data(void);
void RE_free_filt_mask(void);
void RE_init_filt_mask(void);
void RE_init_render_data(void);
/* jitterate is used by blenkernel effect */
void RE_jitterate1(float *jit1, float *jit2, int num, float rad1);
void RE_jitterate2(float *jit1, float *jit2, int num, float rad2);
void RE_make_existing_file(char *name);
void RE_floatbuffer_to_output(void);
/* ------------------------------------------------------------------------- */
/* zbuf (2) */
@ -151,7 +147,7 @@ void RE_zbufferall_radio(struct RadView *vw, struct RNode **rg_elem, int rg_t
/* ------------------------------------------------------------------------- */
/* texture */
/* texture (9) */
/* ------------------------------------------------------------------------- */
struct MTex;
struct Tex;
@ -161,17 +157,11 @@ void end_render_textures(void);
void init_render_texture(struct Tex *tex);
void end_render_texture(struct Tex *tex);
void tubemap(float x, float y, float z, float *adr1, float *adr2);
void spheremap(float x, float y, float z, float *adr1, float *adr2);
void do_material_tex(ShadeInput *shi);
void externtex(struct MTex *mtex, float *vec);
void externtexcol(struct MTex *mtex, float *orco, char *col);
void do_lamp_tex(struct LampRen *la, float *lavec, ShadeInput *shi);
void do_sky_tex(float *);
int multitex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex);
void do_lamp_tex(struct LampRen *la, float *lavec, ShadeInput *shi, float *fcol);
int multitex_ext(struct Tex *tex, float *texvec, float *tin, float *tr, float *tg, float *tb, float *ta);
void externtex(struct MTex *mtex, float *vec, float *tin, float *tr, float *tg, float *tb, float *ta);
/* ------------------------------------------------------------------------- */
/* envmap (4) */
@ -186,7 +176,7 @@ struct EnvMap *RE_add_envmap(void);
struct EnvMap *RE_copy_envmap(struct EnvMap *env);
/* --------------------------------------------------------------------- */
/* rendercore (2) */
/* rendercore (10) */
/* --------------------------------------------------------------------- */
float Phong_Spec(float *n, float *l, float *v, int hard);
float CookTorr_Spec(float *n, float *l, float *v, int hard);
@ -206,9 +196,8 @@ void ramp_spec_result(float *specr, float *specg, float *specb, ShadeInput *shi)
struct VlakRen *RE_findOrAddVlak(int nr);
struct VertRen *RE_findOrAddVert(int nr);
struct HaloRen *RE_findOrAddHalo(int nr);
HaloRen *RE_inithalo(Material *ma, float *vec, float *vec1, float *orco, float hasize,
float vectsize);
HaloRen *RE_inithalo(struct Material *ma, float *vec, float *vec1, float *orco, float hasize,
float vectsize, int seed);
/**
* callbacks (11):
@ -255,13 +244,13 @@ int RE_testclip(float *v);
/* patch for the external if, to support the split for the ui */
void RE_addalphaAddfac(char *doel, char *bron, char addfac);
void RE_sky_char(float *view, char *col);
void RE_sky(float *view, float *col);
void RE_renderflare(struct HaloRen *har);
/**
* Shade the pixel at xn, yn for halo har, and write the result to col.
* Also called in: previewrender.c
* @param har The halo to be rendered on this location
* @param col [unsigned int 3] The destination colour vector
* @param col [char 4] The destination colour vector
* @param colf [float 4] destination colour vector (need both)
* @param zz Some kind of distance
* @param dist Square of the distance of this coordinate to the halo's center
* @param x [f] Pixel x relative to center
@ -269,7 +258,7 @@ void RE_renderflare(struct HaloRen *har);
* @param flarec Flare counter? Always har->flarec...
*/
void RE_shadehalo(struct HaloRen *har,
char *col,
char *col, float *colf,
unsigned int zz,
float dist,
float x,

@ -51,14 +51,48 @@
/* ------------------------------------------------------------------------- */
/* localized texture result data */
typedef struct TexResult {
float tin, tr, tg, tb, ta;
int talpha;
float *nor;
} TexResult;
/* localized renderloop data */
typedef struct ShadeInput
{
struct Material *mat, *matren;
struct Material *mat;
struct VlakRen *vlr;
float co[3];
/* copy from material, keep synced so we can do memcopy */
/* current size: 23*4 */
float r, g, b;
float specr, specg, specb;
float mirr, mirg, mirb;
float ambr, ambb, ambg;
float amb, emit, ang, spectra, ray_mirror;
float alpha, refl, spec, zoffs, add;
float translucency;
/* end direct copy from material */
/* individual copies: */
int har;
/* texture coordinates */
float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3];
float vn[3], view[3], refcol[4], displace[3];
/* dx/dy OSA coordinates */
float dxco[3], dyco[3];
float dxlo[3], dylo[3], dxgl[3], dygl[3], dxuv[3], dyuv[3];
float dxref[3], dyref[3], dxorn[3], dyorn[3];
float dxno[3], dyno[3], dxview, dyview;
float dxlv[3], dylv[3];
float dxwin[3], dywin[3];
float dxsticky[3], dysticky[3];
float dxrefract[3], dyrefract[3];
float xs, ys; /* pixel to be rendered */
short osatex;
int mask;
@ -69,7 +103,7 @@ typedef struct ShadeInput
/* here only stuff to initalize the render itself */
typedef struct RE_Render
{
float grvec[3], inprz, inprh;
float grvec[3];
float imat[3][3];
float viewmat[4][4], viewinv[4][4];
@ -113,6 +147,7 @@ typedef struct RE_Render
unsigned int *rectspare; /* */
/* for 8 byte systems! */
long *rectdaps;
float *rectftot; /* original full color buffer */
short win, winpos, winx, winy, winxof, winyof;
short winpop, displaymode, sparex, sparey;
@ -125,17 +160,6 @@ typedef struct RE_Render
/* ------------------------------------------------------------------------- */
/**
* Part as in part-rendering. An image rendered in parts is rendered
* to a list of parts, with x,y size, and a pointer to the render
* output stored per part. Internal!
*/
typedef struct Part
{
struct Part *next, *prev;
unsigned int *rect;
short x, y;
} Part;
typedef struct ShadBuf {
short samp, shadhalostep;
@ -186,14 +210,14 @@ typedef struct RadFace {
typedef struct VlakRen
{
struct VertRen *v1, *v2, *v3, *v4;
unsigned int lay;
unsigned int raycount;
float n[3];
struct Material *mat;
struct TFace *tface;
unsigned int *vcol;
char snproj, puno;
char flag, ec;
unsigned int lay;
unsigned int raycount;
RadFace *radface;
Object *ob;
} VlakRen;
@ -202,12 +226,12 @@ typedef struct VlakRen
typedef struct HaloRen
{
float alfa, xs, ys, rad, radsq, sin, cos, co[3], no[3];
unsigned int zs, zd;
unsigned int zBufDist;/* depth in the z-buffer coordinate system */
short miny, maxy;
short hard, b, g, r;
char starpoints, add, type, tex;
float alfa, xs, ys, rad, radsq, sin, cos, co[3], no[3];
float hard, b, g, r;
unsigned int zs, zd;
unsigned int zBufDist; /* depth in the z-buffer coordinate system */
char starpoints, type, add, tex;
char linec, ringc, seed;
short flarec; /* used to be a char. why ?*/
float hasize;
@ -274,9 +298,9 @@ typedef struct LampRen
/* ray optim */
VlakRen *vlr_last;
struct LampRen *org;
struct MTex *mtex[MAX_MTEX];
} LampRen;
#endif /* RENDER_TYPES_H */

@ -40,8 +40,11 @@
* environment map as texture.
* (initrender.c)
*/
struct TexResult;
void make_envmaps(void);
int envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex);
int envmaptex(struct Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, struct TexResult *texres);
#endif /* ENVMAP_EXT_H */

@ -67,12 +67,7 @@ float invGammaCorrect(float col);
/**
* Tell whether or not to do gamma.
*/
int doGamma(void);
/**
* Set/unset performing gamma corrections.
*/
void setDoGamma(int);
extern int do_gamma;
#endif

@ -42,16 +42,7 @@
/* Functions */
void init_def_material(void);
void init_render_jit(int nr);
float calc_weight(float *weight, int i, int j);
void defaultlamp(void);
void schrijfplaatje(char *name);
void initparts(void);
short setpart(short nr); /* return 0 als geen goede part */
void addparttorect(short nr, Part *part);
void add_to_blurbuf(int blur);
void oldRenderLoop(void); /* Calls the old renderer. Contains the PART and FIELD loops. */
void render(void); /* Switch between the old and the unified renderer. */
/* void write_screendump(char *name); not here !*/

@ -41,7 +41,8 @@ extern "C" {
extern float jit[64][2];
void initjit(float *jitarr, int num);
extern void initjit(float *jitarr, int num);
extern void init_render_jit(int nr);
#ifdef __cplusplus
}

@ -1,57 +0,0 @@
/**
* $Id$
*
* ***** 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 *****
* Datatypes for old zbuffering algorithms.
*/
#ifndef OLD_ZBUFFER_TYPES_H
#define OLD_ZBUFFER_TYPES_H "$Id$"
typedef struct PixStr
{
struct PixStr *next;
int vlak0, vlak;
unsigned int z;
unsigned int mask;
short aantal, ronde;
} PixStr;
/* ------------------------------------------------------------------------- */
typedef struct PixStrMain
{
struct PixStr *ps;
struct PixStrMain *next;
} PixStrMain;
/* ------------------------------------------------------------------------- */
#endif

@ -39,19 +39,6 @@
/* local includes */
#include "vanillaRenderPipe_types.h"
/* own include */
#include "pixelblending_types.h"
/**
* Samples pixel, depending on R.osa setting
*/
int addtosampcol(unsigned short *sampcol, unsigned short *shortcol, int mask);
/**
* Samples pixel, bring your own R.osa setting
*/
int addToSampCol(unsigned short *sampcol, unsigned short *shortcol, int mask, int osaNr);
/**
* Halo-add pixel, bring your own R.osa setting, and add factor
*/

@ -1,59 +0,0 @@
/*
* pixelblending_types.h
* types pixelblending
*
* $Id$
*
* ***** 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 *****
*/
#ifndef PIXELBLENDING_TYPES_H
#define PIXELBLENDING_TYPES_H
/* Threshold for a 'full' pixel: pixels with alpha above this level are */
/* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF */
#define RE_FULL_COLOUR_FLOAT 0.9998
/* Threshold for an 'empty' pixel: pixels with alpha above this level are */
/* considered completely transparent. This is the decimal value */
/* for 0x000F / 0xFFFF */
#define RE_EMPTY_COLOUR_FLOAT 0.0002
/* A 100% pixel. Sometimes, seems to be too little.... Hm....... */
#define RE_UNITY_COLOUR_FLOAT 1.0
/* A 0% pixel. I wonder how 0 the 0.0 is... */
#define RE_ZERO_COLOUR_FLOAT 0.0
/* threshold for alpha */
#define RE_FULL_ALPHA_FLOAT 0.9998
/* Same set of defines for shorts */
#define RE_FULL_COLOUR_SHORT 0xFFF0
#define RE_EMPTY_COLOUR_SHORT 0x0000
#endif /* PIXELBLENDING_EXT_H */

@ -51,12 +51,13 @@
* mask is pixel coverage in bits
* @return pointer to the object
*/
void *renderPixel(float x, float y, int *t, int mask);
void *renderPixel(RE_COLBUFTYPE *collector, float x, float y, int *t, int mask);
void *renderHaloPixel(float x, float y, int haloNr) ;
void *renderHaloPixel(RE_COLBUFTYPE *collector, float x, float y, int haloNr) ;
void setSkyBlendingMode(enum RE_SkyAlphaBlendingType mode);
void shadeHaloFloat(HaloRen *har,
float *col, unsigned int zz,
float dist, float xn,
@ -69,13 +70,14 @@ enum RE_SkyAlphaBlendingType getSkyBlendingMode(void);
/**
* Render the sky at pixel (x, y).
*/
void renderSkyPixelFloat(float x, float y);
void renderSkyPixelFloat(RE_COLBUFTYPE *collector, float x, float y);
/* used by shadeSkyPixel: */
void shadeSkyPixelFloat(float y, float *view);
void shadeSkyPixelFloat(float *colf, float *view, float *dxyview);
void renderSpotHaloPixel(float x, float y, float *target);
void shadeSkyPixel(float fx, float fy);
void fillBackgroundImage(float x, float y);
void shadeSkyPixel(RE_COLBUFTYPE *collector, float fx, float fy);
void fillBackgroundImage(RE_COLBUFTYPE *collector, float x, float y);
void fillBackgroundImageChar(char *col, float x, float y);
/* ------------------------------------------------------------------------- */

@ -1,62 +0,0 @@
/*
* render_int.h
* misc internal defines for renderer
*
* $Id$
*
* ***** 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 *****
*/
/* XXX, should die, no good reason to write
* regular (non-file related) endian dependant
* code.
*/
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
#define RCOMP 3
#define GCOMP 2
#define BCOMP 1
#define ACOMP 0
#else
#define RCOMP 0
#define GCOMP 1
#define BCOMP 2
#define ACOMP 3
#endif
#define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);}
#define QUATCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2); *(v1+3)= *(v2+3);}
#define CLAMPIS(a, b, c) ((a)<(b) ? (b) : (a)>(c) ? (c) : (a))
typedef struct {
int a, b, c, d;
} byte16;
#define COPY_16(a,b) (*((byte16 *)(a))= *((byte16 *)(b)))

@ -54,20 +54,36 @@ typedef struct ShadeResult
} ShadeResult;
float mistfactor(float *co); /* dist en hoogte, return alpha */
typedef struct PixStr
{
struct PixStr *next;
int vlak0, vlak;
unsigned int z;
unsigned int mask;
short aantal, ronde;
} PixStr;
void render_lighting_halo(struct HaloRen *har, float *colf);
unsigned int calchalo_z(struct HaloRen *har, unsigned int zz);
void add_halo_flare(void);
/* ------------------------------------------------------------------------- */
void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, int i3);
typedef struct PixStrMain
{
struct PixStr *ps;
struct PixStrMain *next;
} PixStrMain;
void shade_color(struct ShadeInput *shi, ShadeResult *shr);
void shade_lamp_loop(struct ShadeInput *shi, ShadeResult *shr);
float fresnel_fac(float *view, float *vn, float fresnel, float fac);
void calc_R_ref(struct ShadeInput *shi);
float spec(float inp, int hard);
float mistfactor(float *co); /* dist and height, return alpha */
void add_halo_flare(void);
void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, int i3);
void shade_color(struct ShadeInput *shi, ShadeResult *shr);
void shade_lamp_loop(struct ShadeInput *shi, ShadeResult *shr);
float fresnel_fac(float *view, float *vn, float fresnel, float fac);
void calc_R_ref(struct ShadeInput *shi);
float spec(float inp, int hard);
/* -------- ray.c ------- */
@ -76,36 +92,12 @@ extern void ray_trace(ShadeInput *, ShadeResult *);
extern void ray_ao(ShadeInput *, World *, float *);
/**
* Apply the background (sky). Depending on the active alphamode and
* worldmode, different filling strategies are applied.
* Active alphamode = R.r.alphamode
* Active worldmode = R.wrld.mode
* <LI>
* <IT> R_ALPHAPREMUL - do not fill sky, but apply alpha to colours
* <IT> R_ALPHAKEY - do not fill sky, do not apply alpha to colours
* <IT> R_ADDSKY - fill skycolour in the background, blend
* transparent colours with the background
* (there's also a world dependency here?
* <LI>
* <IT> R.wrld.mode == WO_MIST
* <IT> R.r.bufflag == 1, R.flag == R_SEC_FIELD
* <IT> R.wrld.skytype == ( WO_SKYBLEND ^ WO_SKYTEX)
* <IT> R.wrld.skytype == WO_SKYPAPER
* <IT> R.r.mode == R_PANORAMA )
* </LI>
* </LI>
* @param rect
* @param y
*/
void scanlinesky(char *rect, int y);
/**
* Do z buffer stuff.
* Do z buffer and shade
*/
void zbufshade(void);
/**
* Insert transparent faces into the z buffer?
* zbuffer and shade, anti aliased
*/
void zbufshadeDA(void); /* Delta Accum Pixel Struct */
@ -113,20 +105,6 @@ void zbufshadeDA(void); /* Delta Accum Pixel Struct */
* Also called in: zbuf.c
*/
void *shadepixel(float x, float y, int vlaknr, int mask, float *col);
void shadepixel_short(float x, float y, int vlaknr, int mask, unsigned short *shortcol);
/**
* Shade the pixel at xn, yn for halo har, and write the result to col.
* Also called in: previewrender.c
* @param har The halo to be rendered on this location
* @param col [unsigned int 3] The destination colour vector
* @param zz Some kind of distance
* @param dist Square of the distance of this coordinate to the halo's center
* @param x [f] Pixel x relative to center
* @param y [f] Pixel y relative to center
* @param flarec Flare counter? Always har->flarec...
*/
/* void shadehalo(struct HaloRen *har, char *col, unsigned int zz, float dist, float x, float y, short flarec); */
/**
* A cryptic but very efficient way of counting the number of bits that

@ -1,52 +0,0 @@
/*
* render_int.h
*
* $Id$
*
* ***** 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 *****
*/
#ifndef RENDER_INT_H
#define RENDER_INT_H
#include "zbuf_types.h"
#include "render_types.h"
void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens);
void add_filt_mask(unsigned int mask, unsigned short *col, unsigned int *rb1, unsigned int *rb2, unsigned int *rb3);
void addps(long *rd, int vlak, unsigned int z, short ronde);
PixStr *addpsmain(void);
float count_maskf(unsigned short mask);
void freeps(void);
void halovert(void);
void renderhalo(HaloRen *har); /* postprocess versie */
void scanlinehaloPS(unsigned int *rectz, long *rectdelta, unsigned int *rectt, short ys);
#endif /* RENDER_INT_H */

@ -52,7 +52,7 @@ void makeshadowbuf(LampRen *lar);
* @param inp The inproduct between viewvector and ?
*
*/
float testshadowbuf(struct ShadBuf *shb, float *rco, float inp);
float testshadowbuf(struct ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp);
/**
* Determines the shadow factor for lamp <lar>, between <p1>

@ -35,12 +35,32 @@
#ifndef TEXTURE_EXT_H
#define TEXTURE_EXT_H
#define BRICONT texres->tin= (texres->tin-0.5)*tex->contrast+tex->bright-0.5; \
if(texres->tin<0.0) texres->tin= 0.0; else if(texres->tin>1.0) texres->tin= 1.0;
#define BRICONTRGB texres->tr= tex->rfac*((texres->tr-0.5)*tex->contrast+tex->bright-0.5); \
if(texres->tr<0.0) texres->tr= 0.0; \
texres->tg= tex->gfac*((texres->tg-0.5)*tex->contrast+tex->bright-0.5); \
if(texres->tg<0.0) texres->tg= 0.0; \
texres->tb= tex->bfac*((texres->tb-0.5)*tex->contrast+tex->bright-0.5); \
if(texres->tb<0.0) texres->tb= 0.0;
struct HaloRen;
struct ShadeInput;
struct TexResult;
struct Tex;
/* texture.h */
void do_halo_tex(struct HaloRen *har, float xn, float yn, float *colf);
void do_sky_tex(float *lo, float *dxyview, float *hor, float *zen, float *blend);
void render_realtime_texture(struct ShadeInput *shi);
/* imagetexture.h */
int imagewraposa(struct Tex *tex, float *texvec, float *dxt, float *dyt, struct TexResult *texres);
int imagewrap(struct Tex *tex, float *texvec, struct TexResult *texres);
#endif /* TEXTURE_EXT_H */

@ -45,5 +45,15 @@
*/
void zBufShadeAdvanced(void);
/**
* Copy the colour buffer output to R.rectot, to line y.
*/
void transferColourBufferToOutput(float *buf, int y);
/**
* using default transforms for brightness, gamma, hue, saturation etc.
*/
void std_floatcol_to_charcol(float *buf, char *target);
#endif /* VANILLARENDERPIPE_EXT_H */

@ -1,192 +0,0 @@
/*
* vanillaRenderPipe_int.h
*
* $Id$
*
* ***** 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 *****
*/
#ifndef VANILLARENDERPIPE_INT_H
#define VANILLARENDERPIPE_INT_H
#include "vanillaRenderPipe_types.h"
#include "zbufferdatastruct_types.h"
/**
* Z buffer initializer, for new pipeline.
* <LI>
* <IT> AColourBuffer : colour buffer for one line
* <IT> APixbufExt : pixel data buffer for one line, depth RE_ZBUFLEN
* </LI>
*/
void initRenderBuffers(int width);
/* void initRenderBuffers(void); */
/**
* Z buffer destructor, frees stuff from initZBuffers().
*/
void freeRenderBuffers(void);
/**
* Fill the accumulation buffer APixbufExt with face and halo indices.
* Note: Uses globals.
* @param y the line number to set
*/
void calcZBufLine(int y);
/**
* Shade and render the pixels in this line, into AColourBuffer
* Note: Uses globals.
* @param y the line number to set
*/
void renderZBufLine(int y);
/**
* Count and sort the list behind ap into buf. Sorts on min. distance.
* Low index <=> high z
*/
int countAndSortPixelFaces(int buf[RE_MAX_FACES_PER_PIXEL][5],
RE_APixstrExt *ap);
/**
* Compose the conflict and colour stacks
* Note: Uses globals.
*/
int composeStack(int zrow[RE_MAX_FACES_PER_PIXEL][RE_PIXELFIELDSIZE],
struct RE_faceField* stack, int ptr,
int totvlak, float x, float y, int osaNr);
/**
* Integrate conflicting layers.
* Note: Uses globals.
*/
int resolveConflict(struct RE_faceField* stack, int ptr, float x, float y);
/**
* Integrate the colour stack, defer conflicts.
* Note: Uses globals.
*/
void integrateStack(struct RE_faceField* stack, int ptr,
float x, float y, int osaNr);
/**
* Calculate the view depth to this object on this location, with
* the current view parameters in R.
*/
int calcDepth(float x, float y, void *data, int type);
/**
* Fills in distances of all faces in a z buffer, for given jitter settings.
*/
int fillZBufDistances(void);
/**
* Fills in distances of faces in the z buffer.
*
* Halo z buffering ----------------------------------------------
*
* A halo is treated here as a billboard: no z-extension, always
* oriented perpendicular to the viewer. The rest of the z-buffer
* stores face-numbers first, then calculates colours as the
* final image is rendered. We'll use the same approach here,
* which differs from the original method (which was add halos per
* scan line). This means that the z-buffer now also needs to
* store info about what sort of 'thing' the index refers to.
*
* Halo extension:
* h.maxy ---------
* | h.xs + h.rad
* | h.xs
* | h.xs - h.rad
* h.miny ---------
*
* These coordinates must be clipped to picture size.
* I'm not quite certain about halo numbering.
*
* Halos and jittering -------------------------------------------
*
* Halos were not jittered previously. Now they are. I wonder
* whether this may have some adverse effects here.
* @return 1 for succes, 0 if the operation was interrupted.
*/
int zBufferAllFaces(void);
/**
* Fills in distances of halos in the z buffer.
* @return 1 for succes, 0 if the operation was interrupted.
*/
int zBufferAllHalos(void);
/**
* New fill function for z buffer, for edge-only rendering.
*/
void zBufferFillEdge(float *vec1, float *vec2);
/**
* New fill function for z buffer.
*/
void zBufferFillFace(float *v1, float *v2, float *v3);
/**
* One more filler: fill in halo data in z buffer.
* Empty so far, but may receive content of halo loop.
*/
void zBufferFillHalo(void);
/**
* Copy the colour buffer output to R.rectot, to line y.
*/
void transferColourBufferToOutput(int y);
/**
* Set the colour buffer fields to zero.
*/
void eraseColBuf(RE_COLBUFTYPE *buf);
/**
* Blend source over dest, and leave result in dest. 1 pixel.
*/
void blendOverFloat(int type, float* dest, float* source, void* data);
/**
* Blend source over dest, and leave result in dest. 1 pixel into
* multiple bins.
*/
void blendOverFloatRow(int type, float* dest, float* source,
void* data, int mask, int osaNr) ;
/**
* Do a post-process step on a finalized render image.
*/
void std_transFloatColV2CharColV( RE_COLBUFTYPE *buf, char *target);
#endif /* VANILLARENDERPIPE_INT_H */

@ -112,7 +112,7 @@ void zbuffershad(struct LampRen *lar);
* Also called in: render.c
* @param y the line number to set
*/
void abufsetrow(int y);
void abufsetrow(float *acolrow, int y);
/**
@ -165,12 +165,12 @@ int vergzvlak(const void *x1, const void *x2);
* @param c2
* @param c3
*/
void zbufclip(float *f1, float *f2, float *f3, int c1, int c2, int c3);
void zbufclip(unsigned int zvlnr, float *f1, float *f2, float *f3, int c1, int c2, int c3);
/**
* same, for edges
*/
void zbufclipwire(struct VlakRen *vlr);
void zbufclipwire(unsigned int zvlnr, struct VlakRen *vlr);
#ifdef __cplusplus
}

@ -1,197 +0,0 @@
/*
* zbuf_int.h
* internal interface for zbuf.h (ie. functions that are not used
* anywhere else)
*
* $Id$
*
* ***** 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 *****
*/
#ifndef ZBUF_INT_H
#define ZBUF_INT_H
#include "render_types.h"
#include "zbuf_types.h"
/**
* Convert a homogenous coordinate to a z buffer coordinate. The
* function makes use of Zmulx, Zmuly, the x and y scale factors for
* the screen, and Zjitx, Zjity, the pixel offset. (These are declared
* in render.c) The normalised z coordinate must fall on [0, 1].
* @param zco [3, 4 floats] pointer to the resulting z buffer coordinate
* @param hoco [4 floats] pointer to the homogenous coordinate of the
* vertex in world space.
*/
void hoco_to_zco(float *zco, float *hoco);
/**
* Fill the z buffer for alpha?
*
* This is one of the z buffer fill functions called in zbufclip() and
* zbufwireclip().
*
* @param v1 [4 floats, world coordinates] first vertex
* @param v2 [4 floats, world coordinates] second vertex
* @param v3 [4 floats, world coordinates] third vertex
*/
void zbufinvulAc(float *v1, float *v2, float *v3);
/**
* Fill the z buffer, but invert z order, and add the face index to
* the corresponing face buffer.
*
* This is one of the z buffer fill functions called in zbufclip() and
* zbufwireclip().
*
* @param v1 [4 floats, world coordinates] first vertex
* @param v2 [4 floats, world coordinates] second vertex
* @param v3 [4 floats, world coordinates] third vertex
*/
void zbufinvulGLinv(float *v1, float *v2, float *v3);
/**
* Fill the z buffer, and add the face index to
* the corresponing face buffer. Writes into R.rectz and R.rectot. It
* assumes that Zvlnr is set to the face index of the face under
* consideration. Zvlnr is written into R.rectot. R.rectz
*
* This is one of the z buffer fill functions called in zbufclip() and
* zbufwireclip().
*
* @param v1 [4 floats, world coordinates] first vertex
* @param v2 [4 floats, world coordinates] second vertex
* @param v3 [4 floats, world coordinates] third vertex
*/
void zbufinvulGL(float *v1, float *v2, float *v3);
/**
* Fill the z buffer. The face buffer is not operated on!
*
* This is one of the z buffer fill functions called in zbufclip() and
* zbufwireclip().
*
* @param v1 [4 floats, world coordinates] first vertex
* @param v2 [4 floats, world coordinates] second vertex
* @param v3 [4 floats, world coordinates] third vertex
*/
void zbufinvulGL_onlyZ(float *v1, float *v2, float *v3);
/**
* Prints 3 unlabelled floating point values to stdout. Used for diagnostics.
* @param v1 any float
* @param v2 any float
* @param v3 any float
*/
void print3floats(float *v1, float *v2, float *v3);
/**
* Checks labda and uses this to make decision about clipping the line
* segment from v1 to v2. labda is the factor by which the vector is
* cut. ( calculate s + l * ( t - s )). The result is appended to the
* vertex list of this face.
* Note: uses globals.
* (arguments: one int, one pointer to int... why?)
* @param v1 start coordinate s
* @param v2 target coordinate t
* @param b1
* @param b2
* @param clve vertex vector.
*/
static void maakvertpira(float *v1, float *v2, int *b1, int b2, int *clve);
/**
* Sets labda: flag, and parametrize the clipping of vertices in
* viewspace coordinates. labda = -1 means no clipping, labda in [0,
* 1] means a clipping.
* Note: uses globals.
* @param v1 start coordinate s
* @param v2 target coordinate t
* @param b1
* @param b2
* @param b3
* @param a index for coordinate (x, y, or z)
*/
static void clipp(float *v1, float *v2, int b1, int *b2, int *b3, int a);
/**
* Tests whether this coordinate is 'inside' or 'outside' of the view
* volume? By definition, this is in [0, 1].
* @param p vertex z difference plus coordinate difference?
* @param q origin z plus r minus some coordinate?
* @param u1 [in/out] clip fraction for ?
* @param u2 [in/out]
* @return 0 if point is outside, or 1 if the point lies on the clip
* boundary
*/
static short cliptestf(float p, float q, float *u1, float *u2);
/* not documented yet */
/* not sure if these should stay static... */
static int clipline(float *v1, float *v2);
/**
* Provide book-keeping for the z buffer data lists.
*/
APixstr *addpsmainA(void);
void freepsA(void);
APixstr *addpsA(void);
/**
* Fill function for the z buffer (fills lines)
*/
void zbuflineAc(float *vec1, float *vec2);
void zbufline(float *vec1, float *vec2);
/**
* Copy results from the solid face z buffering to the transparent
* buffer.
*/
void copyto_abufz(int sample);
/**
* Do accumulation z buffering.
*/
void zbuffer_abuf(void);
/**
* Shade this face at this location in SCS.
*/
void shadetrapixel(float x, float y, int vlak, int mask, unsigned short *shortcol);
/**
* Determine the distance to the camera of this halo, in ZCS.
*/
unsigned int calcHaloDist(HaloRen *har);
#endif /* ZBUF_INT_H */

@ -58,6 +58,7 @@ CPPFLAGS += -I../../../../kernel/gen_messaging
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
# not very neat: the rest of blender..
CPPFLAGS += -I../../../include
CPPFLAGS += $(NAN_SDLCFLAGS)
ifeq ($(WITH_QUICKTIME), true)
CPPFLAGS += -DWITH_QUICKTIME

@ -34,7 +34,6 @@
#include <stdlib.h> /* for NULL??? */
#include <stdio.h>
#include "render.h"
#include "render_intern.h"
#include "RE_callbacks.h"
#ifdef HAVE_CONFIG_H

@ -60,11 +60,11 @@
#include "MEM_guardedalloc.h"
#include "MTC_vectorops.h"
#include "BKE_utildefines.h"
#include "RE_callbacks.h"
#include "edgeRender.h"
#include "render.h"
#include "render_intern.h"
#include "zbuf.h" /* for zbufclipwire and zbufclip */
#include "jitter.h"
@ -78,19 +78,13 @@ char edgeRender_c[] = "$Id$";
#include "errorHandler.h"
#endif
/* ------------------------------------------------------------------------- */
/* the lazy way: */
#define MIN2(x,y) ( (x)<(y) ? (x) : (y) )
/* ------------------------------------------------------------------------- */
/* These function pointers are used for z buffer filling. */
extern void (*zbuffunc)(float *, float *, float *);
extern void (*zbuflinefunc)(float *, float *);
extern void (*zbuffunc)(unsigned int, float *, float *, float *);
extern void (*zbuflinefunc)(unsigned int, float *, float *);
extern float Zmulx, Zmuly; /* Some kind of scale? */
extern float Zjitx,Zjity; /* The x,y values for jitter offset */
extern unsigned int Zvlnr; /* Face rendering pointer and counter: these */
extern VlakRen *Zvlr; /* are used for 'caching' render results. */
/* ------------------------------------------------------------------------- */
@ -148,12 +142,12 @@ void renderEdges(char * colourRect);
/**
* Buffer an edge between these two vertices in the e.r. distance buffer.
*/
void fillEdgeRenderEdge(float *vec1, float *vec2);
static void fillEdgeRenderEdge(unsigned int, float *vec1, float *vec2);
/**
* Buffer a face between these two vertices in the e.r. distance buffer.
*/
void fillEdgeRenderFace(float *v1, float *v2, float *v3);
static void fillEdgeRenderFace(unsigned int, float *v1, float *v2, float *v3);
/**
* Compose the edge render colour buffer.
@ -598,6 +592,8 @@ void calcEdgeRenderColBuf(char* colTargetBuffer)
/* rendering, this should be ok. */
int zBufferEdgeRenderObjects(void)
{
VlakRen *vlr= NULL;
unsigned int zvlnr;
int keepLooping;
int faceCounter; /* counter for face number */
Material *ma;
@ -607,30 +603,30 @@ int zBufferEdgeRenderObjects(void)
faceCounter = 0;
while ( (faceCounter < R.totvlak) && keepLooping) {
if((faceCounter & 255)==0) { Zvlr= R.blovl[faceCounter>>8]; }
else Zvlr++;
if((faceCounter & 255)==0) { vlr= R.blovl[faceCounter>>8]; }
else vlr++;
ma= Zvlr->mat;
ma= vlr->mat;
/*exp*/
mat_cache = ma;
/* face number is used in the fill functions */
Zvlnr = faceCounter + 1;
zvlnr = faceCounter + 1;
if(Zvlr->flag & R_VISIBLE) {
if(vlr->flag & R_VISIBLE) {
/* here we cull all transparent faces if mode == 0 */
if (selectmode || !(ma->mode & MA_ZTRA)) {
/* here we can add all kinds of extra selection criteria */
if(ma->mode & (MA_WIRE)) zbufclipwire(Zvlr);
if(ma->mode & (MA_WIRE)) zbufclipwire(zvlnr, vlr);
else {
zbufclip(Zvlr->v1->ho, Zvlr->v2->ho, Zvlr->v3->ho,
Zvlr->v1->clip, Zvlr->v2->clip, Zvlr->v3->clip);
if(Zvlr->v4) {
Zvlnr+= 0x800000; /* in a sense, the 'adjoint' face */
zbufclip(Zvlr->v1->ho, Zvlr->v3->ho, Zvlr->v4->ho,
Zvlr->v1->clip, Zvlr->v3->clip, Zvlr->v4->clip);
zbufclip(zvlnr, vlr->v1->ho, vlr->v2->ho, vlr->v3->ho,
vlr->v1->clip, vlr->v2->clip, vlr->v3->clip);
if(vlr->v4) {
zvlnr+= 0x800000; /* in a sense, the 'adjoint' face */
zbufclip(zvlnr, vlr->v1->ho, vlr->v3->ho, vlr->v4->ho,
vlr->v1->clip, vlr->v3->clip, vlr->v4->clip);
}
}
}
@ -643,7 +639,7 @@ int zBufferEdgeRenderObjects(void)
/* ------------------------------------------------------------------------- */
void fillEdgeRenderFace(float *v1, float *v2, float *v3)
static void fillEdgeRenderFace(unsigned int zvlnr, float *v1, float *v2, float *v3)
{
/* Coordinates of the vertices are specified in ZCS */
double z0; /* used as temp var*/
@ -851,7 +847,7 @@ void fillEdgeRenderFace(float *v1, float *v2, float *v3)
/* ------------------------------------------------------------------------- */
void fillEdgeRenderEdge(float *vec1, float *vec2)
static void fillEdgeRenderEdge(unsigned int zvlnr, float *vec1, float *vec2)
{
int start, end, x, y, oldx, oldy, ofs;
int dz, vergz/* , mask */;

@ -49,6 +49,8 @@
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
#include "BKE_utildefines.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h" /* for rectcpy */
@ -58,38 +60,24 @@
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BIF_space.h"
#include "BIF_toolbox.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_world.h" // init_render_world
#include "BKE_image.h" // BKE_write_ibuf
#include "MTC_matrixops.h"
/* this module */
#include "RE_callbacks.h"
#include "render.h"
#include "render_intern.h"
#include "envmap.h"
#include "mydevice.h"
#include "rendercore.h" /* calls zbufShade(DA).... I want to replace this with my own :)*/
#include "rendercore.h"
#include "renderHelp.h"
#include "MTC_matrixops.h"
#include "texture.h"
#include "zbuf.h"
/* ------------------------------------------------------------------------- */
void envmap_split_ima(EnvMap *env);
void envmap_renderdata(EnvMap *env);
void envmap_transmatrix(float mat[][4], int part);
void env_rotate_scene(float mat[][4], int mode);
void env_layerflags(unsigned int notlay);
void env_set_imats(void);
void render_envmap(EnvMap *env);
int envcube_isect(float *vec, float *answ);
static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int face);
/* ------------------------------------------------------------------------- */
@ -156,7 +144,7 @@ void RE_free_envmap(EnvMap *env)
/* ------------------------------------------------------------------------- */
void envmap_split_ima(EnvMap *env)
static void envmap_split_ima(EnvMap *env)
{
ImBuf *ibuf;
Image *ima;
@ -168,7 +156,7 @@ void envmap_split_ima(EnvMap *env)
dx= env->ima->ibuf->y;
dx/= 2;
if(3*dx != env->ima->ibuf->x) {
error("Incorrect envmap size");
printf("Incorrect envmap size\n");
env->ok= 0;
env->ima->ok= 0;
}
@ -199,7 +187,7 @@ void envmap_split_ima(EnvMap *env)
/* ------------------------------------------------------------------------- */
/* ****************** RENDER ********************** */
void envmap_renderdata(EnvMap *env)
static void envmap_renderdata(EnvMap *env)
{
static RE_Render envR;
static Object *camera;
@ -245,7 +233,7 @@ void envmap_renderdata(EnvMap *env)
/* ------------------------------------------------------------------------- */
void envmap_transmatrix(float mat[][4], int part)
static void envmap_transmatrix(float mat[][4], int part)
{
float tmat[4][4], eul[3], rotmat[4][4];
@ -277,7 +265,7 @@ void envmap_transmatrix(float mat[][4], int part)
/* ------------------------------------------------------------------------- */
void env_rotate_scene(float mat[][4], int mode)
static void env_rotate_scene(float mat[][4], int mode)
{
VlakRen *vlr = NULL;
VertRen *ver = NULL;
@ -366,7 +354,7 @@ void env_rotate_scene(float mat[][4], int mode)
/* ------------------------------------------------------------------------- */
void env_layerflags(unsigned int notlay)
static void env_layerflags(unsigned int notlay)
{
VlakRen *vlr = NULL;
int a;
@ -392,7 +380,7 @@ void env_hideobject(Object *ob)
/* ------------------------------------------------------------------------- */
void env_set_imats()
static void env_set_imats()
{
Base *base;
float mat[4][4];
@ -409,7 +397,7 @@ void env_set_imats()
/* ------------------------------------------------------------------------- */
void render_envmap(EnvMap *env)
static void render_envmap(EnvMap *env)
{
/* only the cubemap is implemented */
ImBuf *ibuf;
@ -420,6 +408,11 @@ void render_envmap(EnvMap *env)
/* need a recalc: ortho-render has no correct viewinv */
MTC_Mat4Invert(oldviewinv, R.viewmat);
/* do first, envmap_renderdata copies entire R struct */
if(R.rectz) MEM_freeN(R.rectz); R.rectz= NULL;
if(R.rectot) MEM_freeN(R.rectot); R.rectot= NULL;
if(R.rectftot) MEM_freeN(R.rectftot); R.rectftot= NULL;
/* setup necessary globals */
envmap_renderdata(env);
@ -480,8 +473,9 @@ void render_envmap(EnvMap *env)
}
if(R.rectz) MEM_freeN(R.rectz); R.rectz= 0;
if(R.rectot) MEM_freeN(R.rectot); R.rectot= 0;
if(R.rectz) MEM_freeN(R.rectz); R.rectz= NULL;
if(R.rectot) MEM_freeN(R.rectot); R.rectot= NULL;
if(R.rectftot) MEM_freeN(R.rectftot); R.rectftot= NULL;
if(RE_local_test_break()) RE_free_envmapdata(env);
else {
@ -557,7 +551,7 @@ void make_envmaps()
if(do_init) {
RE_local_init_render_display();
RE_local_clear_render_display(R.win);
allqueue(REDRAWBUTSSHADING, 0); // bad!
R.flag |= R_REDRAW_PRV;
}
// restore
R.r.mode |= trace;
@ -566,7 +560,7 @@ void make_envmaps()
/* ------------------------------------------------------------------------- */
int envcube_isect(float *vec, float *answ)
static int envcube_isect(float *vec, float *answ)
{
float labda;
int face;
@ -639,17 +633,16 @@ static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int fac
/* ------------------------------------------------------------------------- */
extern float Tin, Ta, Tr, Tg, Tb; /* texture.c */
int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
{
/* texvec should be the already reflected normal */
EnvMap *env;
float fac, vec[3], sco[3], col[20], dxts[3], dyts[3];
float fac, vec[3], sco[3], dxts[3], dyts[3];
int face, face1;
env= tex->env;
if(env==0 || env->object==0) {
Tin= 0.0;
texres->tin= 0.0;
return 0;
}
if(env->stype==ENV_LOAD) {
@ -662,7 +655,7 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
if(env->ok==0) {
Tin= 0.0;
texres->tin= 0.0;
return 0;
}
@ -674,16 +667,17 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
tex->ima= env->cube[face];
if(osatex) {
MTC_Mat4Mul3Vecfl(env->object->imat, dxt);
MTC_Mat4Mul3Vecfl(env->object->imat, dyt);
set_dxtdyt(dxts, dyts, dxt, dyt, face);
imagewraposa(tex, sco, dxts, dyts);
imagewraposa(tex, sco, dxts, dyts, texres);
/* edges? */
if(Ta<1.0) {
col[0]= Ta; col[1]= Tr; col[2]= Tg; col[3]= Tb;
if(texres->ta<1.0) {
TexResult texr1, texr2;
VecAddf(vec, vec, dxt);
face1= envcube_isect(vec, sco);
@ -692,12 +686,11 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
if(face!=face1) {
tex->ima= env->cube[face1];
set_dxtdyt(dxts, dyts, dxt, dyt, face1);
imagewraposa(tex, sco, dxts, dyts);
col[4]= Ta; col[5]= Tr; col[6]= Tg; col[7]= Tb;
imagewraposa(tex, sco, dxts, dyts, &texr1);
}
else col[4]= col[5]= col[6]= col[7]= 0.0;
else texr1.tr= texr1.tg= texr1.tb= texr1.ta= 0.0;
/* here was the nasty bug! col[5,6,7] were not zero-ed. FPE! */
/* here was the nasty bug! results were not zero-ed. FPE! */
VecAddf(vec, vec, dyt);
face1= envcube_isect(vec, sco);
@ -706,23 +699,23 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex)
if(face!=face1) {
tex->ima= env->cube[face1];
set_dxtdyt(dxts, dyts, dxt, dyt, face1);
imagewraposa(tex, sco, dxts, dyts);
col[8]= Ta; col[9]= Tr; col[10]= Tg; col[11]= Tb;
imagewraposa(tex, sco, dxts, dyts, &texr2);
}
else col[8]= col[9]= col[10]= col[11]= 0.0;
else texr2.tr= texr2.tg= texr2.tb= texr2.ta= 0.0;
fac= (col[0]+col[4]+col[8]);
fac= 1.0/fac;
Tr= fac*(col[0]*col[1] + col[4]*col[5] + col[8]*col[9] );
Tg= fac*(col[0]*col[2] + col[4]*col[6] + col[8]*col[10] );
Tb= fac*(col[0]*col[3] + col[4]*col[7] + col[8]*col[11] );
Ta= 1.0;
fac= (texres->ta+texr1.ta+texr2.ta);
if(fac!=0.0) {
fac= 1.0/fac;
texres->tr= fac*(texres->ta*texres->tr + texr1.ta*texr1.tr + texr2.ta*texr2.tr );
texres->tg= fac*(texres->ta*texres->tg + texr1.ta*texr1.tg + texr2.ta*texr2.tg );
texres->tb= fac*(texres->ta*texres->tb + texr1.ta*texr1.tb + texr2.ta*texr2.tb );
}
texres->ta= 1.0;
}
}
else {
imagewrap(tex, sco);
imagewrap(tex, sco, texres);
}
tex->ima= env->ima;

@ -33,8 +33,8 @@
#include "GEN_messaging.h"
#include "stdio.h"
#include "errorHandler.h"
#include "render_intern.h"
#ifdef HAVE_CONFIG_H
#include <config.h>

@ -35,7 +35,6 @@
#include "gammaCorrectionTables.h"
#include <stdlib.h>
#include <math.h>
#include "render_intern.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -65,7 +64,7 @@ static float inv_colour_step;
static float valid_gamma;
static float valid_inv_gamma;
static int gamma_table_initialised = 0;
static int do_gamma;
int do_gamma=0;
/* ------------------------------------------------------------------------- */
float gammaCorrect(float c)
@ -153,19 +152,5 @@ int gammaTableIsInitialised(void)
}
/* ------------------------------------------------------------------------- */
int doGamma()
{
return do_gamma;
}
/* ------------------------------------------------------------------------- */
/**
* Set/unset performing gamma corrections.
*/
void setDoGamma(int i)
{
do_gamma = i;
}
/* eof */

@ -0,0 +1,911 @@
/**
*
* $Id:
*
* ***** 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 *****
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <math.h>
#ifndef WIN32
#include <unistd.h>
#else
#include <io.h>
#endif
#include "MEM_guardedalloc.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "DNA_image_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_blenlib.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_image.h"
#include "BKE_texture.h"
#include "BKE_library.h"
#include "SDL_thread.h"
#include "render.h"
#include "texture.h"
int imaprepeat, imapextend;
/* *********** IMAGEWRAPPING ****************** */
int imagewrap(Tex *tex, float *texvec, TexResult *texres)
{
Image *ima;
struct ImBuf *ibuf;
float fx, fy, val1, val2, val3;
int ofs, x, y;
char *rect;
texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0;
ima= tex->ima;
if(ima==NULL || ima->ok== 0) {
return 0;
}
if(ima->ibuf==NULL) {
extern SDL_mutex *load_ibuf_lock; // initrender.c
if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock);
if(ima->ibuf==NULL) ima_ibuf_is_nul(tex);
if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock);
}
if (ima->ok) {
ibuf = ima->ibuf;
if(tex->imaflag & TEX_IMAROT) {
fy= texvec[0];
fx= texvec[1];
}
else {
fx= texvec[0];
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) {
return 0;
}
}
else if( tex->extend==TEX_CLIP || tex->extend==TEX_CHECKER) {
if(x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) {
return 0;
}
}
else {
if(tex->extend==TEX_EXTEND) {
if(x>=ibuf->x) x = ibuf->x-1;
else if(x<0) x= 0;
}
else {
x= x % ibuf->x;
if(x<0) x+= ibuf->x;
}
if(tex->extend==TEX_EXTEND) {
if(y>=ibuf->y) y = ibuf->y-1;
else if(y<0) y= 0;
}
else {
y= y % ibuf->y;
if(y<0) y+= ibuf->y;
}
}
/* warning, no return before setting back! */
if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
ibuf->rect+= (ibuf->x*ibuf->y);
}
ofs = y * ibuf->x + x;
rect = (char *)( ibuf->rect+ ofs);
if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
ibuf->rect-= (ibuf->x*ibuf->y);
}
if(tex->imaflag & TEX_USEALPHA) {
if(tex->imaflag & TEX_CALCALPHA);
else texres->talpha= 1;
}
texres->tr = ((float)rect[0])/255.0f;
texres->tg = ((float)rect[1])/255.0f;
texres->tb = ((float)rect[2])/255.0f;
if(texres->nor) {
if(tex->imaflag & TEX_NORMALMAP) {
texres->nor[0]= 0.5-texres->tr;
texres->nor[1]= 0.5-texres->tg;
texres->nor[2]= -texres->tb;
}
else {
/* bump: take three samples */
val1= texres->tr+texres->tg+texres->tb;
if(x<ibuf->x-1) {
rect+=4;
val2= ((float)(rect[0]+rect[1]+rect[2]))/255.0f;
rect-=4;
}
else val2= val1;
if(y<ibuf->y-1) {
rect+= 4*ibuf->x;
val3= ((float)(rect[0]+rect[1]+rect[2]))/255.0f;
}
else val3= val1;
/* do not mix up x and y here! */
texres->nor[0]= (val1-val2);
texres->nor[1]= (val1-val3);
}
}
//BRICONTRGB;
if(texres->talpha) texres->ta= texres->tin= ((float)rect[3])/255.0f;
else if(tex->imaflag & TEX_CALCALPHA) {
texres->ta= texres->tin= MAX3(texres->tr, texres->tg, texres->tb);
}
else texres->ta= texres->tin= 1.0;
if(tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
}
if(texres->nor) return 3;
else return 1;
}
static void clipx_rctf_swap(rctf *stack, short *count, float x1, float x2)
{
rctf *rf, *newrct;
short a;
a= *count;
rf= stack;
for(;a>0;a--) {
if(rf->xmin<x1) {
if(rf->xmax<x1) {
rf->xmin+= (x2-x1);
rf->xmax+= (x2-x1);
}
else {
if(rf->xmax>x2) rf->xmax= x2;
newrct= stack+ *count;
(*count)++;
newrct->xmax= x2;
newrct->xmin= rf->xmin+(x2-x1);
newrct->ymin= rf->ymin;
newrct->ymax= rf->ymax;
if(newrct->xmin==newrct->xmax) (*count)--;
rf->xmin= x1;
}
}
else if(rf->xmax>x2) {
if(rf->xmin>x2) {
rf->xmin-= (x2-x1);
rf->xmax-= (x2-x1);
}
else {
if(rf->xmin<x1) rf->xmin= x1;
newrct= stack+ *count;
(*count)++;
newrct->xmin= x1;
newrct->xmax= rf->xmax-(x2-x1);
newrct->ymin= rf->ymin;
newrct->ymax= rf->ymax;
if(newrct->xmin==newrct->xmax) (*count)--;
rf->xmax= x2;
}
}
rf++;
}
}
static void clipy_rctf_swap(rctf *stack, short *count, float y1, float y2)
{
rctf *rf, *newrct;
short a;
a= *count;
rf= stack;
for(;a>0;a--) {
if(rf->ymin<y1) {
if(rf->ymax<y1) {
rf->ymin+= (y2-y1);
rf->ymax+= (y2-y1);
}
else {
if(rf->ymax>y2) rf->ymax= y2;
newrct= stack+ *count;
(*count)++;
newrct->ymax= y2;
newrct->ymin= rf->ymin+(y2-y1);
newrct->xmin= rf->xmin;
newrct->xmax= rf->xmax;
if(newrct->ymin==newrct->ymax) (*count)--;
rf->ymin= y1;
}
}
else if(rf->ymax>y2) {
if(rf->ymin>y2) {
rf->ymin-= (y2-y1);
rf->ymax-= (y2-y1);
}
else {
if(rf->ymin<y1) rf->ymin= y1;
newrct= stack+ *count;
(*count)++;
newrct->ymin= y1;
newrct->ymax= rf->ymax-(y2-y1);
newrct->xmin= rf->xmin;
newrct->xmax= rf->xmax;
if(newrct->ymin==newrct->ymax) (*count)--;
rf->ymax= y2;
}
}
rf++;
}
}
static float square_rctf(rctf *rf)
{
float x, y;
x= rf->xmax- rf->xmin;
y= rf->ymax- rf->ymin;
return (x*y);
}
static float clipx_rctf(rctf *rf, float x1, float x2)
{
float size;
size= rf->xmax - rf->xmin;
if(rf->xmin<x1) {
rf->xmin= x1;
}
if(rf->xmax>x2) {
rf->xmax= x2;
}
if(rf->xmin > rf->xmax) {
rf->xmin = rf->xmax;
return 0.0;
}
else if(size!=0.0) {
return (rf->xmax - rf->xmin)/size;
}
return 1.0;
}
static float clipy_rctf(rctf *rf, float y1, float y2)
{
float size;
size= rf->ymax - rf->ymin;
if(rf->ymin<y1) {
rf->ymin= y1;
}
if(rf->ymax>y2) {
rf->ymax= y2;
}
if(rf->ymin > rf->ymax) {
rf->ymin = rf->ymax;
return 0.0;
}
else if(size!=0.0) {
return (rf->ymax - rf->ymin)/size;
}
return 1.0;
}
static void boxsampleclip(struct ImBuf *ibuf, rctf *rf, TexResult *texres)
{
/* sample box, is clipped already, and minx etc. have been set at ibuf size.
Enlarge with antialiased edges of the pixels */
float muly,mulx,div;
int ofs;
int x, y, startx, endx, starty, endy;
char *rect;
startx= (int)floor(rf->xmin);
endx= (int)floor(rf->xmax);
starty= (int)floor(rf->ymin);
endy= (int)floor(rf->ymax);
if(startx < 0) startx= 0;
if(starty < 0) starty= 0;
if(endx>=ibuf->x) endx= ibuf->x-1;
if(endy>=ibuf->y) endy= ibuf->y-1;
if(starty==endy && startx==endx) {
ofs = starty*ibuf->x + startx;
rect = (char *)(ibuf->rect +ofs);
texres->tr= ((float)rect[0])/255.0f;
texres->tg= ((float)rect[1])/255.0f;
texres->tb= ((float)rect[2])/255.0f;
/* alpha has been set in function imagewraposa() */
if(texres->talpha) {
texres->ta= ((float)rect[3])/255.0f;
}
}
else {
div= texres->tr= texres->tg= texres->tb= texres->ta= 0.0;
for(y=starty;y<=endy;y++) {
ofs = y*ibuf->x +startx;
rect = (char *)(ibuf->rect+ofs);
muly= 1.0;
if(starty==endy);
else {
if(y==starty) muly= 1.0f-(rf->ymin - y);
if(y==endy) muly= (rf->ymax - y);
}
if(startx==endx) {
mulx= muly;
if(texres->talpha) texres->ta+= mulx*rect[3];
texres->tr+= mulx*rect[0];
texres->tg+= mulx*rect[1];
texres->tb+= mulx*rect[2];
div+= mulx;
}
else {
for(x=startx;x<=endx;x++) {
mulx= muly;
if(x==startx) mulx*= 1.0f-(rf->xmin - x);
if(x==endx) mulx*= (rf->xmax - x);
if(mulx==1.0) {
if(texres->talpha) texres->ta+= rect[3];
texres->tr+= rect[0];
texres->tg+= rect[1];
texres->tb+= rect[2];
div+= 1.0;
}
else {
if(texres->talpha) texres->ta+= mulx*rect[3];
texres->tr+= mulx*rect[0];
texres->tg+= mulx*rect[1];
texres->tb+= mulx*rect[2];
div+= mulx;
}
rect+=4;
}
}
}
if(div!=0.0) {
div*= 255.0;
texres->tb/= div;
texres->tg/= div;
texres->tr/= div;
if(texres->talpha) texres->ta/= div;
}
else {
texres->tr= texres->tg= texres->tb= texres->ta= 0.0;
}
}
}
static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float maxy, TexResult *texres)
{
/* Sample box, performs clip. minx etc are in range 0.0 - 1.0 .
* Enlarge with antialiased edges of pixels.
* If global variable 'imaprepeat' has been set, the
* clipped-away parts are sampled as well.
*/
TexResult texr;
rctf *rf, stack[8];
float opp, tot, alphaclip= 1.0;
short count=1;
rf= stack;
rf->xmin= minx*(ibuf->x);
rf->xmax= maxx*(ibuf->x);
rf->ymin= miny*(ibuf->y);
rf->ymax= maxy*(ibuf->y);
if(imapextend);
else if(imaprepeat) clipx_rctf_swap(stack, &count, 0.0, (float)(ibuf->x));
else {
alphaclip= clipx_rctf(rf, 0.0, (float)(ibuf->x));
if(alphaclip<=0.0) {
texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
return;
}
}
if(imapextend);
else if(imaprepeat) clipy_rctf_swap(stack, &count, 0.0, (float)(ibuf->y));
else {
alphaclip*= clipy_rctf(rf, 0.0, (float)(ibuf->y));
if(alphaclip<=0.0) {
texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
return;
}
}
if(count>1) {
tot= texres->tr= texres->tb= texres->tg= texres->ta= 0.0;
while(count--) {
boxsampleclip(ibuf, rf, &texr);
opp= square_rctf(rf);
tot+= opp;
texres->tr+= opp*texr.tr;
texres->tg+= opp*texr.tg;
texres->tb+= opp*texr.tb;
if(texres->talpha) texres->ta+= opp*texr.ta;
rf++;
}
if(tot!= 0.0) {
texres->tr/= tot;
texres->tg/= tot;
texres->tb/= tot;
if(texres->talpha) texres->ta/= tot;
}
}
else {
boxsampleclip(ibuf, rf, texres);
}
if(texres->talpha==0) texres->ta= 1.0;
if(alphaclip!=1.0) {
/* this is for laetr investigation, premul or not? */
/* texres->tr*= alphaclip; */
/* texres->tg*= alphaclip; */
/* texres->tb*= alphaclip; */
texres->ta*= alphaclip;
}
}
static void makemipmap(Image *ima)
{
struct ImBuf *ibuf;
int minsize, curmap=0;
ibuf= ima->ibuf;
minsize= MIN2(ibuf->x, ibuf->y);
while(minsize>3 && curmap<BLI_ARRAY_NELEMS(ima->mipmap)) {
ibuf= IMB_dupImBuf(ibuf);
IMB_filter(ibuf);
ima->mipmap[curmap]= (struct ImBuf *)IMB_onehalf(ibuf);
IMB_freeImBuf(ibuf);
ibuf= ima->mipmap[curmap];
curmap++;
minsize= MIN2(ibuf->x, ibuf->y);
}
}
int imagewraposa(Tex *tex, float *texvec, float *dxt, float *dyt, TexResult *texres)
{
extern SDL_mutex *load_ibuf_lock; // initrender.c
TexResult texr;
Image *ima;
ImBuf *ibuf, *previbuf;
float fx, fy, minx, maxx, miny, maxy, dx, dy;
float maxd, pixsize, val1, val2, val3;
int curmap;
ima= tex->ima;
texres->tin= texres->ta= texres->tr= texres->tg= texres->tb= 0.0;
if(ima==NULL || ima->ok== 0) {
return 0;
}
if(ima->ibuf==NULL) {
if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock);
if(ima->ibuf==NULL) ima_ibuf_is_nul(tex);
if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock);
}
if (ima->ok) {
if(tex->imaflag & TEX_MIPMAP) {
if(ima->mipmap[0]==NULL) {
if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock);
if(ima->mipmap[0]==NULL) makemipmap(ima);
if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock);
}
}
ibuf = ima->ibuf;
if(tex->imaflag & TEX_USEALPHA) {
if(tex->imaflag & TEX_CALCALPHA);
else texres->talpha= 1;
}
texr.talpha= texres->talpha;
if(tex->imaflag & TEX_IMAROT) {
fy= texvec[0];
fx= texvec[1];
}
else {
fx= texvec[0];
fy= texvec[1];
}
if(ibuf->flags & IB_fields) {
if(R.r.mode & R_FIELDS) { /* field render */
if(R.flag & R_SEC_FIELD) { /* correction for 2nd field */
/* fac1= 0.5/( (float)ibuf->y ); */
/* fy-= fac1; */
}
else { /* first field */
fy+= 0.5f/( (float)ibuf->y );
}
}
}
/* pixel coordinates */
minx= MIN3(dxt[0],dyt[0],dxt[0]+dyt[0] );
maxx= MAX3(dxt[0],dyt[0],dxt[0]+dyt[0] );
miny= MIN3(dxt[1],dyt[1],dxt[1]+dyt[1] );
maxy= MAX3(dxt[1],dyt[1],dxt[1]+dyt[1] );
/* tex_sharper has been removed */
minx= tex->filtersize*(maxx-minx)/2.0f;
miny= tex->filtersize*(maxy-miny)/2.0f;
if(tex->imaflag & TEX_IMAROT) SWAP(float, minx, miny);
if(minx>0.25) minx= 0.25;
else if(minx<0.00001f) minx= 0.00001f; /* side faces of unit-cube */
if(miny>0.25) miny= 0.25;
else if(miny<0.00001f) miny= 0.00001f;
/* repeat and clip */
/* watch it: imaprepeat is global value (see boxsample) */
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) {
return 0;
}
}
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) {
return 0;
}
}
else {
if(tex->extend==TEX_EXTEND) {
if(fx>1.0) fx = 1.0;
else if(fx<0.0) fx= 0.0;
}
else {
if(fx>1.0) fx -= (int)(fx);
else if(fx<0.0) fx+= 1-(int)(fx);
}
if(tex->extend==TEX_EXTEND) {
if(fy>1.0) fy = 1.0;
else if(fy<0.0) fy= 0.0;
}
else {
if(fy>1.0) fy -= (int)(fy);
else if(fy<0.0) fy+= 1-(int)(fy);
}
}
/* warning no return! */
if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
ibuf->rect+= (ibuf->x*ibuf->y);
}
/* choice: */
if(tex->imaflag & TEX_MIPMAP) {
dx= minx;
dy= miny;
maxd= MAX2(dx, dy);
if(maxd>0.5) maxd= 0.5;
pixsize = 1.0f/ (float) MIN2(ibuf->x, ibuf->y);
curmap= 0;
previbuf= ibuf;
while(curmap<BLI_ARRAY_NELEMS(ima->mipmap) && ima->mipmap[curmap]) {
if(maxd < pixsize) break;
previbuf= ibuf;
ibuf= ima->mipmap[curmap];
pixsize= 1.0f / (float)MIN2(ibuf->x, ibuf->y); /* this used to be 1.0 */
curmap++;
}
if(previbuf!=ibuf || (tex->imaflag & TEX_INTERPOL)) {
/* sample at least 1 pixel */
if (minx < 0.5f / ima->ibuf->x) minx = 0.5f / ima->ibuf->x;
if (miny < 0.5f / ima->ibuf->y) miny = 0.5f / ima->ibuf->y;
}
if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
/* a bit extra filter */
minx*= 1.35f;
miny*= 1.35f;
boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, texres);
val1= texres->tr+texres->tg+texres->tb;
boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
val2= texr.tr + texr.tg + texr.tb;
boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &texr);
val3= texr.tr + texr.tg + texr.tb;
if(previbuf!=ibuf) { /* interpolate */
boxsample(previbuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, &texr);
/* calc rgb */
dx= 2.0f*(pixsize-maxd)/pixsize;
if(dx>=1.0f) {
texres->ta= texr.ta; texres->tb= texr.tb;
texres->tg= texr.tg; texres->tr= texr.tr;
}
else {
dy= 1.0f-dx;
texres->tb= dy*texres->tb+ dx*texr.tb;
texres->tg= dy*texres->tg+ dx*texr.tg;
texres->tr= dy*texres->tr+ dx*texr.tr;
texres->ta= dy*texres->ta+ dx*texr.ta;
}
val1= dy*val1+ dx*(texr.tr + texr.tg + texr.tb);
boxsample(previbuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
val2= dy*val2+ dx*(texr.tr + texr.tg + texr.tb);
boxsample(previbuf, fx-2.0f*minx, fy-miny, fx+minx, fy+2.0f*miny, &texr);
val3= dy*val3+ dx*(texr.tr + texr.tg + texr.tb);
}
/* don't switch x or y! */
texres->nor[0]= (val1-val2);
texres->nor[1]= (val1-val3);
}
else {
maxx= fx+minx;
minx= fx-minx;
maxy= fy+miny;
miny= fy-miny;
boxsample(ibuf, minx, miny, maxx, maxy, texres);
if(previbuf!=ibuf) { /* interpolate */
boxsample(previbuf, minx, miny, maxx, maxy, &texr);
fx= 2.0f*(pixsize-maxd)/pixsize;
if(fx>=1.0) {
texres->ta= texr.ta; texres->tb= texr.tb;
texres->tg= texr.tg; texres->tr= texr.tr;
} else {
fy= 1.0f-fx;
texres->tb= fy*texres->tb+ fx*texr.tb;
texres->tg= fy*texres->tg+ fx*texr.tg;
texres->tr= fy*texres->tr+ fx*texr.tr;
texres->ta= fy*texres->ta+ fx*texr.ta;
}
}
}
}
else {
if((tex->imaflag & TEX_INTERPOL)) {
/* sample 1 pixel minimum */
if (minx < 0.5f / ima->ibuf->x) minx = 0.5f / ima->ibuf->x;
if (miny < 0.5f / ima->ibuf->y) miny = 0.5f / ima->ibuf->y;
}
if(texres->nor && (tex->imaflag & TEX_NORMALMAP)==0) {
/* a bit extra filter */
minx*= 1.35f;
miny*= 1.35f;
boxsample(ibuf, fx-2.0f*minx, fy-2.0f*miny, fx+minx, fy+miny, texres);
val1= texres->tr+texres->tg+texres->tb;
boxsample(ibuf, fx-minx, fy-2.0f*miny, fx+2.0f*minx, fy+miny, &texr);
val2= texr.tr + texr.tg + texr.tb;
boxsample(ibuf, fx-2.0f*minx, fy-miny, fx+miny, fy+2.0f*miny, &texr);
val3= texr.tr + texr.tg + texr.tb;
/* don't switch x or y! */
texres->nor[0]= (val1-val2);
texres->nor[1]= (val1-val3);
}
else {
boxsample(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, texres);
}
}
BRICONTRGB;
if(tex->imaflag & TEX_CALCALPHA) {
texres->ta= texres->tin= texres->ta*MAX3(texres->tr, texres->tg, texres->tb);
}
else texres->tin= texres->ta;
if(tex->flag & TEX_NEGALPHA) texres->ta= 1.0f-texres->ta;
if( (R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields) ) {
ibuf->rect-= (ibuf->x*ibuf->y);
}
if(texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
texres->nor[0]= 0.5-texres->tr;
texres->nor[1]= 0.5-texres->tg;
texres->nor[2]= -texres->tb;
}
}
else {
texres->tin= 0.0f;
return 0;
}
if(texres->nor) return 3;
else return 1;
}

@ -86,17 +86,20 @@
#include "quicktime_export.h"
#endif
#include "SDL_thread.h"
/* this module */
#include "render.h"
#include "render_intern.h"
#include "RE_callbacks.h"
#include "zbuf.h"
#include "rendercore.h" /* part handler for the old renderer, shading functions */
#include "pixelshading.h"
#include "renderPreAndPost.h"
#include "vanillaRenderPipe.h"
#include "renderHelp.h"
#include "jitter.h"
#include "gammaCorrectionTables.h"
/* Own includes */
#include "initrender.h"
@ -104,72 +107,16 @@
/* yafray: include for yafray export/render */
#include "YafRay_Api.h"
/* Some crud :/ */
#define ELEM3(a, b, c, d) ( ELEM(a, b, c) || (a)==(d) )
/* from render.c */
extern float fmask[256], centLut[16], *fmask1[9], *fmask2[9];
extern unsigned short *mask1[9], *mask2[9], *igamtab2;
extern char cmask[256], *centmask;
float centLut[16], *fmask1[9], *fmask2[9];
unsigned short *gamtab, *igamtab2, *igamtab1;
char cmask[256], *centmask;
Material defmaterial;
short pa; /* pa is global part, for print */
short allparts[65][4];
int qscount;
/* ********************* *********************** */
void init_def_material(void)
{
Material *ma;
ma= &defmaterial;
init_material(&defmaterial);
init_render_material(ma);
}
void RE_init_render_data(void)
{
memset(&R, 0, sizeof(RE_Render));
memset(&O, 0, sizeof(Osa));
O.dxwin[0]= 1.0;
O.dywin[1]= 1.0;
R.blove= (VertRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blove");
R.blovl= (VlakRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blovl");
R.bloha= (HaloRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Bloha");
R.la= (LampRen **)MEM_mallocN(LAMPINITSIZE*sizeof(void *),"renderlamparray");
init_def_material();
}
void RE_free_render_data()
{
MEM_freeN(R.blove);
R.blove= 0;
MEM_freeN(R.blovl);
R.blovl= 0;
MEM_freeN(R.bloha);
R.bloha= 0;
MEM_freeN(R.la);
R.la= 0;
if(R.rectot) MEM_freeN(R.rectot);
if(R.rectz) MEM_freeN(R.rectz);
if(R.rectspare) MEM_freeN(R.rectspare);
R.rectot= 0;
R.rectz= 0;
R.rectspare= 0;
end_render_material(&defmaterial);
}
/* ****************** GAMMA, MASKS and LUTS **************** */
float calc_weight(float *weight, int i, int j)
static float calc_weight(float *weight, int i, int j)
{
float x, y, dist, totw= 0.0, fac;
int a;
@ -201,23 +148,20 @@ float calc_weight(float *weight, int i, int j)
return totw;
}
void RE_init_filt_mask(void)
static void init_filt_mask(void)
{
static int firsttime=1;
static int lastosa=0;
static int lastgauss=0;
static float lastgamma= 0.0;
float gamma, igamma, flweight[32];
float gamma, igamma, flweight[32], fmask[256];
float weight[32], totw, val, *fpx1, *fpx2, *fpy1, *fpy2, *m3, *m4;
int i, j, a;
unsigned short *m1, *m2, shweight[32];
if(firsttime) {
firsttime= 0;
for(a=0; a<9;a++) {
mask1[a]= MEM_mallocN(256*sizeof(short), "initfilt");
mask2[a]= MEM_mallocN(256*sizeof(short), "initfilt");
fmask1[a]= MEM_mallocN(256*sizeof(float), "initfilt");
fmask2[a]= MEM_mallocN(256*sizeof(float), "initfilt");
}
@ -294,10 +238,8 @@ void RE_init_filt_mask(void)
}
for(a=0; a<9;a++) {
memset(mask1[a], 0, 256*2);
memset(mask2[a], 0, 256*2);
memset(fmask1[a], 0, 256*4);
memset(fmask2[a], 0, 256*4);
memset(fmask1[a], 0, 256*sizeof(float));
memset(fmask2[a], 0, 256*sizeof(float));
}
/* calculate totw */
@ -315,60 +257,41 @@ void RE_init_filt_mask(void)
memset(weight, 0, sizeof(weight));
calc_weight(weight, i, j);
for(a=0; a<16; a++) shweight[a]= weight[a]*(65535.0/totw);
for(a=0; a<16; a++) flweight[a]= weight[a]*(1.0/totw);
m1= mask1[ 3*(j+1)+i+1 ];
m2= mask2[ 3*(j+1)+i+1 ];
m3= fmask1[ 3*(j+1)+i+1 ];
m4= fmask2[ 3*(j+1)+i+1 ];
for(a=0; a<256; a++) {
if(a & 1) {
m1[a]+= shweight[0];
m2[a]+= shweight[8];
m3[a]+= flweight[0];
m4[a]+= flweight[8];
}
if(a & 2) {
m1[a]+= shweight[1];
m2[a]+= shweight[9];
m3[a]+= flweight[1];
m4[a]+= flweight[9];
}
if(a & 4) {
m1[a]+= shweight[2];
m2[a]+= shweight[10];
m3[a]+= flweight[2];
m4[a]+= flweight[10];
}
if(a & 8) {
m1[a]+= shweight[3];
m2[a]+= shweight[11];
m3[a]+= flweight[3];
m4[a]+= flweight[11];
}
if(a & 16) {
m1[a]+= shweight[4];
m2[a]+= shweight[12];
m3[a]+= flweight[4];
m4[a]+= flweight[12];
}
if(a & 32) {
m1[a]+= shweight[5];
m2[a]+= shweight[13];
m3[a]+= flweight[5];
m4[a]+= flweight[13];
}
if(a & 64) {
m1[a]+= shweight[6];
m2[a]+= shweight[14];
m3[a]+= flweight[6];
m4[a]+= flweight[14];
}
if(a & 128) {
m1[a]+= shweight[7];
m2[a]+= shweight[15];
m3[a]+= flweight[7];
m4[a]+= flweight[15];
}
@ -452,13 +375,11 @@ void RE_init_filt_mask(void)
}
}
void RE_free_filt_mask()
static void free_filt_mask()
{
int a;
for(a=0; a<9; a++) {
MEM_freeN(mask1[a]);
MEM_freeN(mask2[a]);
MEM_freeN(fmask1[a]);
MEM_freeN(fmask2[a]);
}
@ -469,9 +390,9 @@ void RE_free_filt_mask()
MEM_freeN(centmask);
}
/* add stuff */
/* unused */
#if 0
void defaultlamp()
{
LampRen *lar;
@ -489,8 +410,60 @@ void defaultlamp()
lar->b= 1.0;
lar->lay= 65535;
}
#endif
/* ********************* init calls *********************** */
static void init_def_material(void)
{
Material *ma;
ma= &defmaterial;
init_material(&defmaterial);
init_render_material(ma);
}
void RE_init_render_data(void)
{
memset(&R, 0, sizeof(RE_Render));
R.blove= (VertRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blove");
R.blovl= (VlakRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Blovl");
R.bloha= (HaloRen **)MEM_callocN(sizeof(void *)*(TABLEINITSIZE),"Bloha");
R.la= (LampRen **)MEM_mallocN(LAMPINITSIZE*sizeof(void *),"renderlamparray");
init_def_material();
init_filt_mask();
}
void RE_free_render_data()
{
MEM_freeN(R.blove);
R.blove= NULL;
MEM_freeN(R.blovl);
R.blovl= NULL;
MEM_freeN(R.bloha);
R.bloha= NULL;
MEM_freeN(R.la);
R.la= NULL;
if(R.rectot) MEM_freeN(R.rectot);
if(R.rectftot) MEM_freeN(R.rectftot);
if(R.rectz) MEM_freeN(R.rectz);
if(R.rectspare) MEM_freeN(R.rectspare);
R.rectot= NULL;
R.rectftot= NULL;
R.rectz= NULL;
R.rectspare= NULL;
end_render_material(&defmaterial);
free_filt_mask();
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void RE_make_existing_file(char *name)
@ -601,13 +574,41 @@ void RE_setwindowclip(int mode, int jmode)
/* ~~~~~~~~~~~~~~~~ PARTS ~~~~~~~~~~~~~~~~~~~~~~ */
#define PART_EMPTY -2
void initparts()
/**
* Part as in part-rendering. An image rendered in parts is rendered
* to a list of parts, with x,y size, and a pointer to the render
* output stored per part. Internal!
*/
typedef struct Part
{
struct Part *next, *prev;
unsigned int *rect; // color 4x8 bits
float *rectf; // color 4x32 bits
unsigned int *rectz; // zbuffer
short minx, miny, maxx, maxy, x, y;
} Part;
static void freeparts(void)
{
Part *part= R.parts.first;
while(part) {
if(part->rect) MEM_freeN(part->rect);
if(part->rectz) MEM_freeN(part->rectz);
if(part->rectf) MEM_freeN(part->rectf);
part= part->next;
}
BLI_freelistN(&R.parts);
}
static void initparts(void)
{
Part *pa;
short nr, xd, yd, xpart, ypart, xparts, yparts;
short a, xminb, xmaxb, yminb, ymaxb;
freeparts();
if(R.r.mode & R_BORDER) {
xminb= R.r.border.xmin*R.rectx;
xmaxb= R.r.border.xmax*R.rectx;
@ -629,9 +630,6 @@ void initparts()
xparts= R.r.xparts; /* for border */
yparts= R.r.yparts;
for(nr=0;nr<xparts*yparts;nr++)
allparts[nr][0]= PART_EMPTY; /* clear array */
xpart= R.rectx/xparts;
ypart= R.recty/yparts;
@ -645,82 +643,108 @@ void initparts()
xpart= (xmaxb-xminb)/xparts;
ypart= (ymaxb-yminb)/yparts;
}
for(nr=0; nr<xparts*yparts; nr++) {
pa= MEM_callocN(sizeof(Part), "new part");
if(R.r.mode & R_PANORAMA) {
allparts[nr][0]= 0;
allparts[nr][1]= 0;
allparts[nr][2]= R.rectx;
allparts[nr][3]= R.recty;
pa->minx= pa->miny= 0;
pa->maxx= pa->x= R.rectx;
pa->maxy= pa->y= R.recty;
}
else {
xd= (nr % xparts);
yd= (nr-xd)/xparts;
allparts[nr][0]= xminb+ xd*xpart;
allparts[nr][1]= yminb+ yd*ypart;
if(xd<R.r.xparts-1) allparts[nr][2]= allparts[nr][0]+xpart;
else allparts[nr][2]= xmaxb;
if(yd<R.r.yparts-1) allparts[nr][3]= allparts[nr][1]+ypart;
else allparts[nr][3]= ymaxb;
pa->minx= xminb+ xd*xpart;
pa->miny= yminb+ yd*ypart;
if(xd<R.r.xparts-1) pa->maxx= pa->minx+xpart;
else pa->maxx= xmaxb;
if(yd<R.r.yparts-1) pa->maxy= pa->miny+ypart;
else pa->maxy= ymaxb;
if(allparts[nr][2]-allparts[nr][0]<=0) allparts[nr][0]= PART_EMPTY;
if(allparts[nr][3]-allparts[nr][1]<=0) allparts[nr][0]= PART_EMPTY;
/* gauss needs 1 pixel extra to work */
if(xparts*yparts>1 && (R.r.mode & R_GAUSS)) {
allparts[nr][0]-= 1;
allparts[nr][1]-= 1;
allparts[nr][2]+= 1;
allparts[nr][3]+= 1;
}
pa->x= pa->maxx-pa->minx;
pa->y= pa->maxy-pa->miny;
}
if(pa->x>0 && pa->y>0) {
/* Gauss needs 1 pixel extra to work */
if(xparts*yparts>1 && (R.r.mode & R_GAUSS)) {
pa->minx-= 1;
pa->miny-= 1;
pa->maxx+= 1;
pa->maxy+= 1;
pa->x+= 2;
pa->y+= 2;
}
BLI_addtail(&R.parts, pa);
}
else MEM_freeN(pa);
}
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
short setpart(short nr) /* return 0 if incorrect part */
static void setpart(Part *pa)
{
if(allparts[nr][0]== PART_EMPTY) return 0;
R.xstart= allparts[nr][0]-R.afmx;
R.ystart= allparts[nr][1]-R.afmy;
R.xend= allparts[nr][2]-R.afmx;
R.yend= allparts[nr][3]-R.afmy;
R.rectx= R.xend-R.xstart;
R.recty= R.yend-R.ystart;
return 1;
R.xstart= pa->minx-R.afmx;
R.ystart= pa->miny-R.afmy;
R.xend= pa->maxx-R.afmx;
R.yend= pa->maxy-R.afmy;
R.rectx= pa->x;
R.recty= pa->y;
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void addparttorect(short nr, Part *part)
static void addparttorect(Part *pa)
{
unsigned int *rt, *rp;
float *rf, *rfp;
unsigned int *rt, *rtp, *rz, *rzp;
int y, heigth, len, copylen;
/* the right offset in rectot */
/* calc the right offset in rects, zbuffer cannot exist... */
rp= part->rect;
copylen=len= (allparts[nr][2]-allparts[nr][0]);
heigth= (allparts[nr][3]-allparts[nr][1]);
rtp= pa->rect;
rzp= pa->rectz;
rfp= pa->rectf;
copylen=len= pa->x;
heigth= pa->y;
if(R.r.mode & R_GAUSS) {
rp+= 1+len;
rtp+= 1+len;
if(rzp) rzp+= 1+len;
if(rfp) rfp+= 4*(1+len);
copylen= len-2;
heigth -= 2;
rt= R.rectot+ (allparts[nr][1] + 1)*R.rectx+ (allparts[nr][0]+1);
rt= R.rectot+ (pa->miny + 1)*R.rectx+ (pa->minx+1);
rz= R.rectz+ (pa->miny + 1)*R.rectx+ (pa->minx+1);
rf= R.rectftot+ 4*( (pa->miny + 1)*R.rectx + (pa->minx+1) );
}
else {
rt= R.rectot+ pa->miny*R.rectx+ pa->minx;
rz= R.rectz+ pa->miny*R.rectx+ pa->minx;
rf= R.rectftot+ 4*(pa->miny*R.rectx+ pa->minx);
}
else rt= R.rectot+ allparts[nr][1]*R.rectx+ allparts[nr][0];
for(y=0; y<heigth; y++) {
memcpy(rt, rp, 4*copylen);
memcpy(rt, rtp, 4*copylen);
rt+= R.rectx;
rp+= len;
rtp+= len;
if(rzp) {
memcpy(rz, rzp, 4*copylen);
rz+= R.rectx;
rzp+= len;
}
if(rfp) {
memcpy(rf, rfp, 16*copylen);
rf+= 4*R.rectx;
rfp+= 4*len;
}
}
}
@ -728,7 +752,7 @@ void addparttorect(short nr, Part *part)
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void add_to_blurbuf(int blur)
static void add_to_blurbuf(int blur)
{
static unsigned int *blurrect= 0;
int tot, gamval;
@ -797,7 +821,7 @@ void yafrayRender()
R.flag |= R_RENDERING; /* !!! */
if (R.rectz) MEM_freeN(R.rectz);
R.rectz = 0;
R.rectz = NULL;
// switch must be done before prepareScene()
if (!R.r.YFexportxml)
@ -815,39 +839,70 @@ void yafrayRender()
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
void render() {
/* yafray: render, see above */
if (R.r.renderer==R_YAFRAY)
yafrayRender();
else
oldRenderLoop();
// exported to other files, belongs in include... later
SDL_mutex *render_abuf_lock=NULL, *load_ibuf_lock=NULL;
static void renderloop_setblending(void)
{
/* this value should only be set here. do_gamma is for gammablended adding of subpixels */
do_gamma= 0;
if(R.r.mode & R_GAMMA) {
if((R.r.mode & R_OSA)) do_gamma= 1;
}
/* always call, it does gamma tables used by alphaunder, but call after R.osa and jit was set */
init_filt_mask();
switch (R.r.alphamode) {
case R_ALPHAKEY:
setSkyBlendingMode(RE_ALPHA_KEY);
break;
case R_ALPHAPREMUL:
setSkyBlendingMode(RE_ALPHA_PREMUL);
break;
default:
setSkyBlendingMode(RE_ALPHA_SKY);
}
/* SHould use slider when the gamma button is pressed. */
if (do_gamma) {
makeGammaTables(2.0);
} else {
makeGammaTables(1.0);
}
}
void oldRenderLoop(void) /* here the PART and FIELD loops */
static void mainRenderLoop(void) /* here the PART and FIELD loops */
{
Part *part;
unsigned int *rt, *rt1, *rt2;
int len, y;
short blur, a,fields,fi,parts; /* pa is a global because of print */
Part *pa;
int blur, fields, fi, totparts, nr;
if (R.rectz) MEM_freeN(R.rectz);
R.rectz = 0;
/* create mutexes for threaded render */
render_abuf_lock = SDL_CreateMutex();
load_ibuf_lock = SDL_CreateMutex();
if(R.rectz) MEM_freeN(R.rectz);
R.rectz = NULL;
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectftot = NULL;
/* FIELD LOOP */
totparts= R.r.xparts*R.r.yparts;
fields= 1;
parts= R.r.xparts*R.r.yparts;
if(R.r.mode & R_FIELDS) {
fields= 2;
R.rectf1= R.rectf2= 0; /* field rects */
R.rectf1= R.rectf2= NULL; /* field rects */
R.r.ysch/= 2;
R.afmy/= 2;
R.r.yasp*= 2;
R.ycor= ( (float)R.r.yasp)/( (float)R.r.xasp);
}
for(fi=0; fi<fields; fi++) {
@ -874,7 +929,7 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
if(R.r.mode & R_MBLUR) set_mblur_offs(R.osa-blur);
initparts(); /* always do, because of border */
setpart(0);
setpart(R.parts.first);
RE_local_init_render_display();
RE_local_clear_render_display(R.win);
@ -882,20 +937,18 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
prepareScene();
/* PARTS */
R.parts.first= R.parts.last= 0;
for(pa=0; pa<parts; pa++) {
/* PARTS LOOP */
nr= 0;
for(pa= R.parts.first; pa; pa= pa->next, nr++) {
if(RE_local_test_break()) break;
if(pa) { /* because case pa==0 has been done */
if(setpart(pa)==0) break;
}
setpart(pa);
if(R.r.mode & R_MBLUR) RE_setwindowclip(0, blur);
else RE_setwindowclip(0,-1);
if(R.r.mode & R_PANORAMA) setPanoRot(pa);
if(R.r.mode & R_PANORAMA) setPanoRot(nr);
/* HOMOGENIC COORDINATES AND ZBUF AND CLIP OPTIMISATION (per part) */
/* There may be some interference with z-coordinate */
@ -903,10 +956,13 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
doClipping(RE_projectverto);
if(RE_local_test_break()) break;
/* rectot is for result and integer face indices */
R.rectot= (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
if(R.rectot) MEM_freeN(R.rectot);
R.rectot= MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
if(R.rectftot) MEM_freeN(R.rectftot);
if(R.r.mode & R_FBUF) R.rectftot= MEM_callocN(4*sizeof(float)*R.rectx*R.recty, "rectftot");
if(R.r.mode & R_MBLUR) {
RE_local_printrenderinfo(0.0, R.osa - blur);
@ -928,17 +984,14 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
if( (R.r.mode & R_BORDER) && (R.r.mode & R_MOVIECROP));
else {
/* HANDLE PART OR BORDER */
if(parts>1 || (R.r.mode & R_BORDER)) {
if(totparts>1 || (R.r.mode & R_BORDER)) {
part= MEM_callocN(sizeof(Part), "part");
BLI_addtail(&R.parts, part);
part->rect= R.rectot;
pa->rect= R.rectot;
R.rectot= NULL;
if (R.rectz) {
MEM_freeN(R.rectz);
R.rectz= NULL;
}
pa->rectf= R.rectftot;
R.rectftot= NULL;
pa->rectz= R.rectz;
R.rectz= NULL;
}
}
@ -955,36 +1008,31 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
if(R.r.mode & R_PANORAMA) R.rectx*= R.r.xparts;
if(parts>1 || (R.r.mode & R_BORDER)) {
if(totparts>1 || (R.r.mode & R_BORDER)) {
int a;
if(R.rectot) MEM_freeN(R.rectot);
if(R.rectftot) MEM_freeN(R.rectftot);
if(R.rectz) MEM_freeN(R.rectz);
R.rectot=(unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
R.rectot= MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
R.rectz= MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectz");
if(R.r.mode & R_FBUF) R.rectftot= MEM_callocN(4*sizeof(float)*R.rectx*R.recty, "rectftot");
else R.rectftot= NULL;
part= R.parts.first;
for(pa=0; pa<parts; pa++) {
if(allparts[pa][0]== PART_EMPTY) break;
if(part==0) break;
for(a=0, pa= R.parts.first; pa; pa= pa->next, a++) {
if(R.r.mode & R_PANORAMA) {
if(pa) {
allparts[pa][0] += pa*R.r.xsch;
allparts[pa][2] += pa*R.r.xsch;
}
if(R.r.mode & R_PANORAMA) { // pano is fake parts...
pa->minx += a*R.r.xsch;
pa->maxx += a*R.r.xsch;
}
addparttorect(pa, part);
part= part->next;
addparttorect(pa);
}
part= R.parts.first;
while(part) {
MEM_freeN(part->rect);
part= part->next;
}
BLI_freelistN(&R.parts);
}
}
freeparts();
if( (R.flag & R_HALO)) {
if(RE_local_test_break()==0) add_halo_flare();
}
@ -1006,7 +1054,7 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
if(R.r.mode & R_FIELDS) {
if(R.flag & R_SEC_FIELD) R.rectf2= R.rectot;
else R.rectf1= R.rectot;
R.rectot= 0;
R.rectot= NULL;
}
if(RE_local_test_break()) break;
@ -1021,8 +1069,11 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
if(R.rectot) MEM_freeN(R.rectot); /* happens when a render has been stopped */
R.rectot=(unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
if(RE_local_test_break()==0) {
unsigned int *rt, *rt1, *rt2;
int len, a;
rt= R.rectot;
if(R.r.mode & R_ODDFIELD) {
@ -1045,48 +1096,58 @@ void oldRenderLoop(void) /* here the PART and FIELD loops */
rt2+= R.rectx;
}
}
if(R.rectf1) MEM_freeN(R.rectf1);
R.rectf1= NULL;
if(R.rectf2) MEM_freeN(R.rectf2);
R.rectf2= NULL;
/* fbuf and zbuf free, image size differs now */
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectftot= NULL;
if(R.rectz) MEM_freeN(R.rectz);
R.rectz= NULL;
}
/* R.rectx= R.r.xsch; */
/* if(R.r.mode & R_PANORAMA) R.rectx*= R.r.xparts; */
/* R.recty= R.r.ysch; */
/* if border: still do skybuf */
if(R.r.mode & R_BORDER) {
if( (R.r.mode & R_MOVIECROP)==0) {
if(R.r.bufflag & 1) {
unsigned int *rt;
int x, y;
R.xstart= -R.afmx;
R.ystart= -R.afmy;
rt= R.rectot;
for(y=0; y<R.recty; y++, rt+= R.rectx) scanlinesky((char *)rt, y);
for(y=0; y<R.recty; y++) {
for(x=0; x<R.rectx; x++, rt++) {
if(*rt==0) fillBackgroundImageChar((char *)rt, x, y);
}
}
}
}
}
set_mblur_offs(0);
/* FREE */
/* mutexes free */
SDL_DestroyMutex(load_ibuf_lock);
SDL_DestroyMutex(render_abuf_lock);
load_ibuf_lock= NULL;
render_abuf_lock= NULL;
}
/* zbuf test */
/* don't free R.rectz, only when its size is not the same as R.rectot */
if (R.rectz && parts == 1 && (R.r.mode & R_FIELDS) == 0);
else {
if(R.rectz) MEM_freeN(R.rectz);
R.rectz= 0;
}
if(R.rectf1) MEM_freeN(R.rectf1);
R.rectf1= 0;
if(R.rectf2) MEM_freeN(R.rectf2);
R.rectf2= 0;
void render() {
/* yafray: render, see above */
if (R.r.renderer==R_YAFRAY)
yafrayRender();
else
mainRenderLoop();
}
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
extern unsigned short usegamtab;
void RE_initrender(struct View3D *ogl_render_view3d)
{
double start_time;
@ -1163,23 +1224,16 @@ void RE_initrender(struct View3D *ogl_render_view3d)
}
}
usegamtab= 0; /* see also further */
if(R.r.mode & (R_OSA|R_MBLUR)) {
R.osa= R.r.osa;
if(R.osa>16) R.osa= 16;
init_render_jit(R.osa);
/* this value sometimes is reset temporally, for example in transp zbuf */
if(R.r.mode & R_GAMMA) {
if((R.r.mode & R_OSA)) usegamtab= 1;
}
}
else R.osa= 0;
/* always call, it does gamma tables used by alphaunder, but call after R.osa and jit was set */
RE_init_filt_mask();
renderloop_setblending(); // alpha, sky, gamma
/* when rendered without camera object */
/* it has to done here because of envmaps */
@ -1205,14 +1259,15 @@ void RE_initrender(struct View3D *ogl_render_view3d)
if(R.rectot) MEM_freeN(R.rectot);
R.rectot= (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectftot= NULL;
RE_local_timecursor((G.scene->r.cfra));
if(RE_local_test_break()==0) do_render_seq();
/* display */
if(R.rectot) RE_local_render_display(0, R.recty-1,
R.rectx, R.recty,
R.rectot);
if(R.rectot) RE_local_render_display(0, R.recty-1, R.rectx, R.recty,R.rectot);
}
else if(R.r.scemode & R_OGL) {
R.rectx= R.r.xsch;
@ -1221,6 +1276,9 @@ void RE_initrender(struct View3D *ogl_render_view3d)
if(R.rectot) MEM_freeN(R.rectot);
R.rectot= (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot");
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectftot= NULL;
RE_local_init_render_display();
drawview3d_render(ogl_render_view3d);
}
@ -1232,8 +1290,11 @@ void RE_initrender(struct View3D *ogl_render_view3d)
if(G.scene->camera==0) {
error("No camera");
/* needed because R.rectx and R.recty can be unmatching R.rectot */
if(R.rectot) MEM_freeN(R.rectot);
R.rectot= NULL;
if(R.rectftot) MEM_freeN(R.rectftot);
R.rectftot= NULL;
G.afbreek=1;
return;
@ -1252,22 +1313,16 @@ void RE_initrender(struct View3D *ogl_render_view3d)
/* display again: fields/seq/parts/pano etc */
if(R.rectot) {
RE_local_init_render_display();
RE_local_render_display(0, R.recty-1,
R.rectx, R.recty,
R.rectot);
RE_local_render_display(0, R.recty-1, R.rectx, R.recty, R.rectot);
}
else RE_local_clear_render_display(R.win);
if ((G.scene->r.scemode & R_OGL)==0) /* header gets scrabled if renderwindow holds OGL context */
RE_local_printrenderinfo((PIL_check_seconds_timer() - start_time), -1);
/* restore variables */
//R.osatex= 0;
//R.vlr= 0;
///* at cubemap */
/* these flags remain on, until reset in caller to render (renderwin.c) */
R.flag &= (R_RENDERING|R_ANIMRENDER);
R.flag &= (R_RENDERING|R_ANIMRENDER|R_REDRAW_PRV);
}
void RE_animrender(struct View3D *ogl_render_view3d)
@ -1285,8 +1340,7 @@ void RE_animrender(struct View3D *ogl_render_view3d)
if(G.scene->r.scemode & R_OGL) R.r.mode &= ~R_PANORAMA;
// these calculations apply for
// all movie formats
// these calculations apply for all movie formats
R.rectx= (R.r.size*R.r.xsch)/100;
R.recty= (R.r.size*R.r.ysch)/100;
if(R.r.mode & R_PANORAMA) {
@ -1295,7 +1349,7 @@ void RE_animrender(struct View3D *ogl_render_view3d)
}
if(R.r.mode & R_MOVIECROP) {
initparts();
setpart(0); // this will adjust r.rectx
setpart(R.parts.first); // this will adjust r.rectx
}
if (0) {
@ -1358,7 +1412,7 @@ void RE_animrender(struct View3D *ogl_render_view3d)
}
(G.scene->r.cfra)= cfrao;
G.scene->r.cfra= cfrao;
/* restore time */
if(R.r.mode & (R_FIELDS|R_MBLUR)) {

@ -40,12 +40,8 @@
#include "BLI_arithb.h"
#include "BLI_rand.h"
#include "render.h"
#include "render_intern.h"
#include "jitter.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
float jit[64][2];

@ -39,13 +39,11 @@
/* global includes */
#include "render.h"
#include "render_intern.h"
/* local includes */
#include "vanillaRenderPipe_types.h"
/* own includes */
#include "pixelblending_types.h"
#include "pixelblending.h"
#include "gammaCorrectionTables.h"
@ -63,6 +61,17 @@
/* blending difficulties otherwise. Be careful here. */
#define RE_ALPHA_CLIPPING
/* Threshold for a 'full' pixel: pixels with alpha above this level are */
/* considered opaque This is the decimal value for 0xFFF0 / 0xFFFF */
#define RE_FULL_COLOUR_FLOAT 0.9998
/* Threshold for an 'empty' pixel: pixels with alpha above this level are */
/* considered completely transparent. This is the decimal value */
/* for 0x000F / 0xFFFF */
#define RE_EMPTY_COLOUR_FLOAT 0.0002
/* functions --------------------------------------------------------------- */
/*
@ -103,7 +112,7 @@ void applyKeyAlphaCharCol(char* target) {
}
}
} /* end of void applyKeyAlphaCharCol(char* target) */
}
/* ------------------------------------------------------------------------- */
@ -116,7 +125,7 @@ void addAddSampColF(float *sampvec, float *source, int mask, int osaNr,
if(mask & (1<<a)) addalphaAddfacFloat(sampvec, source, addfac);
sampvec+= 4;
}
} /* end of void addAddSampColF(float, float, int, int) */
}
/* ------------------------------------------------------------------------- */
@ -128,7 +137,7 @@ void addOverSampColF(float *sampvec, float *source, int mask, int osaNr)
if(mask & (1<<a)) addAlphaOverFloat(sampvec, source);
sampvec+= 4;
}
} /* end of void addOverSampColF(float, float, int, int) */
}
/* ------------------------------------------------------------------------- */
@ -142,35 +151,7 @@ int addUnderSampColF(float *sampvec, float *source, int mask, int osaNr)
sampvec+= 4;
}
return retval;
} /* end of int addToSampColF(float, float, int, int) */
/* ------------------------------------------------------------------------- */
int addToSampCol(unsigned short *sampcol, unsigned short *shortcol, int mask, int osaNr)
{
int a, retval = osaNr;
for(a=0; a < osaNr; a++) {
if(mask & (1<<a)) addAlphaUnderShort(sampcol, shortcol);
if(sampcol[3]>0xFFF0) retval--;
sampcol+= 4;
}
return retval;
} /* end of int addToSampCol(unsigned short, uhost, int, int) */
/* ------------------------------------------------------------------------- */
int addtosampcol(unsigned short *sampcol, unsigned short *shortcol, int mask)
{
int a, retval = R.osa;
for(a=0; a < R.osa; a++) {
if(mask & (1<<a)) addAlphaUnderShort(sampcol, shortcol);
if(sampcol[3]>0xFFF0) retval--;
sampcol+= 4;
}
return retval;
} /* end of int addtosampcol(unsigned short *sampcol, unsigned short *shortcol, int mask) */
}
/* ------------------------------------------------------------------------- */
@ -180,12 +161,6 @@ void addAlphaOverShort(unsigned short *doel, unsigned short *bron)
unsigned int c;
unsigned int mul;
if( doel[3]==0 || bron[3]>=0xFFF0) { /* has been tested */
*((unsigned int *)doel)= *((unsigned int *)bron);
*((unsigned int *)(doel+2))= *((unsigned int *)(bron+2));
return;
}
mul= 0xFFFF-bron[3];
c= ((mul*doel[0])>>16)+bron[0];
@ -201,7 +176,7 @@ void addAlphaOverShort(unsigned short *doel, unsigned short *bron)
if(c>=0xFFF0) doel[3]=0xFFF0;
else doel[3]= c;
} /* end of void addAlphaOverShort(unsigned short *doel, unsigned short *bron) */
}
/* ------------------------------------------------------------------------- */
@ -233,8 +208,8 @@ void addAlphaUnderShort(unsigned short *doel, unsigned short *bron)
if(c>=0xFFF0) doel[3]=0xFFF0;
else doel[3]= c;
} /* end of void addAlphaUnderShort(unsigned short *doel, unsigned short *bron) */
}
/* ------------------------------------------------------------------------- */
void addAlphaOverFloat(float *dest, float *source)
@ -257,8 +232,7 @@ void addAlphaOverFloat(float *dest, float *source)
c= (mul*dest[3]) + source[3];
dest[3]= c;
} /* end of void addAlphaOverFloat(float *doel, float *bron) */
}
/* ------------------------------------------------------------------------- */
@ -291,7 +265,7 @@ void addAlphaUnderFloat(float *dest, float *source)
c= (mul*source[3]) + dest[3];
dest[3]= c;
} /* end of void addAlphaUnderFloat(float *doel, float *bron) */
}
/* ------------------------------------------------------------------------- */
@ -301,7 +275,7 @@ void cpShortColV2CharColV(unsigned short *source, char *dest)
dest[1] = source[1]>>8;
dest[2] = source[2]>>8;
dest[3] = source[3]>>8;
} /* end of void cpShortColV2CharColV(unsigned short *source, char *dest) */
}
/* ------------------------------------------------------------------------- */
void cpCharColV2ShortColV(char *source, unsigned short *dest)
@ -310,7 +284,7 @@ void cpCharColV2ShortColV(char *source, unsigned short *dest)
dest[1] = source[1]<<8;
dest[2] = source[2]<<8;
dest[3] = source[3]<<8;
} /* end of void cpShortColV2CharColV(char *source, unsigned short *dest) */
}
/* ------------------------------------------------------------------------- */
@ -320,7 +294,7 @@ void cpIntColV2CharColV(unsigned int *source, char *dest)
dest[1] = source[1]>>24;
dest[2] = source[2]>>24;
dest[3] = source[3]>>24;
} /* end of void cpIntColV2CharColV(unsigned int *source, char *dest) */
}
/* ------------------------------------------------------------------------- */
@ -330,7 +304,8 @@ void cpCharColV2FloatColV(char *source, float *dest)
dest[1] = source[1]/255.0;
dest[2] = source[2]/255.0;
dest[3] = source[3]/255.0;
} /* end of void cpCharColV2FloatColV(char *source, float *dest) */
}
/* ------------------------------------------------------------------------- */
void cpShortColV2FloatColV(unsigned short *source, float *dest)
@ -339,7 +314,7 @@ void cpShortColV2FloatColV(unsigned short *source, float *dest)
dest[1] = source[1]/65535.0;
dest[2] = source[2]/65535.0;
dest[3] = source[3]/65535.0;
} /* end of void cpShortColV2FloatColV(char *source, float *dest) */
}
/* ------------------------------------------------------------------------- */
@ -362,7 +337,7 @@ void cpFloatColV2CharColV(float* source, char *dest)
else if (source[3] > 1.0) dest[3] = 255;
else dest[3] = (char) (source[3] * 255.0);
} /* end of void cpFloatColV2CharColV(float* source, char *dest) */
}
/* ------------------------------------------------------------------------- */
@ -372,7 +347,7 @@ void cpShortColV(unsigned short *source, unsigned short *dest)
dest[1] = source[1];
dest[2] = source[2];
dest[3] = source[3];
} /* end of void cpShortColV(unsigned short *source, unsigned short *dest) */
}
/* ------------------------------------------------------------------------- */
void cpFloatColV(float *source, float *dest)
@ -381,7 +356,7 @@ void cpFloatColV(float *source, float *dest)
dest[1] = source[1];
dest[2] = source[2];
dest[3] = source[3];
} /* end of void cpFloatColV(float *source, float *dest) */
}
/* ------------------------------------------------------------------------- */
@ -391,7 +366,7 @@ void cpCharColV(char *source, char *dest)
dest[1] = source[1];
dest[2] = source[2];
dest[3] = source[3];
} /* end of void cpCharColV(char *source, char *dest) */
}
/* ------------------------------------------------------------------------- */
void addalphaAddfacFloat(float *dest, float *source, char addfac)
@ -432,7 +407,7 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac)
#endif
dest[3]= c;
} /* end of void addalphaAddfacFloat(unsigned short *doel, unsigned short *bron, char addfac_help) */
}
/* ------------------------------------------------------------------------- */
@ -468,7 +443,7 @@ void addalphaAddfacShort(unsigned short *doel, unsigned short *bron, char addfac
if(c > 65535.0) doel[3] = 65535;
else doel[3]= floor(c);
} /* end of void addalphaAddfacShort(unsigned short *doel, unsigned short *bron, char addfac_help) */
}
/* ------------------------------------------------------------------------- */
@ -520,7 +495,7 @@ void addHaloToHaloShort(unsigned short *d, unsigned short *s)
if( c[3] > 65535.0 ) d[3] = 65535; else d[3]= floor(c[3]);
} /* end of void addHaloToHaloShort(unsigned short *dest, unsigned short *source, char addfac) */
}
/* ------------------------------------------------------------------------- */
@ -542,17 +517,15 @@ void sampleShortColV2ShortColV(unsigned short *sample, unsigned short *dest, int
dest[2]= intcol[2]/osaNr;
dest[3]= intcol[3]/osaNr;
} /* end of void sampleShortColVToShortColV(unsigned short *sample, unsigned short *dest) */
}
/* ------------------------------------------------------------------------- */
float *fmask1[9], *fmask2[9];
/* filtered adding to scanlines */
void add_filt_fmask(unsigned int mask, float *col, float *rb1, float *rb2, float *rb3)
{
/* calc the value of mask */
extern float *fmask1[], *fmask2[];
float val, r, g, b, al;
unsigned int a, maskand, maskshift;
int j;
@ -615,7 +588,7 @@ void sampleFloatColV2FloatColVFilter(float *sample, float *dest1, float *dest2,
dest2[7]= sample[3];
}
else {
if (doGamma()) {
if (do_gamma) {
/* use a LUT and interpolation to do the gamma correction */
for(a=0; a < osaNr; a++, scol+=4) {
intcol[0] = gammaCorrect( (scol[0]<1.0) ? scol[0]:1.0 );

@ -45,6 +45,7 @@
#include "MTC_vectorops.h"
#include "DNA_camera_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_image_types.h"
#include "DNA_texture_types.h"
@ -56,11 +57,11 @@
#include "render.h"
#include "texture.h"
#include "render_intern.h"
#include "vanillaRenderPipe_types.h"
#include "pixelblending.h"
#include "rendercore.h" /* for some shading functions... */
#include "shadbuf.h"
#include "zbufferdatastruct.h"
#include "renderHelp.h"
@ -69,13 +70,6 @@
#include "errorHandler.h"
#include "pixelshading.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* The collector is the communication channel with the render pipe. */
extern RE_COLBUFTYPE collector[4]; /* used throughout as pixel colour accu */
/* ton:
- unified render now uses face render routines from rendercore.c
@ -83,16 +77,15 @@ extern RE_COLBUFTYPE collector[4]; /* used throughout as pixel colour accu */
/* ------------------------------------------------------------------------- */
void *renderPixel(float x, float y, int *obdata, int mask)
void *renderPixel(RE_COLBUFTYPE *collector, float x, float y, int *obdata, int mask)
{
void* data = NULL;
if (obdata[3] & RE_POLY) {
/* face pixels aren't rendered in floats yet, so we wrap it here */
data = shadepixel(x, y, obdata[1], mask, collector);
}
else if (obdata[3] & RE_HALO) {
data = renderHaloPixel(x, y, obdata[1]);
data = renderHaloPixel(collector, x, y, obdata[1]);
}
else if( obdata[1] == 0 ) {
/* for lamphalo, but doesn't seem to be called? Actually it is, and */
@ -126,7 +119,7 @@ static unsigned int calcHaloZ(HaloRen *har, unsigned int zz)
return zz;
}
void *renderHaloPixel(float x, float y, int haloNr)
void *renderHaloPixel(RE_COLBUFTYPE *collector, float x, float y, int haloNr)
{
HaloRen *har = NULL;
float dist = 0.0;
@ -144,8 +137,8 @@ void *renderHaloPixel(float x, float y, int haloNr)
dist = ((x - har->xs) * (x - har->xs))
+ ((y - har->ys) * (y - har->ys) * R.ycor * R.ycor) ;
collector[0] = RE_ZERO_COLOUR_FLOAT; collector[1] = RE_ZERO_COLOUR_FLOAT;
collector[2] = RE_ZERO_COLOUR_FLOAT; collector[3] = RE_ZERO_COLOUR_FLOAT;
collector[0] = 0.0f; collector[1] = 0.0f;
collector[2] = 0.0f; collector[3] = 0.0f;
if (dist < har->radsq) {
shadeHaloFloat(har, collector, zz, dist,
@ -159,14 +152,184 @@ void *renderHaloPixel(float x, float y, int haloNr)
/* ------------------------------------------------------------------------- */
extern float hashvectf[];
void shadeHaloFloat(HaloRen *har,
float *col, unsigned int zz,
float dist, float xn,
float yn, short flarec)
static void render_lighting_halo(HaloRen *har, float *colf)
{
LampRen *lar;
float i, inp, inpr, rco[3], dco[3], lv[3], lampdist, ld, t, *vn;
float ir, ig, ib, shadfac, soft, lacol[3];
int a;
ir= ig= ib= 0.0;
VECCOPY(rco, har->co);
dco[0]=dco[1]=dco[2]= 1.0/har->rad;
vn= har->no;
for(a=0; a<R.totlamp; a++) {
lar= R.la[a];
/* test for lamplayer */
if(lar->mode & LA_LAYER) if((lar->lay & har->lay)==0) continue;
/* lampdist cacluation */
if(lar->type==LA_SUN || lar->type==LA_HEMI) {
VECCOPY(lv, lar->vec);
lampdist= 1.0;
}
else {
lv[0]= rco[0]-lar->co[0];
lv[1]= rco[1]-lar->co[1];
lv[2]= rco[2]-lar->co[2];
ld= sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2]);
lv[0]/= ld;
lv[1]/= ld;
lv[2]/= ld;
/* ld is re-used further on (texco's) */
if(lar->mode & LA_QUAD) {
t= 1.0;
if(lar->ld1>0.0)
t= lar->dist/(lar->dist+lar->ld1*ld);
if(lar->ld2>0.0)
t*= lar->distkw/(lar->distkw+lar->ld2*ld*ld);
lampdist= t;
}
else {
lampdist= (lar->dist/(lar->dist+ld));
}
if(lar->mode & LA_SPHERE) {
t= lar->dist - ld;
if(t<0.0) continue;
t/= lar->dist;
lampdist*= (t);
}
}
lacol[0]= lar->r;
lacol[1]= lar->g;
lacol[2]= lar->b;
if(lar->mode & LA_TEXTURE) {
ShadeInput shi;
VECCOPY(shi.co, rco);
shi.osatex= 0;
do_lamp_tex(lar, lv, &shi, lacol);
}
if(lar->type==LA_SPOT) {
if(lar->mode & LA_SQUARE) {
if(lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2]>0.0) {
float x, lvrot[3];
/* rotate view to lampspace */
VECCOPY(lvrot, lv);
MTC_Mat3MulVecfl(lar->imat, lvrot);
x= MAX2(fabs(lvrot[0]/lvrot[2]) , fabs(lvrot[1]/lvrot[2]));
/* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */
inpr= 1.0/(sqrt(1.0+x*x));
}
else inpr= 0.0;
}
else {
inpr= lv[0]*lar->vec[0]+lv[1]*lar->vec[1]+lv[2]*lar->vec[2];
}
t= lar->spotsi;
if(inpr<t) continue;
else {
t= inpr-t;
i= 1.0;
soft= 1.0;
if(t<lar->spotbl && lar->spotbl!=0.0) {
/* soft area */
i= t/lar->spotbl;
t= i*i;
soft= (3.0*t-2.0*t*i);
inpr*= soft;
}
if(lar->mode & LA_ONLYSHADOW) {
/* if(ma->mode & MA_SHADOW) { */
/* dot product positive: front side face! */
inp= vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2];
if(inp>0.0) {
/* testshadowbuf==0.0 : 100% shadow */
shadfac = testshadowbuf(lar->shb, rco, dco, dco, inp);
if( shadfac>0.0 ) {
shadfac*= inp*soft*lar->energy;
ir -= shadfac;
ig -= shadfac;
ib -= shadfac;
continue;
}
}
/* } */
}
lampdist*=inpr;
}
if(lar->mode & LA_ONLYSHADOW) continue;
}
/* dot product and reflectivity*/
inp= 1.0-fabs(vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]);
/* inp= cos(0.5*M_PI-acos(inp)); */
i= inp;
if(lar->type==LA_HEMI) {
i= 0.5*i+0.5;
}
if(i>0.0) {
i*= lampdist;
}
/* shadow */
if(i> -0.41) { /* heuristic valua! */
shadfac= 1.0;
if(lar->shb) {
shadfac = testshadowbuf(lar->shb, rco, dco, dco, inp);
if(shadfac==0.0) continue;
i*= shadfac;
}
}
if(i>0.0) {
ir+= i*lacol[0];
ig+= i*lacol[1];
ib+= i*lacol[2];
}
}
if(ir<0.0) ir= 0.0;
if(ig<0.0) ig= 0.0;
if(ib<0.0) ib= 0.0;
colf[0]*= ir;
colf[1]*= ig;
colf[2]*= ib;
}
void shadeHaloFloat(HaloRen *har, float *col, unsigned int zz,
float dist, float xn, float yn, short flarec)
{
/* fill in col */
/* migrate: fill collector */
float t, zn, radist, ringf=0.0, linef=0.0, alpha, si, co, colf[4];
float t, zn, radist, ringf=0.0, linef=0.0, alpha, si, co;
int a;
if(R.wrld.mode & WO_MIST) {
@ -306,59 +469,53 @@ void shadeHaloFloat(HaloRen *har,
/* The colour is either the rgb spec-ed by the user, or extracted from */
/* the texture */
if(har->tex) {
colf[0]= har->r; colf[1]= har->g; colf[2]= har->b;
colf[3]= dist;
do_halo_tex(har, xn, yn, colf);
colf[0]*= colf[3];
colf[1]*= colf[3];
colf[2]*= colf[3];
col[0]= har->r;
col[1]= har->g;
col[2]= har->b;
col[3]= dist;
do_halo_tex(har, xn, yn, col);
col[0]*= col[3];
col[1]*= col[3];
col[2]*= col[3];
}
else {
colf[0]= dist*har->r;
colf[1]= dist*har->g;
colf[2]= dist*har->b;
if(har->type & HA_XALPHA) colf[3]= dist*dist;
else colf[3]= dist;
col[0]= dist*har->r;
col[1]= dist*har->g;
col[2]= dist*har->b;
if(har->type & HA_XALPHA) col[3]= dist*dist;
else col[3]= dist;
}
if(har->mat && har->mat->mode & MA_HALO_SHADE) {
/* we test for lights because of preview... */
if(R.totlamp) render_lighting_halo(har, colf);
if(R.totlamp) render_lighting_halo(har, col);
}
/* Next, we do the line and ring factor modifications. It seems we do */
/* uchar calculations, but it's basically doing float arith with a 255 */
/* scale factor. */
/* Next, we do the line and ring factor modifications. */
if(linef!=0.0) {
Material *ma= har->mat;
colf[0]+= 255.0*linef * ma->specr;
colf[1]+= 255.0*linef * ma->specg;
colf[2]+= 255.0*linef * ma->specb;
col[0]+= linef * ma->specr;
col[1]+= linef * ma->specg;
col[2]+= linef * ma->specb;
if(har->type & HA_XALPHA) colf[3]+= linef*linef;
else colf[3]+= linef;
if(har->type & HA_XALPHA) col[3]+= linef*linef;
else col[3]+= linef;
}
if(ringf!=0.0) {
Material *ma= har->mat;
colf[0]+= 255.0*ringf * ma->mirr;
colf[1]+= 255.0*ringf * ma->mirg;
colf[2]+= 255.0*ringf * ma->mirb;
col[0]+= ringf * ma->mirr;
col[1]+= ringf * ma->mirg;
col[2]+= ringf * ma->mirb;
if(har->type & HA_XALPHA) colf[3]+= ringf*ringf;
else colf[3]+= ringf;
if(har->type & HA_XALPHA) col[3]+= ringf*ringf;
else col[3]+= ringf;
}
/* convert to [0.0; 1.0] range */
col[0] = colf[0] / 255.0;
col[1] = colf[1] / 255.0;
col[2] = colf[2] / 255.0;
col[3] = colf[3];
} /* end of shadeHaloFloat() */
}
/* ------------------------------------------------------------------------- */
/*
@ -390,7 +547,7 @@ enum RE_SkyAlphaBlendingType getSkyBlendingMode() {
}
/* This one renders into collector, as always. */
void renderSkyPixelFloat(float x, float y)
void renderSkyPixelFloat(RE_COLBUFTYPE *collector, float x, float y)
{
switch (keyingType) {
@ -418,7 +575,7 @@ void renderSkyPixelFloat(float x, float y)
break;
case RE_ALPHA_SKY:
/* Fill in the sky as if it were a normal face. */
shadeSkyPixel(x, y);
shadeSkyPixel(collector, x, y);
collector[3]= 0.0;
break;
default:
@ -431,9 +588,9 @@ void renderSkyPixelFloat(float x, float y)
/*
Stuff the sky colour into the collector.
*/
void shadeSkyPixel(float fx, float fy)
void shadeSkyPixel(RE_COLBUFTYPE *collector, float fx, float fy)
{
float view[3];
float view[3], dxyview[2];
/*
The rules for sky:
@ -445,7 +602,7 @@ void shadeSkyPixel(float fx, float fy)
/* 1. Do a backbuffer image: */
if(R.r.bufflag & 1) {
if(R.backbuf) fillBackgroundImage(fx, fy);
if(R.backbuf) fillBackgroundImage(collector, fx, fy);
return;
} else if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) {
/*
@ -458,7 +615,7 @@ void shadeSkyPixel(float fx, float fy)
collector[0] = R.wrld.horr;
collector[1] = R.wrld.horg;
collector[2] = R.wrld.horb;
collector[3] = RE_UNITY_COLOUR_FLOAT;
collector[3] = 1.0f;
} else {
/*
3. Which type(s) is(are) this (these)? This has to be done when no simple
@ -486,8 +643,8 @@ void shadeSkyPixel(float fx, float fy)
fac= Normalise(view);
if(R.wrld.skytype & WO_SKYTEX) {
O.dxview= 1.0/fac;
O.dyview= R.ycor/fac;
dxyview[0]= 1.0/fac;
dxyview[1]= R.ycor/fac;
}
}
@ -504,16 +661,15 @@ void shadeSkyPixel(float fx, float fy)
}
/* get sky colour in the collector */
shadeSkyPixelFloat(fy, view);
shadeSkyPixelFloat(collector, view, dxyview);
collector[3] = 1.0f;
}
}
/* Only line number is important here. Result goes to collector[4] */
void shadeSkyPixelFloat(float y, float *view)
/* Only view vector is important here. Result goes to colf[3] */
void shadeSkyPixelFloat(float *colf, float *view, float *dxyview)
{
float lo[3];
float lo[3], zen[3], hor[3], blend, blendm;
/* Why is this setting forced? Seems silly to me. It is tested in the texture unit. */
R.wrld.skytype |= WO_ZENUP;
@ -521,19 +677,22 @@ void shadeSkyPixelFloat(float y, float *view)
/* Some view vector stuff. */
if(R.wrld.skytype & WO_SKYREAL) {
R.inprz= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2];
blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2];
if(R.inprz<0.0) R.wrld.skytype-= WO_ZENUP;
R.inprz= fabs(R.inprz);
if(blend<0.0) R.wrld.skytype-= WO_ZENUP;
blend= fabs(blend);
}
else if(R.wrld.skytype & WO_SKYPAPER) {
R.inprz= 0.5+ 0.5*view[1];
blend= 0.5+ 0.5*view[1];
}
else {
/* the fraction of how far we are above the bottom of the screen */
R.inprz= fabs(0.5+ view[1]);
blend= fabs(0.5+ view[1]);
}
hor[0]= R.wrld.horr; hor[1]= R.wrld.horr; hor[2]= R.wrld.horb;
zen[0]= R.wrld.zenr; zen[1]= R.wrld.zenr; zen[2]= R.wrld.zenb;
/* Careful: SKYTEX and SKYBLEND are NOT mutually exclusive! If */
/* SKYBLEND is active, the texture and colour blend are added. */
if(R.wrld.skytype & WO_SKYTEX) {
@ -545,33 +704,23 @@ void shadeSkyPixelFloat(float y, float *view)
SWAP(float, lo[1], lo[2]);
}
/* sky texture? I wonder how this manages to work... */
/* Does this communicate with R.wrld.hor{rgb}? Yes. */
do_sky_tex(lo);
/* internally, T{rgb} are used for communicating colours in the */
/* texture pipe, externally, this particular routine uses the */
/* R.wrld.hor{rgb} thingies. */
do_sky_tex(lo, dxyview, hor, zen, &blend);
}
/* Why are this R. members? because textures need it (ton) */
if(R.inprz>1.0) R.inprz= 1.0;
R.inprh= 1.0-R.inprz;
if(blend>1.0) blend= 1.0;
blendm= 1.0-blend;
/* No clipping, no conversion! */
if(R.wrld.skytype & WO_SKYBLEND) {
collector[0] = (R.inprh*R.wrld.horr + R.inprz*R.wrld.zenr);
collector[1] = (R.inprh*R.wrld.horg + R.inprz*R.wrld.zeng);
collector[2] = (R.inprh*R.wrld.horb + R.inprz*R.wrld.zenb);
colf[0] = (blendm*hor[0] + blend*zen[0]);
colf[1] = (blendm*hor[1] + blend*zen[1]);
colf[2] = (blendm*hor[2] + blend*zen[2]);
} else {
/* Done when a texture was grabbed. */
collector[0]= R.wrld.horr;
collector[1]= R.wrld.horg;
collector[2]= R.wrld.horb;
colf[0]= hor[0];
colf[1]= hor[1];
colf[2]= hor[2];
}
collector[3]= RE_UNITY_COLOUR_FLOAT;
}
@ -583,30 +732,25 @@ void shadeSkyPixelFloat(float y, float *view)
should be really easy. I hope I understand the way ImBuf works
correctly. (nzc)
*/
void fillBackgroundImage(float x, float y)
void fillBackgroundImageChar(char *col, float x, float y)
{
int iy, ix;
unsigned int* imBufPtr;
char *colSource;
/* This double check is bad... */
if (!(R.backbuf->ok)) {
/* Something went sour here... bail... */
collector[0] = 0.0;
collector[1] = 0.0;
collector[2] = 0.0;
collector[3] = 1.0;
col[0] = 0;
col[1] = 0;
col[2] = 0;
col[3] = 255;
return;
}
/* load image if not already done?*/
if(R.backbuf->ibuf==0) {
R.backbuf->ibuf= IMB_loadiffname(R.backbuf->name, IB_rect);
if(R.backbuf->ibuf==0) {
/* load failed .... keep skipping */
R.backbuf->ok= 0;
return;
}
R.backbuf->ok= 0;
return;
}
/* Now for the real extraction: */
@ -629,10 +773,17 @@ void fillBackgroundImage(float x, float y)
+ (iy * R.backbuf->ibuf->x)
+ ix;
colSource = (char*) imBufPtr;
cpCharColV2FloatColV(colSource, collector);
*( (int *)col) = *imBufPtr;
}
void fillBackgroundImage(RE_COLBUFTYPE *collector, float x, float y)
{
char col[4];
fillBackgroundImageChar(col, x, y);
cpCharColV2FloatColV(col, collector);
}
/* eof */

@ -45,9 +45,9 @@
#include <BLI_rand.h>
#include "render.h"
#include "render_intern.h"
#include "rendercore.h"
#include "pixelblending.h"
#include "pixelshading.h"
#include "jitter.h"
#include "texture.h"
@ -74,8 +74,6 @@ typedef struct Octree {
float ocfacx,ocfacy,ocfacz;
float min[3], max[3];
int ocres;
/* for optimize, last intersected face */
VlakRen *vlr_last;
} Octree;
@ -87,6 +85,9 @@ typedef struct Isect {
float ddalabda;
float col[4]; /* RGBA for shadow_tra */
int lay; /* -1 default, set for layer lamps */
short vlrisect; /* flag whether vlrcontr was done or not */
/* for optimize, last intersected face */
VlakRen *vlr_last;
} Isect;
typedef struct Branch
@ -148,47 +149,36 @@ static void calc_ocval_face(float *v1, float *v2, float *v3, float *v4, short x,
}
static void calc_ocval_ray(OcVal *ov, float x1, float y1, float z1,
float x2, float y2, float z2)
static void calc_ocval_ray(OcVal *ov, float xo, float yo, float zo, float *vec1, float *vec2)
{
static float ox1, ox2, oy1, oy2, oz1, oz2;
int ocmin, ocmax;
if(ov==NULL) {
ox1= x1; ox2= x2;
oy1= y1; oy2= y2;
oz1= z1; oz2= z2;
if(vec1[0]<vec2[0]) {
ocmin= OCVALRES*(vec1[0] - xo);
ocmax= OCVALRES*(vec2[0] - xo);
} else {
ocmin= OCVALRES*(vec2[0] - xo);
ocmax= OCVALRES*(vec1[0] - xo);
}
else {
int ocmin, ocmax;
if(ox1<ox2) {
ocmin= OCVALRES*(ox1 - ((int)x1));
ocmax= OCVALRES*(ox2 - ((int)x1));
} else {
ocmin= OCVALRES*(ox2 - ((int)x1));
ocmax= OCVALRES*(ox1 - ((int)x1));
}
ov->ocx= BROW(ocmin, ocmax);
ov->ocx= BROW(ocmin, ocmax);
if(oy1<oy2) {
ocmin= OCVALRES*(oy1 - ((int)y1));
ocmax= OCVALRES*(oy2 - ((int)y1));
} else {
ocmin= OCVALRES*(oy2 - ((int)y1));
ocmax= OCVALRES*(oy1 - ((int)y1));
}
ov->ocy= BROW(ocmin, ocmax);
if(oz1<oz2) {
ocmin= OCVALRES*(oz1 - ((int)z1));
ocmax= OCVALRES*(oz2 - ((int)z1));
} else {
ocmin= OCVALRES*(oz2 - ((int)z1));
ocmax= OCVALRES*(oz1 - ((int)z1));
}
ov->ocz= BROW(ocmin, ocmax);
if(vec1[1]<vec2[1]) {
ocmin= OCVALRES*(vec1[1] - yo);
ocmax= OCVALRES*(vec2[1] - yo);
} else {
ocmin= OCVALRES*(vec2[1] - yo);
ocmax= OCVALRES*(vec1[1] - yo);
}
ov->ocy= BROW(ocmin, ocmax);
if(vec1[2]<vec2[2]) {
ocmin= OCVALRES*(vec1[2] - zo);
ocmax= OCVALRES*(vec2[2] - zo);
} else {
ocmin= OCVALRES*(vec2[2] - zo);
ocmax= OCVALRES*(vec1[2] - zo);
}
ov->ocz= BROW(ocmin, ocmax);
}
/* ************* octree ************** */
@ -451,7 +441,7 @@ void freeoctree(void)
printf("branches %d nodes %d\n", branchcount, nodecount);
printf("raycount %d \n", raycount);
printf("ray coherent %d \n", coherent_ray);
// printf("accepted %d rejected %d\n", accepted, rejected);
printf("accepted %d rejected %d\n", accepted, rejected);
}
branchcount= 0;
nodecount= 0;
@ -483,7 +473,6 @@ void makeoctree()
/* fill main octree struct */
g_oc.ocres= R.r.ocres;
ocres2= g_oc.ocres*g_oc.ocres;
g_oc.vlr_last= NULL;
INIT_MINMAX(g_oc.min, g_oc.max);
/* first min max octree space */
@ -710,11 +699,8 @@ static short intersection(Isect *is)
VertRen *v1,*v2,*v3,*v4=NULL;
float x0,x1,x2,t00,t01,t02,t10,t11,t12,t20,t21,t22,r0,r1,r2;
float m0, m1, m2, divdet, det1;
static short vlrisect=0;
short ok=0;
is->vlr->raycount= raycount;
v1= is->vlr->v1;
v2= is->vlr->v2;
if(is->vlr->v4) {
@ -811,7 +797,6 @@ static short intersection(Isect *is)
/* for mirror: large faces can be filled in too often, this prevents
a face being detected too soon... */
if(is->labda > is->ddalabda) {
is->vlr->raycount= 0;
return 0;
}
}
@ -819,7 +804,7 @@ static short intersection(Isect *is)
/* when a shadow ray leaves a face, it can be little outside the edges of it, causing
intersection to be detected in its neighbour face */
if(is->vlrcontr && vlrisect); // optimizing, the tests below are not needed
if(is->vlrcontr && is->vlrisect); // optimizing, the tests below are not needed
else if(is->labda< .1) {
VlakRen *vlr= is->vlrorig;
short de= 0;
@ -838,10 +823,10 @@ static short intersection(Isect *is)
if(is->vlrcontr==NULL) {
is->vlrcontr= vlr;
vlrisect= intersection2(vlr, -r0, -r1, -r2, is->start[0], is->start[1], is->start[2]);
is->vlrisect= intersection2(vlr, -r0, -r1, -r2, is->start[0], is->start[1], is->start[2]);
}
if(vlrisect) return 1;
if(is->vlrisect) return 1;
return 0;
}
}
@ -853,23 +838,20 @@ static short intersection(Isect *is)
}
/* check all faces in this node */
static int testnode(Isect *is, Node *no, int x, int y, int z)
static int testnode(Isect *is, Node *no, OcVal ocval)
{
VlakRen *vlr;
short nr=0, ocvaldone=0;
OcVal ocval, *ov;
short nr=0;
OcVal *ov;
if(is->mode==DDA_SHADOW) {
vlr= no->v[0];
while(vlr) {
if(raycount != vlr->raycount) {
if(is->vlrorig != vlr) {
if(is->lay & vlr->lay) {
if(ocvaldone==0) {
calc_ocval_ray(&ocval, (float)x, (float)y, (float)z, 0.0, 0.0, 0.0);
ocvaldone= 1;
}
ov= no->ov+nr;
if( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) ) {
@ -877,7 +859,7 @@ static int testnode(Isect *is, Node *no, int x, int y, int z)
is->vlr= vlr;
if(intersection(is)) {
g_oc.vlr_last= vlr;
is->vlr_last= vlr;
return 1;
}
}
@ -904,12 +886,7 @@ static int testnode(Isect *is, Node *no, int x, int y, int z)
vlr= no->v[0];
while(vlr) {
if(raycount != vlr->raycount) {
if(ocvaldone==0) {
calc_ocval_ray(&ocval, (float)x, (float)y, (float)z, 0.0, 0.0, 0.0);
ocvaldone= 1;
}
if(is->vlrorig != vlr) {
ov= no->ov+nr;
if( (ov->ocx & ocval.ocx) && (ov->ocy & ocval.ocy) && (ov->ocz & ocval.ocz) ) {
@ -942,81 +919,59 @@ static int testnode(Isect *is, Node *no, int x, int y, int z)
/* find the Node for the octree coord x y z */
static Node *ocread(int x, int y, int z)
{
static int mdiff=0, xo, yo, zo;
Branch *br;
int oc1, diff;
/* outside of octree check, reset */
if( x >= g_oc.ocres) {
xo= g_oc.ocres; yo= g_oc.ocres; zo= g_oc.ocres;
return NULL;
int oc1;
x<<=2;
y<<=1;
br= g_oc.adrbranch[0];
if(g_oc.ocres==512) {
oc1= ((x & 1024)+(y & 512)+(z & 256))>>8;
br= br->b[oc1];
if(br==NULL) {
return NULL;
}
}
if(g_oc.ocres>=256) {
oc1= ((x & 512)+(y & 256)+(z & 128))>>7;
br= br->b[oc1];
if(br==NULL) {
return NULL;
}
}
if(g_oc.ocres>=128) {
oc1= ((x & 256)+(y & 128)+(z & 64))>>6;
br= br->b[oc1];
if(br==NULL) {
return NULL;
}
}
diff= (xo ^ x) | (yo ^ y) | (zo ^ z);
if(diff>mdiff) {
xo=x; yo=y; zo=z;
x<<=2;
y<<=1;
br= g_oc.adrbranch[0];
if(g_oc.ocres==512) {
oc1= ((x & 1024)+(y & 512)+(z & 256))>>8;
br= br->b[oc1];
if(br==NULL) {
mdiff= 255;
return NULL;
}
}
if(g_oc.ocres>=256) {
oc1= ((x & 512)+(y & 256)+(z & 128))>>7;
br= br->b[oc1];
if(br==NULL) {
mdiff= 127;
return NULL;
}
}
if(g_oc.ocres>=128) {
oc1= ((x & 256)+(y & 128)+(z & 64))>>6;
br= br->b[oc1];
if(br==NULL) {
mdiff= 63;
return NULL;
}
}
oc1= ((x & 128)+(y & 64)+(z & 32))>>5;
oc1= ((x & 128)+(y & 64)+(z & 32))>>5;
br= br->b[oc1];
if(br) {
oc1= ((x & 64)+(y & 32)+(z & 16))>>4;
br= br->b[oc1];
if(br) {
oc1= ((x & 64)+(y & 32)+(z & 16))>>4;
oc1= ((x & 32)+(y & 16)+(z & 8))>>3;
br= br->b[oc1];
if(br) {
oc1= ((x & 32)+(y & 16)+(z & 8))>>3;
oc1= ((x & 16)+(y & 8)+(z & 4))>>2;
br= br->b[oc1];
if(br) {
oc1= ((x & 16)+(y & 8)+(z & 4))>>2;
oc1= ((x & 8)+(y & 4)+(z & 2))>>1;
br= br->b[oc1];
if(br) {
oc1= ((x & 8)+(y & 4)+(z & 2))>>1;
br= br->b[oc1];
if(br) {
mdiff=0;
oc1= ((x & 4)+(y & 2)+(z & 1));
return (Node *)br->b[oc1];
}
else mdiff=1;
oc1= ((x & 4)+(y & 2)+(z & 1));
return (Node *)br->b[oc1];
}
else mdiff=3;
}
else mdiff=7;
}
else mdiff=15;
}
else mdiff=31;
}
return NULL;
}
@ -1081,9 +1036,10 @@ static int do_coherence_test(int ocx1, int ocx2, int ocy1, int ocy2, int ocz1, i
static int d3dda(Isect *is)
{
Node *no;
OcVal ocval;
float vec1[3], vec2[3];
float u1,u2,ox1,ox2,oy1,oy2,oz1,oz2;
float labdao,labdax,ldx,labday,ldy,labdaz,ldz, ddalabda;
float vec1[3], vec2[3];
int dx,dy,dz;
int xo,yo,zo,c1=0;
int ocx1,ocx2,ocy1, ocy2,ocz1,ocz2;
@ -1092,17 +1048,15 @@ static int d3dda(Isect *is)
if(branchcount==0) return 0;
/* do this before intersect calls */
raycount++;
is->vlrorig->raycount= raycount;
is->vlrcontr= NULL; /* to check shared edge */
/* only for shadow! */
if(is->mode==DDA_SHADOW) {
/* check with last intersected shadow face */
if(g_oc.vlr_last!=NULL && g_oc.vlr_last!=is->vlrorig) {
if(is->lay & g_oc.vlr_last->lay) {
is->vlr= g_oc.vlr_last;
if(is->vlr_last!=NULL && is->vlr_last!=is->vlrorig) {
if(is->lay & is->vlr_last->lay) {
is->vlr= is->vlr_last;
VECSUB(is->vec, is->end, is->start);
if(intersection(is)) return 1;
}
@ -1143,7 +1097,7 @@ static int d3dda(Isect *is)
if(c1==0) return 0;
/* reset static variables in ocread */
ocread(g_oc.ocres, 0, 0);
//ocread(g_oc.ocres, 0, 0);
/* setup 3dda to traverse octree */
ox1= (is->start[0]-g_oc.min[0])*g_oc.ocfacx;
@ -1166,10 +1120,12 @@ static int d3dda(Isect *is)
if(ocx1==ocx2 && ocy1==ocy2 && ocz1==ocz2) {
no= ocread(ocx1, ocy1, ocz1);
if(no) {
/* no calc, this is store */
calc_ocval_ray(NULL, ox1, oy1, oz1, ox2, oy2, oz2);
/* exact intersection with node */
vec1[0]= ox1; vec1[1]= oy1; vec1[2]= oz1;
vec2[0]= ox2; vec2[1]= oy2; vec2[2]= oz2;
calc_ocval_ray(&ocval, (float)ocx1, (float)ocy1, (float)ocz1, vec1, vec2);
is->ddalabda= 1.0;
if( testnode(is, no, ocx1, ocy1, ocz1) ) return 1;
if( testnode(is, no, ocval) ) return 1;
}
}
else {
@ -1225,7 +1181,7 @@ static int d3dda(Isect *is)
}
xo=ocx1; yo=ocy1; zo=ocz1;
ddalabda= MIN3(labdax,labday,labdaz);
labdao= ddalabda= MIN3(labdax,labday,labdaz);
vec2[0]= ox1;
vec2[1]= oy1;
@ -1241,15 +1197,14 @@ static int d3dda(Isect *is)
/* calculate ray intersection with octree node */
VECCOPY(vec1, vec2);
// dox,y,z is negative
// dox,y,z is negative
vec2[0]= ox1-ddalabda*dox;
vec2[1]= oy1-ddalabda*doy;
vec2[2]= oz1-ddalabda*doz;
/* no calc, this is store */
calc_ocval_ray(NULL, vec1[0], vec1[1], vec1[2], vec2[0], vec2[1], vec2[2]);
calc_ocval_ray(&ocval, (float)xo, (float)yo, (float)zo, vec1, vec2);
is->ddalabda= ddalabda;
if( testnode(is, no, xo,yo,zo) ) return 1;
if( testnode(is, no, ocval) ) return 1;
}
labdao= ddalabda;
@ -1319,7 +1274,7 @@ static int d3dda(Isect *is)
}
/* reached end, no intersections found */
g_oc.vlr_last= NULL;
is->vlr_last= NULL;
return 0;
}
@ -1342,7 +1297,8 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shi->vlr= vlr;
shi->mat= vlr->mat;
shi->matren= shi->mat->ren;
memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); // note, keep this synced with render_types.h
shi->har= shi->mat->har;
/* face normal, check for flip */
l= vlr->n[0]*shi->view[0]+vlr->n[1]*shi->view[1]+vlr->n[2]*shi->view[2];
@ -1358,10 +1314,13 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
// Osa structs we leave unchanged now
SWAP(int, osatex, shi->osatex);
shi->dxco[0]= shi->dxco[1]= shi->dxco[2]= 0.0;
shi->dyco[0]= shi->dyco[1]= shi->dyco[2]= 0.0;
// but, set O structs zero where it can confuse texture code
if(shi->matren->texco & (TEXCO_NORM|TEXCO_REFL) ) {
O.dxno[0]= O.dxno[1]= O.dxno[2]= 0.0;
O.dyno[0]= O.dyno[1]= O.dyno[2]= 0.0;
if(shi->mat->texco & (TEXCO_NORM|TEXCO_REFL) ) {
shi->dxno[0]= shi->dxno[1]= shi->dxno[2]= 0.0;
shi->dyno[0]= shi->dyno[1]= shi->dyno[2]= 0.0;
}
if(vlr->v4) {
@ -1374,26 +1333,28 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shade_input_set_coords(shi, is->u, is->v, 0, 1, 2);
}
SWAP(int, osatex, shi->osatex);
// SWAP(int, osatex, shi->osatex); XXXXX!!!!
if(is->mode==DDA_SHADOW_TRA) shade_color(shi, shr);
else {
shade_lamp_loop(shi, shr);
if(shi->matren->translucency!=0.0) {
if(shi->translucency!=0.0) {
ShadeResult shr_t;
VecMulf(shi->vn, -1.0);
VecMulf(vlr->n, -1.0);
shade_lamp_loop(shi, &shr_t);
shr->diff[0]+= shi->matren->translucency*shr_t.diff[0];
shr->diff[1]+= shi->matren->translucency*shr_t.diff[1];
shr->diff[2]+= shi->matren->translucency*shr_t.diff[2];
shr->diff[0]+= shi->translucency*shr_t.diff[0];
shr->diff[1]+= shi->translucency*shr_t.diff[1];
shr->diff[2]+= shi->translucency*shr_t.diff[2];
VecMulf(shi->vn, -1.0);
VecMulf(vlr->n, -1.0);
}
}
SWAP(int, osatex, shi->osatex); // XXXXX!!!!
if(flip) {
vlr->n[0]= -vlr->n[0];
vlr->n[1]= -vlr->n[1];
@ -1499,20 +1460,20 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen
if(depth>0) {
if(shi.matren->mode & (MA_RAYTRANSP|MA_ZTRA) && shr.alpha!=1.0) {
if(shi.mat->mode & (MA_RAYTRANSP|MA_ZTRA) && shr.alpha!=1.0) {
float f, f1, refract[3], tracol[3];
if(shi.matren->mode & MA_RAYTRANSP) {
if(shi.mat->mode & MA_RAYTRANSP) {
/* odd depths: use normal facing viewer, otherwise flip */
if(traflag & RAY_TRAFLIP) {
float norm[3];
norm[0]= - shi.vn[0];
norm[1]= - shi.vn[1];
norm[2]= - shi.vn[2];
refraction(refract, norm, shi.view, shi.matren->ang);
refraction(refract, norm, shi.view, shi.ang);
}
else {
refraction(refract, shi.vn, shi.view, shi.matren->ang);
refraction(refract, shi.vn, shi.view, shi.ang);
}
traflag |= RAY_TRA;
traceray(depth-1, shi.co, refract, tracol, shi.vlr, shi.mask, osatex, traflag ^ RAY_TRAFLIP);
@ -1532,9 +1493,9 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen
shr.alpha= 1.0;
}
if(shi.matren->mode & MA_RAYMIRROR) {
f= shi.matren->ray_mirror;
if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.matren->fresnel_mir_i, shi.matren->fresnel_mir);
if(shi.mat->mode & MA_RAYMIRROR) {
f= shi.ray_mirror;
if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.mat->fresnel_mir_i, shi.mat->fresnel_mir);
}
else f= 0.0;
@ -1551,9 +1512,9 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen
//col[1]+= shr.spec[1];
//col[2]+= shr.spec[2];
fr= shi.matren->mirr;
fg= shi.matren->mirg;
fb= shi.matren->mirb;
fr= shi.mirr;
fg= shi.mirg;
fb= shi.mirb;
col[0]= f*fr*(1.0-shr.spec[0])*col[0] + f1*shr.diff[0] + shr.spec[0];
col[1]= f*fg*(1.0-shr.spec[1])*col[1] + f1*shr.diff[1] + shr.spec[1];
@ -1576,8 +1537,8 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen
VECCOPY(shi.view, vec);
Normalise(shi.view);
RE_sky(shi.view, col);
shadeSkyPixelFloat(col, shi.view, NULL);
}
}
@ -1666,7 +1627,7 @@ static float *jitter_plane(LampRen *lar, int xs, int ys)
tot= lar->ray_totsamp;
if(lar->jitter==NULL) {
lar->jitter= (float *)4; // mislead thread quickly (tsk!)
fp=lar->jitter= MEM_mallocN(4*tot*2*sizeof(float), "lamp jitter tab");
/* fill table with random locations, area_size large */
@ -1688,13 +1649,25 @@ static float *jitter_plane(LampRen *lar, int xs, int ys)
}
if(lar->ray_samp_type & LA_SAMP_JITTER) {
static int xold=0, yold=0;
/* new OSA allows to enter this function many times for 1 pixel */
if(xold!=xs || yold!=ys) {
jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, BLI_frand(), BLI_frand());
xold= xs; yold= ys;
/* made it threadsafe */
if(ys & 1) {
static int xold=0, yold=0;
if(xold!=xs || yold!=ys) {
jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, BLI_frand(), BLI_frand());
xold= xs; yold= ys;
}
return lar->jitter+2*tot;
}
else {
static int xold=0, yold=0;
if(xold!=xs || yold!=ys) {
jitter_plane_offset(lar->jitter, lar->jitter+4*tot, tot, lar->area_size, lar->area_sizey, BLI_frand(), BLI_frand());
xold= xs; yold= ys;
}
return lar->jitter+4*tot;
}
return lar->jitter+2*tot;
}
if(lar->ray_samp_type & LA_SAMP_DITHER) {
return lar->jitter + 2*tot*((xs & 1)+2*(ys & 1));
@ -1714,19 +1687,19 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr)
float i, f, f1, fr, fg, fb, vec[3], mircol[3], tracol[3];
int do_tra, do_mir;
do_tra= ((shi->matren->mode & (MA_RAYTRANSP|MA_ZTRA)) && shr->alpha!=1.0);
do_mir= ((shi->matren->mode & MA_RAYMIRROR) && shi->matren->ray_mirror!=0.0);
do_tra= ((shi->mat->mode & (MA_RAYTRANSP|MA_ZTRA)) && shr->alpha!=1.0);
do_mir= ((shi->mat->mode & MA_RAYMIRROR) && shi->ray_mirror!=0.0);
vlr= shi->vlr;
if(do_tra) {
float refract[3];
if(shi->matren->mode & MA_RAYTRANSP) {
refraction(refract, shi->vn, shi->view, shi->matren->ang);
traceray(shi->matren->ray_depth_tra, shi->co, refract, tracol, shi->vlr, shi->mask, 0, RAY_TRA|RAY_TRAFLIP);
if(shi->mat->mode & MA_RAYTRANSP) {
refraction(refract, shi->vn, shi->view, shi->ang);
traceray(shi->mat->ray_depth_tra, shi->co, refract, tracol, shi->vlr, shi->mask, 0, RAY_TRA|RAY_TRAFLIP);
}
else
traceray(shi->matren->ray_depth_tra, shi->co, shi->view, tracol, shi->vlr, shi->mask, 0, 0);
traceray(shi->mat->ray_depth_tra, shi->co, shi->view, tracol, shi->vlr, shi->mask, 0, 0);
f= shr->alpha; f1= 1.0-f;
shr->diff[0]= f*shr->diff[0] + f1*tracol[0];
@ -1737,18 +1710,18 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr)
if(do_mir) {
i= shi->matren->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->matren->fresnel_mir_i, shi->matren->fresnel_mir);
i= shi->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->mat->fresnel_mir_i, shi->mat->fresnel_mir);
if(i!=0.0) {
fr= shi->matren->mirr;
fg= shi->matren->mirg;
fb= shi->matren->mirb;
fr= shi->mirr;
fg= shi->mirg;
fb= shi->mirb;
if(vlr->flag & R_SMOOTH)
reflection(vec, shi->vn, shi->view, vlr->n);
else
reflection(vec, shi->vn, shi->view, NULL);
traceray(shi->matren->ray_depth, shi->co, vec, mircol, shi->vlr, shi->mask, shi->osatex, 0);
traceray(shi->mat->ray_depth, shi->co, vec, mircol, shi->vlr, shi->mask, shi->osatex, 0);
f= i*fr*(1.0-shr->spec[0]); f1= 1.0-i;
shr->diff[0]= f*mircol[0] + f1*shr->diff[0];
@ -1928,9 +1901,31 @@ static void DistributedSpherical(float *sphere, int tot, int iter)
}
}
static float *threadsafe_table_sphere(int test, int xs, int ys)
{
static float sphere1[2*3*256];
static float sphere2[2*3*256];
static int xs1=-1, xs2=-1, ys1=-1, ys2=-1;
if(ys & 1) {
if(xs==xs1 && ys==ys1) return sphere1;
if(test) return NULL;
xs1= xs; ys1= ys;
return sphere1;
}
else {
if(xs==xs2 && ys==ys2) return sphere2;
if(test) return NULL;
xs2= xs; ys2= ys;
return sphere2;
}
}
static float *sphere_sampler(int type, int resol, int xs, int ys)
{
static float sphere[2*3*256], sphere1[2*3*256];
static float sphere[2*3*256];
float *sphere1;
int tot;
float *vec;
@ -1948,16 +1943,19 @@ static float *sphere_sampler(int type, int resol, int xs, int ys)
}
}
else {
static int last_distr= 0, xold=0xffff, yold=0;
static int last_distr= 0;
float cosf, sinf, cost, sint;
float ang, *vec1;
int a;
if(last_distr!=resol) DistributedSpherical(sphere, tot, 16);
last_distr= resol;
if(last_distr!=resol) {
last_distr= resol;
DistributedSpherical(sphere, tot, 16);
}
if(xold!=xs || yold!=ys) {
xold=xs; yold=ys;
sphere1= threadsafe_table_sphere(1, xs, ys);
if(sphere1==NULL) {
sphere1= threadsafe_table_sphere(0, xs, ys);
// random rotation
ang= BLI_frand();
@ -1988,21 +1986,12 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
int j=0, tot, actual=0, skyadded=0;
isec.vlrorig= shi->vlr;
isec.vlr_last= NULL;
isec.mode= DDA_SHADOW;
isec.lay= -1;
shadfac[0]= shadfac[1]= shadfac[2]= 0.0;
/* if sky texture used, these values have to be reset back to original */
if(wrld->aocolor==WO_AOSKYCOL && G.scene->world) {
R.wrld.horr= G.scene->world->horr;
R.wrld.horg= G.scene->world->horg;
R.wrld.horb= G.scene->world->horb;
R.wrld.zenr= G.scene->world->zenr;
R.wrld.zeng= G.scene->world->zeng;
R.wrld.zenb= G.scene->world->zenb;
}
// bias prevents smoothed faces to appear flat
if(shi->vlr->flag & R_SMOOTH) {
bias= G.scene->world->aobias;
@ -2060,7 +2049,7 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
shadfac[2]+= (1.0-fac)*R.wrld.horb + fac*R.wrld.zenb;
}
else {
RE_sky(view, skycol);
shadeSkyPixelFloat(skycol, view, NULL);
shadfac[0]+= skycol[0];
shadfac[1]+= skycol[1];
shadfac[2]+= skycol[2];
@ -2089,16 +2078,18 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac)
{
Isect isec;
Material stored;
float lampco[3];
if(shi->matren->mode & MA_SHADOW_TRA) {
isec.mode= DDA_SHADOW_TRA;
/* needed to prevent shade_ray changing matren (textures) */
stored= *(shi->matren);
}
/* setup isec */
if(shi->mat->mode & MA_SHADOW_TRA) isec.mode= DDA_SHADOW_TRA;
else isec.mode= DDA_SHADOW;
if(lar->mode & LA_LAYER) isec.lay= lar->lay; else isec.lay= -1;
/* only when not mir tracing, first hit optimm */
if(shi->depth==0) isec.vlr_last= lar->vlr_last;
else isec.vlr_last= NULL;
isec.vlrorig= shi->vlr;
shadfac[3]= 1.0; // 1=full light
@ -2111,15 +2102,12 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac)
VECCOPY(lampco, lar->co);
}
/* only when not tracing, first hit optimm */
if(shi->depth==0) g_oc.vlr_last= lar->vlr_last;
/* transp-shadow and soft not implemented yet */
if(lar->ray_totsamp<2 || isec.mode == DDA_SHADOW_TRA) {
/* set up isec */
/* set up isec vec */
VECCOPY(isec.start, shi->co);
VECCOPY(isec.end, lampco);
isec.vlrorig= shi->vlr;
if(isec.mode==DDA_SHADOW_TRA) {
isec.col[0]= isec.col[1]= isec.col[2]= 1.0;
@ -2142,8 +2130,6 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac)
float fac=0.0, div=0.0, vec[3];
int a, j= -1, mask;
isec.vlrorig= shi->vlr;
fac= 0.0;
jitlamp= jitter_plane(lar, floor(shi->xs+0.5), floor(shi->ys+0.5));
@ -2188,13 +2174,8 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac)
shadfac[3]= 1.0-fac/div;
}
if(shi->matren->mode & MA_SHADOW_TRA) {
/* needed to prevent shade_ray changing matren (textures) */
*(shi->matren)= stored;
}
/* for first hit optim, set last interesected shadow face */
if(shi->depth==0) lar->vlr_last= g_oc.vlr_last;
if(shi->depth==0) lar->vlr_last= isec.vlr_last;
}

@ -38,17 +38,13 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "render.h"
#include "render_intern.h"
#include "renderHelp.h"
#include "zbuf.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
static float panovco, panovsi;
static float panophi=0.0;
static float tempPanoPhi;

@ -35,7 +35,6 @@
#include "MEM_guardedalloc.h"
#include "render.h"
#include "render_intern.h"
#include "renderPreAndPost.h"
#include "RE_callbacks.h"
@ -56,11 +55,6 @@ void prepareScene()
int a;
extern void makeoctree(void);
if(R.rectot) MEM_freeN(R.rectot);
R.rectot= 0;
if(R.rectz) MEM_freeN(R.rectz);
R.rectz= 0;
RE_local_get_renderdata();
/* SHADOW BUFFER */

File diff suppressed because it is too large Load Diff

@ -59,18 +59,17 @@
#include <math.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "DNA_material_types.h"
#include "DNA_texture_types.h"
#include "BKE_texture.h"
#include "render.h"
#include "render_intern.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* ------------------------------------------------------------------------- */
@ -176,16 +175,12 @@ VlakRen *RE_findOrAddVlak(int nr)
/* ------------------------------------------------------------------------- */
extern float Tin, Tr, Tg, Tb;
HaloRen *RE_inithalo(Material *ma,
float *vec,
float *vec1,
float *orco,
float hasize,
float vectsize)
HaloRen *RE_inithalo(Material *ma, float *vec, float *vec1,
float *orco, float hasize, float vectsize, int seed)
{
HaloRen *har;
MTex *mtex;
float tin, tr, tg, tb, ta;
float xn, yn, zn, texvec[3], hoco[4], hoco1[4];
if(hasize==0) return 0;
@ -213,7 +208,7 @@ HaloRen *RE_inithalo(Material *ma,
har->ys= 0.5*R.recty*(hoco[1]/zn);
har->zs= 0x7FFFFF*(1.0+hoco[2]/zn);
har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
har->zBufDist = 0x7FFFFFFF*(hoco[2]/zn);
xn= har->xs - 0.5*R.rectx*(hoco1[0]/hoco1[3]);
yn= har->ys - 0.5*R.recty*(hoco1[1]/hoco1[3]);
@ -233,13 +228,13 @@ HaloRen *RE_inithalo(Material *ma,
if(ma->mode & MA_HALO_XALPHA) har->type |= HA_XALPHA;
har->alfa= ma->alpha;
har->r= 255.0*ma->r;
har->g= 255.0*ma->g;
har->b= 255.0*ma->b;
har->add= 255.0*ma->add;
har->mat= ma->ren;
har->r= ma->r;
har->g= ma->g;
har->b= ma->b;
har->add= (255.0*ma->add);
har->mat= ma;
har->hard= ma->har;
har->seed= ma->ren->seed1 % 256;
har->seed= seed % 256;
if(ma->mode & MA_STAR) har->starpoints= ma->starc;
if(ma->mode & MA_HALO_LINES) har->linec= ma->linec;
@ -270,19 +265,19 @@ HaloRen *RE_inithalo(Material *ma,
}
}
externtex(mtex, texvec);
externtex(mtex, texvec, &tin, &tr, &tg, &tb, &ta);
yn= Tin*mtex->colfac;
zn= Tin*mtex->varfac;
yn= tin*mtex->colfac;
zn= tin*mtex->varfac;
if(mtex->mapto & MAP_COL) {
zn= 1.0-yn;
har->r= 255.0*(yn*Tr+ zn*ma->r);
har->g= 255.0*(yn*Tg+ zn*ma->g);
har->b= 255.0*(yn*Tb+ zn*ma->b);
har->r= (yn*tr+ zn*ma->r);
har->g= (yn*tg+ zn*ma->g);
har->b= (yn*tb+ zn*ma->b);
}
if(mtex->texco & 16) {
har->alfa= 255.0*Tin;
har->alfa= tin;
}
}
}

@ -42,38 +42,32 @@
#include "MTC_matrixops.h"
#include "MEM_guardedalloc.h"
#include "BLI_arithb.h"
#include "DNA_lamp_types.h"
#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "render.h"
#include "render_intern.h"
#include "shadbuf.h"
#include "renderHelp.h"
#include "jitter.h"
#include "zbuf.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
/* XXX, could be better implemented...
*/
#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__BIG_ENDIAN__)
#define RCOMP 3
#define GCOMP 2
#define BCOMP 1
#define ACOMP 0
#else
#define RCOMP 0
#define GCOMP 1
#define BCOMP 2
#define ACOMP 3
#endif
/* if defined: objects don't cast shadows anymore */
/* #define RE_NO_SHADOWS */
/* unused? */
static int bias= 0x00500000;
/* crud */
#define MIN2(x,y) ( (x)<(y) ? (x) : (y) )
/* ------------------------------------------------------------------------- */
void lrectreadRectz(int x1, int y1, int x2, int y2, char *r1);
int sizeoflampbuf(struct ShadBuf *shb);
int firstreadshadbuf(struct ShadBuf *shb, int xs, int ys, int nr);
float readshadowbuf(struct ShadBuf *shb, int xs, int ys, int zs);
float readshadowbuf_halo(struct ShadBuf *shb, int xs, int ys, int zs);
float *give_jitter_tab(int samp);
/* ------------------------------------------------------------------------- */
@ -138,7 +132,7 @@ void RE_initshadowbuf(LampRen *lar, float mat[][4])
/* ------------------------------------------------------------------------- */
void lrectreadRectz(int x1, int y1, int x2, int y2, char *r1) /* reads part from rectz in r1 */
static void lrectreadRectz(int x1, int y1, int x2, int y2, char *r1) /* reads part from rectz in r1 */
{
unsigned int len4, *rz;
@ -154,8 +148,8 @@ void lrectreadRectz(int x1, int y1, int x2, int y2, char *r1) /* reads part from
}
}
int sizeoflampbuf(struct ShadBuf *shb)
#if 0
static int sizeoflampbuf(struct ShadBuf *shb)
{
int num,count=0;
char *cp;
@ -167,8 +161,9 @@ int sizeoflampbuf(struct ShadBuf *shb)
return 256*count;
}
#endif
float *give_jitter_tab(int samp)
static float *give_jitter_tab(int samp)
{
/* these are all possible jitter tables, takes up some
* 12k, not really bad!
@ -345,7 +340,7 @@ void makeshadowbuf(LampRen *lar)
/* printf("lampbuf %d\n", sizeoflampbuf(shb)); */
}
int firstreadshadbuf(struct ShadBuf *shb, int xs, int ys, int nr)
static int firstreadshadbuf(struct ShadBuf *shb, int xs, int ys, int nr)
{
/* return a 1 if fully compressed shadbuf-tile && z==const */
static int *rz;
@ -372,7 +367,7 @@ int firstreadshadbuf(struct ShadBuf *shb, int xs, int ys, int nr)
return 0;
}
float readshadowbuf(struct ShadBuf *shb, int xs, int ys, int zs) /* return 1.0 : fully in light */
static float readshadowbuf(struct ShadBuf *shb, int bias, int xs, int ys, int zs) /* return 1.0 : fully in light */
{
float temp;
int *rz, ofs;
@ -435,12 +430,13 @@ float readshadowbuf(struct ShadBuf *shb, int xs, int ys, int zs) /* return 1.0 :
}
}
float testshadowbuf(struct ShadBuf *shb, float *rco, float inp) /* return 1.0: no shadow at all */
/* the externally called shadow testing (reading) function */
/* return 1.0: no shadow at all */
float testshadowbuf(struct ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp)
{
float fac, co[4], dx[3], dy[3], aantal=0;
float xs1,ys1, siz, *j, xres, yres;
int xs,ys, zs;
int xs,ys, zs, bias;
short a,num;
/* if(inp <= 0.0) return 1.0; */
@ -477,20 +473,20 @@ float testshadowbuf(struct ShadBuf *shb, float *rco, float inp) /* return 1.0:
bias= (1.5-inp*inp)*shb->bias;
if(num==1) {
return readshadowbuf(shb,(int)xs1, (int)ys1, zs);
return readshadowbuf(shb, bias, (int)xs1, (int)ys1, zs);
}
co[0]= rco[0]+O.dxco[0];
co[1]= rco[1]+O.dxco[1];
co[2]= rco[2]+O.dxco[2];
co[0]= rco[0]+dxco[0];
co[1]= rco[1]+dxco[1];
co[2]= rco[2]+dxco[2];
co[3]= 1.0;
MTC_Mat4MulVec4fl(shb->persmat,co); /* rational hom co */
dx[0]= xs1- siz*(1.0+co[0]/co[3]);
dx[1]= ys1- siz*(1.0+co[1]/co[3]);
co[0]= rco[0]+O.dyco[0];
co[1]= rco[1]+O.dyco[1];
co[2]= rco[2]+O.dyco[2];
co[0]= rco[0]+dyco[0];
co[1]= rco[1]+dyco[1];
co[2]= rco[2]+dyco[2];
co[3]= 1.0;
MTC_Mat4MulVec4fl(shb->persmat,co); /* rational hom co */
dy[0]= xs1- siz*(1.0+co[0]/co[3]);
@ -512,7 +508,7 @@ float testshadowbuf(struct ShadBuf *shb, float *rco, float inp) /* return 1.0:
if(firstreadshadbuf(shb, (int)(xs1+xres), (int)ys1, 1)) {
if(firstreadshadbuf(shb, (int)xs1, (int)(ys1+yres), 1)) {
if(firstreadshadbuf(shb, (int)(xs1+xres), (int)(ys1+yres), 1)) {
return readshadowbuf(shb,(int)xs1, (int)ys1, zs);
return readshadowbuf(shb, bias,(int)xs1, (int)ys1, zs);
}
}
}
@ -526,7 +522,7 @@ float testshadowbuf(struct ShadBuf *shb, float *rco, float inp) /* return 1.0:
ys= ys1 + yres*(j[1] + 0.5);
j+=2;
aantal+= readshadowbuf(shb, xs, ys, zs);
aantal+= readshadowbuf(shb, bias, xs, ys, zs);
}
/* Renormalizes for the sample number: */
@ -535,13 +531,16 @@ float testshadowbuf(struct ShadBuf *shb, float *rco, float inp) /* return 1.0:
/* different function... sampling behind clipend can be LIGHT, bias is negative! */
/* return: light */
float readshadowbuf_halo(struct ShadBuf *shb, int xs, int ys, int zs)
static float readshadowbuf_halo(struct ShadBuf *shb, int xs, int ys, int zs)
{
float temp;
int *rz, ofs;
int zbias, zsamp;
int bias, zbias, zsamp;
char *ct, *cz;
/* negative! The other side is more important */
bias= -shb->bias;
/* simpleclip */
if(xs<0 || ys<0) return 0.0;
if(xs>=shb->size || ys>=shb->size) return 0.0;
@ -616,8 +615,6 @@ float shadow_halo(LampRen *lar, float *p1, float *p2)
int dx = 0, dy = 0;
siz= 0.5*(float)shb->size;
/* negative! The other side is more important */
bias= -shb->bias;
co[0]= p1[0];
co[1]= p1[1];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -62,7 +62,6 @@
#include "MEM_guardedalloc.h"
#include "zbufferdatastruct.h"
#include "render.h"
#include "render_intern.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -185,6 +184,11 @@ void insertObject(int apteller,
RE_APixstrExt* apn = &APixbufExt[apteller];
int all_subpixels= 0;
//if(obtype==RE_POLY) {
// VlakRen *vlr= RE_findOrAddVlak( (obindex-1) & 0x7FFFFF);
// if(vlr->flag & R_FULL_OSA) all_subpixels= 1;
//}
while(apn) {
if(apn->t[0] == RE_NONE) {
apn->p[0] = obindex; apn->t[0] = obtype;

@ -86,7 +86,12 @@ extern "C" {
void RE_make_stars(void (*initfunc)(void),
void (*vertexfunc)(float*),
void (*termfunc)(void));
/**
* called by meshtools
*/
void RE_make_sticky(void);
#ifdef __cplusplus
}

@ -798,7 +798,7 @@ static void make_render_halos(Object *ob, Mesh *me, int totvert, MVert *mvert, M
HaloRen *har;
float xn, yn, zn, nor[3], view[3];
float *orco, vec[3], hasize, mat[4][4], imat[3][3];
int start, end, a, ok;
int start, end, a, ok, seed= ma->seed1;
MTC_Mat4MulMat4(mat, ob->obmat, R.viewmat);
MTC_Mat3CpyMat4(imat, ob->imat);
@ -813,8 +813,6 @@ static void make_render_halos(Object *ob, Mesh *me, int totvert, MVert *mvert, M
mvert+= start;
if(extverts) extverts+= 3*start;
ma->ren->seed1= ma->seed1;
for(a=start; a<end; a++, mvert++) {
ok= 1;
@ -849,12 +847,12 @@ static void make_render_halos(Object *ob, Mesh *me, int totvert, MVert *mvert, M
else hasize*= zn*zn*zn*zn;
}
if(orco) har= RE_inithalo(ma, vec, 0, orco, hasize, 0);
else har= RE_inithalo(ma, vec, 0, mvert->co, hasize, 0);
if(orco) har= RE_inithalo(ma, vec, 0, orco, hasize, 0, seed);
else har= RE_inithalo(ma, vec, 0, mvert->co, hasize, 0, seed);
if(har) har->lay= ob->lay;
}
if(orco) orco+= 3;
ma->ren->seed1++;
seed++;
}
}
@ -867,7 +865,7 @@ static void render_particle_system(Object *ob, PartEff *paf)
HaloRen *har=0;
Material *ma=0;
float xn, yn, zn, imat[3][3], mat[4][4], hasize, ptime, ctime, vec[3], vec1[3], view[3], nor[3];
int a, mat_nr=1;
int a, mat_nr=1, seed;
pa= paf->keys;
if(pa==NULL) {
@ -877,7 +875,6 @@ static void render_particle_system(Object *ob, PartEff *paf)
}
ma= give_render_material(ob, 1);
if(ma==NULL) ma= &defmaterial;
MTC_Mat4MulMat4(mat, ob->obmat, R.viewmat);
MTC_Mat4Invert(ob->imat, mat); /* this is correct, for imat texture */
@ -890,7 +887,7 @@ static void render_particle_system(Object *ob, PartEff *paf)
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
else ptime= 0.0;
ctime= bsystem_time(ob, 0, (float)G.scene->r.cfra, ptime);
ma->ren->seed1= ma->seed1;
seed= ma->seed1;
for(a=0; a<paf->totpart; a++, pa+=paf->totkey) {
@ -912,7 +909,6 @@ static void render_particle_system(Object *ob, PartEff *paf)
if(pa->mat_nr != mat_nr) {
mat_nr= pa->mat_nr;
ma= give_render_material(ob, mat_nr);
if(ma==0) ma= &defmaterial;
}
if(ma->ipo) {
@ -943,9 +939,9 @@ static void render_particle_system(Object *ob, PartEff *paf)
else hasize*= zn*zn*zn*zn;
}
if(paf->stype==PAF_VECT) har= RE_inithalo(ma, vec, vec1, pa->co, hasize, paf->vectsize);
if(paf->stype==PAF_VECT) har= RE_inithalo(ma, vec, vec1, pa->co, hasize, paf->vectsize, seed);
else {
har= RE_inithalo(ma, vec, 0, pa->co, hasize, 0);
har= RE_inithalo(ma, vec, 0, pa->co, hasize, 0, seed);
if(har && ma->mode & MA_HALO_SHADE) {
VecSubf(har->no, vec, vec1);
Normalise(har->no);
@ -954,7 +950,7 @@ static void render_particle_system(Object *ob, PartEff *paf)
if(har) har->lay= ob->lay;
}
}
ma->ren->seed1++;
seed++;
}
/* restore material */
@ -977,7 +973,7 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
VlakRen *vlr;
float xn, yn, zn, imat[3][3], mat[4][4], hasize;
float mtime, ptime, ctime, vec[3], vec1[3], view[3], nor[3];
int a, mat_nr=1;
int a, mat_nr=1, seed;
pa= paf->keys;
if(pa==NULL || (paf->flag & PAF_ANIMATED)) {
@ -987,7 +983,6 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
}
ma= give_render_material(ob, 1);
if(ma==NULL) ma= &defmaterial;
MTC_Mat4MulMat4(mat, ob->obmat, R.viewmat);
MTC_Mat4Invert(ob->imat, mat); /* need to be that way, for imat texture */
@ -999,7 +994,7 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
if(ob->ipoflag & OB_OFFS_PARTICLE) ptime= ob->sf;
else ptime= 0.0;
ctime= bsystem_time(ob, 0, (float)G.scene->r.cfra, ptime);
ma->ren->seed1= ma->seed1;
seed= ma->seed1;
for(a=0; a<paf->totpart; a++, pa+=paf->totkey) {
@ -1026,7 +1021,6 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
if(pa->mat_nr != mat_nr) {
mat_nr= pa->mat_nr;
ma= give_render_material(ob, mat_nr);
if(ma==0) ma= &defmaterial;
}
if(ma->mode & MA_WIRE) {
@ -1085,9 +1079,9 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
else hasize*= zn*zn*zn*zn;
}
if(paf->stype==PAF_VECT) har= RE_inithalo(ma, vec, vec1, pa->co, hasize, paf->vectsize);
if(paf->stype==PAF_VECT) har= RE_inithalo(ma, vec, vec1, pa->co, hasize, paf->vectsize, seed);
else {
har= RE_inithalo(ma, vec, 0, pa->co, hasize, 0);
har= RE_inithalo(ma, vec, 0, pa->co, hasize, 0, seed);
if(har && (ma->mode & MA_HALO_SHADE)) {
VecSubf(har->no, vec, vec1);
Normalise(har->no);
@ -1099,7 +1093,7 @@ static void render_static_particle_system(Object *ob, PartEff *paf)
VECCOPY(vec1, vec);
}
ma->ren->seed1++;
seed++;
}
}
@ -1167,7 +1161,9 @@ static void sort_halos(void)
static Material *give_render_material(Object *ob, int nr)
{
extern Material defmaterial; // initrender.c
Object *temp;
Material *ma;
if(ob->flag & OB_FROMDUPLI) {
temp= (Object *)ob->id.newid;
@ -1176,7 +1172,10 @@ static Material *give_render_material(Object *ob, int nr)
}
}
return give_current_material(ob, nr);
ma= give_current_material(ob, nr);
if(ma==NULL) ma= &defmaterial;
return ma;
}
/* ------------------------------------------------------------------------- */
@ -1197,10 +1196,9 @@ static void init_render_mball(Object *ob)
MTC_Mat3CpyMat4(imat, ob->imat);
ma= give_render_material(ob, 1);
if(ma==0) ma= &defmaterial;
need_orco= 0;
if(ma->ren->texco & TEXCO_ORCO) {
if(ma->texco & TEXCO_ORCO) {
need_orco= 1;
}
@ -1328,7 +1326,7 @@ static void init_render_mesh(Object *ob)
for(a=1; a<=ob->totcol; a++) {
ma= give_render_material(ob, a);
if(ma) {
if(ma->ren->texco & TEXCO_ORCO) {
if(ma->texco & TEXCO_ORCO) {
need_orco= 1;
break;
}
@ -1398,8 +1396,6 @@ static void init_render_mesh(Object *ob)
orco= me->orco;
ma= give_render_material(ob, 1);
if(ma==0) ma= &defmaterial;
if(ma->mode & MA_HALO) {
make_render_halos(ob, me, totvert, mvert, ma, extverts);
@ -1444,7 +1440,6 @@ static void init_render_mesh(Object *ob)
for(a1=0; (a1<ob->totcol || (a1==0 && ob->totcol==0)); a1++) {
ma= give_render_material(ob, a1+1);
if(ma==0) ma= &defmaterial;
/* test for 100% transparant */
ok= 1;
@ -1804,14 +1799,12 @@ void RE_add_render_lamp(Object *ob, int doshadbuf)
lar->mode &= ~LA_SHAD_RAY;
}
}
lar->org= MEM_dupallocN(lar);
}
/* ------------------------------------------------------------------------- */
static void init_render_surf(Object *ob)
{
extern Material defmaterial; // initrender.c
Nurb *nu=0;
Curve *cu;
ListBase displist;
@ -1840,8 +1833,7 @@ static void init_render_surf(Object *ob)
matar[0]= &defmaterial;
for(a=0; a<ob->totcol; a++) {
matar[a]= give_render_material(ob, a+1);
if(matar[a]==0) matar[a]= &defmaterial;
if(matar[a] && matar[a]->ren->texco & TEXCO_ORCO) {
if(matar[a] && matar[a]->texco & TEXCO_ORCO) {
need_orco= 1;
}
}
@ -2185,8 +2177,8 @@ static void init_render_surf(Object *ob)
static void init_render_curve(Object *ob)
{
extern Material defmaterial; // initrender.c
Ika *ika=0;
Lattice *lt=0;
Curve *cu;
VertRen *ver;
@ -2228,8 +2220,7 @@ static void init_render_curve(Object *ob)
matar[0]= &defmaterial;
for(a=0; a<ob->totcol; a++) {
matar[a]= give_render_material(ob, a+1);
if(matar[a]==0) matar[a]= &defmaterial;
if(matar[a]->ren->texco & TEXCO_ORCO) {
if(matar[a]->texco & TEXCO_ORCO) {
need_orco= 1;
}
}
@ -2681,7 +2672,6 @@ void RE_freeRotateBlenderScene(void)
MEM_freeN(shb->cbuf);
MEM_freeN(R.la[a]->shb);
}
if(R.la[a]->org) MEM_freeN(R.la[a]->org);
if(R.la[a]->jitter) MEM_freeN(R.la[a]->jitter);
MEM_freeN(R.la[a]);
}
@ -2898,9 +2888,6 @@ void RE_rotateBlenderScene(void)
if(G.scene->camera==0) return;
O.dxwin[0]= 0.5/(float)R.r.xsch;
O.dywin[1]= 0.5/(float)R.r.ysch;
slurph_opt= 0;
R.totvlak=R.totvert=R.totlamp=R.tothalo= 0;
@ -3123,6 +3110,78 @@ void RE_rotateBlenderScene(void)
set_normalflags();
}
/* **************************************************************** */
/* sticky texture coords */
/* **************************************************************** */
void RE_make_sticky(void)
{
Object *ob;
Base *base;
MVert *mvert;
Mesh *me;
MSticky *ms;
float ho[4], mat[4][4];
int a;
if(G.scene->camera==0) return;
if(G.obedit) {
error("Unable to make sticky in Edit Mode");
return;
}
base= FIRSTBASE;
while(base) {
if TESTBASELIB(base) {
if(base->object->type==OB_MESH) {
ob= base->object;
me= ob->data;
mvert= me->mvert;
if(me->msticky) MEM_freeN(me->msticky);
me->msticky= MEM_mallocN(me->totvert*sizeof(MSticky), "sticky");
/* like convert to render data */
R.r= G.scene->r;
R.r.xsch= (R.r.size*R.r.xsch)/100;
R.r.ysch= (R.r.size*R.r.ysch)/100;
R.afmx= R.r.xsch/2;
R.afmy= R.r.ysch/2;
R.ycor= ( (float)R.r.yasp)/( (float)R.r.xasp);
R.rectx= R.r.xsch;
R.recty= R.r.ysch;
R.xstart= -R.afmx;
R.ystart= -R.afmy;
R.xend= R.xstart+R.rectx-1;
R.yend= R.ystart+R.recty-1;
where_is_object(G.scene->camera);
Mat4CpyMat4(R.viewinv, G.scene->camera->obmat);
Mat4Ortho(R.viewinv);
Mat4Invert(R.viewmat, R.viewinv);
RE_setwindowclip(1, -1);
where_is_object(ob);
Mat4MulMat4(mat, ob->obmat, R.viewmat);
ms= me->msticky;
for(a=0; a<me->totvert; a++, ms++, mvert++) {
VECCOPY(ho, mvert->co);
Mat4MulVecfl(mat, ho);
RE_projectverto(ho, ho);
ms->co[0]= ho[0]/ho[3];
ms->co[1]= ho[1]/ho[3];
}
}
}
base= base->next;
}
}
/* **************************************************************** */
/* Displacement mapping */
@ -3136,7 +3195,7 @@ static short test_for_displace(Object *ob)
for (i=1; i<=ob->totcol; i++) {
ma=give_render_material(ob, i);
/* ma->mapto is ORed total of all mapto channels */
if(ma && (ma->ren->mapto & MAP_DISPLACE)) return 1;
if(ma && (ma->mapto & MAP_DISPLACE)) return 1;
}
return 0;
}
@ -3185,10 +3244,10 @@ static void displace_render_face(VlakRen *vlr, float *scale)
shi.osatex= 0; /* signal not to use dx[] and dy[] texture AA vectors */
shi.vlr= vlr; /* current render face */
shi.mat= vlr->mat; /* current input material */
shi.matren= shi.mat->ren; /* material temp block where output is written into */
/* UV coords must come from face */
hasuv = vlr->tface && (shi.matren->texco & TEXCO_UV);
hasuv = vlr->tface && (shi.mat->texco & TEXCO_UV);
if (hasuv) shi.uv[2]=0.0f;
/* I don't think this is used, but seting it just in case */
@ -3244,7 +3303,7 @@ static void displace_render_face(VlakRen *vlr, float *scale)
static void displace_render_vert(ShadeInput *shi, VertRen *vr, float *scale)
{
short texco= shi->matren->texco;
short texco= shi->mat->texco;
float sample=0;
/* shi->co is current render coord, just make sure at least some vector is here */
VECCOPY(shi->co, vr->co);

@ -153,6 +153,8 @@
#include "LOD_DependKludge.h"
#include "LOD_decimation.h"
#include "RE_renderconverter.h" // make_sticky
#include "butspace.h" // own module
static int decim_faces=0;
@ -441,6 +443,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
new_material_to_objectdata((G.scene->basact) ? (G.scene->basact->object) : 0);
scrarea_queue_winredraw(curarea);
BIF_undo_push("New material");
allqueue(REDRAWBUTSSHADING, 0);
allqueue(REDRAWVIEW3D_Z, 0);
allqueue(REDRAWOOPS, 0);
break;
@ -448,6 +451,7 @@ void do_common_editbuts(unsigned short event) // old name, is a mix of object an
delete_material_index();
scrarea_queue_winredraw(curarea);
BIF_undo_push("Delete material index");
allqueue(REDRAWBUTSSHADING, 0);
allqueue(REDRAWVIEW3D_Z, 0);
allqueue(REDRAWOOPS, 0);
break;
@ -1899,7 +1903,8 @@ void do_meshbuts(unsigned short event)
allqueue(REDRAWBUTSEDIT, 0);
break;
case B_MAKESTICKY:
make_sticky();
RE_make_sticky();
allqueue(REDRAWBUTSEDIT, 0);
break;
case B_MAKEEDGES:

@ -64,14 +64,15 @@
#include "BIF_gl.h"
#include "BIF_graphics.h"
#include "BIF_keyval.h"
#include "BIF_mainqueue.h"
#include "BIF_resources.h"
#include "BIF_screen.h"
#include "BIF_mywindow.h"
#include "BIF_space.h"
#include "BIF_glutil.h"
#include "BIF_interface.h"
#include "BIF_keyval.h"
#include "BIF_mainqueue.h"
#include "BIF_mywindow.h"
#include "BIF_resources.h"
#include "BIF_renderwin.h"
#include "BIF_screen.h"
#include "BIF_space.h"
#include "BIF_toolbox.h"
#include "BIF_butspace.h"
@ -85,7 +86,6 @@
#include "DNA_image_types.h"
#include "BKE_writeavi.h"
#include "BKE_image.h"
#include "BIF_renderwin.h"
#include "BIF_writeimage.h"
#include "BIF_writeavicodec.h"
#include "BIF_editsound.h"
@ -475,7 +475,7 @@ static void run_playanim(char *file) {
char str[FILE_MAXDIR+FILE_MAXFILE];
int pos[2], size[2];
calc_renderwin_rectangle(R.winpos, pos, size);
calc_renderwin_rectangle(G.winpos, pos, size);
sprintf(str, "%s -a -p %d %d \"%s\"", bprogname, pos[0], pos[1], file);
system(str);
@ -793,6 +793,21 @@ void do_render_panels(unsigned short event)
case B_CLEARSET:
scene_change_set(G.scene, NULL);
break;
case B_FBUF_REDO:
if(R.rectftot) {
/* copy is needed... not so nice, but how better? */
R.r.postgamma= G.scene->r.postgamma;
R.r.postigamma= 1.0/R.r.postgamma;
R.r.postadd= G.scene->r.postadd;
R.r.postmul= G.scene->r.postmul;
R.r.posthue= G.scene->r.posthue;
R.r.postsat= G.scene->r.postsat;
R.r.dither_intensity= G.scene->r.dither_intensity;
RE_floatbuffer_to_output();
BIF_redraw_render_rect();
}
break;
}
}
@ -843,14 +858,18 @@ static uiBlock *post_render_menu(void *arg_unused)
block= uiNewBlock(&curarea->uiblocks, "post render", UI_EMBOSS, UI_HELV, curarea->win);
/* use this for a fake extra empy space around the buttons */
uiDefBut(block, LABEL, 0, "", -10, 10, 200, 80, NULL, 0, 0, 0, 0, "");
uiDefButF(block, NUMSLI, 0,"Add:", 0,60,180,19, &G.scene->r.postadd, -1.0, 1.0, 0, 0, "");
uiDefButF(block, NUMSLI, 0,"Mul:", 0,40,180,19, &G.scene->r.postmul, 0.01, 4.0, 0, 0, "");
uiDefButF(block, NUMSLI, 0,"Gamma:", 0,20,180,19, &G.scene->r.postgamma, 0.2, 2.0, 0, 0, "");
uiDefBut(block, LABEL, 0, "", -10, -10, 200, 120, NULL, 0, 0, 0, 0, "");
uiBlockBeginAlign(block);
uiDefButF(block, NUMSLI, 0, "Add:", 0,80,180,19, &G.scene->r.postadd, -1.0, 1.0, 0, 0, "");
uiDefButF(block, NUMSLI, 0, "Mul:", 0,60,180,19, &G.scene->r.postmul, 0.01, 4.0, 0, 0, "");
uiDefButF(block, NUMSLI, 0, "Gamma:", 0,40,180,19, &G.scene->r.postgamma, 0.1, 4.0, 0, 0, "");
uiDefButF(block, NUMSLI, 0, "Hue:", 0,20,180,19, &G.scene->r.posthue, -0.5, 0.5, 0, 0, "");
uiDefButF(block, NUMSLI, 0, "Sat:", 0, 0,180,19, &G.scene->r.postsat, 0.0, 4.0, 0, 0, "");
uiBlockSetDirection(block, UI_TOP);
addqueue(curarea->win, UI_BUT_EVENT, B_FBUF_REDO);
return block;
}
@ -1039,41 +1058,47 @@ static void render_panel_output(void)
uiBlockEndAlign(block);
uiBlockSetCol(block, TH_BUT_SETTING1);
uiDefButS(block, TOG|BIT|0, 0,"Backbuf", 10, 94, 60, 20, &G.scene->r.bufflag, 0, 0, 0, 0, "Enable/Disable use of Backbuf image");
uiDefButS(block, TOG|BIT|0, B_NOP,"Backbuf", 10, 94, 80, 20, &G.scene->r.bufflag, 0, 0, 0, 0, "Enable/Disable use of Backbuf image");
uiDefButI(block, TOG|BIT|19, B_NOP,"Threads", 10, 68, 80, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable/Disable render in two threads");
uiBlockSetCol(block, TH_AUTO);
uiBlockBeginAlign(block);
for(b=2; b>=0; b--)
for(a=0; a<3; a++)
uiDefButS(block, TOG|BIT|(3*b+a), 800,"", (short)(10+18*a),(short)(10+14*b),16,12, &R.winpos, 0, 0, 0, 0, "Render window placement on screen");
uiDefButS(block, TOG|BIT|(3*b+a), 800,"", (short)(10+18*a),(short)(10+14*b),16,12, &G.winpos, 0, 0, 0, 0, "Render window placement on screen");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButS(block, TOG|BIT|2, REDRAWVIEW3D, "Passepartout", 72, 30, 122, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Draws darkened passepartout in camera view");
uiDefButS(block, ROW, B_REDR, "DispWin", 72, 10, 60, 20, &R.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output to display in a seperate window");
uiDefButS(block, ROW, B_REDR, "DispView", 134, 10, 60, 20, &R.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view");
uiDefButS(block, ROW, B_REDR, "DispWin", 72, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYWIN, 0, 0, "Sets render output to display in a seperate window");
uiDefButS(block, ROW, B_REDR, "DispView", 134, 10, 60, 20, &G.displaymode, 0.0, (float)R_DISPLAYVIEW, 0, 0, "Sets render output to display in 3D view");
uiBlockEndAlign(block);
uiDefButS(block, TOG|BIT|4, 0, "Extensions", 250, 10, 60, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations");
uiDefButS(block, TOG|BIT|4, 0, "Extensions", 205, 10, 105, 19, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations");
/* Dither control */
uiDefButF(block, NUM,B_DIFF, "Dither:", 205,31,105,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)");
/* Toon shading buttons */
uiBlockBeginAlign(block);
uiDefButI(block, TOG|BIT|5, 0,"Edge", 155, 94, 44, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon shading");
uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 200, 94, 110, 20, "Display edge settings");
uiBlockEndAlign(block);
uiDefButI(block, TOG|BIT|5, 0,"Edge", 100, 94, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Toon edge shading");
uiDefBlockBut(block, edge_render_menu, NULL, "Edge Settings", 170, 94, 140, 20, "Display edge settings");
/* unified render buttons */
if(G.scene->r.mode & R_UNIFIED) {
uiDefBlockBut(block, post_render_menu, NULL, "Post process", 200, 68, 110, 20, "Only for unified render");
if (G.scene->r.mode & R_GAMMA) {
uiDefButF(block, NUMSLI, 0,"Gamma:", 10, 68, 142, 20,
&(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0,
"The gamma value for blending oversampled images (1.0 = no correction).");
}
}
/* postprocess render buttons */
uiBlockBeginAlign(block);
if(R.rectftot)
uiDefIconTextButI(block, TOG|BIT|18, B_NOP, ICON_IMAGE_DEHLT," Fbuf", 100, 68, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render; buffer available");
else
uiDefButI(block, TOG|BIT|18, 0,"Fbuf", 100, 68, 70, 20, &G.scene->r.mode, 0, 0, 0, 0, "Keep RGBA float buffer after render, no buffer available now");
uiDefBlockBut(block, post_render_menu, NULL, "Post process", 170, 68, 140, 20, "Applies on RGBA floats while render or with Fbuf available");
uiBlockEndAlign(block);
/* removed, for time being unified and normal render will use same gamma for blending (2.0) */
//if (G.scene->r.mode & R_GAMMA) {
// uiDefButF(block, NUMSLI, 0,"Gamma:", 10, 68, 142, 20,
// &(G.scene->r.gamma), 0.2, 5.0, B_GAMMASLI, 0,
// "The gamma value for blending oversampled images (1.0 = no correction).");
//}
}
static void render_panel_render(void)

@ -53,6 +53,7 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_packedFile_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
@ -82,7 +83,6 @@
/* Modules used */
#include "mydevice.h"
#include "blendef.h"
#include "render.h"
#include "butspace.h" // event codes

@ -68,6 +68,7 @@
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_property.h"
#include "BKE_utildefines.h"
#include "BIF_resources.h"
#include "BIF_gl.h"
@ -785,7 +786,7 @@ static int set_gl_light(Object *ob)
static Material *give_current_material_or_def(Object *ob, int matnr)
{
extern Material defmaterial;
extern Material defmaterial; // render module abuse...
Material *ma= give_current_material(ob, matnr);
return ma?ma:&defmaterial;

@ -127,7 +127,7 @@ static float matbuf[MAXMATBUF][2][4];
static void init_gl_materials(Object *ob)
{
extern Material defmaterial;
extern Material defmaterial; // render module abuse...
Material *ma;
int a;

@ -56,9 +56,10 @@
#include "DNA_space_types.h"
#include "DNA_view2d_types.h"
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BKE_plugin_types.h"
#include "BKE_scene.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
#include "BIF_mywindow.h"

@ -126,14 +126,9 @@
#include "butspace.h" // event codes
/* Modules used */
#include "render.h"
#include "render.h" // for ogl render
#include "radio.h"
/* for physics in animation playback */
#ifdef NAN_LINEAR_PHYSICS
#include "sumo.h"
#endif
/* locals */
void drawname(Object *ob);
void star_stuff_init_func(void);
@ -2234,253 +2229,6 @@ double key_to_swaptime(int key)
return speed_to_swaptime(G.animspeed);
}
#ifdef NAN_LINEAR_PHYSICS
void sumo_callback(void *obp)
{
Object *ob= obp;
SM_Vector3 vec;
float matf[3][3];
int i, j;
SM_GetMatrixf(ob->sumohandle, ob->obmat[0]);
VECCOPY(ob->loc, ob->obmat[3]);
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
matf[i][j] = ob->obmat[i][j];
}
}
Mat3ToEul(matf, ob->rot);
}
/* for test and fun, i've written the next functions to play with dynamics
using a variant of play-anim... was never released nor really tested (ton) */
void init_anim_sumo(void)
{
extern Material defmaterial;
Base *base;
Mesh *me;
Object *ob;
Material *mat;
MFace *mface;
MVert *mvert;
float centre[3], size[3];
int a;
SM_ShapeHandle shape;
SM_SceneHandle scene;
SM_Material material;
SM_MassProps massprops;
SM_Vector3 vec;
SM_Vector3 scaling;
scene= SM_CreateScene();
G.scene->sumohandle = scene;
vec[0]= 0.0;
vec[1]= 0.0;
vec[2]= -9.8;
SM_SetForceField(scene, vec);
/* ton: cylinders & cones are still Y-axis up, will be Z-axis later */
/* ton: write location/rotation save and restore */
base= FIRSTBASE;
while (base) {
if (G.vd->lay & base->lay) {
ob= base->object;
/* define shape, for now only meshes take part in physics */
get_local_bounds(ob, centre, size);
if (ob->type==OB_MESH) {
me= ob->data;
if (ob->gameflag & OB_DYNAMIC) {
if (me->sumohandle)
shape= me->sumohandle;
else {
/* make new handle */
switch(ob->boundtype) {
case OB_BOUND_BOX:
shape= SM_Box(2.0*size[0], 2.0*size[1], 2.0*size[2]);
break;
case OB_BOUND_SPHERE:
shape= SM_Sphere(size[0]);
break;
case OB_BOUND_CYLINDER:
shape= SM_Cylinder(size[0], 2.0*size[2]);
break;
case OB_BOUND_CONE:
shape= SM_Cone(size[0], 2.0*size[2]);
break;
}
me->sumohandle= shape;
}
/* sumo material properties */
mat= give_current_material(ob, 0);
if(mat==NULL)
mat= &defmaterial;
material.restitution= mat->reflect;
material.static_friction= mat->friction;
material.dynamic_friction= mat->friction;
/* sumo mass properties */
massprops.mass= ob->mass;
massprops.center[0]= 0.0;
massprops.center[1]= 0.0;
massprops.center[2]= 0.0;
massprops.inertia[0]= 0.5*ob->mass;
massprops.inertia[1]= 0.5*ob->mass;
massprops.inertia[2]= 0.5*ob->mass;
massprops.orientation[0]= 0.0;
massprops.orientation[1]= 0.0;
massprops.orientation[2]= 0.0;
massprops.orientation[3]= 1.0;
ob->sumohandle = SM_CreateObject(ob, shape, &material,
&massprops, sumo_callback);
SM_AddObject(scene, ob->sumohandle);
scaling[0] = ob->size[0];
scaling[1] = ob->size[1];
scaling[2] = ob->size[2];
SM_SetMatrixf(ob->sumohandle, ob->obmat[0]);
SM_SetScaling(ob->sumohandle, scaling);
}
else {
if(me->sumohandle) shape= me->sumohandle;
else {
/* make new handle */
shape= SM_NewComplexShape();
mface= me->mface;
mvert= me->mvert;
for(a=0; a<me->totface; a++,mface++) {
if(mface->v3) {
SM_Begin();
SM_Vertex( (mvert+mface->v1)->co[0], (mvert+mface->v1)->co[1], (mvert+mface->v1)->co[2]);
SM_Vertex( (mvert+mface->v2)->co[0], (mvert+mface->v2)->co[1], (mvert+mface->v2)->co[2]);
SM_Vertex( (mvert+mface->v3)->co[0], (mvert+mface->v3)->co[1], (mvert+mface->v3)->co[2]);
if(mface->v4)
SM_Vertex( (mvert+mface->v4)->co[0], (mvert+mface->v4)->co[1], (mvert+mface->v4)->co[2]);
SM_End();
}
}
SM_EndComplexShape();
me->sumohandle= shape;
}
/* sumo material properties */
mat= give_current_material(ob, 0);
if(mat==NULL)
mat= &defmaterial;
material.restitution= mat->reflect;
material.static_friction= mat->friction;
material.dynamic_friction= mat->friction;
/* sumo mass properties */
massprops.mass= ob->mass;
massprops.center[0]= 0.0;
massprops.center[1]= 0.0;
massprops.center[2]= 0.0;
massprops.inertia[0]= 0.5*ob->mass;
massprops.inertia[1]= 0.5*ob->mass;
massprops.inertia[2]= 0.5*ob->mass;
massprops.orientation[0]= 0.0;
massprops.orientation[1]= 0.0;
massprops.orientation[2]= 0.0;
massprops.orientation[3]= 1.0;
ob->sumohandle= SM_CreateObject(ob, shape, &material, NULL, NULL);
SM_AddObject(scene, ob->sumohandle);
scaling[0] = ob->size[0];
scaling[1] = ob->size[1];
scaling[2] = ob->size[2];
SM_SetMatrixf(ob->sumohandle, ob->obmat[0]);
SM_SetScaling(ob->sumohandle, scaling);
}
}
}
base= base->next;
}
}
/* update animated objects */
void update_anim_sumo(void)
{
SM_Vector3 scaling;
Base *base;
Object *ob;
Mesh *me;
base= FIRSTBASE;
while(base) {
if(G.vd->lay & base->lay) {
ob= base->object;
if(ob->sumohandle) {
if((ob->gameflag & OB_DYNAMIC)==0) {
/* maybe: optimise, check for anim */
scaling[0] = ob->size[0];
scaling[1] = ob->size[1];
scaling[2] = ob->size[2];
SM_SetMatrixf(ob->sumohandle, ob->obmat[0]);
SM_SetScaling(ob->sumohandle, scaling);
}
}
}
base= base->next;
}
}
void end_anim_sumo(void)
{
Base *base;
Object *ob;
Mesh *me;
base= FIRSTBASE;
while(base) {
if(G.vd->lay & base->lay) {
ob= base->object;
if(ob->type==OB_MESH) {
if(ob->sumohandle) {
SM_RemoveObject(G.scene->sumohandle, ob->sumohandle);
SM_DeleteObject(ob->sumohandle);
ob->sumohandle= NULL;
}
me= ob->data;
if(me->sumohandle) {
SM_DeleteShape(me->sumohandle);
me->sumohandle= NULL;
}
}
}
base= base->next;
}
if(G.scene->sumohandle) {
SM_DeleteScene(G.scene->sumohandle);
G.scene->sumohandle= NULL;
}
}
#endif
void inner_play_anim_loop(int init, int mode)
{
ScrArea *sa;
@ -2494,9 +2242,7 @@ void inner_play_anim_loop(int init, int mode)
swaptime= speed_to_swaptime(G.animspeed);
tottime= 0.0;
curmode= mode;
#ifdef NAN_LINEAR_PHYSICS
init_anim_sumo();
#endif
return;
}
@ -2511,11 +2257,7 @@ void inner_play_anim_loop(int init, int mode)
update_for_newframe_muted();
//test_all_displists();
#ifdef NAN_LINEAR_PHYSICS
update_anim_sumo();
SM_Proceed(G.scene->sumohandle, swaptime, 40, NULL);
#endif
sa= G.curscreen->areabase.first;
while(sa) {
if(sa==oldsa) {
@ -2639,9 +2381,7 @@ int play_anim(int mode)
allqueue (REDRAWACTION, 0);
/* for the time being */
update_for_newframe_muted();
#ifdef NAN_LINEAR_PHYSICS
end_anim_sumo();
#endif
waitcursor(0);
G.f &= ~G_PLAYANIM;

@ -61,16 +61,17 @@
#include "DNA_mesh_types.h"
#include "DNA_lattice_types.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_constraint.h"
#include "BKE_displist.h"
#include "BKE_curve.h"
#include "BKE_ipo.h"
#include "BKE_displist.h"
#include "BKE_global.h"
#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_action.h"
#include "BKE_key.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
#include "BIF_mywindow.h"

@ -57,6 +57,7 @@
#include "DNA_object_types.h"
#include "DNA_space_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "DNA_userdef_types.h"
@ -87,7 +88,6 @@
#include "mydevice.h"
#include "blendef.h"
#include "render.h"
#include "butspace.h"
#include "TPT_DependKludge.h"

@ -62,23 +62,24 @@
#include "DNA_constraint_types.h"
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_object_types.h"
#include "DNA_lamp_types.h"
#include "DNA_sequence_types.h"
#include "DNA_sound_types.h"
#include "DNA_camera_types.h"
#include "DNA_material_types.h"
#include "DNA_texture_types.h"
#include "DNA_key_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "DNA_ipo_types.h"
#include "DNA_curve_types.h"
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "DNA_group_types.h"
#include "DNA_ika_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "DNA_sequence_types.h"
#include "DNA_sound_types.h"
#include "DNA_texture_types.h"
#include "DNA_userdef_types.h"
#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
#include "BKE_utildefines.h"
#include "BKE_action.h"
@ -118,7 +119,6 @@
#include "blendef.h"
#include "mydevice.h"
#include "render.h"
/* forwards */
#define BEZSELECTED(bezt) (((bezt)->f1 & 1) || ((bezt)->f2 & 1) || ((bezt)->f3 & 1))

@ -58,6 +58,7 @@
#include "BKE_displist.h"
#include "BKE_lattice.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BIF_space.h"
#include "BIF_screen.h"
@ -74,8 +75,6 @@
#include "blendef.h"
#include "mydevice.h"
#include "render.h"
#include "BKE_armature.h"
/* ***************************** */

@ -47,6 +47,7 @@
#include "DNA_screen_types.h"
#include "DNA_meta_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
#include "BKE_utildefines.h"
@ -67,7 +68,6 @@
#include "BSE_edit.h"
#include "BSE_view.h"
#include "render.h"
#include "blendef.h"
#include "mydevice.h"

@ -93,7 +93,6 @@
#include "mydevice.h"
#include "blendef.h"
#include "render.h"
/* own include */
#include "editmesh.h"

@ -95,7 +95,7 @@ editmesh_mods.c, UI level access, no geometry changes
#include "mydevice.h"
#include "blendef.h"
#include "render.h" // externtex, badlevel call (ton)
#include "render.h" // externtex
#include "editmesh.h"
@ -2158,7 +2158,6 @@ void vertexsmooth(void)
void vertexnoise(void)
{
EditMesh *em = G.editMesh;
extern float Tin;
Material *ma;
Tex *tex;
EditVert *eve;
@ -2189,10 +2188,9 @@ void vertexnoise(void)
VecAddf(eve->co, eve->co, vec);
}
else {
externtex(ma->mtex[0], eve->co);
eve->co[2]+= 0.05*Tin;
float tin, dum;
externtex(ma->mtex[0], eve->co, &tin, &dum, &dum, &dum, &dum);
eve->co[2]+= 0.05*tin;
}
}
eve= eve->next;

@ -60,6 +60,7 @@
#include "DNA_action_types.h"
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
#include "DNA_curve_types.h"
#include "DNA_effect_types.h"
#include "DNA_ika_types.h"
@ -68,6 +69,7 @@
#include "DNA_key_types.h"
#include "DNA_lamp_types.h"
#include "DNA_lattice_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_meta_types.h"
@ -80,7 +82,6 @@
#include "DNA_userdef_types.h"
#include "DNA_property_types.h"
#include "DNA_vfont_types.h"
#include "DNA_constraint_types.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
@ -153,7 +154,6 @@
#include "BDR_editcurve.h"
#include "BDR_unwrapper.h"
#include "render.h"
#include <time.h>
#include "mydevice.h"
#include "nla.h"

@ -61,6 +61,7 @@
#include "BKE_scene.h"
#include "BKE_library.h"
#include "BKE_material.h"
#include "BKE_utildefines.h"
#include "BIF_space.h"
#include "BIF_screen.h"

@ -101,7 +101,7 @@
#include "BPY_extern.h"
#include "mydevice.h"
#include "blendef.h"
#include "render.h"
#include "render.h" /* R.flag */
#include "winlay.h"

@ -70,6 +70,7 @@
#include "BKE_image.h"
#include "BKE_library.h"
#include "BKE_main.h"
#include "BKE_scene.h"
#include "BIF_space.h"
#include "BIF_interface.h"

@ -63,6 +63,7 @@
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_displist.h"
#include "BKE_utildefines.h"
#include "BIF_gl.h"
#include "BIF_interface.h"

@ -65,6 +65,7 @@
#include "DNA_image_types.h"
#include "DNA_ipo_types.h"
#include "DNA_vfont_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
#include "DNA_texture_types.h"
@ -101,7 +102,6 @@
#include "mydevice.h"
#include "blendef.h"
#include "render.h"
#include "nla.h"

@ -74,6 +74,7 @@
#include "BKE_main.h"
#include "BKE_constraint.h"
#include "BKE_armature.h"
#include "BKE_utildefines.h"
#include "BSE_drawipo.h"
#include "BSE_editaction.h"

@ -67,6 +67,7 @@
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_packedFile.h"
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BIF_drawimage.h"

Some files were not shown because too many files have changed in this diff Show More