[Bf-committers] More Woody Goody
Johnny Matthews
johnny.matthews at gmail.com
Tue Mar 1 16:00:19 CET 2005
Chris,
I tried your patch. These are great additions! Keep it up.
Johnny Matthews (guitarGeek)
Chris Burt wrote:
> Hi all, this is an upgrade to the wood patch which maintains backwards
> compatibility (so far as I know) and also features an improvement:
>
> The Wood Texture panel now offers a "Sin" "Tri" and "Saw" waveform
> button, allowing the user to select which waveform they wish to use.
> Results vary quite a lot from option to option. I'll make screen shots
> tomorrow. I think this patch is actually quite nice and I've tidied up
> the wood texture code a little bit, adding defines where magic numbers
> existed before. Its now a bit more readable and the functions which
> determine the intensity of the wood are now three separate calls
> wood_sin (original), wood_saw and wood_tri (both new). So more
> information and screenshots tomorrow for those interested. This still
> needs testing etc, but my from my experiments its quite fun. Here's
> one small sample already:
>
> http://blender.spaceisbig.com/wood_or_steel.png
>
> Looks a little like diamond plate I thought. Its two wood texture
> criss-crossing.
>
> Anyway.. late now! Patch is attached. Thanks!
>
> Regards,
> --Chris Burt
>
>------------------------------------------------------------------------
>
>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 1 Mar 2005 05:05:03 -0000
>@@ -354,30 +354,94 @@ 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, float b)
>+{
>+ int n = (int)(a / b);
>+ a -= n*b;
>+ if (a < 0)
>+ a += b;
>+ return a;
>+}
>+
>+/* creates a triangle wave */
>+static float wood_tri(float a)
>+{
>+ a = (M_PI/2.0 + (4.0/M_PI)*(cos(a) + cos(3.0*a)/9.0 + cos(5.0*a)/25.0 + cos(7.0*a)/49.0))/M_PI;
>+
>+ 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);
>+ if (wt==TEX_BAND) {
>+ if (wf==TEX_SIN) {
>+ wi = wood_sin((x + y + z)*10.0);
>+ }
>+ else if (wf==TEX_SAW) {
>+ wi = wood_saw(x + y + z, 0.5)/0.5;
>+ }
>+ else if (wf==TEX_TRI) {
>+ wi = wood_tri((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) {
>+ if (wf==TEX_SIN) {
>+ wi = wood_sin(sqrt(x*x + y*y + z*z)*20.0);
>+ }
>+ else if (wf==TEX_SAW) {
>+ wi = wood_saw(sqrt(x*x + y*y + z*z) * 5.0, 1.5)/1.5;
>+ }
>+ else if (wf==TEX_TRI) {
>+ wi = wood_tri(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);
>+
>+ if (wf==TEX_SIN) {
>+ wi = wood_sin((x + y + z)*10.0 + wi);
>+ }
>+ else if (wf==TEX_SAW) {
>+ wi = wood_saw((x + y + z) + wi/10.0, 0.5)/0.5;
>+ }
>+ else if (wf==TEX_TRI) {
>+ wi = wood_tri((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);
>+
>+ if (wf==TEX_SIN) {
>+ wi = wood_sin(sqrt(x*x + y*y + z*z)*20.0 + wi);
>+ }
>+ else if (wf==TEX_SAW) {
>+ wi = wood_saw(sqrt(x*x + y*y + z*z)*5.0 + wi/10.0, 1.5)/1.5;
>+ }
>+ else if (wf==TEX_TRI) {
>+ wi = wood_tri(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 +451,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 1 Mar 2005 05:05:03 -0000
>@@ -243,6 +243,15 @@ typedef struct Tex {
> #define TEX_NOISESOFT 0
> #define TEX_NOISEPERL 1
>
>+/* wood waveforms/types */
>+#define TEX_SIN 0
>+#define TEX_SAW 1
>+#define TEX_TRI 2
>+#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 1 Mar 2005 05:05:04 -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 function to produce texture output.");
>+ uiDefButS(block, ROW, B_TEXPRV, "Saw", 60, 160, 50, 19, &tex->noisebasis2, 8.0, 1.0, 0, 0, "Uses a saw wave function to produce texture output.");
>+ uiDefButS(block, ROW, B_TEXPRV, "Tri", 110, 160, 50, 19, &tex->noisebasis2, 8.0, 2.0, 0, 0, "Uses a triangle wave function to produce texture output.");
>+ 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
>
>
More information about the Bf-committers
mailing list