Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2003-12-22 00:52:51 +0300
committerTon Roosendaal <ton@blender.org>2003-12-22 00:52:51 +0300
commitec99255c2729b555f34d75c0a2c59f141e327924 (patch)
tree9b8b03fca39f16c2dfc8b05627bda786786fc140 /source/blender/blenkernel
parent16eec383fda747ff97b44e3f93cfc7e0b1033174 (diff)
Phew, a lot of work, and no new features...
Main target was to make the inner rendering loop using no globals anymore. This is essential for proper usage while raytracing, it caused a lot of hacks in the raycode as well, which even didn't work correctly for all situations (textures especially). Done this by creating a new local struct RenderInput, which replaces usage of the global struct Render R. The latter now only is used to denote image size, viewmatrix, and the like. Making the inner render loops using no globals caused 1000s of vars to be changed... but the result definitely is much nicer code, which enables making 'real' shaders in a next stage. It also enabled me to remove the hacks from ray.c Then i went to the task of removing redundant code. Especially the calculus of texture coords took place (identical) in three locations. Most obvious is the change in the unified render part, which is much less code now; it uses the same rendering routines as normal render now. (Note; not for halos yet!) I also removed 6 files called 'shadowbuffer' something. This was experimen- tal stuff from NaN days. And again saved a lot of double used code. Finally I went over the blenkernel and blender/src calls to render stuff. Here the same local data is used now, resulting in less dependency. I also moved render-texture to the render module, this was still in Kernel. (new file: texture.c) So! After this commit I will check on the autofiles, to try to fix that. MSVC people have to do it themselves. This commit will need quite some testing help, but I'm around!
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_global.h1
-rw-r--r--source/blender/blenkernel/BKE_texture.h23
-rw-r--r--source/blender/blenkernel/bad_level_call_stubs/stubs.c7
-rw-r--r--source/blender/blenkernel/intern/displist.c51
-rw-r--r--source/blender/blenkernel/intern/effect.c3
-rw-r--r--source/blender/blenkernel/intern/exotic.c5
-rw-r--r--source/blender/blenkernel/intern/library.c4
-rw-r--r--source/blender/blenkernel/intern/object.c3
-rw-r--r--source/blender/blenkernel/intern/scene.c1
-rw-r--r--source/blender/blenkernel/intern/texture.c1785
10 files changed, 34 insertions, 1849 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 698982f5396..c8564e44cdc 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -244,7 +244,6 @@ typedef struct Global {
#define B_ENDIAN 0
/* G.special1 */
-#define G_HOLO 1
/* Memory is allocated where? blender.c */
extern Global G;
diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h
index 711ad893486..547ac593d15 100644
--- a/source/blender/blenkernel/BKE_texture.h
+++ b/source/blender/blenkernel/BKE_texture.h
@@ -59,29 +59,6 @@ struct MTex *add_mtex(void);
struct Tex *copy_texture(struct Tex *tex);
void make_local_texture(struct Tex *tex);
void autotexname(struct Tex *tex);
-void init_render_texture(struct Tex *tex);
-void init_render_textures(void);
-void end_render_texture(struct Tex *tex);
-void end_render_textures(void);
-int clouds(struct Tex *tex, float *texvec);
-int blend(struct Tex *tex, float *texvec);
-int wood(struct Tex *tex, float *texvec);
-int marble(struct Tex *tex, float *texvec);
-int magic(struct Tex *tex, float *texvec);
-int stucci(struct Tex *tex, float *texvec);
-int texnoise(struct Tex *tex);
-int plugintex(struct Tex *tex, float *texvec, float *dxt, float *dyt);
-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_2d_mapping(struct MTex *mtex, float *t, float *dxt, float *dyt);
-int multitex(struct Tex *tex, float *texvec, float *dxt, float *dyt);
-void do_material_tex(void);
-void do_halo_tex(struct HaloRen *har, float xn, float yn, float *colf);
-void do_sky_tex(void);
-void do_lamp_tex(struct LampRen *la, float *lavec);
-void externtex(struct MTex *mtex, float *vec);
-void externtexcol(struct MTex *mtex, float *orco, char *col);
-void render_realtime_texture(void);
#endif
diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
index 302810fa919..81d77dac227 100644
--- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c
+++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
@@ -90,13 +90,6 @@ ListBase editNurb;
#include "render_types.h"
struct RE_Render R;
-float Phong_Spec(float *n, float *l, float *v, int hard){return 0;}
-float Blinn_Spec(float *n, float *l, float *v, float a, float b){return 0;}
-float CookTorr_Spec(float *n, float *l, float *v, int hard){return 0;}
-float Toon_Spec(float *n, float *l, float *v, float a, float b){return 0;}
-float Toon_Diff(float *n, float *l, float *v, float a, float b){return 0;}
-float OrenNayar_Diff(float *n, float *l, float *v, float a, float b){return 0;}
-
void waitcursor(int val){}
void allqueue(unsigned short event, short val){}
#define REDRAWVIEW3D 0x4010
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 3a42d708f28..c60a614bab8 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -46,9 +46,6 @@
#endif
#include "MEM_guardedalloc.h"
-#include "nla.h" /* For __NLA: Please do not remove yet */
-#include "render.h"
-
#include "IMB_imbuf_types.h"
#include "DNA_texture_types.h"
@@ -88,6 +85,10 @@
#include "BKE_scene.h"
#include "BKE_subsurf.h"
+#include "nla.h" /* For __NLA: Please do not remove yet */
+#include "render.h"
+
+
/***/
typedef struct _FastLamp FastLamp;
@@ -226,8 +227,6 @@ static void initfastshade(void)
FastLamp *fl;
float mat[4][4];
- R.vlr= 0;
-
init_render_world();
if(fastlamplist) return;
@@ -301,16 +300,18 @@ void freefastshade()
static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2, char *vertcol)
{
+ ShadeInput shi;
FastLamp *fl;
float i, t, inp, soft, inpr, inpg, inpb, isr=0, isg=0, isb=0, lv[3], view[3], lampdist, ld;
float inpr1, inpg1, inpb1, isr1=0, isg1=0, isb1=0;
int a, back;
if(ma==0) return;
- R.mat= ma;
- R.matren= ma->ren;
- ma= R.matren;
-
+ shi.mat= ma;
+ shi.matren= ma->ren;
+ shi.vlr= NULL; // have to do this!
+ ma= shi.matren;
+
if(ma->mode & MA_VERTEXCOLP) {
if(vertcol) {
ma->r= vertcol[3]/255.0;
@@ -320,41 +321,41 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
}
if(ma->texco) {
- VECCOPY(R.lo, orco);
- VECCOPY(R.vn, nor);
+ VECCOPY(shi.lo, orco);
+ VECCOPY(shi.vn, nor);
if(ma->texco & TEXCO_GLOB) {
- VECCOPY(R.gl, R.lo);
+ VECCOPY(shi.gl, shi.lo);
}
if(ma->texco & TEXCO_WINDOW) {
- VECCOPY(R.winco, R.lo);
+ VECCOPY(shi.winco, shi.lo);
}
if(ma->texco & TEXCO_STICKY) {
- VECCOPY(R.sticky, R.lo);
+ VECCOPY(shi.sticky, shi.lo);
}
if(ma->texco & TEXCO_UV) {
- VECCOPY(R.uv, R.lo);
+ VECCOPY(shi.uv, shi.lo);
}
if(ma->texco & TEXCO_OBJECT) {
- VECCOPY(R.co, R.lo);
+ VECCOPY(shi.co, shi.lo);
}
if(ma->texco & TEXCO_NORM) {
- VECCOPY(R.orn, R.vn);
+ VECCOPY(shi.orn, shi.vn);
}
if(ma->texco & TEXCO_REFL) {
- inp= 2.0*(R.vn[2]);
- R.ref[0]= (inp*R.vn[0]);
- R.ref[1]= (inp*R.vn[1]);
- R.ref[2]= (-1.0+inp*R.vn[2]);
+ inp= 2.0*(shi.vn[2]);
+ shi.ref[0]= (inp*shi.vn[0]);
+ shi.ref[1]= (inp*shi.vn[1]);
+ shi.ref[2]= (-1.0+inp*shi.vn[2]);
}
if(ma->mode & MA_VERTEXCOLP) {
- R.mat->r= ma->r;
- R.mat->g= ma->g;
- R.mat->b= ma->b;
+ shi.mat->r= ma->r;
+ shi.mat->g= ma->g;
+ shi.mat->b= ma->b;
}
- do_material_tex();
+ do_material_tex(&shi);
}
if(ma->mode & MA_SHLESS) {
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index 7dbc7f05f8f..18f3ebd7197 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -59,12 +59,13 @@
#include "BKE_key.h"
#include "BKE_ipo.h"
#include "BKE_screen.h"
-#include "BKE_texture.h"
#include "BKE_blender.h"
#include "BKE_object.h"
#include "BKE_displist.h"
#include "BKE_lattice.h"
+#include "render.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c
index fb4735bbb9d..e1ff554494d 100644
--- a/source/blender/blenkernel/intern/exotic.c
+++ b/source/blender/blenkernel/intern/exotic.c
@@ -683,7 +683,8 @@ static void read_videoscape_nurbs(char *str)
static void read_videoscape(char *str)
{
int file, type;
- unsigned int val, numlen;
+ unsigned int val;
+ unsigned short numlen;
char name[FILE_MAXDIR+FILE_MAXFILE], head[FILE_MAXFILE], tail[FILE_MAXFILE];
strcpy(name, str);
@@ -2234,7 +2235,7 @@ void write_videoscape(char *str)
{
Base *base;
int file, val, lampdone=0;
- unsigned int numlen;
+ unsigned short numlen;
char head[FILE_MAXFILE], tail[FILE_MAXFILE];
if(BLI_testextensie(str,".trace")) str[ strlen(str)-6]= 0;
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index d693148fe94..51d22b2802d 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -514,7 +514,7 @@ void free_main(Main *mainvar)
ListBase *lb= lbarray[a];
ID *id;
- while (id= lb->first) {
+ while ( (id= lb->first) ) {
free_libblock(lb, id);
}
}
@@ -810,7 +810,7 @@ int new_id(ListBase *lb, ID *id, char *tname)
return (new_id(lb, id, left));
}
/* this format specifier is from hell... */
- sprintf(id->name+2, "%s.%0.3d", left, nr);
+ sprintf(id->name+2, "%s.%.3d", left, nr);
}
sort_alpha_id(lb, id);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index cabaf088147..eeba4b91e01 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -356,9 +356,6 @@ void *add_camera()
cam->clipsta= 0.1f;
cam->clipend= 100.0f;
cam->drawsize= 0.5f;
- cam->netsta= 0.5f;
- cam->netend= 10.0f;
- cam->hold= 50;
return cam;
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 38c23e3d09c..4ca2187e576 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -33,6 +33,7 @@
*/
#include <stdio.h>
+#include <string.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c
index 32856145727..5875356bae9 100644
--- a/source/blender/blenkernel/intern/texture.c
+++ b/source/blender/blenkernel/intern/texture.c
@@ -588,1790 +588,5 @@ void autotexname(Tex *tex)
/* ------------------------------------------------------------------------- */
-void init_render_texture(Tex *tex)
-{
- Image *ima;
- int imanr;
- unsigned short numlen;
- char name[256], head[FILE_MAXFILE], tail[FILE_MAXFILE];
-
- /* is also used as signal */
- tex->nor= 0;
-
- /* imap test */
- if(tex->frames && tex->ima && tex->ima->name) { /* frames */
- strcpy(name, tex->ima->name);
-
- imanr= calcimanr(G.scene->r.cfra, tex);
-
- if(tex->imaflag & TEX_ANIM5) {
- if(tex->ima->lastframe != imanr) {
- if(tex->ima->ibuf) IMB_freeImBuf(tex->ima->ibuf);
- tex->ima->ibuf= 0;
- tex->ima->lastframe= imanr;
- }
- }
- else {
- /* for patch field-ima rendering */
- tex->ima->lastframe= imanr;
-
- BLI_stringdec(name, head, tail, &numlen);
- BLI_stringenc(name, head, tail, numlen, imanr);
-
- ima= add_image(name);
-
- if(ima) {
- ima->flag |= IMA_FROMANIM;
-
- if(tex->ima) tex->ima->id.us--;
- tex->ima= ima;
-
- ima->ok= 1;
- }
- }
- }
- if(tex->imaflag & (TEX_ANTIALI+TEX_ANTISCALE)) {
- if(tex->ima && tex->ima->lastquality<R.osa) {
- if(tex->ima->ibuf) IMB_freeImBuf(tex->ima->ibuf);
- tex->ima->ibuf= 0;
- }
- }
-
- if(tex->type==TEX_PLUGIN) {
- if(tex->plugin && tex->plugin->doit) {
- if(tex->plugin->cfra) {
- *(tex->plugin->cfra)= frame_to_float(G.scene->r.cfra);
- }
- }
- }
- else if(tex->type==TEX_ENVMAP) {
- /* just in case */
- tex->imaflag= TEX_INTERPOL | TEX_MIPMAP;
- tex->extend= TEX_CLIP;
-
- if(tex->env) {
- if(R.flag & R_RENDERING) {
- if(tex->env->stype==ENV_ANIM) RE_free_envmapdata(tex->env);
- }
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void init_render_textures()
-{
- Tex *tex;
-
- tex= G.main->tex.first;
- while(tex) {
- if(tex->id.us) init_render_texture(tex);
- tex= tex->id.next;
- }
-
- free_unused_animimages();
-}
-
-/* ------------------------------------------------------------------------- */
-
-void end_render_texture(Tex *tex)
-{
-
-
-}
-
-/* ------------------------------------------------------------------------- */
-
-void end_render_textures()
-{
- Tex *tex;
-
- tex= G.main->tex.first;
- while(tex) {
- if(tex->id.us) end_render_texture(tex);
- tex= tex->id.next;
- }
-
-}
-
-
-/* ************************** */
-
-int clouds(Tex *tex, float *texvec)
-{
- float (*turbfunc)(float, float, float, float, int);
-
- if(tex->noisetype==TEX_NOISESOFT) turbfunc= BLI_turbulence;
- else turbfunc= BLI_turbulence1;
-
- Tin= turbfunc(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth);
-
- if(tex->stype==1) {
-
- Tr= Tin;
- Tg= turbfunc(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth);
-
- Tb= turbfunc(tex->noisesize,texvec[1],texvec[2],texvec[0], tex->noisedepth);
-
- BRICONRGB;
- Ta= 1.0;
-
- return 1;
- }
-
- BRICON;
-
- if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int blend(Tex *tex, float *texvec)
-{
- float x, y, t;
-
- if(tex->flag & TEX_FLIPBLEND) {
- x= texvec[1];
- y= texvec[0];
- }
- else {
- x= texvec[0];
- y= texvec[1];
- }
-
- if(tex->stype==0) { /* lin */
- Tin= (1.0+x)/2.0;
- }
- else if(tex->stype==1) { /* quad */
- Tin= (1.0+x)/2.0;
- if(Tin<0.0) Tin= 0.0;
- else Tin*= Tin;
- }
- else if(tex->stype==2) { /* ease */
- Tin= (1.0+x)/2.0;
- if(Tin<=.0) Tin= 0.0;
- else if(Tin>=1.0) Tin= 1.0;
- else {
- t= Tin*Tin;
- Tin= (3.0*t-2.0*t*Tin);
- }
- }
- else if(tex->stype==3) { /* diag */
- Tin= (2.0+x+y)/4.0;
- }
- else { /* sphere */
- Tin= 1.0-sqrt(x*x+ y*y+texvec[2]*texvec[2]);
- if(Tin<0.0) Tin= 0.0;
- if(tex->stype==5) Tin*= Tin; /* halo */
- }
-
- BRICON;
- if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int wood(Tex *tex, float *texvec)
-{
- float (*noisefunc)(float, float, float, float);
-
- if(tex->noisetype==TEX_NOISESOFT) noisefunc= BLI_hnoise;
- else noisefunc= BLI_hnoisep;
-
-
- if(tex->stype==0) {
- Tin= 0.5+0.5*sin( (texvec[0]+texvec[1]+texvec[2])*10.0 );
- }
- else if(tex->stype==1) {
- Tin= 0.5+0.5*sin( sqrt(texvec[0]*texvec[0]+texvec[1]*texvec[1]+texvec[2]*texvec[2])*20.0 );
- }
- else if(tex->stype==2) {
- Tin= noisefunc(tex->noisesize, texvec[0], texvec[1], texvec[2]);
- Tin= 0.5+ 0.5*sin(tex->turbul*Tin+(texvec[0]+texvec[1]+texvec[2])*10.0);
- }
- else if(tex->stype==3) {
- Tin= noisefunc(tex->noisesize, texvec[0], texvec[1], texvec[2]);
- Tin= 0.5+ 0.5*sin(tex->turbul*Tin+(sqrt(texvec[0]*texvec[0]+texvec[1]*texvec[1]+texvec[2]*texvec[2]))*20.0);
- }
-
-
- BRICON;
- if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int marble(Tex *tex, float *texvec)
-{
- float n;
- float (*turbfunc)(float, float, float, float, int);
-
- if(tex->noisetype==TEX_NOISESOFT) turbfunc= BLI_turbulence;
- else turbfunc= BLI_turbulence1;
-
- n= 5.0*(texvec[0]+texvec[1]+texvec[2]);
-
- Tin = 0.5+0.5*sin(n+tex->turbul*turbfunc(tex->noisesize, texvec[0],texvec[1],texvec[2], tex->noisedepth));
-
- switch (tex->stype) {
- case 1:
- Tin= sqrt(Tin);
- break;
- case 2:
- Tin= sqrt(Tin);
- Tin= sqrt(Tin);
- break;
- }
-
- BRICON;
- if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int magic(Tex *tex, float *texvec)
-{
- float x, y, z, turb=1.0;
- int n;
-
- n= tex->noisedepth;
- turb= tex->turbul/5.0;
-
- x= sin( ( texvec[0]+texvec[1]+texvec[2])*5.0 );
- y= cos( (-texvec[0]+texvec[1]-texvec[2])*5.0 );
- z= -cos( (-texvec[0]-texvec[1]+texvec[2])*5.0 );
- if(n>0) {
- x*= turb;
- y*= turb;
- z*= turb;
- y= -cos(x-y+z);
- y*= turb;
- if(n>1) {
- x= cos(x-y-z);
- x*= turb;
- if(n>2) {
- z= sin(-x-y-z);
- z*= turb;
- if(n>3) {
- x= -cos(-x+y-z);
- x*= turb;
- if(n>4) {
- y= -sin(-x+y+z);
- y*= turb;
- if(n>5) {
- y= -cos(-x+y+z);
- y*= turb;
- if(n>6) {
- x= cos(x+y+z);
- x*= turb;
- if(n>7) {
- z= sin(x+y-z);
- z*= turb;
- if(n>8) {
- x= -cos(-x-y+z);
- x*= turb;
- if(n>9) {
- y= -sin(x-y+z);
- y*= turb;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-
- if(turb!=0.0) {
- turb*= 2.0;
- x/= turb;
- y/= turb;
- z/= turb;
- }
- Tr= 0.5-x;
- Tg= 0.5-y;
- Tb= 0.5-z;
-
- BRICONRGB;
- Ta= 1.0;
-
- return 1;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int stucci(Tex *tex, float *texvec)
-{
- float b2, vec[3];
- float ofs;
- float (*noisefunc)(float, float, float, float);
-
- if(tex->nor == NULL) return 0;
-
- if(tex->noisetype==TEX_NOISESOFT) noisefunc= BLI_hnoise;
- else noisefunc= BLI_hnoisep;
-
- ofs= tex->turbul/200.0;
-
- b2= noisefunc(tex->noisesize, texvec[0], texvec[1], texvec[2]);
- if(tex->stype) ofs*=(b2*b2);
- vec[0]= b2-noisefunc(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2]);
- vec[1]= b2-noisefunc(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2]);
- vec[2]= b2-noisefunc(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs);
-
- if(tex->stype==1) {
- tex->nor[0]= vec[0];
- tex->nor[1]= vec[1];
- tex->nor[2]= vec[2];
- }
- else {
- tex->nor[0]= -vec[0];
- tex->nor[1]= -vec[1];
- tex->nor[2]= -vec[2];
- }
-
- return 2;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int texnoise(Tex *tex)
-{
- float div=3.0;
- int val, ran, loop;
-
- ran= BLI_rand();
- val= (ran & 3);
-
- loop= tex->noisedepth;
- while(loop--) {
- ran= (ran>>2);
- val*= (ran & 3);
- div*= 3.0;
- }
-
- Tin= ((float)val)/div;;
-
- BRICON;
- if(tex->flag & TEX_COLORBAND) return do_colorband(tex->coba);
-
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt)
-{
- PluginTex *pit;
- int rgbnor=0;
-
- Tin= 0.0;
-
- pit= tex->plugin;
- if(pit && pit->doit) {
- VECCOPY(pit->result+5, R.vn);
-
- if(R.osatex) rgbnor= ((TexDoit)pit->doit)(tex->stype, pit->data, texvec, dxt, dyt);
- else rgbnor= ((TexDoit)pit->doit)(tex->stype, pit->data, texvec, 0, 0);
-
- Tin= pit->result[0];
-
- if(rgbnor & TEX_NOR) {
- if(tex->nor) {
- VECCOPY(tex->nor, pit->result+5);
- }
- }
-
- if(rgbnor & TEX_RGB) {
- Tr= pit->result[1];
- Tg= pit->result[2];
- Tb= pit->result[3];
- Ta= pit->result[4];
-
- BRICONRGB;
- }
-
- BRICON;
- if(tex->flag & TEX_COLORBAND) rgbnor |= do_colorband(tex->coba);
- }
-
- return rgbnor;
-}
-
-/* *************** PROJECTIONS ******************* */
-
-void tubemap(float x, float y, float z, float *adr1, float *adr2)
-{
- float len;
-
- *adr2 = (z + 1.0) / 2.0;
-
- len= sqrt(x*x+y*y);
- if(len>0) {
- *adr1 = (1.0 - (atan2(x/len,y/len) / M_PI)) / 2.0;
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void spheremap(float x, float y, float z, float *adr1, float *adr2)
-{
- float len;
-
- len= sqrt(x*x+y*y+z*z);
- if(len>0.0) {
-
- if(x==0.0 && y==0.0) *adr1= 0.0; /* othwise domain error */
- else *adr1 = (1.0 - atan2(x,y)/M_PI )/2.0;
-
- z/=len;
- *adr2 = 1.0- saacos(z)/M_PI;
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int cubemap_glob(MTex *mtex, float x, float y, float z, float *adr1, float *adr2)
-{
- float x1, y1, z1, nor[3];
- int ret;
-
- VECCOPY(nor, R.vn);
- MTC_Mat4Mul3Vecfl(R.viewinv, nor);
-
- x1= fabs(nor[0]);
- y1= fabs(nor[1]);
- z1= fabs(nor[2]);
-
- if(z1>=x1 && z1>=y1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (y + 1.0) / 2.0;
- ret= 0;
- }
- else if(y1>=x1 && y1>=z1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
- ret= 1;
- }
- else {
- *adr1 = (y + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
- ret= 2;
- }
- return ret;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int cubemap(MTex *mtex, float x, float y, float z, float *adr1, float *adr2)
-{
- int proj[4], ret= 0;
-
- if(R.vlr && R.vlr->mface) {
- int index;
- /* the mtex->proj{xyz} have type char. maybe this should be wider? */
- /* casting to int ensures that the index type is right. */
- index = (int) mtex->projx;
- proj[index]= ME_PROJXY;
-
- index = (int) mtex->projy;
- proj[index]= ME_PROJXZ;
-
- index = (int) mtex->projz;
- proj[index]= ME_PROJYZ;
-
- if(R.vlr->mface->puno & proj[1]) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (y + 1.0) / 2.0;
- }
- else if(R.vlr->mface->puno & proj[2]) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
- ret= 1;
- }
- else {
- *adr1 = (y + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
- ret= 2;
- }
- } else
- return cubemap_glob(mtex, x, y, z, adr1, adr2);
-
- return ret;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static int cubemap_ob(MTex *mtex, float x, float y, float z, float *adr1, float *adr2)
-{
- float x1, y1, z1, nor[3];
- int ret;
-
- VECCOPY(nor, R.vn);
- if(mtex->object) MTC_Mat4Mul3Vecfl(mtex->object->imat, nor);
-
- x1= fabs(nor[0]);
- y1= fabs(nor[1]);
- z1= fabs(nor[2]);
-
- if(z1>=x1 && z1>=y1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (y + 1.0) / 2.0;
- ret= 0;
- }
- else if(y1>=x1 && y1>=z1) {
- *adr1 = (x + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
- ret= 1;
- }
- else {
- *adr1 = (y + 1.0) / 2.0;
- *adr2 = (z + 1.0) / 2.0;
- ret= 2;
- }
- return ret;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void do_2d_mapping(MTex *mtex, float *t, float *dxt, float *dyt)
-{
- Tex *tex;
- float fx, fy, fac1, area[8];
- int ok, proj, areaflag= 0, wrap;
-
- wrap= mtex->mapping;
- tex= mtex->tex;
-
- if(R.osa==0) {
-
- if(wrap==MTEX_FLAT) {
- fx = (t[0] + 1.0) / 2.0;
- fy = (t[1] + 1.0) / 2.0;
- }
- else if(wrap==MTEX_TUBE) tubemap(t[0], t[1], t[2], &fx, &fy);
- else if(wrap==MTEX_SPHERE) spheremap(t[0], t[1], t[2], &fx, &fy);
- else {
- if(mtex->texco==TEXCO_OBJECT) cubemap_ob(mtex, t[0], t[1], t[2], &fx, &fy);
- else if(mtex->texco==TEXCO_GLOB) cubemap_glob(mtex, t[0], t[1], t[2], &fx, &fy);
- else cubemap(mtex, t[0], t[1], t[2], &fx, &fy);
- }
-
- /* repeat */
- if(tex->xrepeat>1) {
- fx *= tex->xrepeat;
- if(fx>1.0) fx -= (int)(fx);
- else if(fx<0.0) fx+= 1-(int)(fx);
- }
- if(tex->yrepeat>1) {
- fy *= tex->yrepeat;
- if(fy>1.0) fy -= (int)(fy);
- else if(fy<0.0) fy+= 1-(int)(fy);
- }
-
- /* crop */
- if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) {
- fac1= tex->cropxmax - tex->cropxmin;
- fx= tex->cropxmin+ fx*fac1;
- }
- if(tex->cropymin!=0.0 || tex->cropymax!=1.0) {
- fac1= tex->cropymax - tex->cropymin;
- fy= tex->cropymin+ fy*fac1;
- }
-
- t[0]= fx;
- t[1]= fy;
- }
- else {
-
- if(wrap==MTEX_FLAT) {
- fx= (t[0] + 1.0) / 2.0;
- fy= (t[1] + 1.0) / 2.0;
- dxt[0]/= 2.0;
- dxt[1]/= 2.0;
- dyt[0]/= 2.0;
- dyt[1]/= 2.0;
- }
- else if ELEM(wrap, MTEX_TUBE, MTEX_SPHERE) {
- /* exception: the seam behind (y<0.0) */
- ok= 1;
- if(t[1]<=0.0) {
- fx= t[0]+dxt[0];
- fy= t[0]+dyt[0];
- if(fx>=0.0 && fy>=0.0 && t[0]>=0.0);
- else if(fx<=0.0 && fy<=0.0 && t[0]<=0.0);
- else ok= 0;
- }
- if(ok) {
- if(wrap==MTEX_TUBE) {
- tubemap(t[0], t[1], t[2], area, area+1);
- tubemap(t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2], area+2, area+3);
- tubemap(t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2], area+4, area+5);
- }
- else {
- spheremap(t[0], t[1], t[2],area,area+1);
- spheremap(t[0]+dxt[0], t[1]+dxt[1], t[2]+dxt[2], area+2, area+3);
- spheremap(t[0]+dyt[0], t[1]+dyt[1], t[2]+dyt[2], area+4, area+5);
- }
- areaflag= 1;
- }
- else {
- if(wrap==MTEX_TUBE) tubemap(t[0], t[1], t[2], &fx, &fy);
- else spheremap(t[0], t[1], t[2], &fx, &fy);
- dxt[0]/= 2.0;
- dxt[1]/= 2.0;
- dyt[0]/= 2.0;
- dyt[1]/= 2.0;
- }
- }
- else {
-
- if(mtex->texco==TEXCO_OBJECT) proj = cubemap_ob(mtex, t[0], t[1], t[2], &fx, &fy);
- else if (mtex->texco==TEXCO_GLOB) proj = cubemap_glob(mtex, t[0], t[1], t[2], &fx, &fy);
- else proj = cubemap(mtex, t[0], t[1], t[2], &fx, &fy);
-
- if(proj==1) {
- dxt[1]= dxt[2];
- dyt[1]= dyt[2];
- }
- else if(proj==2) {
- dxt[0]= dxt[1];
- dyt[0]= dyt[1];
- dxt[1]= dxt[2];
- dyt[1]= dyt[2];
- }
- dxt[0]/= 2.0;
- dxt[1]/= 2.0;
- dyt[0]/= 2.0;
- dyt[1]/= 2.0;
- }
-
- /* if area, then reacalculate dxt[] and dyt[] */
- if(areaflag) {
- fx= area[0];
- fy= area[1];
- dxt[0]= area[2]-fx;
- dxt[1]= area[3]-fy;
- dyt[0]= area[4]-fx;
- dyt[1]= area[5]-fy;
- }
-
- /* repeat */
- if(tex->xrepeat>1) {
- fx *= tex->xrepeat;
- dxt[0]*= tex->xrepeat;
- dyt[0]*= tex->xrepeat;
- if(fx>1.0) fx -= (int)(fx);
- else if(fx<0.0) fx+= 1-(int)(fx);
- }
- if(tex->yrepeat>1) {
- fy *= tex->yrepeat;
- dxt[1]*= tex->yrepeat;
- dyt[1]*= tex->yrepeat;
- if(fy>1.0) fy -= (int)(fy);
- else if(fy<0.0) fy+= 1-(int)(fy);
- }
-
- /* crop */
- if(tex->cropxmin!=0.0 || tex->cropxmax!=1.0) {
- fac1= tex->cropxmax - tex->cropxmin;
- fx= tex->cropxmin+ fx*fac1;
- dxt[0]*= fac1;
- dyt[0]*= fac1;
- }
- if(tex->cropymin!=0.0 || tex->cropymax!=1.0) {
- fac1= tex->cropymax - tex->cropymin;
- fy= tex->cropymin+ fy*fac1;
- dxt[1]*= fac1;
- dyt[1]*= fac1;
- }
-
- t[0]= fx;
- t[1]= fy;
-
- }
-}
-
-
-/* ************************************** */
-
-int multitex(Tex *tex, float *texvec, float *dxt, float *dyt)
-{
-
-
- switch(tex->type) {
-
- case 0:
- Tin= 0.0;
- return 0;
- case TEX_CLOUDS:
- return clouds(tex, texvec);
- case TEX_WOOD:
- return wood(tex, texvec);
- case TEX_MARBLE:
- return marble(tex, texvec);
- case TEX_MAGIC:
- return magic(tex, texvec);
- case TEX_BLEND:
- return blend(tex, texvec);
- case TEX_STUCCI:
- Tin= 0.0;
- return stucci(tex, texvec);
- case TEX_NOISE:
- return texnoise(tex);
- case TEX_IMAGE:
- if(R.osatex) return imagewraposa(tex, texvec, dxt, dyt);
- else return imagewrap(tex, texvec);
- break;
- case TEX_PLUGIN:
- return plugintex(tex, texvec, dxt, dyt);
- break;
- case TEX_ENVMAP:
- return RE_envmaptex(tex, texvec, dxt, dyt);
- break;
- }
- return 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void do_material_tex()
-{
- Object *ob;
- Material *mat_col, *mat_colspec, *mat_colmir, *mat_ref;
- Material *mat_spec, *mat_har, *mat_emit, *mat_alpha, *mat_ray_mirr, *mat_translu;
- MTex *mtex;
- Tex *tex;
- float *co = NULL, *dx = NULL, *dy = NULL, fact,
- facm, factt, facmm, facmul = 0.0, stencilTin=1.0;
- float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], Tnor=1.0;
- int tex_nr, rgbnor= 0;
-
- /* here: test flag if there's a tex (todo) */
-
- mat_col=mat_colspec=mat_colmir=mat_ref=mat_spec=mat_har=mat_emit=mat_alpha=mat_ray_mirr=mat_translu= R.mat;
-
- for(tex_nr=0; tex_nr<8; tex_nr++) {
-
- /* separate tex switching */
- if(R.mat->septex & (1<<tex_nr)) continue;
-
- if(R.mat->mtex[tex_nr]) {
- mtex= R.mat->mtex[tex_nr];
-
- tex= mtex->tex;
- if(tex==0) continue;
-
- /* which coords */
- if(mtex->texco==TEXCO_ORCO) {
- co= R.lo; dx= O.dxlo; dy= O.dylo;
- }
- else if(mtex->texco==TEXCO_STICKY) {
- co= R.sticky; dx= O.dxsticky; dy= O.dysticky;
- }
- else if(mtex->texco==TEXCO_OBJECT) {
- ob= mtex->object;
- if(ob) {
- co= tempvec;
- dx= dxt;
- dy= dyt;
- VECCOPY(tempvec, R.co);
- MTC_Mat4MulVecfl(ob->imat, tempvec);
- if(R.osatex) {
- VECCOPY(dxt, O.dxco);
- VECCOPY(dyt, O.dyco);
- MTC_Mat4Mul3Vecfl(ob->imat, dxt);
- MTC_Mat4Mul3Vecfl(ob->imat, dyt);
- }
- }
- else {
- /* if object doesn't exist, do not use orcos (not initialized) */
- co= R.co;
- dx= O.dxco; dy= O.dyco;
- }
- }
- else if(mtex->texco==TEXCO_REFL) {
- co= R.ref; dx= O.dxref; dy= O.dyref;
- }
- else if(mtex->texco==TEXCO_NORM) {
- co= R.orn; dx= O.dxno; dy= O.dyno;
- }
- else if(mtex->texco==TEXCO_GLOB) {
- co= R.gl; dx= O.dxco; dy= O.dyco;
- }
- else if(mtex->texco==TEXCO_UV) {
- co= R.uv; dx= O.dxuv; dy= O.dyuv;
- }
- else if(mtex->texco==TEXCO_WINDOW) {
- co= R.winco; dx= O.dxwin; dy= O.dywin;
- }
-
- /* de pointer defines if bumping happens */
- if(mtex->mapto & MAP_NORM) {
- tex->nor= norvec;
- norvec[0]= norvec[1]= norvec[2]= 0.0;
- }
- else tex->nor= 0;
-
- if(tex->type==TEX_IMAGE) {
-
- /* new: first swap coords, then map, then trans/scale */
-
- /* placement */
- if(mtex->projx) texvec[0]= co[mtex->projx-1];
- else texvec[0]= 0.0;
- if(mtex->projy) texvec[1]= co[mtex->projy-1];
- else texvec[1]= 0.0;
- if(mtex->projz) texvec[2]= co[mtex->projz-1];
- else texvec[2]= 0.0;
-
- if(R.osatex) {
-
- if(mtex->projx) {
- dxt[0]= dx[mtex->projx-1];
- dyt[0]= dy[mtex->projx-1];
- }
- else dxt[0]= 0.0;
- if(mtex->projy) {
- dxt[1]= dx[mtex->projy-1];
- dyt[1]= dy[mtex->projy-1];
- }
- else dxt[1]= 0.0;
- if(mtex->projx) {
- dxt[2]= dx[mtex->projz-1];
- dyt[2]= dy[mtex->projz-1];
- }
- else dxt[2]= 0.0;
- }
-
- do_2d_mapping(mtex, texvec, dxt, dyt);
-
- /* translate and scale */
- texvec[0]= mtex->size[0]*(texvec[0]-0.5) +mtex->ofs[0]+0.5;
- texvec[1]= mtex->size[1]*(texvec[1]-0.5) +mtex->ofs[1]+0.5;
- if(R.osatex) {
- dxt[0]= mtex->size[0]*dxt[0];
- dxt[1]= mtex->size[1]*dxt[1];
- dyt[0]= mtex->size[0]*dyt[0];
- dyt[1]= mtex->size[1]*dyt[1];
- }
- }
- else {
-
- /* placement */
- if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- if(R.osatex) {
- if(mtex->projx) {
- dxt[0]= mtex->size[0]*dx[mtex->projx-1];
- dyt[0]= mtex->size[0]*dy[mtex->projx-1];
- }
- else dxt[0]= 0.0;
- if(mtex->projy) {
- dxt[1]= mtex->size[1]*dx[mtex->projy-1];
- dyt[1]= mtex->size[1]*dy[mtex->projy-1];
- }
- else dxt[1]= 0.0;
- if(mtex->projx) {
- dxt[2]= mtex->size[2]*dx[mtex->projz-1];
- dyt[2]= mtex->size[2]*dy[mtex->projz-1];
- }
- else dxt[2]= 0.0;
- }
- }
-
- rgbnor= multitex(tex, texvec, dxt, dyt);
-
- /* texture output */
-
- if( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) {
- Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- rgbnor-= 1;
- }
- if(mtex->texflag & MTEX_NEGATIVE) {
- if(rgbnor & TEX_RGB) {
- Tr= 1.0-Tr;
- Tg= 1.0-Tg;
- Tb= 1.0-Tb;
- }
- Tin= 1.0-Tin;
- }
- if(mtex->texflag & MTEX_STENCIL) {
- if(rgbnor & TEX_RGB) {
- fact= Ta;
- Ta*= stencilTin;
- stencilTin*= fact;
- }
- else {
- fact= Tin;
- Tin*= stencilTin;
- stencilTin*= fact;
- }
- }
- else {
- Ta*= stencilTin;
- Tnor*= stencilTin;
- Tin*= stencilTin;
- }
-
- if(tex->nor && (rgbnor & TEX_NOR)==0) {
- /* make our own normal */
- if(rgbnor & TEX_RGB) {
- tex->nor[0]= Tr;
- tex->nor[1]= Tg;
- tex->nor[2]= Tb;
- }
- else {
- float co= 0.5*cos(Tin-0.5);
- float si= 0.5*sin(Tin-0.5);
- float f1, f2;
-
- f1= R.vn[0];
- f2= R.vn[1];
- tex->nor[0]= f1*co+f2*si;
- tex->nor[1]= f2*co-f1*si;
- f1= R.vn[1];
- f2= R.vn[2];
- tex->nor[1]= f1*co+f2*si;
- tex->nor[2]= f2*co-f1*si;
- }
- }
-
-
- /* mapping */
- if(mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) {
-
- if((rgbnor & TEX_RGB)==0) {
- Tr= mtex->r;
- Tg= mtex->g;
- Tb= mtex->b;
- }
- else if(mtex->mapto & MAP_ALPHA) {
- if(mtex->texflag & MTEX_ALPHAMIX) Tin= Ta;
- else Tin= stencilTin;
- }
- else Tin= Ta;
-
- fact= Tin*mtex->colfac;
- facm= 1.0-fact;
- if(mtex->blendtype==MTEX_MUL) facm= 1.0-mtex->colfac;
- if(mtex->blendtype==MTEX_SUB) fact= -fact;
-
- if(mtex->mapto & MAP_COL) {
- if(mtex->blendtype==MTEX_BLEND) {
- R.matren->r= (fact*Tr + facm*mat_col->r);
- R.matren->g= (fact*Tg + facm*mat_col->g);
- R.matren->b= (fact*Tb + facm*mat_col->b);
- }
- else if(mtex->blendtype==MTEX_MUL) {
- R.matren->r= (facm+fact*Tr)*mat_col->r;
- R.matren->g= (facm+fact*Tg)*mat_col->g;
- R.matren->b= (facm+fact*Tb)*mat_col->b;
- }
- else {
- R.matren->r= (fact*Tr + mat_col->r);
- R.matren->g= (fact*Tg + mat_col->g);
- R.matren->b= (fact*Tb + mat_col->b);
- }
- mat_col= R.matren;
- }
- if(mtex->mapto & MAP_COLSPEC) {
- if(mtex->blendtype==MTEX_BLEND) {
- R.matren->specr= (fact*Tr + facm*mat_colspec->specr);
- R.matren->specg= (fact*Tg + facm*mat_colspec->specg);
- R.matren->specb= (fact*Tb + facm*mat_colspec->specb);
- }
- else if(mtex->blendtype==MTEX_MUL) {
- R.matren->specr= (facm+fact*Tr)*mat_colspec->specr;
- R.matren->specg= (facm+fact*Tg)*mat_colspec->specg;
- R.matren->specb= (facm+fact*Tb)*mat_colspec->specb;
- }
- else {
- R.matren->specr= (fact*Tr + mat_colspec->specr);
- R.matren->specg= (fact*Tg + mat_colspec->specg);
- R.matren->specb= (fact*Tb + mat_colspec->specb);
- }
- mat_colspec= R.matren;
- }
- if(mtex->mapto & MAP_COLMIR) {
- if(mtex->blendtype==MTEX_BLEND) {
- // exception for envmap only
- if(tex->type==TEX_ENVMAP) {
- R.refcol[0]= fact + facm*R.refcol[0];
- R.refcol[1]= fact*Tr + facm*R.refcol[1];
- R.refcol[2]= fact*Tg + facm*R.refcol[2];
- R.refcol[3]= fact*Tb + facm*R.refcol[3];
- } else {
- R.matren->mirr= fact*Tr + facm*mat_colmir->mirr;
- R.matren->mirg= fact*Tg + facm*mat_colmir->mirg;
- R.matren->mirb= fact*Tb + facm*mat_colmir->mirb;
- }
- }
- else if(mtex->blendtype==MTEX_MUL) {
- R.matren->mirr= (facm+fact*Tr)*mat_colmir->mirr;
- R.matren->mirg= (facm+fact*Tg)*mat_colmir->mirg;
- R.matren->mirb= (facm+fact*Tb)*mat_colmir->mirb;
- }
- else {
- R.matren->mirr= (fact*Tr + mat_colmir->mirr);
- R.matren->mirg= (fact*Tg + mat_colmir->mirg);
- R.matren->mirb= (fact*Tb + mat_colmir->mirb);
- }
- mat_colmir= R.matren;
- }
- }
- if( (mtex->mapto & MAP_NORM) ) {
- if(tex->nor) {
-
- if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac;
- else tex->norfac= mtex->norfac;
-
- R.vn[0]+= Tnor*tex->norfac*tex->nor[0];
- R.vn[1]+= Tnor*tex->norfac*tex->nor[1];
- R.vn[2]+= Tnor*tex->norfac*tex->nor[2];
-
- Normalise(R.vn);
-
- /* this makes sure the bump is passed on to the next texture */
- R.orn[0]= R.vn[0];
- R.orn[1]= -R.vn[1];
- R.orn[2]= R.vn[2];
-
- /* reflection vector */
- RE_calc_R_ref();
- }
- }
-
- if(mtex->mapto & MAP_VARS) {
- if(rgbnor & TEX_RGB) {
- if(Talpha) Tin= Ta;
- else Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- }
-
- fact= Tin*mtex->varfac;
- facm= 1.0-fact;
- if(mtex->blendtype==MTEX_MUL) facmul= 1.0-mtex->varfac;
- if(mtex->blendtype==MTEX_SUB) fact= -fact;
-
- if(mtex->mapto & MAP_REF) {
- if(mtex->maptoneg & MAP_REF) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND)
- R.matren->ref= factt*mtex->def_var+ facmm*mat_ref->ref;
- else if(mtex->blendtype==MTEX_MUL)
- R.matren->ref= (facmul+factt)*mat_ref->ref;
- else {
- R.matren->ref= factt+mat_ref->ref;
- if(R.matren->ref<0.0) R.matren->ref= 0.0;
- }
- mat_ref= R.matren;
- }
- if(mtex->mapto & MAP_SPEC) {
- if(mtex->maptoneg & MAP_SPEC) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND)
- R.matren->spec= factt*mtex->def_var+ facmm*mat_spec->spec;
- else if(mtex->blendtype==MTEX_MUL)
- R.matren->spec= (facmul+factt)*mat_spec->spec;
- else {
- R.matren->spec= factt+mat_spec->spec;
- if(R.matren->spec<0.0) R.matren->spec= 0.0;
- }
- mat_spec= R.matren;
- }
- if(mtex->mapto & MAP_EMIT) {
- if(mtex->maptoneg & MAP_EMIT) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND)
- R.matren->emit= factt*mtex->def_var+ facmm*mat_emit->emit;
- else if(mtex->blendtype==MTEX_MUL)
- R.matren->emit= (facmul+factt)*mat_emit->emit;
- else {
- R.matren->emit= factt+mat_emit->emit;
- if(R.matren->emit<0.0) R.matren->emit= 0.0;
- }
- mat_emit= R.matren;
- }
- if(mtex->mapto & MAP_ALPHA) {
- if(mtex->maptoneg & MAP_ALPHA) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND)
- R.matren->alpha= factt*mtex->def_var+ facmm*mat_alpha->alpha;
- else if(mtex->blendtype==MTEX_MUL)
- R.matren->alpha= (facmul+factt)*mat_alpha->alpha;
- else {
- R.matren->alpha= factt+mat_alpha->alpha;
- if(R.matren->alpha<0.0) R.matren->alpha= 0.0;
- else if(R.matren->alpha>1.0) R.matren->alpha= 1.0;
- }
- mat_alpha= R.matren;
- }
- if(mtex->mapto & MAP_HAR) {
- if(mtex->maptoneg & MAP_HAR) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND) {
- R.matren->har= 128.0*factt*mtex->def_var+ facmm*mat_har->har;
- } else if(mtex->blendtype==MTEX_MUL) {
- R.matren->har= (facmul+factt)*mat_har->har;
- } else {
- R.matren->har= 128.0*factt+mat_har->har;
- if(R.matren->har<1) R.matren->har= 1;
- }
- mat_har= R.matren;
- }
- if(mtex->mapto & MAP_RAYMIRR) {
- if(mtex->maptoneg & MAP_RAYMIRR) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND)
- R.matren->ray_mirror= factt*mtex->def_var+ facmm*mat_ray_mirr->ray_mirror;
- else if(mtex->blendtype==MTEX_MUL)
- R.matren->ray_mirror= (facmul+factt)*mat_ray_mirr->ray_mirror;
- else {
- R.matren->ray_mirror= factt+mat_ray_mirr->ray_mirror;
- if(R.matren->ray_mirror<0.0) R.matren->ray_mirror= 0.0;
- else if(R.matren->ray_mirror>1.0) R.matren->ray_mirror= 1.0;
- }
- mat_ray_mirr= R.matren;
- }
- if(mtex->mapto & MAP_TRANSLU) {
- if(mtex->maptoneg & MAP_TRANSLU) {factt= facm; facmm= fact;}
- else {factt= fact; facmm= facm;}
-
- if(mtex->blendtype==MTEX_BLEND)
- R.matren->translucency= factt*mtex->def_var+ facmm*mat_translu->translucency;
- else if(mtex->blendtype==MTEX_MUL)
- R.matren->translucency= (facmul+factt)*mat_translu->translucency;
- else {
- R.matren->translucency= factt+mat_translu->translucency;
- if(R.matren->translucency<0.0) R.matren->translucency= 0.0;
- else if(R.matren->translucency>1.0) R.matren->translucency= 1.0;
- }
- mat_translu= R.matren;
- }
- }
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
-{
- MTex *mtex;
- float texvec[3], dxt[3], dyt[3], fact, facm, dx;
- int rgb;
-
- mtex= har->mat->mtex[0];
- if(mtex->tex==0) return;
- /* no normal mapping */
- mtex->tex->nor= 0;
-
- texvec[0]= xn/har->rad;
- texvec[1]= yn/har->rad;
- texvec[2]= 0.0;
-
- R.osatex= (har->mat->texco & TEXCO_OSA);
-
- /* placement */
- if(mtex->projx) texvec[0]= mtex->size[0]*(texvec[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if(mtex->projy) texvec[1]= mtex->size[1]*(texvec[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if(mtex->projz) texvec[2]= mtex->size[2]*(texvec[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- if(R.osatex) {
-
- dx= 1.0/har->rad;
-
- if(mtex->projx) {
- dxt[0]= mtex->size[0]*dx;
- dyt[0]= mtex->size[0]*dx;
- }
- else dxt[0]= 0.0;
- if(mtex->projy) {
- dxt[1]= mtex->size[1]*dx;
- dyt[1]= mtex->size[1]*dx;
- }
- else dxt[1]= 0.0;
- if(mtex->projz) {
- dxt[2]= 0.0;
- dyt[2]= 0.0;
- }
- else dxt[2]= 0.0;
-
- }
-
-
- if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, dxt, dyt);
-
- rgb= multitex(mtex->tex, texvec, dxt, dyt);
-
- /* texture output */
- if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- rgb= 0;
- }
- if(mtex->texflag & MTEX_NEGATIVE) {
- if(rgb) {
- Tr= 1.0-Tr;
- Tg= 1.0-Tg;
- Tb= 1.0-Tb;
- }
- else Tin= 1.0-Tin;
- }
-
- /* mapping */
- if(mtex->mapto & MAP_COL) {
-
- if(rgb==0) {
- Tr= mtex->r;
- Tg= mtex->g;
- Tb= mtex->b;
- }
- else if(mtex->mapto & MAP_ALPHA) {
- if(mtex->texflag & MTEX_ALPHAMIX) Tin= Ta;
- else Tin= 1.0;
- }
- else Tin= Ta;
-
- fact= Tin*mtex->colfac;
- facm= 1.0-fact;
-
- if(mtex->blendtype==MTEX_MUL) {
- facm= 1.0-mtex->colfac;
- }
- else fact*= 256;
-
- if(mtex->blendtype==MTEX_SUB) fact= -fact;
-
- if(mtex->blendtype==MTEX_BLEND) {
- colf[0]= (fact*Tr + facm*har->r);
- colf[1]= (fact*Tg + facm*har->g);
- colf[2]= (fact*Tb + facm*har->b);
- }
- else if(mtex->blendtype==MTEX_MUL) {
- colf[0]= (facm+fact*Tr)*har->r;
- colf[1]= (facm+fact*Tg)*har->g;
- colf[2]= (facm+fact*Tb)*har->b;
- }
- else {
- colf[0]= (fact*Tr + har->r);
- colf[1]= (fact*Tg + har->g);
- colf[2]= (fact*Tb + har->b);
-
- CLAMP(colf[0], 0.0, 1.0);
- CLAMP(colf[1], 0.0, 1.0);
- CLAMP(colf[2], 0.0, 1.0);
- }
- }
- if(mtex->mapto & MAP_ALPHA) {
- if(rgb) {
- if(Talpha) Tin= Ta;
- else Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- }
-
- colf[3]*= Tin;
- }
-
- R.osatex= 0;
-}
-
-/* ------------------------------------------------------------------------- */
-
-void do_sky_tex()
-{
- World *wrld_hor, *wrld_zen;
- MTex *mtex;
- float *co, fact, facm, factt, facmm, facmul = 0.0, stencilTin=1.0;
- float tempvec[3], texvec[3], dxt[3], dyt[3];
- int tex_nr, rgb= 0, ok;
-
-
- /* todo: add flag to test if there's a tex */
-
- wrld_hor= wrld_zen= G.scene->world;
-
- /* The 6 here is the max amount of channels for a world */
- for(tex_nr=0; tex_nr<6; tex_nr++) {
- if(R.wrld.mtex[tex_nr]) {
- mtex= R.wrld.mtex[tex_nr];
-
- if(mtex->tex==0) continue;
- /* if(mtex->mapto==0) continue; */
-
- /* which coords */
- co= R.lo;
-
- /* Grab the mapping settings for this texture */
- if(mtex->texco==TEXCO_OBJECT) {
- Object *ob= mtex->object;
- if(ob) {
- VECCOPY(tempvec, R.lo);
- MTC_Mat4MulVecfl(ob->imat, tempvec);
- co= tempvec;
- }
- }
-
- /* placement */
- if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- /* texture */
- if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(mtex, texvec, dxt, dyt);
-
- rgb= multitex(mtex->tex, texvec, dxt, dyt);
-
- /* texture output */
- if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- rgb= 0;
- }
- if(mtex->texflag & MTEX_NEGATIVE) {
- if(rgb) {
- Tr= 1.0-Tr;
- Tg= 1.0-Tg;
- Tb= 1.0-Tb;
- }
- else Tin= 1.0-Tin;
- }
- if(mtex->texflag & MTEX_STENCIL) {
- if(rgb) {
-
- }
- else {
- fact= Tin;
- Tin*= stencilTin;
- stencilTin*= fact;
- }
- }
- else {
- if(rgb) ;
- else Tin*= stencilTin;
- }
-
- /* colour mapping */
- if(mtex->mapto & (WOMAP_HORIZ+WOMAP_ZENUP+WOMAP_ZENDOWN)) {
-
- if(rgb==0) {
- Tr= mtex->r;
- Tg= mtex->g;
- Tb= mtex->b;
- }
- else Tin= 1.0;
-
- fact= Tin*mtex->colfac;
- facm= 1.0-fact;
- if(mtex->blendtype==MTEX_MUL) facm= 1.0-mtex->colfac;
- if(mtex->blendtype==MTEX_SUB) fact= -fact;
-
- if(mtex->mapto & WOMAP_HORIZ) {
- if(mtex->blendtype==MTEX_BLEND) {
- R.wrld.horr= (fact*Tr + facm*wrld_hor->horr);
- R.wrld.horg= (fact*Tg + facm*wrld_hor->horg);
- R.wrld.horb= (fact*Tb + facm*wrld_hor->horb);
- }
- else if(mtex->blendtype==MTEX_MUL) {
- R.wrld.horr= (facm+fact*Tr)*wrld_hor->horr;
- R.wrld.horg= (facm+fact*Tg)*wrld_hor->horg;
- R.wrld.horb= (facm+fact*Tb)*wrld_hor->horb;
- }
- else {
- R.wrld.horr= (fact*Tr + wrld_hor->horr);
- R.wrld.horg= (fact*Tg + wrld_hor->horg);
- R.wrld.horb= (fact*Tb + wrld_hor->horb);
- }
- wrld_hor= &R.wrld;
- }
- if(mtex->mapto & (WOMAP_ZENUP+WOMAP_ZENDOWN)) {
- ok= 0;
- if(R.wrld.skytype & WO_SKYREAL) {
- if((R.wrld.skytype & WO_ZENUP)) {
- if(mtex->mapto & WOMAP_ZENUP) ok= 1;
- }
- else if(mtex->mapto & WOMAP_ZENDOWN) ok= 1;
- }
- else ok= 1;
-
- if(ok) {
-
- if(mtex->blendtype==MTEX_BLEND) {
- R.wrld.zenr= (fact*Tr + facm*wrld_zen->zenr);
- R.wrld.zeng= (fact*Tg + facm*wrld_zen->zeng);
- R.wrld.zenb= (fact*Tb + facm*wrld_zen->zenb);
- }
- else if(mtex->blendtype==MTEX_MUL) {
- R.wrld.zenr= (facm+fact*Tr)*wrld_zen->zenr;
- R.wrld.zeng= (facm+fact*Tg)*wrld_zen->zeng;
- R.wrld.zenb= (facm+fact*Tb)*wrld_zen->zenb;
- }
- else {
- R.wrld.zenr= (fact*Tr + wrld_zen->zenr);
- R.wrld.zeng= (fact*Tg + wrld_zen->zeng);
- R.wrld.zenb= (fact*Tb + wrld_zen->zenb);
- }
- wrld_zen= &R.wrld;
- }
- else {
- /* otherwise zenRGB undefined */
- R.wrld.zenr= wrld_zen->zenr;
- R.wrld.zeng= wrld_zen->zeng;
- R.wrld.zenb= wrld_zen->zenb;
- }
- }
- }
- if(mtex->mapto & WOMAP_BLEND) {
- if(rgb) Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
-
- fact= Tin*mtex->varfac;
- facm= 1.0-fact;
- if(mtex->blendtype==MTEX_MUL) facmul= 1.0-mtex->varfac;
- if(mtex->blendtype==MTEX_SUB) fact= -fact;
-
- factt= fact; facmm= facm;
-
- if(mtex->blendtype==MTEX_BLEND)
- R.inprz= factt*mtex->def_var+ facmm*R.inprz;
- else if(mtex->blendtype==MTEX_MUL)
- R.inprz= (facmul+factt)*R.inprz;
- else {
- R.inprz= factt+R.inprz;
- }
- }
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-/* explicit lampren stuff should be factored out! or rather, the
- texturing stuff might need to go...*/
-void do_lamp_tex(LampRen *la, float *lavec)
-{
- Object *ob;
- LampRen *la_col;
- MTex *mtex;
- Tex *tex;
- float *co = NULL, *dx = NULL, *dy = NULL, fact, facm, stencilTin=1.0;
- float texvec[3], dxt[3], dyt[3], tempvec[3];
- int tex_nr, rgb= 0;
-
- la_col= la->org;
-
- tex_nr= 0;
-
- for(; tex_nr<6; tex_nr++) {
-
- if(la->mtex[tex_nr]) {
- mtex= la->mtex[tex_nr];
-
- tex= mtex->tex;
- if(tex==0) continue;
-
- /* which coords */
- if(mtex->texco==TEXCO_OBJECT) {
- ob= mtex->object;
- if(ob) {
- co= tempvec;
- dx= dxt;
- dy= dyt;
- VECCOPY(tempvec, R.co);
- MTC_Mat4MulVecfl(ob->imat, tempvec);
- if(R.osatex) {
- VECCOPY(dxt, O.dxco);
- VECCOPY(dyt, O.dyco);
- MTC_Mat4Mul3Vecfl(ob->imat, dxt);
- MTC_Mat4Mul3Vecfl(ob->imat, dyt);
- }
- }
- else {
- co= R.co;
- dx= O.dxco; dy= O.dyco;
- }
- }
- else if(mtex->texco==TEXCO_GLOB) {
- co= R.gl; dx= O.dxco; dy= O.dyco;
- VECCOPY(R.gl, R.co);
- MTC_Mat4MulVecfl(R.viewinv, R.gl);
- }
- else if(mtex->texco==TEXCO_VIEW) {
-
- VECCOPY(tempvec, lavec);
- MTC_Mat3MulVecfl(la->imat, tempvec);
-
- tempvec[0]*= la->spottexfac;
- tempvec[1]*= la->spottexfac;
- co= tempvec;
-
- dx= dxt; dy= dyt;
- if(R.osatex) {
- VECCOPY(dxt, O.dxlv);
- VECCOPY(dyt, O.dylv);
- /* need some matrix conversion here? la->imat is a [3][3] matrix!!! **/
- MTC_Mat3MulVecfl(la->imat, dxt);
- MTC_Mat3MulVecfl(la->imat, dyt);
-
- VecMulf(dxt, la->spottexfac);
- VecMulf(dyt, la->spottexfac);
- }
- }
-
-
- /* placement */
- if(mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if(mtex->projy) texvec[1]= mtex->size[1]*(co[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if(mtex->projz) texvec[2]= mtex->size[2]*(co[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- if(R.osatex) {
- if(mtex->projx) {
- dxt[0]= mtex->size[0]*dx[mtex->projx-1];
- dyt[0]= mtex->size[0]*dy[mtex->projx-1];
- }
- else dxt[0]= 0.0;
- if(mtex->projy) {
- dxt[1]= mtex->size[1]*dx[mtex->projy-1];
- dyt[1]= mtex->size[1]*dy[mtex->projy-1];
- }
- else dxt[1]= 0.0;
- if(mtex->projx) {
- dxt[2]= mtex->size[2]*dx[mtex->projz-1];
- dyt[2]= mtex->size[2]*dy[mtex->projz-1];
- }
- else dxt[2]= 0.0;
- }
-
- /* texture */
- if(tex->type==TEX_IMAGE) {
- do_2d_mapping(mtex, texvec, dxt, dyt);
-
- if(mtex->mapto & MAP_NORM) {
- /* the pointer defines if bump happens */
- tex->nor= R.vn;
- if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac;
- else tex->norfac= mtex->norfac;
- }
- else tex->nor= 0;
- }
-
- rgb= multitex(tex, texvec, dxt, dyt);
-
-
-
- /* texture output */
- if(rgb && (mtex->texflag & MTEX_RGBTOINT)) {
- Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- rgb= 0;
- }
- if(mtex->texflag & MTEX_NEGATIVE) {
- if(rgb) {
- Tr= 1.0-Tr;
- Tg= 1.0-Tg;
- Tb= 1.0-Tb;
- }
- else Tin= 1.0-Tin;
- }
- if(mtex->texflag & MTEX_STENCIL) {
- if(rgb) {
- fact= Ta;
- Ta*= stencilTin;
- stencilTin*= fact;
- }
- else {
- fact= Tin;
- Tin*= stencilTin;
- stencilTin*= fact;
- }
- }
- else {
- if(rgb) Ta*= stencilTin;
- else Tin*= stencilTin;
- }
-
- /* mapping */
- if(mtex->mapto & LAMAP_COL) {
-
- if(rgb==0) {
- Tr= mtex->r;
- Tg= mtex->g;
- Tb= mtex->b;
- }
- else if(mtex->mapto & MAP_ALPHA) {
- if(mtex->texflag & MTEX_ALPHAMIX) Tin= Ta;
- else Tin= stencilTin;
- }
- else Tin= Ta;
-
- Tr*= la->energy;
- Tg*= la->energy;
- Tb*= la->energy;
-
- fact= Tin*mtex->colfac;
- facm= 1.0-fact;
- if(mtex->blendtype==MTEX_MUL) facm= 1.0-mtex->colfac;
- if(mtex->blendtype==MTEX_SUB) fact= -fact;
-
- if(mtex->blendtype==MTEX_BLEND) {
- la->r= (fact*Tr + facm*la_col->r);
- la->g= (fact*Tg + facm*la_col->g);
- la->b= (fact*Tb + facm*la_col->b);
- }
- else if(mtex->blendtype==MTEX_MUL) {
- la->r= (facm+fact*Tr)*la_col->r;
- la->g= (facm+fact*Tg)*la_col->g;
- la->b= (facm+fact*Tb)*la_col->b;
- }
- else {
- la->r= (fact*Tr + la_col->r);
- la->g= (fact*Tg + la_col->g);
- la->b= (fact*Tb + la_col->b);
- }
- la_col= la; /* Is it just me or is this a useless statement? */
- }
-
- }
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void externtex(MTex *mtex, float *vec)
-{
- Tex *tex;
- float dxt[3], dyt[3], texvec[3];
- int rgb;
-
- tex= mtex->tex;
- if(tex==0) return;
-
- R.osatex= 0;
- R.vlr= 0;
-
- /* placement */
- if(mtex->projx) texvec[0]= mtex->size[0]*(vec[mtex->projx-1]+mtex->ofs[0]);
- else texvec[0]= mtex->size[0]*(mtex->ofs[0]);
-
- if(mtex->projy) texvec[1]= mtex->size[1]*(vec[mtex->projy-1]+mtex->ofs[1]);
- else texvec[1]= mtex->size[1]*(mtex->ofs[1]);
-
- if(mtex->projz) texvec[2]= mtex->size[2]*(vec[mtex->projz-1]+mtex->ofs[2]);
- else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
-
- /* texture */
- if(tex->type==TEX_IMAGE) {
- do_2d_mapping(mtex, texvec, dxt, dyt);
-
- if(mtex->mapto & MAP_NORM) {
- /* the pointer defines if there's bump */
- tex->nor= R.vn;
- if(mtex->maptoneg & MAP_NORM) tex->norfac= -mtex->norfac;
- else tex->norfac= mtex->norfac;
- }
- else tex->nor= 0;
- }
-
- rgb= multitex(tex, texvec, dxt, dyt);
- if(rgb) {
- Tin= (0.35*Tr+0.45*Tg+0.2*Tb);
- }
- else {
- Tr= mtex->r;
- Tg= mtex->g;
- Tb= mtex->b;
- }
-}
-
-/* ------------------------------------------------------------------------- */
-
-void externtexcol(MTex *mtex, float *orco, char *col)
-{
- int temp;
- float b1;
-
- if(mtex->tex==0) return;
-
- externtex(mtex, orco);
-
- b1= 1.0-Tin;
-
- temp= 255*(Tin*Tr)+b1*col[0];
- if(temp>255) col[0]= 255; else col[0]= temp;
- temp= 255*(Tin*Tg)+b1*col[1];
- if(temp>255) col[1]= 255; else col[1]= temp;
- temp= 255*(Tin*Tb)+b1*col[2];
- if(temp>255) col[2]= 255; else col[2]= temp;
-
-}
-
-/* ------------------------------------------------------------------------- */
-
-void render_realtime_texture()
-{
- static Tex tex;
- static int firsttime= 1;
- float texvec[2], dx[2], dy[2];
-
- if(firsttime) {
- default_tex(&tex);
- tex.type= TEX_IMAGE;
- firsttime= 0;
- }
-
- tex.ima = R.vlr->tface->tpage;
- if(tex.ima) {
-
- texvec[0]= 0.5+0.5*R.uv[0];
- texvec[1]= 0.5+0.5*R.uv[1];
- if(R.osatex) {
- dx[0]= 0.5*O.dxuv[0];
- dx[1]= 0.5*O.dxuv[1];
- dy[0]= 0.5*O.dyuv[0];
- dy[1]= 0.5*O.dyuv[1];
- }
-
- if(R.osatex) imagewraposa(&tex, texvec, dx, dy);
- else imagewrap(&tex, texvec);
-
- R.vcol[0]*= Tr;
- R.vcol[1]*= Tg;
- R.vcol[2]*= Tb;
- }
-
-
-}
/* eof */