Merged changes in the trunk up to revision 48893.
Conflicts resolved: source/blender/blenkernel/CMakeLists.txt source/blender/blenloader/intern/readfile.c source/blender/editors/animation/anim_filter.c source/blender/makesrna/RNA_enum_types.h
This commit is contained in:
@@ -526,7 +526,7 @@ typedef struct {
|
||||
|
||||
} SRenderMeshToTangent;
|
||||
|
||||
// interface
|
||||
/* interface */
|
||||
#include "mikktspace.h"
|
||||
|
||||
static int GetNumFaces(const SMikkTSpaceContext * pContext)
|
||||
@@ -1030,7 +1030,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
static int second=0;
|
||||
|
||||
sub_v3_v3v3(nor, vec, vec1);
|
||||
normalize_v3(nor); // nor needed as tangent
|
||||
normalize_v3(nor); /* nor needed as tangent */
|
||||
cross_v3_v3v3(cross, vec, nor);
|
||||
|
||||
/* turn cross in pixelsize */
|
||||
@@ -1090,7 +1090,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
add_v3_v3(vlr->v1->co, cross);
|
||||
copy_v3_v3(vlr->v1->n, nor);
|
||||
vlr->v1->orco= sd->orco;
|
||||
vlr->v1->accum= -1.0f; // accum abuse for strand texco
|
||||
vlr->v1->accum = -1.0f; /* accum abuse for strand texco */
|
||||
|
||||
copy_v3_v3(vlr->v2->co, vec);
|
||||
sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross);
|
||||
@@ -1102,8 +1102,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
add_v3_v3(vlr->v4->co, cross);
|
||||
copy_v3_v3(vlr->v4->n, nor);
|
||||
vlr->v4->orco= sd->orco;
|
||||
vlr->v4->accum= 1.0f; // accum abuse for strand texco
|
||||
|
||||
vlr->v4->accum = 1.0f; /* accum abuse for strand texco */
|
||||
|
||||
copy_v3_v3(vlr->v3->co, vec1);
|
||||
sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
|
||||
copy_v3_v3(vlr->v3->n, nor);
|
||||
@@ -1164,7 +1164,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
add_v3_v3(v1->co, cross);
|
||||
copy_v3_v3(v1->n, nor);
|
||||
v1->orco= sd->orco;
|
||||
v1->accum= -1.0f; // accum abuse for strand texco
|
||||
v1->accum = -1.0f; /* accum abuse for strand texco */
|
||||
|
||||
copy_v3_v3(v2->co, vec);
|
||||
sub_v3_v3v3(v2->co, v2->co, cross);
|
||||
@@ -1181,11 +1181,11 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
vlr->v2= v2;
|
||||
vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
|
||||
vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
|
||||
|
||||
v1= vlr->v4; // cycle
|
||||
v2= vlr->v3; // cycle
|
||||
|
||||
|
||||
v1= vlr->v4; /* cycle */
|
||||
v2= vlr->v3; /* cycle */
|
||||
|
||||
|
||||
if (sd->adapt) {
|
||||
second=0;
|
||||
copy_v3_v3(anor, nor);
|
||||
@@ -1210,9 +1210,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
vlr->v2= v2;
|
||||
vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
|
||||
vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
|
||||
|
||||
v1= vlr->v4; // cycle
|
||||
v2= vlr->v3; // cycle
|
||||
|
||||
v1= vlr->v4; /* cycle */
|
||||
v2= vlr->v3; /* cycle */
|
||||
|
||||
copy_v3_v3(anor, nor);
|
||||
copy_v3_v3(avec, vec);
|
||||
@@ -1226,8 +1226,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
|
||||
add_v3_v3(vlr->v4->co, cross);
|
||||
copy_v3_v3(vlr->v4->n, nor);
|
||||
vlr->v4->orco= sd->orco;
|
||||
vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco
|
||||
|
||||
vlr->v4->accum= -1.0f + 2.0f * sd->time; /* accum abuse for strand texco */
|
||||
|
||||
copy_v3_v3(vlr->v3->co, vec);
|
||||
sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
|
||||
copy_v3_v3(vlr->v3->n, nor);
|
||||
@@ -1310,7 +1310,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3
|
||||
vlr->v3= vlr->v2;
|
||||
vlr->v4= NULL;
|
||||
|
||||
v1= vlr->v2; // cycle
|
||||
v1= vlr->v2; /* cycle */
|
||||
copy_v3_v3(v1->co, vec);
|
||||
|
||||
sub_v3_v3v3(vlr->n, vec, vec1);
|
||||
@@ -1631,12 +1631,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
|
||||
/* 2.1 setup material stff */
|
||||
ma= give_render_material(re, ob, part->omat);
|
||||
|
||||
#if 0 // XXX old animation system
|
||||
#if 0 /* XXX old animation system */
|
||||
if (ma->ipo) {
|
||||
calc_ipo(ma->ipo, cfra);
|
||||
execute_ipo((ID *)ma, ma->ipo);
|
||||
}
|
||||
#endif // XXX old animation system
|
||||
#endif /* XXX old animation system */
|
||||
|
||||
hasize = ma->hasize;
|
||||
seed = ma->seed1;
|
||||
@@ -2088,10 +2088,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
|
||||
strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset);
|
||||
|
||||
/* 4. clean up */
|
||||
#if 0 // XXX old animation system
|
||||
#if 0 /* XXX old animation system */
|
||||
if (ma) do_mat_ipo(re->scene, ma);
|
||||
#endif // XXX old animation system
|
||||
|
||||
#endif /* XXX old animation system */
|
||||
|
||||
if (orco1)
|
||||
MEM_freeN(sd.orco);
|
||||
|
||||
@@ -3286,7 +3286,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
|
||||
int a, a1, ok, vertofs;
|
||||
int end, do_autosmooth = FALSE, totvert = 0;
|
||||
int use_original_normals = FALSE;
|
||||
int recalc_normals = 0; // false by default
|
||||
int recalc_normals = 0; /* false by default */
|
||||
int negative_scale;
|
||||
|
||||
me= ob->data;
|
||||
@@ -3511,7 +3511,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
|
||||
int t;
|
||||
mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1);
|
||||
mtface= (MTFace*)layer->data;
|
||||
*mtf= mtface[a]; // copy face info
|
||||
*mtf = mtface[a]; /* copy face info */
|
||||
for (vindex=0; vindex<nr_verts; vindex++)
|
||||
for (t=0; t<2; t++)
|
||||
mtf->uv[vindex][t]=mtface[a].uv[rev_tab[vindex]][t];
|
||||
@@ -3776,7 +3776,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
|
||||
lar->shdwb= la->shdwb;
|
||||
lar->k= la->k;
|
||||
|
||||
// area
|
||||
/* area */
|
||||
lar->ray_samp= la->ray_samp;
|
||||
lar->ray_sampy= la->ray_sampy;
|
||||
lar->ray_sampz= la->ray_sampz;
|
||||
@@ -3827,7 +3827,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
|
||||
}
|
||||
|
||||
area_lamp_vectors(lar);
|
||||
init_jitter_plane(lar); // subsamples
|
||||
init_jitter_plane(lar); /* subsamples */
|
||||
}
|
||||
else if (lar->type==LA_SUN) {
|
||||
lar->ray_totsamp= lar->ray_samp*lar->ray_samp;
|
||||
@@ -3862,7 +3862,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
|
||||
|
||||
memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
|
||||
|
||||
lar->lay= ob->lay & 0xFFFFFF; // higher 8 bits are localview layers
|
||||
lar->lay = ob->lay & 0xFFFFFF; /* higher 8 bits are localview layers */
|
||||
|
||||
lar->falloff_type = la->falloff_type;
|
||||
lar->ld1= la->att1;
|
||||
@@ -3947,7 +3947,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
|
||||
/* Per lamp, one shadow buffer is made. */
|
||||
lar->bufflag= la->bufflag;
|
||||
copy_m4_m4(mat, ob->obmat);
|
||||
initshadowbuf(re, lar, mat); // mat is altered
|
||||
initshadowbuf(re, lar, mat); /* mat is altered */
|
||||
}
|
||||
|
||||
|
||||
@@ -4290,8 +4290,8 @@ static void check_non_flat_quads(ObjectRen *obr)
|
||||
|
||||
xn = dot_v3v3(nor, vlr->n);
|
||||
|
||||
if (ABS(xn) < 0.999995f ) { // checked on noisy fractal grid
|
||||
|
||||
if (ABS(xn) < 0.999995f ) { /* checked on noisy fractal grid */
|
||||
|
||||
float d1, d2;
|
||||
|
||||
vlr1= RE_vlakren_copy(obr, vlr);
|
||||
@@ -5098,7 +5098,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
|
||||
/* per second, per object, stats print this */
|
||||
re->i.infostr= "Preparing Scene data";
|
||||
re->i.cfra= scene->r.cfra;
|
||||
BLI_strncpy(re->i.scenename, scene->id.name+2, sizeof(re->i.scenename));
|
||||
BLI_strncpy(re->i.scene_name, scene->id.name + 2, sizeof(re->i.scene_name));
|
||||
|
||||
/* XXX add test if dbase was filled already? */
|
||||
|
||||
@@ -5538,7 +5538,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
|
||||
else
|
||||
ver++;
|
||||
|
||||
// get fluid velocity
|
||||
/* get fluid velocity */
|
||||
fsvec[3] = 0.0f;
|
||||
//fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.0; fsvec[2] = 2.0f; // NT fixed test
|
||||
for (j=0;j<3;j++) fsvec[j] = velarray[a].vel[j];
|
||||
@@ -5550,31 +5550,31 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
|
||||
fsvec[2] = avgvel[2];
|
||||
}
|
||||
|
||||
// transform (=rotate) to cam space
|
||||
/* transform (=rotate) to cam space */
|
||||
camco[0] = dot_v3v3(imat[0], fsvec);
|
||||
camco[1] = dot_v3v3(imat[1], fsvec);
|
||||
camco[2] = dot_v3v3(imat[2], fsvec);
|
||||
|
||||
// get homogenous coordinates
|
||||
/* get homogenous coordinates */
|
||||
projectvert(camco, winmat, hoco);
|
||||
projectvert(ver->co, winmat, ho);
|
||||
|
||||
/* now map hocos to screenspace, uses very primitive clip still */
|
||||
// use ho[3] of original vertex, xy component of vel. direction
|
||||
/* use ho[3] of original vertex, xy component of vel. direction */
|
||||
if (ho[3]<0.1f) div= 10.0f;
|
||||
else div= 1.0f/ho[3];
|
||||
zco[0]= zmulx*hoco[0]*div;
|
||||
zco[1]= zmuly*hoco[1]*div;
|
||||
|
||||
// maximize speed as usual
|
||||
/* maximize speed as usual */
|
||||
len= zco[0]*zco[0] + zco[1]*zco[1];
|
||||
if (len > winsq) {
|
||||
len= winroot/sqrtf(len);
|
||||
zco[0]*= len; zco[1]*= len;
|
||||
}
|
||||
|
||||
|
||||
speed= RE_vertren_get_winspeed(obi, ver, 1);
|
||||
// set both to the same value
|
||||
/* set both to the same value */
|
||||
speed[0]= speed[2]= zco[0];
|
||||
speed[1]= speed[3]= zco[1];
|
||||
//if (a < 20) fprintf(stderr,"speed %d %f,%f | camco %f,%f,%f | hoco %f,%f,%f,%f\n", a, speed[0], speed[1], camco[0],camco[1], camco[2], hoco[0],hoco[1], hoco[2],hoco[3]); // NT DEBUG
|
||||
@@ -5711,7 +5711,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned
|
||||
continue;
|
||||
}
|
||||
|
||||
// NT check for fluidsim special treatment
|
||||
/* NT check for fluidsim special treatment */
|
||||
fluidmd = (FluidsimModifierData *)modifiers_findByType(obi->ob, eModifierType_Fluidsim);
|
||||
if (fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) {
|
||||
/* use preloaded per vertex simulation data, only does calculation for step=1 */
|
||||
@@ -5724,7 +5724,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned
|
||||
calculate_speedvectors(re, obi, oldobi->vectors, step);
|
||||
else
|
||||
printf("Warning: object %s has different amount of vertices or strands on other frame\n", obi->ob->id.name+2);
|
||||
} // not fluidsim
|
||||
} /* not fluidsim */
|
||||
|
||||
oldobi= oldobi->next;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_image.h" // BKE_imbuf_write
|
||||
#include "BKE_image.h" /* BKE_imbuf_write */
|
||||
#include "BKE_texture.h"
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ void make_envmaps(Render *re)
|
||||
re->display_clear(re->dch, re->result);
|
||||
// re->flag |= R_REDRAW_PRV;
|
||||
}
|
||||
// restore
|
||||
/* restore */
|
||||
re->r.mode |= trace;
|
||||
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ void RE_engine_update_result(RenderEngine *engine, RenderResult *result)
|
||||
Render *re = engine->re;
|
||||
|
||||
if (result) {
|
||||
result->renlay = result->layers.first; // weak, draws first layer always
|
||||
result->renlay = result->layers.first; /* weak, draws first layer always */
|
||||
re->display_draw(re->ddh, result, NULL);
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result)
|
||||
|
||||
/* draw */
|
||||
if (!re->test_break(re->tbh)) {
|
||||
result->renlay = result->layers.first; // weak, draws first layer always
|
||||
result->renlay = result->layers.first; /* weak, draws first layer always */
|
||||
re->display_draw(re->ddh, result, NULL);
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ int RE_engine_render(Render *re, int do_all)
|
||||
|
||||
/* set render info */
|
||||
re->i.cfra = re->scene->r.cfra;
|
||||
BLI_strncpy(re->i.scenename, re->scene->id.name + 2, sizeof(re->i.scenename));
|
||||
BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name));
|
||||
re->i.totface = re->i.totvert = re->i.totstrand = re->i.totlamp = re->i.tothalo = 0;
|
||||
|
||||
/* render */
|
||||
|
||||
@@ -231,13 +231,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul
|
||||
|
||||
if (texres->nor) {
|
||||
if (tex->imaflag & TEX_NORMALMAP) {
|
||||
// qdn: normal from color
|
||||
// The invert of the red channel is to make
|
||||
// the normal map compliant with the outside world.
|
||||
// It needs to be done because in Blender
|
||||
// the normal used in the renderer points inward. It is generated
|
||||
// this way in calc_vertexnormals(). Should this ever change
|
||||
// this negate must be removed.
|
||||
/* qdn: normal from color
|
||||
* The invert of the red channel is to make
|
||||
* the normal map compliant with the outside world.
|
||||
* It needs to be done because in Blender
|
||||
* the normal used in the renderer points inward. It is generated
|
||||
* this way in calc_vertexnormals(). Should this ever change
|
||||
* this negate must be removed. */
|
||||
texres->nor[0] = -2.f*(texres->tr - 0.5f);
|
||||
texres->nor[1] = 2.f*(texres->tg - 0.5f);
|
||||
texres->nor[2] = 2.f*(texres->tb - 0.5f);
|
||||
@@ -619,36 +619,36 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------------------
|
||||
// from here, some functions only used for the new filtering
|
||||
/*-----------------------------------------------------------------------------------------------------------------
|
||||
* from here, some functions only used for the new filtering */
|
||||
|
||||
// anisotropic filters, data struct used instead of long line of (possibly unused) func args
|
||||
/* anisotropic filters, data struct used instead of long line of (possibly unused) func args */
|
||||
typedef struct afdata_t {
|
||||
float dxt[2], dyt[2];
|
||||
int intpol, extflag;
|
||||
// feline only
|
||||
/* feline only */
|
||||
float majrad, minrad, theta;
|
||||
int iProbes;
|
||||
float dusc, dvsc;
|
||||
} afdata_t;
|
||||
|
||||
// this only used here to make it easier to pass extend flags as single int
|
||||
enum {TXC_XMIR=1, TXC_YMIR, TXC_REPT, TXC_EXTD};
|
||||
/* this only used here to make it easier to pass extend flags as single int */
|
||||
enum {TXC_XMIR = 1, TXC_YMIR, TXC_REPT, TXC_EXTD};
|
||||
|
||||
// similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
|
||||
// returns true if out of range in clipmode
|
||||
/* similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags
|
||||
* returns true if out of range in clipmode */
|
||||
static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag)
|
||||
{
|
||||
int clip = 0;
|
||||
switch (extflag) {
|
||||
case TXC_XMIR: // y rep
|
||||
case TXC_XMIR: /* y rep */
|
||||
x %= 2*ibuf->x;
|
||||
x += x < 0 ? 2*ibuf->x : 0;
|
||||
x = x >= ibuf->x ? 2*ibuf->x - x - 1 : x;
|
||||
y %= ibuf->y;
|
||||
y += y < 0 ? ibuf->y : 0;
|
||||
break;
|
||||
case TXC_YMIR: // x rep
|
||||
case TXC_YMIR: /* x rep */
|
||||
x %= ibuf->x;
|
||||
x += x < 0 ? ibuf->x : 0;
|
||||
y %= 2*ibuf->y;
|
||||
@@ -665,11 +665,12 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
|
||||
y %= ibuf->y;
|
||||
y += (y < 0) ? ibuf->y : 0;
|
||||
break;
|
||||
default: { // as extend, if clipped, set alpha to 0.0
|
||||
if (x < 0) { x = 0; } // TXF alpha: clip = 1; }
|
||||
if (x >= ibuf->x) { x = ibuf->x - 1; } // TXF alpha: clip = 1; }
|
||||
if (y < 0) { y = 0; } // TXF alpha: clip = 1; }
|
||||
if (y >= ibuf->y) { y = ibuf->y - 1; } // TXF alpha: clip = 1; }
|
||||
default:
|
||||
{ /* as extend, if clipped, set alpha to 0.0 */
|
||||
if (x < 0) { x = 0; } /* TXF alpha: clip = 1; } */
|
||||
if (x >= ibuf->x) { x = ibuf->x - 1; } /* TXF alpha: clip = 1; } */
|
||||
if (y < 0) { y = 0; } /* TXF alpha: clip = 1; } */
|
||||
if (y >= ibuf->y) { y = ibuf->y - 1; } /* TXF alpha: clip = 1; } */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,7 +695,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf
|
||||
return clip;
|
||||
}
|
||||
|
||||
// as above + bilerp
|
||||
/* as above + bilerp */
|
||||
static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float v, int intpol, int extflag)
|
||||
{
|
||||
if (intpol) {
|
||||
@@ -749,12 +750,12 @@ static void area_sample(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata
|
||||
texr->tr *= xsd;
|
||||
texr->tg *= xsd;
|
||||
texr->tb *= xsd;
|
||||
// clipping can be ignored if alpha used, texr->ta already includes filtered edge
|
||||
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
|
||||
texr->ta = texr->talpha ? texr->ta*xsd : (clip ? cw*xsd : 1.f);
|
||||
}
|
||||
|
||||
// table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
|
||||
// used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible
|
||||
/* table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2
|
||||
* used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible */
|
||||
#define EWA_MAXIDX 255
|
||||
static float EWA_WTS[EWA_MAXIDX + 1] =
|
||||
{ 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f,
|
||||
@@ -791,9 +792,9 @@ static float EWA_WTS[EWA_MAXIDX + 1] =
|
||||
0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f
|
||||
};
|
||||
|
||||
// test if a float value is 'nan'
|
||||
// there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns),
|
||||
// and may not be supported by other compilers either
|
||||
/* test if a float value is 'nan'
|
||||
* there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns),
|
||||
* and may not be supported by other compilers either */
|
||||
#ifndef ISNAN
|
||||
#define ISNAN(x) ((x) != (x))
|
||||
#endif
|
||||
@@ -802,7 +803,7 @@ static float EWA_WTS[EWA_MAXIDX + 1] =
|
||||
static void radangle2imp(float a2, float b2, float th, float* A, float* B, float* C, float* F)
|
||||
{
|
||||
float ct2 = cosf(th);
|
||||
const float st2 = 1.f - ct2*ct2; // <- sin(th)^2
|
||||
const float st2 = 1.0f - ct2 * ct2; /* <- sin(th)^2 */
|
||||
ct2 *= ct2;
|
||||
*A = a2*st2 + b2*ct2;
|
||||
*B = (b2 - a2)*sinf(2.f*th);
|
||||
@@ -810,10 +811,10 @@ static void radangle2imp(float a2, float b2, float th, float* A, float* B, float
|
||||
*F = a2*b2;
|
||||
}
|
||||
|
||||
// all tests here are done to make sure possible overflows are hopefully minimized
|
||||
/* all tests here are done to make sure possible overflows are hopefully minimized */
|
||||
static void imp2radangle(float A, float B, float C, float F, float* a, float* b, float* th, float* ecc)
|
||||
{
|
||||
if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity
|
||||
if (F <= 1e-5f) { /* use arbitrary major radius, zero minor, infinite eccentricity */
|
||||
*a = sqrtf(A > C ? A : C);
|
||||
*b = 0.f;
|
||||
*ecc = 1e10f;
|
||||
@@ -833,31 +834,31 @@ static void imp2radangle(float A, float B, float C, float F, float* a, float* b,
|
||||
*b = sqrtf(F2 / d);
|
||||
*ecc = *a / *b;
|
||||
}
|
||||
// incr theta by 0.5*pi (angle of major axis)
|
||||
/* incr theta by 0.5*pi (angle of major axis) */
|
||||
*th = 0.5f*(atan2f(B, AmC) + (float)M_PI);
|
||||
}
|
||||
}
|
||||
|
||||
static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD)
|
||||
{
|
||||
// scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values,
|
||||
// scaling by aspect ratio alone does the opposite, so try something in between instead...
|
||||
/* scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values,
|
||||
* scaling by aspect ratio alone does the opposite, so try something in between instead... */
|
||||
const float ff2 = ibuf->x, ff = sqrtf(ff2), q = ibuf->y / ff;
|
||||
const float Ux = AFD->dxt[0]*ff, Vx = AFD->dxt[1]*q, Uy = AFD->dyt[0]*ff, Vy = AFD->dyt[1]*q;
|
||||
float A = Vx*Vx + Vy*Vy;
|
||||
float B = -2.f*(Ux*Vx + Uy*Vy);
|
||||
float C = Ux*Ux + Uy*Uy;
|
||||
float F = A*C - B*B*0.25f;
|
||||
float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; // TXF alpha: cw = 0.f;
|
||||
int u, v, u1, u2, v1, v2; // TXF alpha: clip = 0;
|
||||
float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; /* TXF alpha: cw = 0.f; */
|
||||
int u, v, u1, u2, v1, v2; /* TXF alpha: clip = 0; */
|
||||
|
||||
// The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C,
|
||||
// so the ellipse always covers at least some texels. But since the filter is now always larger,
|
||||
// it also means that everywhere else it's also more blurry then ideally should be the case.
|
||||
// So instead here the ellipse radii are modified instead whenever either is too low.
|
||||
// Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off,
|
||||
// and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on
|
||||
// (minimum values: const float rmin = intpol ? 1.f : 0.5f;)
|
||||
/* The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C,
|
||||
* so the ellipse always covers at least some texels. But since the filter is now always larger,
|
||||
* it also means that everywhere else it's also more blurry then ideally should be the case.
|
||||
* So instead here the ellipse radii are modified instead whenever either is too low.
|
||||
* Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off,
|
||||
* and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on
|
||||
* (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */
|
||||
const float rmin = (AFD->intpol ? 1.5625f : 0.765625f)/ff2;
|
||||
imp2radangle(A, B, C, F, &a, &b, &th, &ecc);
|
||||
if ((b2 = b*b) < rmin) {
|
||||
@@ -903,8 +904,8 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t*
|
||||
float tc[4];
|
||||
const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q];
|
||||
/*const int out =*/ ibuf_get_color_clip(tc, ibuf, u, v, AFD->extflag);
|
||||
// TXF alpha: clip |= out;
|
||||
// TXF alpha: cw += out ? 0.f : wt;
|
||||
/* TXF alpha: clip |= out;
|
||||
* TXF alpha: cw += out ? 0.f : wt; */
|
||||
texr->tr += tc[0]*wt;
|
||||
texr->tg += tc[1]*wt;
|
||||
texr->tb += tc[2]*wt;
|
||||
@@ -916,13 +917,13 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t*
|
||||
}
|
||||
}
|
||||
|
||||
// d should hopefully never be zero anymore
|
||||
/* d should hopefully never be zero anymore */
|
||||
d = 1.f/d;
|
||||
texr->tr *= d;
|
||||
texr->tg *= d;
|
||||
texr->tb *= d;
|
||||
// clipping can be ignored if alpha used, texr->ta already includes filtered edge
|
||||
texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha (clip ? cw*d : 1.f);
|
||||
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
|
||||
texr->ta = texr->talpha ? texr->ta*d : 1.f; /* TXF alpha (clip ? cw*d : 1.f); */
|
||||
}
|
||||
|
||||
static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD)
|
||||
@@ -931,11 +932,11 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata
|
||||
const float ll = ((AFD->majrad == AFD->minrad) ? 2.f*AFD->majrad : 2.f*(AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f);
|
||||
float du = maxn ? cosf(AFD->theta)*ll : 0.f;
|
||||
float dv = maxn ? sinf(AFD->theta)*ll : 0.f;
|
||||
//const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad);
|
||||
/* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */
|
||||
const float D = (EWA_MAXIDX + 1)*0.25f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad);
|
||||
float d; // TXF alpha: cw = 0.f;
|
||||
int n; // TXF alpha: clip = 0;
|
||||
// have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.)
|
||||
float d; /* TXF alpha: cw = 0.f; */
|
||||
int n; /* TXF alpha: clip = 0; */
|
||||
/* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */
|
||||
du *= AFD->dusc;
|
||||
dv *= AFD->dvsc;
|
||||
d = texr->tr = texr->tb = texr->tg = texr->ta = 0.f;
|
||||
@@ -943,12 +944,12 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata
|
||||
float tc[4];
|
||||
const float hn = n*0.5f;
|
||||
const float u = fx + hn*du, v = fy + hn*dv;
|
||||
//const float wt = expf(n*n*D);
|
||||
// can use ewa table here too
|
||||
/*const float wt = expf(n*n*D);
|
||||
* can use ewa table here too */
|
||||
const float wt = EWA_WTS[(int)(n*n*D)];
|
||||
/*const int out =*/ ibuf_get_color_clip_bilerp(tc, ibuf, ibuf->x*u, ibuf->y*v, AFD->intpol, AFD->extflag);
|
||||
// TXF alpha: clip |= out;
|
||||
// TXF alpha: cw += out ? 0.f : wt;
|
||||
/* TXF alpha: clip |= out;
|
||||
* TXF alpha: cw += out ? 0.f : wt; */
|
||||
texr->tr += tc[0]*wt;
|
||||
texr->tg += tc[1]*wt;
|
||||
texr->tb += tc[2]*wt;
|
||||
@@ -960,7 +961,7 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata
|
||||
texr->tr *= d;
|
||||
texr->tg *= d;
|
||||
texr->tb *= d;
|
||||
// clipping can be ignored if alpha used, texr->ta already includes filtered edge
|
||||
/* clipping can be ignored if alpha used, texr->ta already includes filtered edge */
|
||||
texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha: (clip ? cw*d : 1.f);
|
||||
}
|
||||
#undef EWA_MAXIDX
|
||||
@@ -970,8 +971,8 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl
|
||||
float alphaclip;
|
||||
rctf rf;
|
||||
|
||||
// TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting
|
||||
// if this is actually correct for the all the filtering algorithms ..
|
||||
/* TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting
|
||||
* if this is actually correct for the all the filtering algorithms .. */
|
||||
|
||||
if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) {
|
||||
rf.xmin = minx*(ibuf->x);
|
||||
@@ -1040,13 +1041,13 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
|
||||
texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.f;
|
||||
|
||||
// we need to set retval OK, otherwise texture code generates normals itself...
|
||||
/* we need to set retval OK, otherwise texture code generates normals itself... */
|
||||
retval = texres->nor ? 3 : 1;
|
||||
|
||||
// quick tests
|
||||
/* quick tests */
|
||||
if (ibuf==NULL && ima==NULL) return retval;
|
||||
|
||||
if (ima) { // hack for icon render
|
||||
if (ima) { /* hack for icon render */
|
||||
if ((ima->ibufs.first == NULL) && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval;
|
||||
ibuf = BKE_image_get_ibuf(ima, &tex->iuser);
|
||||
}
|
||||
@@ -1079,18 +1080,18 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
}
|
||||
}
|
||||
|
||||
// pixel coordinates
|
||||
/* 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
|
||||
/* tex_sharper has been removed */
|
||||
minx = (maxx - minx)*0.5f;
|
||||
miny = (maxy - miny)*0.5f;
|
||||
|
||||
if (tex->imaflag & TEX_FILTER_MIN) {
|
||||
// make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy)
|
||||
/* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */
|
||||
const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y);
|
||||
if (addval > minx) minx = addval;
|
||||
if (addval > miny) miny = addval;
|
||||
@@ -1107,9 +1108,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
if (tex->imaflag & TEX_IMAROT) {
|
||||
float t;
|
||||
SWAP(float, minx, miny);
|
||||
// must rotate dxt/dyt 90 deg
|
||||
// yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar,
|
||||
// but it doesn't, it only swaps coords, so filter area will be incorrect in those cases.
|
||||
/* must rotate dxt/dyt 90 deg
|
||||
* yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar,
|
||||
* but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. */
|
||||
t = dxt[0];
|
||||
dxt[0] = dxt[1];
|
||||
dxt[1] = -t;
|
||||
@@ -1118,11 +1119,11 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
dyt[1] = -t;
|
||||
}
|
||||
|
||||
// side faces of unit-cube
|
||||
/* side faces of unit-cube */
|
||||
minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5f : minx);
|
||||
miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5f : miny);
|
||||
|
||||
// repeat and clip
|
||||
/* repeat and clip */
|
||||
|
||||
if (tex->extend == TEX_REPEAT) {
|
||||
if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR))
|
||||
@@ -1139,7 +1140,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
|
||||
if (tex->extend == TEX_CHECKER) {
|
||||
int xs = (int)floorf(fx), ys = (int)floorf(fy);
|
||||
// both checkers available, no boundary exceptions, checkerdist will eat aliasing
|
||||
/* 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;
|
||||
@@ -1166,7 +1167,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
fy -= ys;
|
||||
}
|
||||
}
|
||||
// scale around center, (0.5, 0.5)
|
||||
/* scale around center, (0.5, 0.5) */
|
||||
if (tex->checkerdist < 1.f) {
|
||||
const float omcd = 1.f / (1.f - tex->checkerdist);
|
||||
fx = (fx - 0.5f)*omcd + 0.5f;
|
||||
@@ -1195,34 +1196,34 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
|
||||
intpol = tex->imaflag & TEX_INTERPOL;
|
||||
|
||||
// warning no return!
|
||||
/* warning no return! */
|
||||
if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields))
|
||||
ibuf->rect += ibuf->x*ibuf->y;
|
||||
|
||||
// struct common data
|
||||
/* struct common data */
|
||||
copy_v2_v2(AFD.dxt, dxt);
|
||||
copy_v2_v2(AFD.dyt, dyt);
|
||||
AFD.intpol = intpol;
|
||||
AFD.extflag = extflag;
|
||||
|
||||
// brecht: added stupid clamping here, large dx/dy can give very large
|
||||
// filter sizes which take ages to render, it may be better to do this
|
||||
// more intelligently later in the code .. probably it's not noticeable
|
||||
/* brecht: added stupid clamping here, large dx/dy can give very large
|
||||
* filter sizes which take ages to render, it may be better to do this
|
||||
* more intelligently later in the code .. probably it's not noticeable */
|
||||
if (AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f)
|
||||
mul_v2_fl(AFD.dxt, 2.0f/len_v2(AFD.dxt));
|
||||
if (AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f)
|
||||
mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt));
|
||||
|
||||
// choice:
|
||||
/* choice: */
|
||||
if (tex->imaflag & TEX_MIPMAP) {
|
||||
ImBuf *previbuf, *curibuf;
|
||||
float levf;
|
||||
int maxlev;
|
||||
ImBuf* mipmaps[IB_MIPMAP_LEVELS + 1];
|
||||
|
||||
// modify ellipse minor axis if too eccentric, use for area sampling as well
|
||||
// scaling dxt/dyt as done in pbrt is not the same
|
||||
// (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision)
|
||||
/* modify ellipse minor axis if too eccentric, use for area sampling as well
|
||||
* scaling dxt/dyt as done in pbrt is not the same
|
||||
* (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) */
|
||||
const float ff = sqrtf(ibuf->x), q = ibuf->y/ff;
|
||||
const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q;
|
||||
const float A = Vx*Vx + Vy*Vy;
|
||||
@@ -1248,7 +1249,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
AFD.dusc = 1.f/ff;
|
||||
AFD.dvsc = ff / (float)ibuf->y;
|
||||
}
|
||||
else { // EWA & area
|
||||
else { /* EWA & area */
|
||||
if (ecc > (float)tex->afmax) b = a / (float)tex->afmax;
|
||||
b *= ff;
|
||||
}
|
||||
@@ -1264,8 +1265,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
curmap++;
|
||||
}
|
||||
|
||||
// mipmap level
|
||||
if (levf < 0.f) { // original image only
|
||||
/* mipmap level */
|
||||
if (levf < 0.f) { /* original image only */
|
||||
previbuf = curibuf = mipmaps[0];
|
||||
levf = 0.f;
|
||||
}
|
||||
@@ -1281,39 +1282,39 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
levf -= floorf(levf);
|
||||
}
|
||||
|
||||
// filter functions take care of interpolation themselves, no need to modify dxt/dyt here
|
||||
/* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */
|
||||
|
||||
if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) {
|
||||
// color & normal
|
||||
/* color & normal */
|
||||
filterfunc(texres, curibuf, fx, fy, &AFD);
|
||||
val1 = texres->tr + texres->tg + texres->tb;
|
||||
filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD);
|
||||
val2 = texr.tr + texr.tg + texr.tb;
|
||||
filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD);
|
||||
val3 = texr.tr + texr.tg + texr.tb;
|
||||
// don't switch x or y!
|
||||
/* don't switch x or y! */
|
||||
texres->nor[0] = val1 - val2;
|
||||
texres->nor[1] = val1 - val3;
|
||||
if (previbuf != curibuf) { // interpolate
|
||||
if (previbuf != curibuf) { /* interpolate */
|
||||
filterfunc(&texr, previbuf, fx, fy, &AFD);
|
||||
// rgb
|
||||
/* rgb */
|
||||
texres->tr += levf*(texr.tr - texres->tr);
|
||||
texres->tg += levf*(texr.tg - texres->tg);
|
||||
texres->tb += levf*(texr.tb - texres->tb);
|
||||
texres->ta += levf*(texr.ta - texres->ta);
|
||||
// normal
|
||||
/* normal */
|
||||
val1 += levf*((texr.tr + texr.tg + texr.tb) - val1);
|
||||
filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD);
|
||||
val2 += levf*((texr.tr + texr.tg + texr.tb) - val2);
|
||||
filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD);
|
||||
val3 += levf*((texr.tr + texr.tg + texr.tb) - val3);
|
||||
texres->nor[0] = val1 - val2; // vals have been interpolated above!
|
||||
texres->nor[0] = val1 - val2; /* vals have been interpolated above! */
|
||||
texres->nor[1] = val1 - val3;
|
||||
}
|
||||
}
|
||||
else { // color
|
||||
else { /* color */
|
||||
filterfunc(texres, curibuf, fx, fy, &AFD);
|
||||
if (previbuf != curibuf) { // interpolate
|
||||
if (previbuf != curibuf) { /* interpolate */
|
||||
filterfunc(&texr, previbuf, fx, fy, &AFD);
|
||||
texres->tr += levf*(texr.tr - texres->tr);
|
||||
texres->tg += levf*(texr.tg - texres->tg);
|
||||
@@ -1324,8 +1325,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
alpha_clip_aniso(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, extflag, texres);
|
||||
}
|
||||
}
|
||||
else { // no mipmap
|
||||
// filter functions take care of interpolation themselves, no need to modify dxt/dyt here
|
||||
else { /* no mipmap */
|
||||
/* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */
|
||||
if (tex->texfilter == TXF_FELINE) {
|
||||
const float ff = sqrtf(ibuf->x), q = ibuf->y/ff;
|
||||
const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q;
|
||||
@@ -1340,7 +1341,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
a = MAX2(a, 1.f);
|
||||
b = MAX2(b, 1.f);
|
||||
fProbes = 2.f*(a / b) - 1.f;
|
||||
// no limit to number of Probes here
|
||||
/* no limit to number of Probes here */
|
||||
AFD.iProbes = (int)floorf(fProbes + 0.5f);
|
||||
if (AFD.iProbes < fProbes) b = 2.f*a / (float)(AFD.iProbes + 1);
|
||||
AFD.majrad = a/ff;
|
||||
@@ -1350,14 +1351,14 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
AFD.dvsc = ff / (float)ibuf->y;
|
||||
}
|
||||
if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) {
|
||||
// color & normal
|
||||
/* color & normal */
|
||||
filterfunc(texres, ibuf, fx, fy, &AFD);
|
||||
val1 = texres->tr + texres->tg + texres->tb;
|
||||
filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD);
|
||||
val2 = texr.tr + texr.tg + texr.tb;
|
||||
filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD);
|
||||
val3 = texr.tr + texr.tg + texr.tb;
|
||||
// don't switch x or y!
|
||||
/* don't switch x or y! */
|
||||
texres->nor[0] = val1 - val2;
|
||||
texres->nor[1] = val1 - val3;
|
||||
}
|
||||
@@ -1376,23 +1377,23 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex
|
||||
if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields))
|
||||
ibuf->rect -= ibuf->x*ibuf->y;
|
||||
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { // normal from color
|
||||
// The invert of the red channel is to make
|
||||
// the normal map compliant with the outside world.
|
||||
// It needs to be done because in Blender
|
||||
// the normal used in the renderer points inward. It is generated
|
||||
// this way in calc_vertexnormals(). Should this ever change
|
||||
// this negate must be removed.
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */
|
||||
/* The invert of the red channel is to make
|
||||
* the normal map compliant with the outside world.
|
||||
* It needs to be done because in Blender
|
||||
* the normal used in the renderer points inward. It is generated
|
||||
* this way in calc_vertexnormals(). Should this ever change
|
||||
* this negate must be removed. */
|
||||
texres->nor[0] = -2.f*(texres->tr - 0.5f);
|
||||
texres->nor[1] = 2.f*(texres->tg - 0.5f);
|
||||
texres->nor[2] = 2.f*(texres->tb - 0.5f);
|
||||
}
|
||||
|
||||
// de-premul, this is being premulled in shade_input_do_shade()
|
||||
// TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out
|
||||
// also disabled in imagewraposa() to be able to compare results with blender's default texture filtering
|
||||
|
||||
// brecht: tried to fix this, see "TXF alpha" comments
|
||||
/* de-premul, this is being premulled in shade_input_do_shade()
|
||||
* TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out
|
||||
* also disabled in imagewraposa() to be able to compare results with blender's default texture filtering */
|
||||
|
||||
/* brecht: tried to fix this, see "TXF alpha" comments */
|
||||
|
||||
if (texres->ta != 1.f && (texres->ta > 1e-4f)) {
|
||||
fx = 1.f/texres->ta;
|
||||
@@ -1414,12 +1415,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
|
||||
float maxd, pixsize, val1, val2, val3;
|
||||
int curmap, retval, imaprepeat, imapextend;
|
||||
|
||||
// TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call,
|
||||
// make a local copy here so that original vecs remain untouched
|
||||
/* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call,
|
||||
* make a local copy here so that original vecs remain untouched */
|
||||
copy_v3_v3(dxt, DXT);
|
||||
copy_v3_v3(dyt, DYT);
|
||||
|
||||
// anisotropic filtering
|
||||
/* anisotropic filtering */
|
||||
if (tex->texfilter != TXF_BOX)
|
||||
return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres);
|
||||
|
||||
@@ -1530,7 +1531,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
|
||||
xs= (int)floor(fx);
|
||||
ys= (int)floor(fy);
|
||||
|
||||
// both checkers available, no boundary exceptions, checkerdist will eat aliasing
|
||||
/* 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;
|
||||
@@ -1765,18 +1766,18 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const
|
||||
}
|
||||
|
||||
if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) {
|
||||
// qdn: normal from color
|
||||
// The invert of the red channel is to make
|
||||
// the normal map compliant with the outside world.
|
||||
// It needs to be done because in Blender
|
||||
// the normal used in the renderer points inward. It is generated
|
||||
// this way in calc_vertexnormals(). Should this ever change
|
||||
// this negate must be removed.
|
||||
/* qdn: normal from color
|
||||
* The invert of the red channel is to make
|
||||
* the normal map compliant with the outside world.
|
||||
* It needs to be done because in Blender
|
||||
* the normal used in the renderer points inward. It is generated
|
||||
* this way in calc_vertexnormals(). Should this ever change
|
||||
* this negate must be removed. */
|
||||
texres->nor[0] = -2.f*(texres->tr - 0.5f);
|
||||
texres->nor[1] = 2.f*(texres->tg - 0.5f);
|
||||
texres->nor[2] = 2.f*(texres->tb - 0.5f);
|
||||
}
|
||||
|
||||
|
||||
/* de-premul, this is being premulled in shade_input_do_shade() */
|
||||
if (texres->ta!=1.0f && texres->ta>1e-4f) {
|
||||
fx= 1.0f/texres->ta;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -169,9 +169,9 @@ static void stats_background(void *UNUSED(arg), RenderStats *rs)
|
||||
}
|
||||
else {
|
||||
if (rs->tothalo)
|
||||
fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->tothalo, rs->totlamp);
|
||||
fprintf(stdout, "Sce: %s Ve:%d Fa:%d Ha:%d La:%d", rs->scene_name, rs->totvert, rs->totface, rs->tothalo, rs->totlamp);
|
||||
else
|
||||
fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scenename, rs->totvert, rs->totface, rs->totlamp);
|
||||
fprintf(stdout, "Sce: %s Ve:%d Fa:%d La:%d", rs->scene_name, rs->totvert, rs->totface, rs->totlamp);
|
||||
}
|
||||
|
||||
BLI_callback_exec(G.main, NULL, BLI_CB_EVT_RENDER_STATS);
|
||||
|
||||
@@ -99,7 +99,7 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size)
|
||||
RayObject * res = NULL;
|
||||
|
||||
if (type == R_RAYSTRUCTURE_AUTO) {
|
||||
//TODO
|
||||
/* TODO */
|
||||
//if (detect_simd())
|
||||
#ifdef __SSE__
|
||||
type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH;
|
||||
@@ -216,12 +216,12 @@ static int is_raytraceable(Render *re, ObjectInstanceRen *obi)
|
||||
|
||||
RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi)
|
||||
{
|
||||
//TODO
|
||||
// out-of-memory safeproof
|
||||
// break render
|
||||
// update render stats
|
||||
/*TODO
|
||||
* out-of-memory safeproof
|
||||
* break render
|
||||
* update render stats */
|
||||
ObjectRen *obr = obi->obr;
|
||||
|
||||
|
||||
if (obr->raytree == NULL) {
|
||||
RayObject *raytree;
|
||||
RayFace *face = NULL;
|
||||
@@ -421,8 +421,8 @@ void makeraytree(Render *re)
|
||||
re->stats_draw(re->sdh, &re->i);
|
||||
}
|
||||
else {
|
||||
//Calculate raytree max_size
|
||||
//This is ONLY needed to kept a bogus behavior of SUN and HEMI lights
|
||||
/* Calculate raytree max_size
|
||||
* This is ONLY needed to kept a bogus behavior of SUN and HEMI lights */
|
||||
INIT_MINMAX(min, max);
|
||||
RE_rayobject_merge_bb(re->raytree, min, max);
|
||||
for (i=0; i<3; i++) {
|
||||
@@ -739,8 +739,8 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con
|
||||
tracol[0]= shi.r;
|
||||
tracol[1]= shi.g;
|
||||
tracol[2]= shi.b;
|
||||
tracol[3]= col[3]; // we pass on and accumulate alpha
|
||||
|
||||
tracol[3]= col[3]; /* we pass on and accumulate alpha */
|
||||
|
||||
if ((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) {
|
||||
/* don't overwrite traflag, it's value is used in mirror reflection */
|
||||
int new_traflag = traflag;
|
||||
@@ -883,12 +883,12 @@ static void DP_energy(float *table, float vec[2], int tot, float xsize, float ys
|
||||
}
|
||||
vec[0] += 0.1f*min*result[0]/(float)tot;
|
||||
vec[1] += 0.1f*min*result[1]/(float)tot;
|
||||
// cyclic clamping
|
||||
/* cyclic clamping */
|
||||
vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f);
|
||||
vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f);
|
||||
}
|
||||
|
||||
// random offset of 1 in 2
|
||||
/* random offset of 1 in 2 */
|
||||
static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float sizex, float sizey, float ofsx, float ofsy)
|
||||
{
|
||||
float dsizex= sizex*ofsx;
|
||||
@@ -974,10 +974,10 @@ static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys)
|
||||
|
||||
static void halton_sample(double *ht_invprimes, double *ht_nums, double *v)
|
||||
{
|
||||
// incremental halton sequence generator, from:
|
||||
// "Instant Radiosity", Keller A.
|
||||
/* incremental halton sequence generator, from:
|
||||
* "Instant Radiosity", Keller A. */
|
||||
unsigned int i;
|
||||
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
double r = fabs((1.0 - ht_nums[i]) - 1e-10);
|
||||
|
||||
@@ -1812,7 +1812,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in
|
||||
float *sphere;
|
||||
int a;
|
||||
|
||||
// always returns table
|
||||
/* always returns table */
|
||||
sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
|
||||
|
||||
/* total random sampling. NOT THREADSAFE! (should be removed, is not useful) */
|
||||
@@ -1827,7 +1827,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in
|
||||
float *sphere;
|
||||
float *vec1;
|
||||
|
||||
// returns table if xs and ys were equal to last call, and not resetting
|
||||
/* returns table if xs and ys were equal to last call, and not resetting */
|
||||
sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot);
|
||||
if (sphere==NULL) {
|
||||
float cosfi, sinfi, cost, sint;
|
||||
@@ -1836,7 +1836,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in
|
||||
|
||||
sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
|
||||
|
||||
// random rotation
|
||||
/* random rotation */
|
||||
ang= BLI_thread_frand(thread);
|
||||
sinfi= sin(ang); cosfi= cos(ang);
|
||||
ang= BLI_thread_frand(thread);
|
||||
@@ -2056,7 +2056,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3])
|
||||
* for strand render we always require a new sampler because x/y are not set */
|
||||
vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys, shi->strand != NULL);
|
||||
|
||||
// warning: since we use full sphere now, and dotproduct is below, we do twice as much
|
||||
/* warning: since we use full sphere now, and dotproduct is below, we do twice as much */
|
||||
tot= 2*resol*resol;
|
||||
|
||||
if (envcolor == WO_AOSKYTEX) {
|
||||
@@ -2116,7 +2116,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3])
|
||||
skyadded++;
|
||||
}
|
||||
}
|
||||
// samples
|
||||
/* samples */
|
||||
vec+= 3;
|
||||
}
|
||||
|
||||
@@ -2436,7 +2436,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[
|
||||
shadfac[3] /= div;
|
||||
}
|
||||
else {
|
||||
// sqrt makes nice umbra effect
|
||||
/* sqrt makes nice umbra effect */
|
||||
if (lar->ray_samp_type & LA_SAMP_UMBRA)
|
||||
shadfac[3]= sqrt(1.0f-fac/div);
|
||||
else
|
||||
@@ -2501,8 +2501,8 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4])
|
||||
isec.orig.ob = shi->obi;
|
||||
isec.orig.face = shi->vlr;
|
||||
|
||||
shadfac[3]= 1.0f; // 1.0=full light
|
||||
|
||||
shadfac[3]= 1.0f; /* 1.0=full light */
|
||||
|
||||
/* set up isec.dir */
|
||||
copy_v3_v3(isec.start, shi->co);
|
||||
sub_v3_v3v3(isec.dir, lampco, isec.start);
|
||||
|
||||
@@ -461,7 +461,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
|
||||
rl->lay_zmask = srl->lay_zmask;
|
||||
rl->lay_exclude = srl->lay_exclude;
|
||||
rl->layflag = srl->layflag;
|
||||
rl->passflag = srl->passflag; // for debugging: srl->passflag|SCE_PASS_RAYHITS;
|
||||
rl->passflag = srl->passflag; /* for debugging: srl->passflag | SCE_PASS_RAYHITS; */
|
||||
rl->pass_xor = srl->pass_xor;
|
||||
rl->light_override = srl->light_override;
|
||||
rl->mat_override = srl->mat_override;
|
||||
@@ -585,7 +585,7 @@ RenderResult *render_result_new_full_sample(Render *re, ListBase *lb, rcti *part
|
||||
}
|
||||
|
||||
/* callbacks for render_result_new_from_exr */
|
||||
static void *ml_addlayer_cb(void *base, char *str)
|
||||
static void *ml_addlayer_cb(void *base, const char *str)
|
||||
{
|
||||
RenderResult *rr = base;
|
||||
RenderLayer *rl;
|
||||
@@ -597,7 +597,7 @@ static void *ml_addlayer_cb(void *base, char *str)
|
||||
return rl;
|
||||
}
|
||||
|
||||
static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect, int totchan, char *chan_id)
|
||||
static void ml_addpass_cb(void *UNUSED(base), void *lay, const char *str, float *rect, int totchan, const char *chan_id)
|
||||
{
|
||||
RenderLayer *rl = lay;
|
||||
RenderPass *rpass = MEM_callocN(sizeof(RenderPass), "loaded pass");
|
||||
@@ -621,7 +621,7 @@ static void ml_addpass_cb(void *UNUSED(base), void *lay, char *str, float *rect,
|
||||
/* from imbuf, if a handle was returned we convert this to render result */
|
||||
RenderResult *render_result_new_from_exr(void *exrhandle, int rectx, int recty)
|
||||
{
|
||||
RenderResult *rr = MEM_callocN(sizeof(RenderResult), "loaded render result");
|
||||
RenderResult *rr = MEM_callocN(sizeof(RenderResult), __func__);
|
||||
RenderLayer *rl;
|
||||
RenderPass *rpass;
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres)
|
||||
texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
|
||||
|
||||
if (texres->nor!=NULL) {
|
||||
// calculate bumpnormal
|
||||
/* calculate bumpnormal */
|
||||
texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
|
||||
texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
|
||||
texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
|
||||
@@ -254,8 +254,8 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres)
|
||||
}
|
||||
|
||||
if (tex->stype==TEX_COLOR) {
|
||||
// in this case, int. value should really be computed from color,
|
||||
// and bumpnormal from that, would be too slow, looks ok as is
|
||||
/* in this case, int. value should really be computed from color,
|
||||
* and bumpnormal from that, would be too slow, looks ok as is */
|
||||
texres->tr = texres->tin;
|
||||
texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
|
||||
texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
|
||||
@@ -538,8 +538,8 @@ static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres)
|
||||
texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
|
||||
|
||||
if (texres->nor!=NULL) {
|
||||
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
|
||||
|
||||
float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
|
||||
|
||||
/* calculate bumpnormal */
|
||||
texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
|
||||
texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
|
||||
@@ -568,8 +568,8 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres)
|
||||
texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
|
||||
|
||||
if (texres->nor!=NULL) {
|
||||
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
|
||||
|
||||
float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
|
||||
|
||||
/* calculate bumpnormal */
|
||||
texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
|
||||
texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
|
||||
@@ -593,8 +593,8 @@ static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres)
|
||||
texres->tin = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
|
||||
|
||||
if (texres->nor!=NULL) {
|
||||
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
|
||||
|
||||
float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
|
||||
|
||||
/* calculate bumpnormal */
|
||||
texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
|
||||
texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
|
||||
@@ -618,8 +618,8 @@ static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres)
|
||||
texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
|
||||
|
||||
if (texres->nor!=NULL) {
|
||||
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
|
||||
|
||||
float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
|
||||
|
||||
/* calculate bumpnormal */
|
||||
texres->nor[0] = mg_VLNoise(texvec[0] + offs, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
|
||||
texres->nor[1] = mg_VLNoise(texvec[0], texvec[1] + offs, texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
|
||||
@@ -688,7 +688,7 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres)
|
||||
}
|
||||
|
||||
if (texres->nor!=NULL) {
|
||||
float offs= tex->nabla/tex->noisesize; // also scaling of texvec
|
||||
float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */
|
||||
|
||||
/* calculate bumpnormal */
|
||||
voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm);
|
||||
@@ -745,7 +745,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1
|
||||
int ret;
|
||||
|
||||
if (n==NULL) {
|
||||
nor[0]= x; nor[1]= y; nor[2]= z; // use local render coord
|
||||
nor[0]= x; nor[1]= y; nor[2]= z; /* use local render coord */
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(nor, n);
|
||||
@@ -1026,7 +1026,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
|
||||
if (tex->xrepeat>1) {
|
||||
float origf= fx *= tex->xrepeat;
|
||||
|
||||
// TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call
|
||||
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
|
||||
if (tex->texfilter == TXF_BOX) {
|
||||
if (fx>1.0f) fx -= (int)(fx);
|
||||
else if (fx<0.0f) fx+= 1-(int)(fx);
|
||||
@@ -1046,7 +1046,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3],
|
||||
if (tex->yrepeat>1) {
|
||||
float origf= fy *= tex->yrepeat;
|
||||
|
||||
// TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call
|
||||
/* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */
|
||||
if (tex->texfilter == TXF_BOX) {
|
||||
if (fy>1.0f) fy -= (int)(fy);
|
||||
else if (fy<0.0f) fy+= 1-(int)(fy);
|
||||
@@ -1512,9 +1512,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen
|
||||
|
||||
static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, float* dx, float* dy, float* texvec, float* dxt, float* dyt)
|
||||
{
|
||||
// new: first swap coords, then map, then trans/scale
|
||||
/* new: first swap coords, then map, then trans/scale */
|
||||
if (tex->type == TEX_IMAGE) {
|
||||
// placement
|
||||
/* placement */
|
||||
texvec[0] = mtex->projx ? co[mtex->projx - 1] : 0.f;
|
||||
texvec[1] = mtex->projy ? co[mtex->projy - 1] : 0.f;
|
||||
texvec[2] = mtex->projz ? co[mtex->projz - 1] : 0.f;
|
||||
@@ -1538,7 +1538,7 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa
|
||||
}
|
||||
do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt);
|
||||
|
||||
// translate and scale
|
||||
/* translate and scale */
|
||||
texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f;
|
||||
texvec[1] = mtex->size[1]*(texvec[1] - 0.5f) + mtex->ofs[1] + 0.5f;
|
||||
if (shi->osatex) {
|
||||
@@ -1549,13 +1549,13 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa
|
||||
}
|
||||
|
||||
/* problem: repeat-mirror is not a 'repeat' but 'extend' in imagetexture.c */
|
||||
// TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too.
|
||||
// New texfilters solve mirroring differently so that it also works correctly when
|
||||
// textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping().
|
||||
// (since currently only done in osa mode, results will look incorrect without osa TODO)
|
||||
/* TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too.
|
||||
* New texfilters solve mirroring differently so that it also works correctly when
|
||||
* textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping().
|
||||
* (since currently only done in osa mode, results will look incorrect without osa TODO) */
|
||||
if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_XMIR)) {
|
||||
if (tex->texfilter == TXF_BOX)
|
||||
texvec[0] -= floorf(texvec[0]); // this line equivalent to old code, same below
|
||||
texvec[0] -= floorf(texvec[0]); /* this line equivalent to old code, same below */
|
||||
else if (texvec[0] < 0.f || texvec[0] > 1.f) {
|
||||
const float tx = 0.5f*texvec[0];
|
||||
texvec[0] = 2.f*(tx - floorf(tx));
|
||||
@@ -1573,8 +1573,8 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa
|
||||
}
|
||||
|
||||
}
|
||||
else { // procedural
|
||||
// placement
|
||||
else { /* procedural */
|
||||
/* placement */
|
||||
texvec[0] = mtex->size[0]*(mtex->projx ? (co[mtex->projx - 1] + mtex->ofs[0]) : mtex->ofs[0]);
|
||||
texvec[1] = mtex->size[1]*(mtex->projy ? (co[mtex->projy - 1] + mtex->ofs[1]) : mtex->ofs[1]);
|
||||
texvec[2] = mtex->size[2]*(mtex->projz ? (co[mtex->projz - 1] + mtex->ofs[2]) : mtex->ofs[2]);
|
||||
@@ -1617,11 +1617,16 @@ static void compatible_bump_init(CompatibleBump *compat_bump)
|
||||
|
||||
static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, int i)
|
||||
{
|
||||
// uvmapping only, calculation of normal tangent u/v partial derivatives
|
||||
// (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct,
|
||||
// nu/nv in ShadeInput and this calculation should then move to shadeinput.c, shade_input_set_shade_texco() func.)
|
||||
// NOTE: test for shi->obr->ob here, since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it..
|
||||
// NOTE: shi->v1 is NULL when called from displace_render_vert, assigning verts in this case is not trivial because the shi quad face side is not know.
|
||||
/* uvmapping only, calculation of normal tangent u/v partial derivatives
|
||||
* (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct,
|
||||
* nu/nv in ShadeInput and this calculation should then move to shadeinput.c,
|
||||
* shade_input_set_shade_texco() func.) */
|
||||
|
||||
/* NOTE: test for shi->obr->ob here,
|
||||
* since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. */
|
||||
|
||||
/* NOTE: shi->v1 is NULL when called from displace_render_vert,
|
||||
* assigning verts in this case is not trivial because the shi quad face side is not know. */
|
||||
if ((mtex->texflag & MTEX_COMPAT_BUMP) && shi->obr && shi->obr->ob && shi->v1) {
|
||||
if (mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) {
|
||||
MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0);
|
||||
@@ -1629,9 +1634,9 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s
|
||||
|
||||
vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3);
|
||||
|
||||
// compute ortho basis around normal
|
||||
/* compute ortho basis around normal */
|
||||
if (!compat_bump->nunvdone) {
|
||||
// render normal is negated
|
||||
/* render normal is negated */
|
||||
compat_bump->nn[0] = -shi->vn[0];
|
||||
compat_bump->nn[1] = -shi->vn[1];
|
||||
compat_bump->nn[2] = -shi->vn[2];
|
||||
@@ -1672,32 +1677,32 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s
|
||||
|
||||
static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt)
|
||||
{
|
||||
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult
|
||||
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
|
||||
float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv;
|
||||
const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0));
|
||||
const float bf = -0.04f*Tnor*mtex->norfac;
|
||||
int rgbnor;
|
||||
// disable internal bump eval
|
||||
/* disable internal bump eval */
|
||||
float* nvec = texres->nor;
|
||||
texres->nor = NULL;
|
||||
// du & dv estimates, constant value defaults
|
||||
/* du & dv estimates, constant value defaults */
|
||||
du = dv = 0.01f;
|
||||
|
||||
// compute ortho basis around normal
|
||||
/* compute ortho basis around normal */
|
||||
if (!compat_bump->nunvdone) {
|
||||
// render normal is negated
|
||||
/* render normal is negated */
|
||||
negate_v3_v3(compat_bump->nn, shi->vn);
|
||||
ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn);
|
||||
compat_bump->nunvdone = TRUE;
|
||||
}
|
||||
|
||||
// two methods, either constant based on main image resolution,
|
||||
// (which also works without osa, though of course not always good (or even very bad) results),
|
||||
// or based on tex derivative max values (osa only). Not sure which is best...
|
||||
/* two methods, either constant based on main image resolution,
|
||||
* (which also works without osa, though of course not always good (or even very bad) results),
|
||||
* or based on tex derivative max values (osa only). Not sure which is best... */
|
||||
|
||||
if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) {
|
||||
// in case we have no proper derivatives, fall back to
|
||||
// computing du/dv it based on image size
|
||||
/* in case we have no proper derivatives, fall back to
|
||||
* computing du/dv it based on image size */
|
||||
ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
|
||||
if (ibuf) {
|
||||
du = 1.f/(float)ibuf->x;
|
||||
@@ -1705,14 +1710,14 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
}
|
||||
}
|
||||
else if (shi->osatex) {
|
||||
// we have derivatives, can compute proper du/dv
|
||||
if (tex->type == TEX_IMAGE) { // 2d image, use u & v max. of dx/dy 2d vecs
|
||||
/* we have derivatives, can compute proper du/dv */
|
||||
if (tex->type == TEX_IMAGE) { /* 2d image, use u & v max. of dx/dy 2d vecs */
|
||||
const float adx[2] = {fabsf(dx[0]), fabsf(dx[1])};
|
||||
const float ady[2] = {fabsf(dy[0]), fabsf(dy[1])};
|
||||
du = MAX2(adx[0], ady[0]);
|
||||
dv = MAX2(adx[1], ady[1]);
|
||||
}
|
||||
else { // 3d procedural, estimate from all dx/dy elems
|
||||
else { /* 3d procedural, estimate from all dx/dy elems */
|
||||
const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])};
|
||||
const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])};
|
||||
du = MAX3(adx[0], adx[1], adx[2]);
|
||||
@@ -1720,18 +1725,18 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
}
|
||||
}
|
||||
|
||||
// center, main return value
|
||||
/* center, main return value */
|
||||
texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
|
||||
rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres);
|
||||
cd = fromrgb ? (texres->tr + texres->tg + texres->tb)*0.33333333f : texres->tin;
|
||||
|
||||
if (mtex->texco == TEXCO_UV) {
|
||||
// for the uv case, use the same value for both du/dv,
|
||||
// since individually scaling the normal derivatives makes them useless...
|
||||
/* for the uv case, use the same value for both du/dv,
|
||||
* since individually scaling the normal derivatives makes them useless... */
|
||||
du = MIN2(du, dv);
|
||||
idu = (du < 1e-5f) ? bf : (bf/du);
|
||||
|
||||
// +u val
|
||||
/* +u val */
|
||||
tco[0] = co[0] + compat_bump->dudnu*du;
|
||||
tco[1] = co[1] + compat_bump->dvdnu*du;
|
||||
tco[2] = 0.f;
|
||||
@@ -1739,7 +1744,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr);
|
||||
ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin));
|
||||
|
||||
// +v val
|
||||
/* +v val */
|
||||
tco[0] = co[0] + compat_bump->dudnv*du;
|
||||
tco[1] = co[1] + compat_bump->dvdnv*du;
|
||||
tco[2] = 0.f;
|
||||
@@ -1773,7 +1778,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
normalize_v3(tv);
|
||||
}
|
||||
|
||||
// +u val
|
||||
/* +u val */
|
||||
tco[0] = co[0] + tu[0]*du;
|
||||
tco[1] = co[1] + tu[1]*du;
|
||||
tco[2] = co[2] + tu[2]*du;
|
||||
@@ -1781,7 +1786,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr);
|
||||
ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin));
|
||||
|
||||
// +v val
|
||||
/* +v val */
|
||||
tco[0] = co[0] + tv[0]*dv;
|
||||
tco[1] = co[1] + tv[1]*dv;
|
||||
tco[2] = co[2] + tv[2]*dv;
|
||||
@@ -1790,7 +1795,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin));
|
||||
}
|
||||
|
||||
// bumped normal
|
||||
/* bumped normal */
|
||||
compat_bump->nu[0] += ud*compat_bump->nn[0];
|
||||
compat_bump->nu[1] += ud*compat_bump->nn[1];
|
||||
compat_bump->nu[2] += ud*compat_bump->nn[2];
|
||||
@@ -1812,13 +1817,13 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi,
|
||||
|
||||
typedef struct NTapBump {
|
||||
int init_done;
|
||||
int iPrevBumpSpace; // 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace
|
||||
// bumpmapping
|
||||
float vNorg[3]; // backup copy of shi->vn
|
||||
float vNacc[3]; // original surface normal minus the surface gradient of every bump map which is encountered
|
||||
float vR1[3], vR2[3]; // cross products (sigma_y, original_normal), (original_normal, sigma_x)
|
||||
float sgn_det; // sign of the determinant of the matrix {sigma_x, sigma_y, original_normal}
|
||||
float fPrevMagnitude; // copy of previous magnitude, used for multiple bumps in different spaces
|
||||
int iPrevBumpSpace; /* 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace */
|
||||
/* bumpmapping */
|
||||
float vNorg[3]; /* backup copy of shi->vn */
|
||||
float vNacc[3]; /* original surface normal minus the surface gradient of every bump map which is encountered */
|
||||
float vR1[3], vR2[3]; /* cross products (sigma_y, original_normal), (original_normal, sigma_x) */
|
||||
float sgn_det; /* sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} */
|
||||
float fPrevMagnitude; /* copy of previous magnitude, used for multiple bumps in different spaces */
|
||||
} NTapBump;
|
||||
|
||||
static void ntap_bump_init(NTapBump *ntap_bump)
|
||||
@@ -1828,38 +1833,38 @@ static void ntap_bump_init(NTapBump *ntap_bump)
|
||||
|
||||
static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt)
|
||||
{
|
||||
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult
|
||||
TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */
|
||||
|
||||
const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0));
|
||||
|
||||
// The negate on Hscale is done because the
|
||||
// normal in the renderer points inward which corresponds
|
||||
// to inverting the bump map. The normals are generated
|
||||
// this way in calc_vertexnormals(). Should this ever change
|
||||
// this negate must be removed.
|
||||
/* The negate on Hscale is done because the
|
||||
* normal in the renderer points inward which corresponds
|
||||
* to inverting the bump map. The normals are generated
|
||||
* this way in calc_vertexnormals(). Should this ever change
|
||||
* this negate must be removed. */
|
||||
float Hscale = -Tnor*mtex->norfac;
|
||||
|
||||
int dimx=512, dimy=512;
|
||||
const int imag_tspace_dimension_x = 1024; // only used for texture space variant
|
||||
const int imag_tspace_dimension_x = 1024; /* only used for texture space variant */
|
||||
float aspect = 1.0f;
|
||||
|
||||
// 2 channels for 2D texture and 3 for 3D textures.
|
||||
/* 2 channels for 2D texture and 3 for 3D textures. */
|
||||
const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3;
|
||||
int c, rgbnor, iBumpSpace;
|
||||
float dHdx, dHdy;
|
||||
int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP);
|
||||
|
||||
// disable internal bump eval in sampler, save pointer
|
||||
/* disable internal bump eval in sampler, save pointer */
|
||||
float *nvec = texres->nor;
|
||||
texres->nor = NULL;
|
||||
|
||||
if (found_deriv_map==0) {
|
||||
if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
|
||||
if (tex->ima)
|
||||
Hscale *= 13.0f; // appears to be a sensible default value
|
||||
Hscale *= 13.0f; /* appears to be a sensible default value */
|
||||
}
|
||||
else
|
||||
Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code
|
||||
Hscale *= 0.1f; /* factor 0.1 proved to look like the previous bump code */
|
||||
}
|
||||
|
||||
if ( !ntap_bump->init_done ) {
|
||||
@@ -1871,7 +1876,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
ntap_bump->init_done = TRUE;
|
||||
}
|
||||
|
||||
// resolve image dimensions
|
||||
/* resolve image dimensions */
|
||||
if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) {
|
||||
ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser);
|
||||
if (ibuf) {
|
||||
@@ -1883,7 +1888,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
|
||||
if (found_deriv_map) {
|
||||
float dBdu, dBdv, auto_bump = 1.0f;
|
||||
float s = 1; // negate this if flipped texture coordinate
|
||||
float s = 1; /* negate this if flipped texture coordinate */
|
||||
texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
|
||||
rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres);
|
||||
|
||||
@@ -1895,9 +1900,9 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
float fVirtDim = sqrtf(fabsf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1]));
|
||||
auto_bump /= MAX2(fVirtDim, FLT_EPSILON);
|
||||
}
|
||||
|
||||
// this variant using a derivative map is described here
|
||||
// http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
|
||||
|
||||
/* this variant using a derivative map is described here
|
||||
* http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html */
|
||||
dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1);
|
||||
dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1);
|
||||
|
||||
@@ -1905,32 +1910,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
dHdy = dBdu*dyt[0] + s * dBdv*dyt[1];
|
||||
}
|
||||
else if (!(mtex->texflag & MTEX_5TAP_BUMP)) {
|
||||
// compute height derivatives with respect to output image pixel coordinates x and y
|
||||
/* compute height derivatives with respect to output image pixel coordinates x and y */
|
||||
float STll[3], STlr[3], STul[3];
|
||||
float Hll, Hlr, Hul;
|
||||
|
||||
texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt);
|
||||
|
||||
for (c=0; c<nr_channels; c++) {
|
||||
// dx contains the derivatives (du/dx, dv/dx)
|
||||
// dy contains the derivatives (du/dy, dv/dy)
|
||||
/* dx contains the derivatives (du/dx, dv/dx)
|
||||
* dy contains the derivatives (du/dy, dv/dy) */
|
||||
STll[c] = texvec[c];
|
||||
STlr[c] = texvec[c]+dxt[c];
|
||||
STul[c] = texvec[c]+dyt[c];
|
||||
}
|
||||
|
||||
// clear unused derivatives
|
||||
/* clear unused derivatives */
|
||||
for (c=nr_channels; c<3; c++) {
|
||||
STll[c] = 0.0f;
|
||||
STlr[c] = 0.0f;
|
||||
STul[c] = 0.0f;
|
||||
}
|
||||
|
||||
// use texres for the center sample, set rgbnor
|
||||
/* use texres for the center sample, set rgbnor */
|
||||
rgbnor = multitex_mtex(shi, mtex, STll, dxt, dyt, texres);
|
||||
Hll = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin;
|
||||
|
||||
// use ttexr for the other 2 taps
|
||||
/* use ttexr for the other 2 taps */
|
||||
multitex_mtex(shi, mtex, STlr, dxt, dyt, &ttexr);
|
||||
Hlr = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin;
|
||||
|
||||
@@ -1955,7 +1960,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
STu[c] = texvec[c] + 0.5f*dyt[c];
|
||||
}
|
||||
|
||||
// clear unused derivatives
|
||||
/* clear unused derivatives */
|
||||
for (c=nr_channels; c<3; c++) {
|
||||
STc[c] = 0.0f;
|
||||
STl[c] = 0.0f;
|
||||
@@ -1964,11 +1969,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
STu[c] = 0.0f;
|
||||
}
|
||||
|
||||
// use texres for the center sample, set rgbnor
|
||||
/* use texres for the center sample, set rgbnor */
|
||||
rgbnor = multitex_mtex(shi, mtex, STc, dxt, dyt, texres);
|
||||
/* Hc = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; */ /* UNUSED */
|
||||
|
||||
// use ttexr for the other taps
|
||||
/* use ttexr for the other taps */
|
||||
multitex_mtex(shi, mtex, STl, dxt, dyt, &ttexr);
|
||||
Hl = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin;
|
||||
multitex_mtex(shi, mtex, STr, dxt, dyt, &ttexr);
|
||||
@@ -1982,7 +1987,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
dHdy = Hscale*(Hu - Hd);
|
||||
}
|
||||
|
||||
// restore pointer
|
||||
/* restore pointer */
|
||||
texres->nor = nvec;
|
||||
|
||||
/* replaced newbump with code based on listing 1 and 2 of
|
||||
@@ -1994,32 +1999,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE )
|
||||
iBumpSpace = 2;
|
||||
else
|
||||
iBumpSpace = 4; // ViewSpace
|
||||
|
||||
iBumpSpace = 4; /* ViewSpace */
|
||||
|
||||
if ( ntap_bump->iPrevBumpSpace != iBumpSpace ) {
|
||||
|
||||
// initialize normal perturbation vectors
|
||||
|
||||
/* initialize normal perturbation vectors */
|
||||
int xyz;
|
||||
float fDet, abs_fDet, fMagnitude;
|
||||
// object2view and inverted matrix
|
||||
/* object2view and inverted matrix */
|
||||
float obj2view[3][3], view2obj[3][3], tmp[4][4];
|
||||
// local copies of derivatives and normal
|
||||
/* local copies of derivatives and normal */
|
||||
float dPdx[3], dPdy[3], vN[3];
|
||||
copy_v3_v3(dPdx, shi->dxco);
|
||||
copy_v3_v3(dPdy, shi->dyco);
|
||||
copy_v3_v3(vN, ntap_bump->vNorg);
|
||||
|
||||
if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
|
||||
// TODO: these calculations happen for every pixel!
|
||||
// -> move to shi->obi
|
||||
/* TODO: these calculations happen for every pixel!
|
||||
* -> move to shi->obi */
|
||||
mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat);
|
||||
copy_m3_m4(obj2view, tmp); // use only upper left 3x3 matrix
|
||||
copy_m3_m4(obj2view, tmp); /* use only upper left 3x3 matrix */
|
||||
invert_m3_m3(view2obj, obj2view);
|
||||
|
||||
// generate the surface derivatives in object space
|
||||
|
||||
/* generate the surface derivatives in object space */
|
||||
mul_m3_v3(view2obj, dPdx);
|
||||
mul_m3_v3(view2obj, dPdy);
|
||||
// generate the unit normal in object space
|
||||
/* generate the unit normal in object space */
|
||||
mul_transposed_m3_v3(obj2view, vN);
|
||||
normalize_v3(vN);
|
||||
}
|
||||
@@ -2032,7 +2037,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
|
||||
if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
|
||||
if (tex->ima) {
|
||||
// crazy hack solution that gives results similar to normal mapping - part 1
|
||||
/* crazy hack solution that gives results similar to normal mapping - part 1 */
|
||||
normalize_v3(ntap_bump->vR1);
|
||||
normalize_v3(ntap_bump->vR2);
|
||||
abs_fDet = 1.0f;
|
||||
@@ -2041,7 +2046,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
|
||||
fMagnitude = abs_fDet;
|
||||
if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) {
|
||||
// pre do transform of texres->nor by the inverse transposed of obj2view
|
||||
/* pre do transform of texres->nor by the inverse transposed of obj2view */
|
||||
mul_transposed_m3_v3(view2obj, vN);
|
||||
mul_transposed_m3_v3(view2obj, ntap_bump->vR1);
|
||||
mul_transposed_m3_v3(view2obj, ntap_bump->vR2);
|
||||
@@ -2059,7 +2064,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
|
||||
if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) {
|
||||
if (tex->ima) {
|
||||
// crazy hack solution that gives results similar to normal mapping - part 2
|
||||
/* crazy hack solution that gives results similar to normal mapping - part 2 */
|
||||
float vec[2];
|
||||
const float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x;
|
||||
|
||||
@@ -2072,11 +2077,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T
|
||||
}
|
||||
}
|
||||
|
||||
// subtract the surface gradient from vNacc
|
||||
/* subtract the surface gradient from vNacc */
|
||||
for (c=0; c<3; c++) {
|
||||
float vSurfGrad_compi = ntap_bump->sgn_det * (dHdx * ntap_bump->vR1[c] + dHdy * ntap_bump->vR2[c]);
|
||||
ntap_bump->vNacc[c] -= vSurfGrad_compi;
|
||||
texres->nor[c] = ntap_bump->vNacc[c]; // copy
|
||||
texres->nor[c] = ntap_bump->vNacc[c]; /* copy */
|
||||
}
|
||||
|
||||
rgbnor |= TEX_NOR;
|
||||
@@ -2235,7 +2240,9 @@ void do_material_tex(ShadeInput *shi, Render *re)
|
||||
dy[0]= 0.0f;
|
||||
dy[1]= dy[2]= 0.0f;
|
||||
}
|
||||
else continue; // can happen when texco defines disappear and it renders old files
|
||||
else {
|
||||
continue; /* can happen when texco defines disappear and it renders old files */
|
||||
}
|
||||
|
||||
/* the pointer defines if bumping happens */
|
||||
if (mtex->mapto & (MAP_NORM|MAP_WARP)) {
|
||||
@@ -2319,7 +2326,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
|
||||
texres.nor[2]= f2*co_nor-f1*si;
|
||||
}
|
||||
}
|
||||
// warping, local space
|
||||
/* warping, local space */
|
||||
if (mtex->mapto & MAP_WARP) {
|
||||
float *warpnor= texres.nor, warpnor_[3];
|
||||
|
||||
@@ -2335,11 +2342,11 @@ void do_material_tex(ShadeInput *shi, Render *re)
|
||||
}
|
||||
#if 0
|
||||
if (mtex->texflag & MTEX_VIEWSPACE) {
|
||||
// rotate to global coords
|
||||
/* rotate to global coords */
|
||||
if (mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) {
|
||||
if (shi->vlr && shi->obr && shi->obr->ob) {
|
||||
float len= normalize_v3(texres.nor);
|
||||
// can be optimized... (ton)
|
||||
/* can be optimized... (ton) */
|
||||
mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor);
|
||||
mul_mat3_m4_v3(re->viewmat, texres.nor);
|
||||
normalize_v3(texres.nor);
|
||||
@@ -2388,7 +2395,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
|
||||
if (mtex->mapto & MAP_COLMIR) {
|
||||
float mirrfac= mtex->mirrfac*stencilTin;
|
||||
|
||||
// exception for envmap only
|
||||
/* exception for envmap only */
|
||||
if (tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) {
|
||||
fact= texres.tin*mirrfac;
|
||||
facm= 1.0f- fact;
|
||||
@@ -2565,7 +2572,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
|
||||
else if (shi->alpha>1.0f) shi->alpha= 1.0f;
|
||||
}
|
||||
if (mtex->mapto & MAP_HAR) {
|
||||
float har; // have to map to 0-1
|
||||
float har; /* have to map to 0-1 */
|
||||
float hardfac= mtex->hardfac*stencilTin;
|
||||
|
||||
har= ((float)shi->har)/128.0f;
|
||||
@@ -2605,7 +2612,7 @@ void do_material_tex(ShadeInput *shi, Render *re)
|
||||
}
|
||||
if ((use_compat_bump || use_ntap_bump || found_nmapping) && (shi->mat->mode & MA_TANGENT_V) != 0) {
|
||||
const float fnegdot = -dot_v3v3(shi->vn, shi->tang);
|
||||
// apply Gram-Schmidt projection
|
||||
/* apply Gram-Schmidt projection */
|
||||
madd_v3_v3fl(shi->tang, shi->vn, fnegdot);
|
||||
normalize_v3(shi->tang);
|
||||
}
|
||||
@@ -2665,12 +2672,14 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_
|
||||
copy_v3_v3(co, xyz);
|
||||
mul_m4_v3(re->viewinv, co);
|
||||
}
|
||||
else continue; // can happen when texco defines disappear and it renders old files
|
||||
else {
|
||||
continue; /* can happen when texco defines disappear and it renders old files */
|
||||
}
|
||||
|
||||
texres.nor= NULL;
|
||||
|
||||
if (tex->type==TEX_IMAGE) {
|
||||
continue; /* not supported yet */
|
||||
if (tex->type == TEX_IMAGE) {
|
||||
continue; /* not supported yet */
|
||||
//do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt);
|
||||
}
|
||||
else {
|
||||
@@ -3381,7 +3390,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg,
|
||||
void render_realtime_texture(ShadeInput *shi, Image *ima)
|
||||
{
|
||||
TexResult texr;
|
||||
static Tex imatex[BLENDER_MAX_THREADS]; // threadsafe
|
||||
static Tex imatex[BLENDER_MAX_THREADS]; /* threadsafe */
|
||||
static int firsttime= 1;
|
||||
Tex *tex;
|
||||
float texvec[3], dx[2], dy[2];
|
||||
@@ -3409,7 +3418,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
|
||||
|
||||
texvec[0]= 0.5f+0.5f*suv->uv[0];
|
||||
texvec[1]= 0.5f+0.5f*suv->uv[1];
|
||||
texvec[2] = 0.0f; // initalize it because imagewrap looks at it.
|
||||
texvec[2] = 0.0f; /* initalize it because imagewrap looks at it. */
|
||||
if (shi->osatex) {
|
||||
dx[0]= 0.5f*suv->dxuv[0];
|
||||
dx[1]= 0.5f*suv->dxuv[1];
|
||||
|
||||
@@ -2098,12 +2098,12 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua
|
||||
|
||||
normalize_v3(nor); /* in case object has scaling */
|
||||
|
||||
// The invert of the red channel is to make
|
||||
// the normal map compliant with the outside world.
|
||||
// It needs to be done because in Blender
|
||||
// the normal used in the renderer points inward. It is generated
|
||||
// this way in calc_vertexnormals(). Should this ever change
|
||||
// this negate must be removed.
|
||||
/* The invert of the red channel is to make
|
||||
* the normal map compliant with the outside world.
|
||||
* It needs to be done because in Blender
|
||||
* the normal used in the renderer points inward. It is generated
|
||||
* this way in calc_vertexnormals(). Should this ever change
|
||||
* this negate must be removed. */
|
||||
shr.combined[0]= (-nor[0])/2.0f + 0.5f;
|
||||
shr.combined[1]= nor[1]/2.0f + 0.5f;
|
||||
shr.combined[2]= nor[2]/2.0f + 0.5f;
|
||||
|
||||
@@ -1561,9 +1561,9 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem)
|
||||
right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch));
|
||||
|
||||
/* new sample array */
|
||||
left->samples= BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *));
|
||||
right->samples= samples; // tmp
|
||||
|
||||
left->samples = BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *));
|
||||
right->samples = samples; /* tmp */
|
||||
|
||||
/* split samples */
|
||||
for (a=BSPMAX_SAMPLE-1; a>=0; a--) {
|
||||
int comp= 0;
|
||||
@@ -1824,7 +1824,7 @@ static void isb_bsp_face_inside(ISBBranch *bspn, BSPFace *face)
|
||||
|
||||
if ((samp->facenr!=face->facenr || samp->obi!=face->obi) && samp->shadfac) {
|
||||
if (face->box.zmin < samp->zco[2]) {
|
||||
if (BLI_in_rctf((rctf *)&face->box, samp->zco[0], samp->zco[1])) {
|
||||
if (BLI_in_rctf_v((rctf *)&face->box, samp->zco)) {
|
||||
int inshadow= 0;
|
||||
|
||||
if (face->type) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -173,7 +173,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens)
|
||||
p1[1]= shi->co[1]-lar->co[1];
|
||||
p1[2]= -lar->co[2];
|
||||
mul_m3_v3(lar->imat, p1);
|
||||
copy_v3db_v3fl(npos, p1); // npos is double!
|
||||
copy_v3db_v3fl(npos, p1); /* npos is double! */
|
||||
|
||||
/* pre-scale */
|
||||
npos[2] *= (double)lar->sh_zfac;
|
||||
@@ -371,11 +371,12 @@ void renderspothalo(ShadeInput *shi, float col[4], float alpha)
|
||||
continue;
|
||||
|
||||
spothalo(lar, shi, &i);
|
||||
if (i>0.0f) {
|
||||
col[3]+= i*alpha; // all premul
|
||||
col[0]+= i*lar->r*alpha;
|
||||
col[1]+= i*lar->g*alpha;
|
||||
col[2]+= i*lar->b*alpha;
|
||||
if (i > 0.0f) {
|
||||
const float i_alpha = i * alpha;
|
||||
col[0] += i_alpha * lar->r;
|
||||
col[1] += i_alpha * lar->g;
|
||||
col[2] += i_alpha * lar->b;
|
||||
col[3] += i_alpha; /* all premul */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,7 +520,7 @@ static float area_lamp_energy_multisample(LampRen *lar, const float co[3], float
|
||||
}
|
||||
intens /= (float)lar->ray_totsamp;
|
||||
|
||||
return pow(intens*lar->areasize, lar->k); // corrected for buttons size and lar->dist^2
|
||||
return pow(intens * lar->areasize, lar->k); /* corrected for buttons size and lar->dist^2 */
|
||||
}
|
||||
|
||||
static float spec(float inp, int hard)
|
||||
@@ -932,7 +933,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa
|
||||
|
||||
/* MA_RAMP_IN_RESULT is exceptional */
|
||||
if (ma->rampin_col==MA_RAMP_IN_RESULT) {
|
||||
// normal add
|
||||
/* normal add */
|
||||
diff[0] += r * shi->r;
|
||||
diff[1] += g * shi->g;
|
||||
diff[2] += b * shi->b;
|
||||
@@ -1368,10 +1369,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
|
||||
|
||||
/* diffuse shaders */
|
||||
if (lar->mode & LA_NO_DIFF) {
|
||||
is= 0.0f; // skip shaders
|
||||
is = 0.0f; /* skip shaders */
|
||||
}
|
||||
else if (lar->type==LA_HEMI) {
|
||||
is= 0.5f*inp + 0.5f;
|
||||
is = 0.5f * inp + 0.5f;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1383,12 +1384,13 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
|
||||
else if (ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]);
|
||||
else if (ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness);
|
||||
else if (ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]);
|
||||
else is= inp; // Lambert
|
||||
else is= inp; /* Lambert */
|
||||
}
|
||||
|
||||
|
||||
/* 'is' is diffuse */
|
||||
if ((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f)
|
||||
is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades
|
||||
if ((ma->shade_flag & MA_CUBIC) && is > 0.0f && is < 1.0f) {
|
||||
is= 3.0f * is * is - 2.0f * is * is * is; /* nicer termination of shades */
|
||||
}
|
||||
|
||||
i= is*phongcorr;
|
||||
|
||||
@@ -1397,7 +1399,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
|
||||
}
|
||||
i_noshad= i;
|
||||
|
||||
vn= shi->vn; // bring back original vector, we use special specular shaders for tangent
|
||||
vn = shi->vn; /* bring back original vector, we use special specular shaders for tangent */
|
||||
if (ma->mode & MA_TANGENT_V)
|
||||
vn= shi->tang;
|
||||
|
||||
@@ -1734,7 +1736,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
|
||||
return;
|
||||
}
|
||||
|
||||
if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light
|
||||
if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { /* vertexcolor light */
|
||||
shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]);
|
||||
shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]);
|
||||
shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]);
|
||||
@@ -1755,8 +1757,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
|
||||
if (shi->depth || shi->volume_depth)
|
||||
ambient_occlusion(shi);
|
||||
copy_v3_v3(shr->ao, shi->ao);
|
||||
copy_v3_v3(shr->env, shi->env); // XXX multiply
|
||||
copy_v3_v3(shr->indirect, shi->indirect); // XXX multiply
|
||||
copy_v3_v3(shr->env, shi->env); /* XXX multiply */
|
||||
copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b
|
||||
|
||||
DirectionToThetaPhi(sunsky->toSun, &sunsky->theta, &sunsky->phi);
|
||||
|
||||
sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); // = 6.7443e-05
|
||||
sunsky->sunSolidAngle = 0.25 * M_PI * 1.39 * 1.39 / (150 * 150); /* = 6.7443e-05 */
|
||||
|
||||
theta2 = sunsky->theta * sunsky->theta;
|
||||
theta3 = theta2 * sunsky->theta;
|
||||
@@ -183,7 +183,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b
|
||||
|
||||
chi = (4.0f / 9.0f - T / 120.0f) * ((float)M_PI - 2.0f * sunsky->theta);
|
||||
sunsky->zenith_Y = (4.0453f * T - 4.9710f) * tanf(chi) - 0.2155f * T + 2.4192f;
|
||||
sunsky->zenith_Y *= 1000; // conversion from kcd/m^2 to cd/m^2
|
||||
sunsky->zenith_Y *= 1000; /* conversion from kcd/m^2 to cd/m^2 */
|
||||
|
||||
if (sunsky->zenith_Y <= 0)
|
||||
sunsky->zenith_Y = 1e-6;
|
||||
@@ -272,7 +272,7 @@ void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float colo
|
||||
|
||||
gamma = AngleBetween(theta, phi, sunsky->theta, sunsky->phi);
|
||||
|
||||
// Compute xyY values
|
||||
/* Compute xyY values */
|
||||
x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x);
|
||||
y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y);
|
||||
Y = 6.666666667e-5f *nfade *hfade *PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y);
|
||||
@@ -340,13 +340,13 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3])
|
||||
m = 1.0f / (cosf(theta) + 0.15f * powf(93.885f - theta / (float)M_PI * 180.0f, -1.253f));
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
// Rayleigh Scattering
|
||||
/* Rayleigh Scattering */
|
||||
fTauR = expf(-m * 0.008735f * powf(fLambda[i], (float)(-4.08f)));
|
||||
|
||||
// Aerosal (water + dust) attenuation
|
||||
/* Aerosal (water + dust) attenuation */
|
||||
fTauA = exp(-m * fBeta * powf(fLambda[i], -fAlpha));
|
||||
|
||||
fTau[i] = fTauR * fTauA;
|
||||
fTau[i] = fTauR * fTauA;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r
|
||||
float inscattf, float extincf, float disf)
|
||||
{
|
||||
const float pi = M_PI;
|
||||
const float n = 1.003f; // refractive index
|
||||
const float n = 1.003f; /* refractive index */
|
||||
const float N = 2.545e25;
|
||||
const float pn = 0.035f;
|
||||
const float T = 2.0f;
|
||||
@@ -406,16 +406,16 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r
|
||||
vLambda4[1] = fLambda4[1];
|
||||
vLambda4[2] = fLambda4[2];
|
||||
|
||||
// Rayleigh scattering constants.
|
||||
/* Rayleigh scattering constants. */
|
||||
fTemp = pi * pi * (n * n - 1) * (n * n - 1) * (6 + 3 * pn) / (6 - 7 * pn) / N;
|
||||
fBeta = 8 * fTemp * pi / 3;
|
||||
|
||||
|
||||
VEC3OPF(sunSky->atm_BetaRay, vLambda4, *, fBeta);
|
||||
fBetaDash = fTemp / 2;
|
||||
VEC3OPF(sunSky->atm_BetaDashRay, vLambda4, *, fBetaDash);
|
||||
|
||||
|
||||
// Mie scattering constants.
|
||||
|
||||
/* Mie scattering constants. */
|
||||
fTemp2 = 0.434f * c * (2 * pi) * (2 * pi) * 0.5f;
|
||||
VEC3OPF(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2);
|
||||
|
||||
@@ -457,23 +457,23 @@ void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float
|
||||
sunDirection[0] = sunSky->toSun[0];
|
||||
sunDirection[1] = sunSky->toSun[1];
|
||||
sunDirection[2] = sunSky->toSun[2];
|
||||
|
||||
costheta = dot_v3v3(view, sunDirection); // cos(theta)
|
||||
Phase_1 = 1 + (costheta * costheta); // Phase_1
|
||||
|
||||
|
||||
costheta = dot_v3v3(view, sunDirection); /* cos(theta) */
|
||||
Phase_1 = 1 + (costheta * costheta); /* Phase_1 */
|
||||
|
||||
VEC3OPF(sunSky->atm_BetaRay, sunSky->atm_BetaRay, *, sunSky->atm_BetaRayMultiplier);
|
||||
VEC3OPF(sunSky->atm_BetaMie, sunSky->atm_BetaMie, *, sunSky->atm_BetaMieMultiplier);
|
||||
VEC3OPV(sunSky->atm_BetaRM, sunSky->atm_BetaRay, +, sunSky->atm_BetaMie);
|
||||
|
||||
//e^(-(beta_1 + beta_2) * s) = E1
|
||||
|
||||
/* e^(-(beta_1 + beta_2) * s) = E1 */
|
||||
VEC3OPF(E1, sunSky->atm_BetaRM, *, -s / (float)M_LN2);
|
||||
E1[0] = exp(E1[0]);
|
||||
E1[1] = exp(E1[1]);
|
||||
E1[2] = exp(E1[2]);
|
||||
|
||||
copy_v3_v3(E, E1);
|
||||
|
||||
//Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2)
|
||||
|
||||
/* Phase2(theta) = (1-g^2)/(1+g-2g*cos(theta))^(3/2) */
|
||||
fTemp = 1 + sunSky->atm_HGg - 2 * sunSky->atm_HGg * costheta;
|
||||
fTemp = fTemp * sqrtf(fTemp);
|
||||
Phase_2 = (1 - sunSky->atm_HGg * sunSky->atm_HGg) / fTemp;
|
||||
@@ -491,8 +491,8 @@ void AtmospherePixleShader(struct SunSky *sunSky, float view[3], float s, float
|
||||
|
||||
VEC3OPF(I, I, *, sunSky->atm_InscatteringMultiplier);
|
||||
VEC3OPF(E, E, *, sunSky->atm_ExtinctionMultiplier);
|
||||
|
||||
//scale to color sun
|
||||
|
||||
/* scale to color sun */
|
||||
ComputeAttenuatedSunlight(sunSky->theta, sunSky->turbidity, sunColor);
|
||||
VEC3OPV(E, E, *, sunColor);
|
||||
|
||||
|
||||
@@ -81,12 +81,12 @@ int ocean_texture(Tex *tex, float *texvec, TexResult *texres)
|
||||
if (omd->oceancache && omd->cached == TRUE) {
|
||||
|
||||
CLAMP(cfra, omd->bakestart, omd->bakeend);
|
||||
cfra -= omd->bakestart; // shift to 0 based
|
||||
cfra -= omd->bakestart; /* shift to 0 based */
|
||||
|
||||
BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v);
|
||||
|
||||
}
|
||||
else { // non-cached
|
||||
else { /* non-cached */
|
||||
|
||||
if (G.rendering)
|
||||
BKE_ocean_eval_uv_catrom(omd->ocean, &ocr, u, v);
|
||||
|
||||
@@ -261,14 +261,14 @@ static void lightcache_filter2(VolumePrecache *vp)
|
||||
}
|
||||
#endif
|
||||
|
||||
BLI_INLINE int ms_I(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation
|
||||
{
|
||||
BLI_INLINE int ms_I(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */
|
||||
{
|
||||
/* different ordering to light cache */
|
||||
return x*(n[1]+2)*(n[2]+2) + y*(n[2]+2) + z;
|
||||
return x*(n[1]+2)*(n[2]+2) + y*(n[2]+2) + z;
|
||||
}
|
||||
|
||||
BLI_INLINE int v_I_pad(int x, int y, int z, int *n) //has a pad of 1 voxel surrounding the core for boundary simulation
|
||||
{
|
||||
BLI_INLINE int v_I_pad(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */
|
||||
{
|
||||
/* same ordering to light cache, with padding */
|
||||
return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x;
|
||||
}
|
||||
@@ -465,7 +465,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi
|
||||
|
||||
|
||||
|
||||
#if 0 // debug stuff
|
||||
#if 0 /* debug stuff */
|
||||
static void *vol_precache_part_test(void *data)
|
||||
{
|
||||
VolPrecachePart *pa = data;
|
||||
@@ -526,10 +526,10 @@ static void *vol_precache_part(void *data)
|
||||
|
||||
/* convert from world->camera space for shading */
|
||||
mul_v3_m4v3(cco, pa->viewmat, co);
|
||||
|
||||
|
||||
i = BLI_VOXEL_INDEX(x, y, z, res);
|
||||
|
||||
// don't bother if the point is not inside the volume mesh
|
||||
|
||||
/* don't bother if the point is not inside the volume mesh */
|
||||
if (!point_inside_obi(tree, obi, cco)) {
|
||||
obi->volume_precache->data_r[i] = -1.0f;
|
||||
obi->volume_precache->data_g[i] = -1.0f;
|
||||
@@ -563,7 +563,7 @@ static void precache_setup_shadeinput(Render *re, ObjectInstanceRen *obi, Materi
|
||||
shi->mask= 1;
|
||||
shi->mat = ma;
|
||||
shi->vlr = NULL;
|
||||
memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); // note, keep this synced with render_types.h
|
||||
memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); /* note, keep this synced with render_types.h */
|
||||
shi->har= shi->mat->har;
|
||||
shi->obi= obi;
|
||||
shi->obr= obi->obr;
|
||||
@@ -757,7 +757,8 @@ static void vol_precache_objectinstance_threads(Render *re, ObjectInstanceRen *o
|
||||
BLI_freelistN(&re->volume_precache_parts);
|
||||
|
||||
if (tree) {
|
||||
//TODO: makeraytree_object creates a tree and saves it on OBI, if we free this tree we should also clear other pointers to it
|
||||
/* TODO: makeraytree_object creates a tree and saves it on OBI,
|
||||
* if we free this tree we should also clear other pointers to it */
|
||||
//RE_rayobject_free(tree);
|
||||
//tree= NULL;
|
||||
}
|
||||
|
||||
@@ -253,9 +253,9 @@ static float metadensity(Object *ob, const float co[3])
|
||||
/* element rotation transform */
|
||||
float tp[3] = {ml->x - tco[0], ml->y - tco[1], ml->z - tco[2]};
|
||||
quat_to_mat3(bmat, ml->quat);
|
||||
transpose_m3(bmat); // rot.only, so inverse == transpose
|
||||
transpose_m3(bmat); /* rot.only, so inverse == transpose */
|
||||
mul_m3_v3(bmat, tp);
|
||||
|
||||
|
||||
/* MB_BALL default */
|
||||
switch (ml->type) {
|
||||
case MB_ELIPSOID:
|
||||
@@ -263,14 +263,14 @@ static float metadensity(Object *ob, const float co[3])
|
||||
break;
|
||||
case MB_CUBE:
|
||||
tp[2] = (tp[2] > ml->expz) ? (tp[2] - ml->expz) : ((tp[2] < -ml->expz) ? (tp[2] + ml->expz) : 0.f);
|
||||
// no break, xy as plane
|
||||
/* no break, xy as plane */
|
||||
case MB_PLANE:
|
||||
tp[1] = (tp[1] > ml->expy) ? (tp[1] - ml->expy) : ((tp[1] < -ml->expy) ? (tp[1] + ml->expy) : 0.f);
|
||||
// no break, x as tube
|
||||
/* no break, x as tube */
|
||||
case MB_TUBE:
|
||||
tp[0] = (tp[0] > ml->expx) ? (tp[0] - ml->expx) : ((tp[0] < -ml->expx) ? (tp[0] + ml->expx) : 0.f);
|
||||
}
|
||||
|
||||
|
||||
/* ml->rad2 is not set */
|
||||
dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad));
|
||||
if (dist2 > 0.f)
|
||||
@@ -289,7 +289,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3])
|
||||
if (shi->mat->mapto_textured & MAP_DENSITY)
|
||||
do_volume_tex(shi, co, MAP_DENSITY, NULL, &density, &R);
|
||||
|
||||
// if meta-object, modulate by metadensity without increasing it
|
||||
/* if meta-object, modulate by metadensity without increasing it */
|
||||
if (shi->obi->obr->ob->type == OB_MBALL) {
|
||||
const float md = metadensity(shi->obi->obr->ob, co);
|
||||
if (md < 1.f) density *= md;
|
||||
|
||||
@@ -240,7 +240,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
copy_v3_v3_int(vd->resol, smd->domain->res);
|
||||
totRes = vd_resol_size(vd);
|
||||
|
||||
// scaling heat values from -2.0-2.0 to 0.0-1.0
|
||||
/* scaling heat values from -2.0-2.0 to 0.0-1.0 */
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
|
||||
|
||||
|
||||
@@ -250,7 +250,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
vd->dataset[i] = (heat[i] + 2.0f) / 4.0f;
|
||||
}
|
||||
|
||||
//vd->dataset = smoke_get_heat(smd->domain->fluid);
|
||||
/* vd->dataset = smoke_get_heat(smd->domain->fluid); */
|
||||
}
|
||||
else if (vd->smoked_type == TEX_VD_SMOKEVEL) {
|
||||
size_t totRes;
|
||||
@@ -260,7 +260,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
copy_v3_v3_int(vd->resol, smd->domain->res);
|
||||
totRes = vd_resol_size(vd);
|
||||
|
||||
// scaling heat values from -2.0-2.0 to 0.0-1.0
|
||||
/* scaling heat values from -2.0-2.0 to 0.0-1.0 */
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
|
||||
|
||||
xvel = smoke_get_velocity_x(smd->domain->fluid);
|
||||
@@ -290,7 +290,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra)
|
||||
/* always store copy, as smoke internal data can change */
|
||||
vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data");
|
||||
memcpy(vd->dataset, density, sizeof(float) * totRes);
|
||||
} // end of fluid condition
|
||||
} /* end of fluid condition */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -466,7 +466,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co
|
||||
vergz= v1[2];
|
||||
vergz-= zspan->polygon_offset;
|
||||
dz= (v2[2]-v1[2])/dx;
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
|
||||
|
||||
rectz= (int *)(zspan->arectz+zspan->rectx*(oldy) +start);
|
||||
rectmask= (int *)(zspan->rectmask+zspan->rectx*(oldy) +start);
|
||||
@@ -537,7 +537,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co
|
||||
vergz= v1[2];
|
||||
vergz-= zspan->polygon_offset;
|
||||
dz= (v2[2]-v1[2])/dy;
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
|
||||
|
||||
rectz= (int *)( zspan->arectz+ (start)*zspan->rectx+ oldx );
|
||||
rectmask= (int *)( zspan->rectmask+ (start)*zspan->rectx+ oldx );
|
||||
@@ -619,7 +619,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons
|
||||
|
||||
vergz= floor(v1[2]);
|
||||
dz= floor((v2[2]-v1[2])/dx);
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
|
||||
|
||||
rectz= zspan->rectz + oldy*zspan->rectx+ start;
|
||||
rectp= zspan->rectp + oldy*zspan->rectx+ start;
|
||||
@@ -678,7 +678,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons
|
||||
|
||||
vergz= floor(v1[2]);
|
||||
dz= floor((v2[2]-v1[2])/dy);
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
|
||||
|
||||
rectz= zspan->rectz + start*zspan->rectx+ oldx;
|
||||
rectp= zspan->rectp + start*zspan->rectx+ oldx;
|
||||
@@ -749,7 +749,7 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con
|
||||
|
||||
vergz= floor(v1[2]);
|
||||
dz= floor((v2[2]-v1[2])/dx);
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
|
||||
|
||||
rectz= zspan->rectz + oldy*zspan->rectx+ start;
|
||||
if (zspan->rectz1)
|
||||
@@ -806,8 +806,8 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con
|
||||
|
||||
vergz= floor(v1[2]);
|
||||
dz= floor((v2[2]-v1[2])/dy);
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow
|
||||
|
||||
if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */
|
||||
|
||||
rectz= zspan->rectz + start*zspan->rectx+ oldx;
|
||||
if (zspan->rectz1)
|
||||
rectz1= zspan->rectz1 + start*zspan->rectx+ oldx;
|
||||
@@ -1447,21 +1447,21 @@ void zspan_scanconvert_strand(ZSpan *zspan, void *handle, float *v1, float *v2,
|
||||
zxd= -(double)x0/(double)z0;
|
||||
zyd= -(double)y0/(double)z0;
|
||||
zy0= ((double)my2)*zyd + (double)xx1;
|
||||
|
||||
z1= 1.0f; // (u1 - u2)
|
||||
z2= 0.0f; // (u2 - u3)
|
||||
|
||||
z1= 1.0f; /* (u1 - u2) */
|
||||
z2= 0.0f; /* (u2 - u3) */
|
||||
|
||||
x0= y1*z2-z1*y2;
|
||||
y0= z1*x2-x1*z2;
|
||||
|
||||
xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f;
|
||||
|
||||
xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f;
|
||||
uxd= -(double)x0/(double)z0;
|
||||
uyd= -(double)y0/(double)z0;
|
||||
uy0= ((double)my2)*uyd + (double)xx1;
|
||||
|
||||
z1= -1.0f; // (v1 - v2)
|
||||
z2= 1.0f; // (v2 - v3)
|
||||
|
||||
z1= -1.0f; /* (v1 - v2) */
|
||||
z2= 1.0f; /* (v2 - v3) */
|
||||
|
||||
x0= y1*z2-z1*y2;
|
||||
y0= z1*x2-x1*z2;
|
||||
|
||||
@@ -1535,23 +1535,23 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float *
|
||||
y1= v1[1]- v2[1];
|
||||
y2= v2[1]- v3[1];
|
||||
|
||||
z1= 1.0f; // (u1 - u2)
|
||||
z2= 0.0f; // (u2 - u3)
|
||||
|
||||
z1= 1.0f; /* (u1 - u2) */
|
||||
z2= 0.0f; /* (u2 - u3) */
|
||||
|
||||
x0= y1*z2-z1*y2;
|
||||
y0= z1*x2-x1*z2;
|
||||
z0= x1*y2-y1*x2;
|
||||
|
||||
|
||||
if (z0==0.0f) return;
|
||||
|
||||
xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f;
|
||||
|
||||
xx1= (x0*v1[0] + y0*v1[1])/z0 + 1.0f;
|
||||
uxd= -(double)x0/(double)z0;
|
||||
uyd= -(double)y0/(double)z0;
|
||||
uy0= ((double)my2)*uyd + (double)xx1;
|
||||
|
||||
z1= -1.0f; // (v1 - v2)
|
||||
z2= 1.0f; // (v2 - v3)
|
||||
|
||||
z1= -1.0f; /* (v1 - v2) */
|
||||
z2= 1.0f; /* (v2 - v3) */
|
||||
|
||||
x0= y1*z2-z1*y2;
|
||||
y0= z1*x2-x1*z2;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user