[Bf-committers] More Woody Goody
Ton Roosendaal
ton at blender.org
Sat Mar 5 15:07:45 CET 2005
Hi,
> AND the corresponding screen shots I promised:
> http://blender.spaceisbig.com/wood/index.htm
Hah, very cool page! You choose a ColorBand which made old wood look
quite bad, you sneaky american! :)
I tested the previous patch... not much time to review this version
fully again, so what actually changed in woody 4.0?
Thanks, this new wood is a real improvement!
-Ton-
> Enjoy :)
>
> Regards,
> --Chris
> 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.38
> diff -u -p -u -r1.38 texture.c
> --- source/blender/render/intern/source/texture.c 25 Feb 2005 12:19:42
> -0000 1.38
> +++ source/blender/render/intern/source/texture.c 4 Mar 2005 03:18:21
> -0000
> @@ -354,30 +354,71 @@ static int clouds(Tex *tex, float *texve
>
> }
>
> +/* creates a sine wave */
> +static float wood_sin(float a)
> +{
> + a = 0.5 + 0.5*sin(a);
> +
> + return a;
> +}
> +
> +/* creates a saw wave */
> +static float wood_saw(float a)
> +{
> + const float b = 2*M_PI;
> +
> + int n = (int)(a / b);
> + a -= n*b;
> + if (a < 0) a += b;
> + return a / b;
> +}
> +
> +/* creates a triangle wave */
> +static float wood_tri(float a)
> +{
> + const float b = 2*M_PI;
> + const float rmax = 1.0;
> +
> + a = rmax - 2.0*fabs(floor((a*(1.0/b))+0.5) - (a*(1.0/b)));
> +
> + return a;
> +}
> +
> /* computes basic wood intensity value at x,y,z */
> static float wood_int(Tex *tex, float x, float y, float z)
> {
> - float wi=0;
> + float wi=0;
> + short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1,
> TEX_TRI=2 */
> + short wt = tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1,
> TEX_BANDNOISE=2, TEX_RINGNOISE=3 */
>
> - if (tex->stype==0)
> - wi = 0.5 + 0.5*sin((x + y + z)*10.0);
> - else if (tex->stype==1)
> - wi = 0.5 + 0.5*sin(sqrt(x*x + y*y + z*z)*20.0);
> - else if (tex->stype==2) {
> - wi = BLI_gNoise(tex->noisesize, x, y, z,
> (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
> - wi = 0.5 + 0.5*sin(tex->turbul*wi + (x + y + z)*10.0);
> + float (*waveform[3])(float); /* create array of pointers to waveform
> functions */
> + waveform[0] = wood_sin; /* assign address of wood_sin() function
> to pointer array */
> + waveform[1] = wood_saw;
> + waveform[2] = wood_tri;
> +
> + if ((wf>TEX_TRI) || (wf<TEX_SIN)) wf=0; /* check to be sure
> noisebasis2 is initialized ahead of time */
> +
> + if (wt==TEX_BAND) {
> + wi = waveform[wf]((x + y + z)*10.0);
> }
> - else if (tex->stype==3) {
> - wi = BLI_gNoise(tex->noisesize, x, y, z,
> (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
> - wi = 0.5 + 0.5*sin(tex->turbul*wi + (sqrt(x*x + y*y + z*z))*20.0);
> + else if (wt==TEX_RING) {
> + wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0);
> }
> -
> + else if (wt==TEX_BANDNOISE) {
> + wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z,
> (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
> + wi = waveform[wf]((x + y + z)*10.0 + wi);
> + }
> + else if (wt==TEX_RINGNOISE) {
> + wi = tex->turbul*BLI_gNoise(tex->noisesize, x, y, z,
> (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis);
> + wi = waveform[wf](sqrt(x*x + y*y + z*z)*20.0 + wi);
> + }
> +
> return wi;
> }
>
> static int wood(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 = wood_int(tex, texvec[0], texvec[1], texvec[2]);
> if (texres->nor!=NULL) {
> @@ -387,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 += 2;
> + rv = TEX_NOR;
> }
>
> BRICONT;
> Index: source/blender/makesdna/DNA_texture_types.h
> ===================================================================
> RCS file:
> /cvsroot/bf-blender/blender/source/blender/makesdna/
> DNA_texture_types.h,v
> retrieving revision 1.17
> diff -u -p -u -r1.17 DNA_texture_types.h
> --- source/blender/makesdna/DNA_texture_types.h 27 Dec 2004 19:28:49
> -0000 1.17
> +++ source/blender/makesdna/DNA_texture_types.h 4 Mar 2005 03:18:21
> -0000
> @@ -243,6 +243,16 @@ typedef struct Tex {
> #define TEX_NOISESOFT 0
> #define TEX_NOISEPERL 1
>
> +/* tex->noisebasis2 in texture.c - wood waveforms */
> +#define TEX_SIN 0
> +#define TEX_SAW 1
> +#define TEX_TRI 2
> +/* tex->stype in texture.c - wood types */
> +#define TEX_BAND 0
> +#define TEX_RING 1
> +#define TEX_BANDNOISE 2
> +#define TEX_RINGNOISE 3
> +
> /* wrap */
> #define MTEX_FLAT 0
> #define MTEX_CUBE 1
> Index: source/blender/src/buttons_shading.c
> ===================================================================
> RCS file:
> /cvsroot/bf-blender/blender/source/blender/src/buttons_shading.c,v
> retrieving revision 1.120
> diff -u -p -u -r1.120 buttons_shading.c
> --- source/blender/src/buttons_shading.c 2 Feb 2005 17:26:24
> -0000 1.120
> +++ source/blender/src/buttons_shading.c 4 Mar 2005 03:18:22 -0000
> @@ -882,10 +882,13 @@ static void texture_panel_wood(Tex *tex)
> uiDefButS(block, ROW, B_TEXPRV, "Bands", 10, 180, 75, 18,
> &tex->stype, 2.0, 0.0, 0, 0, "Uses standard wood texture in bands");
> uiDefButS(block, ROW, B_TEXPRV, "Rings", 85, 180, 75, 18,
> &tex->stype, 2.0, 1.0, 0, 0, "Uses wood texture in rings");
> uiDefButS(block, ROW, B_TEXPRV, "BandNoise", 160, 180, 75, 18,
> &tex->stype, 2.0, 2.0, 0, 0, "Adds noise to standard wood");
> - uiDefButS(block, ROW, B_TEXPRV, "RingNoise", 235, 180, 75, 18,
> &tex->stype, 2.0, 3.0, 0, 0, "Adds noise to rings");
> -
> - uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 10, 160, 150, 19,
> &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise");
> - uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 160, 160, 150, 19,
> &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise");
> + uiDefButS(block, ROW, B_TEXPRV, "RingNoise", 235, 180, 75, 18,
> &tex->stype, 2.0, 3.0, 0, 0, "Adds noise to rings");
> +
> + uiDefButS(block, ROW, B_TEXPRV, "Sin", 10, 160, 50, 19,
> &tex->noisebasis2, 8.0, 0.0, 0, 0, "Uses a sine wave to produce
> bands.");
> + uiDefButS(block, ROW, B_TEXPRV, "Saw", 60, 160, 50, 19,
> &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave to produce
> bands.");
> + uiDefButS(block, ROW, B_TEXPRV, "Tri", 110, 160, 50, 19,
> &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave to produce
> bands.");
> + uiDefButS(block, ROW, B_TEXPRV, "Soft noise", 160, 160, 75, 19,
> &tex->noisetype, 12.0, 0.0, 0, 0, "Generates soft noise");
> + uiDefButS(block, ROW, B_TEXPRV, "Hard noise", 235, 160, 75, 19,
> &tex->noisetype, 12.0, 1.0, 0, 0, "Generates hard noise");
>
> uiBlockBeginAlign(block);
> uiDefButF(block, NUM, B_TEXPRV, "NoiseSize :", 10, 130, 150, 19,
> &tex->noisesize, 0.0001, 2.0, 10, 0, "Sets scaling for noise input");
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers
>
------------------------------------------------------------------------
--
Ton Roosendaal Blender Foundation ton at blender.org
http://www.blender.org
More information about the Bf-committers
mailing list