[Bf-committers] Re: Texture.c patch for hard coded values
GSR - FR
famrom at infernal-iceberg.com
Tue Mar 8 17:58:57 CET 2005
Hi,
hmetalcowgirl at cowgirl.exenex.com (2005-03-07 at 1720.38 -0500):
> This is a simple patch, I just changed the hard coded return values
> for textures to defines as listed in DNA_texture_type.h. Desoto will
> probably commit, but if you want to get it before he does, here it is.
> No hurry.
I have a different version based in your patch. It uses the defines in
more places, shows the return value is a bit field more clearly and
also reports the peculiarity that stucci has.
GSR
-------------- next part --------------
Index: source/blender/render/intern/source/texture.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/render/intern/source/texture.c,v
retrieving revision 1.40
diff -u -p -r1.40 texture.c
--- source/blender/render/intern/source/texture.c 7 Mar 2005 12:41:23 -0000 1.40
+++ source/blender/render/intern/source/texture.c 8 Mar 2005 16:28:01 -0000
@@ -313,7 +313,7 @@ static int blend(Tex *tex, float *texvec
BRICONT;
- return 0;
+ return TEX_INT;
}
/* ------------------------------------------------------------------------- */
@@ -323,7 +323,7 @@ static int blend(Tex *tex, float *texvec
static int clouds(Tex *tex, float *texvec, TexResult *texres)
{
- int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int rv = TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
@@ -334,7 +334,7 @@ static int clouds(Tex *tex, float *texve
texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
tex_normal_derivate(tex, texres);
- rv += 2;
+ rv |= TEX_NOR;
}
if (tex->stype==1) {
@@ -345,7 +345,7 @@ static int clouds(Tex *tex, float *texve
texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
BRICONTRGB;
texres->ta = 1.0;
- return (rv+1);
+ return (rv | TEX_RGB);
}
BRICONT;
@@ -428,7 +428,7 @@ static int wood(Tex *tex, float *texvec,
texres->nor[2] = wood_int(tex, texvec[0], texvec[1], texvec[2] + tex->nabla);
tex_normal_derivate(tex, texres);
- rv = TEX_NOR;
+ rv |= TEX_NOR;
}
BRICONT;
@@ -481,7 +481,7 @@ static int marble(Tex *tex, float *texve
tex_normal_derivate(tex, texres);
- rv = TEX_NOR;
+ rv |= TEX_NOR;
}
BRICONT;
@@ -561,7 +561,7 @@ static int magic(Tex *tex, float *texvec
BRICONTRGB;
texres->ta= 1.0;
- return 1;
+ return TEX_RGB;
}
/* ------------------------------------------------------------------------- */
@@ -571,11 +571,14 @@ static int stucci(Tex *tex, float *texve
{
float b2, ofs;
+ /* Special case: same value than TEX_INT but no same meaning because
+ when using colour band it uses tex_normal_derivate(). So it's
+ on purpose that texres->tin is only computed if textes->nor[] is too */
if(texres->nor == NULL) return 0;
+ texres->tin=b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
ofs= tex->turbul/200.0;
- texres->tin=b2= BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
if(tex->stype) ofs*=(b2*b2);
texres->nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
texres->nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
@@ -589,7 +592,7 @@ static int stucci(Tex *tex, float *texve
texres->nor[2]= -texres->nor[2];
}
- return 2;
+ return TEX_NOR;
}
/* ------------------------------------------------------------------------- */
@@ -597,7 +600,7 @@ static int stucci(Tex *tex, float *texve
static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres)
{
- int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int rv = TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
float (*mgravefunc)(float, float, float, float, float, float, int);
if (tex->stype==TEX_MFRACTAL)
@@ -616,7 +619,7 @@ static float mg_mFractalOrfBmTex(Tex *te
texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis);
tex_normal_derivate(tex, texres);
- rv += 2;
+ rv |= TEX_NOR;
}
BRICONT;
@@ -627,7 +630,7 @@ static float mg_mFractalOrfBmTex(Tex *te
static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres)
{
- int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int rv = TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
float (*mgravefunc)(float, float, float, float, float, float, float, float, int);
if (tex->stype==TEX_RIDGEDMF)
@@ -646,7 +649,7 @@ static float mg_ridgedOrHybridMFTex(Tex
texres->nor[2] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis);
tex_normal_derivate(tex, texres);
- rv += 2;
+ rv |= TEX_NOR;
}
BRICONT;
@@ -658,7 +661,7 @@ static float mg_ridgedOrHybridMFTex(Tex
static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres)
{
- int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int rv = TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
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);
@@ -671,7 +674,7 @@ static float mg_HTerrainTex(Tex *tex, fl
texres->nor[2] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2] + offs, tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis);
tex_normal_derivate(tex, texres);
- rv += 2;
+ rv |= TEX_NOR;
}
BRICONT;
@@ -683,7 +686,7 @@ static float mg_HTerrainTex(Tex *tex, fl
static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres)
{
- int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int rv = TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2);
@@ -696,7 +699,7 @@ static float mg_distNoiseTex(Tex *tex, f
texres->nor[2] = mg_VLNoise(texvec[0], texvec[1], texvec[2] + offs, tex->dist_amount, tex->noisebasis, tex->noisebasis2);
tex_normal_derivate(tex, texres);
- rv += 2;
+ rv |= TEX_NOR;
}
BRICONT;
@@ -712,7 +715,7 @@ static float mg_distNoiseTex(Tex *tex, f
static float voronoiTex(Tex *tex, float *texvec, TexResult *texres)
{
- int rv=0; /* return value, int:0, col:1, nor:2, everything:3 */
+ int rv = TEX_INT; /* return value, int:0, col:1, nor:2, everything:3 */
float da[4], pa[12]; /* distance and point coordinate arrays of 4 nearest neighbours */
float aw1 = fabs(tex->vn_w1);
float aw2 = fabs(tex->vn_w2);
@@ -769,13 +772,13 @@ static float voronoiTex(Tex *tex, float
texres->nor[2] = sc * fabs(tex->vn_w1*da[0] + tex->vn_w2*da[1] + tex->vn_w3*da[2] + tex->vn_w4*da[3]);
tex_normal_derivate(tex, texres);
- rv += 2;
+ rv |= TEX_NOR;
}
if (tex->vn_coltype) {
BRICONTRGB;
texres->ta = 1.0;
- return (rv+1);
+ return (rv | TEX_RGB);
}
BRICONT;
@@ -805,7 +808,7 @@ static int texnoise(Tex *tex, TexResult
texres->tin= ((float)val)/div;;
BRICONT;
- return 0;
+ return TEX_INT;
}
/* ------------------------------------------------------------------------- */
More information about the Bf-committers
mailing list