POV-Ray : Newsgroups : povray.pov4.discussion.general : Wood pattern and v4.0. Server Time
21 Dec 2024 11:59:08 EST (-0500)
  Wood pattern and v4.0. (Message 1 to 9 of 9)  
From: William F Pokorny
Subject: Wood pattern and v4.0.
Date: 13 Sep 2023 13:36:40
Message: <6501f328@news.povray.org>
I'd re-written the povr fork's wood, scalar value pattern (not povr's 
f_wood() inbuilt) a couple years back. I found myself twiddling with it 
again recently. I wanted to document some of how I understand it to be 
working in official releases (since v1.0) and how it is now working in 
the povr fork.

An image is attached. In the top row on the left and right showing how 
'special turbulence' (naked 'turbulence' and associated keywords) today 
produces a wood pattern with harmonics. This is due a melding of the 
incoming x and y coordinates with the turbulence.

My best guess is odd turbulence treatment was done to get differing size 
growth rings - so long as users carefully position the pattern with 
respect to the surface(s) being textured. Namely, orthogonal / ortho45 
arrangements with respect to x & y axes. The behavior is very touchy 
with respect to the turbulence settings.

Lastly, the middle top row shows that if the user codes 'warp { 
turbulence ...}' over 'turbulence ...' they get no internal / special 
turbulence treatment at all, but rather only warp turbulence. This one 
of the reasons the povr fork has new it_ prefixed (internal turbulence) 
keywords where features make use of internal turbulence.

     //...  Official POV-Ray code
     plane { -z 0
         pigment {
             wood
             turbulence 0.05
             color_map {
                 [0 rgb 0]
                 [1 rgb 1]
             }
         }
         scale 1/8
         finish { emission 1 }
     }

---

Originally, I'd re-code to match the behavior above, but the povr fork 
now has f_wood() and I wanted to change the basic wood pattern to 
something easier to understand and use well.

The povr update is shown on the bottom row. The special melding of x and 
y with the DTurbulence() result is gone in favor of using the output of 
DTurbulence() directly. Further, as a general enhancement, there is now 
an it_scale option for warp { turbulence .. } and also scalar value 
patterns like wood.

     //... Example for povr fork using it_* turbulence and
     // warp{ turbulence ... it_scale ... }
     plane { -z 0
         pigment {
             wood
             it_amount 0.05  // New
             it_scale 1/4    // New
//          scale 1/3  // Old turbulence scaling method
             translate <pi,pi/2,pi/3>
             warp {
		turbulence 0.1 octaves 3
		omega 0.67 lambda 1.7 it_scale 3.0 // New
             }
             translate <pi,pi/2,pi/3>*-1
//          scale 3   // Old turbulence scaling method
             scale 1/24
             color_map {
                 [0 rgb 0]
                 [1 rgb 1]
             }
         }
         finish { emission 1 }
     }

Bill P.


Post a reply to this message


Attachments:
Download 'woodpatstory.jpg' (577 KB)

Preview of image 'woodpatstory.jpg'
woodpatstory.jpg


 

From: And
Subject: Re: Wood pattern and v4.0.
Date: 15 Sep 2023 07:15:00
Message: <web.65043b9678885d763b5b2d1eaa81652d@news.povray.org>
I haven't used povr yet.

I found that your image (top row) are similar to the deform of the IsoWood
include files of Christoph Hormann.

The bottom row is interesting, too.


Post a reply to this message


Attachments:
Download 'povr-wood observe.png' (353 KB)

Preview of image 'povr-wood observe.png'
povr-wood observe.png


 

From: William F Pokorny
Subject: Re: Wood pattern and v4.0.
Date: 15 Sep 2023 21:34:32
Message: <65050628@news.povray.org>
On 9/15/23 07:10, And wrote:
> I haven't used povr yet.
> 
> I found that your image (top row) are similar to the deform of the IsoWood
> include files of Christoph Hormann.
> 
> The bottom row is interesting, too.

I played a little with the IsoWood macros a 'long' time ago and have a 
copy somewhere, but I don't recall what pattern / functions were used 
for the wood patterning - thanks for the info on the look of it in 
comparison.

I've been following your 'wood work' programming effort. I confess to 
more or less thrashing around, pushing here and there, on what can be 
done and only sometimes with 'wood' grain specifically in mind.

Yes, the approach in the bottom row is to start with an internal 
turbulence scaled small to make the rings just a little bit noisy as 
they go around - and then on top of that to layer one or more additional 
warp turbulences at larger scales to get a more complete wood pattern look.

This turbulence layering approach is difficult with the old style 'wood' 
because it has those fixed, positional harmonics. It's too easy to push 
the 'favorable' portion of the pattern off of the surface being textured.

I'm starting to look now at pushing into the warp{} mechanisms with 
thoughts toward a re-work of the underlying functionality of that code. 
In the povr fork, I have quite a few fixes and additions hacked into 
that code over what is in official POV-Ray releases, but it's all 
'hacked in'. I'd like to refined what's there into something better.

Anyhow... I'll attach another image using the povr updated 'wood' as the 
base pattern - not really aimed to be anything in particular. It's a 
test image for other features as much as the changed 'wood', but I think 
it looks interesting.

Using it_* turbulence and warp{it_* ...} turbulence with emitting, 
media{density{density_map{...}...}}.

Oh, the containing shape is an isosurface based upon povr's inbuilt 
f_toupie() function. Here with options forming a shape somewhat like a 
spinning top. It's thicker in the middle, thinning as it moves out from 
the center before thickening into an outer torus at the edges.

Bill P.


Post a reply to this message


Attachments:
Download 'woodturbtest.png' (472 KB)

Preview of image 'woodturbtest.png'
woodturbtest.png


 

From: And
Subject: Re: Wood pattern and v4.0.
Date: 19 Sep 2023 04:55:00
Message: <web.650960e978885d7676afd5b8aa81652d@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
>
> I played a little with the IsoWood macros a 'long' time ago and have a
> copy somewhere, but I don't recall what pattern / functions were used
> for the wood patterning - thanks for the info on the look of it in
> comparison.
>
> I've been following your 'wood work' programming effort. I confess to
> more or less thrashing around, pushing here and there, on what can be
> done and only sometimes with 'wood' grain specifically in mind.
>

Ha... I explored the concept (deform, growth rates, knots, etc) separately. I
would like integrate them. But I don't have enough ability on developing a
program. I just learn it by DIY.

Thank you. I feel encouraged.

> Yes, the approach in the bottom row is to start with an internal
> turbulence scaled small to make the rings just a little bit noisy as
> they go around - and then on top of that to layer one or more additional
> warp turbulences at larger scales to get a more complete wood pattern look.
>
> This turbulence layering approach is difficult with the old style 'wood'
> because it has those fixed, positional harmonics. It's too easy to push
> the 'favorable' portion of the pattern off of the surface being textured.
>

I cannot understand it very well.

> I'm starting to look now at pushing into the warp{} mechanisms with
> thoughts toward a re-work of the underlying functionality of that code.
> In the povr fork, I have quite a few fixes and additions hacked into
> that code over what is in official POV-Ray releases, but it's all
> 'hacked in'. I'd like to refined what's there into something better.
>
> Anyhow... I'll attach another image using the povr updated 'wood' as the
> base pattern - not really aimed to be anything in particular. It's a
> test image for other features as much as the changed 'wood', but I think
> it looks interesting.
>
> Using it_* turbulence and warp{it_* ...} turbulence with emitting,
> media{density{density_map{...}...}}.
>
> Oh, the containing shape is an isosurface based upon povr's inbuilt
> f_toupie() function. Here with options forming a shape somewhat like a
> spinning top. It's thicker in the middle, thinning as it moves out from
> the center before thickening into an outer torus at the edges.
>
> Bill P.


I noticed that povr is running on Linux. I don't have much ability on
C/C++,(additional I'm learning another thing) so I'm not trying it. I will try
it in the future or waiting the integration with official POV-Ray version.

-----------------------------------
Are you have facebook? I have searched(a little) people on this newsgroup. I
have found you. I think that I ought to add people on facebook, otherwise I
cannot imagine any character about people here.


Post a reply to this message

From: William F Pokorny
Subject: Re: Wood pattern and v4.0.
Date: 19 Sep 2023 16:59:07
Message: <650a0b9b$1@news.povray.org>
On 9/19/23 04:52, And wrote:
> Are you have facebook? I have searched(a little) people on this newsgroup. I
> have found you. I think that I ought to add people on facebook, otherwise I
> cannot imagine any character about people here.

There is probably an old facebook account out there that I created years 
ago. However, I have long not used it. It got far too noisy for this old 
man. :-)

Bill P.


Post a reply to this message

From: Bald Eagle
Subject: Re: Wood pattern and v4.0.
Date: 19 Sep 2023 17:55:00
Message: <web.650a17f278885d761f9dae3025979125@news.povray.org>
https://www.youtube.com/watch?v=FG57kqn7GC8

https://arxiv.org/pdf/1511.04224.pdf

I think this is doable, just need to figure out how to implement it, and perhaps
get a bit of help with the Jacobian and outer product (tensor product)
functions.

- BW


Post a reply to this message

From: Bald Eagle
Subject: Re: Wood pattern and v4.0.
Date: 19 Sep 2023 20:45:00
Message: <web.650a406c78885d761f9dae3025979125@news.povray.org>
https://www.cs.cornell.edu/~srm/publications/SG05-wood-lr.pdf

https://www.cs.cornell.edu/~srm/publications/SG05-wood.html

has a link to a tar/gz archive with code.   :)



/*
 * woodreflectance.sl -- wood (anisotropic)
 *
 * DESCRIPTION:
 *   Simple wood shader, driven by four textures:
 *    RGB diffuse color
 *    RGB fiber (anisotropic highlight) color
 *    x,y,z of unit vector giving local fiber orientation in local
 *      coordinates
 *    beta, a "roughness" parameter to control width of highlight.
 *   If any of these files is not specified, we fall back on a
 *    uniform parameter. So far, every map has had uniform beta.
 *
 * PARAMETERS:
 *
 *   diffuse_texture: name of file containing 3-channel texture
 *     modulating color across the patch.
 *
 *   fiber_texture: name of file containing 3-channel texture
 *     modulating fiberColor across the patch. This map is divided by
 *     20 because it generally contains values greater than 1, which
 *     would be clamped in an integer pixel format.
 *
 *   axis_texture: name of file containing 3-channel texture
 *     modulating fiberAxis across the patch. Values are mapped
 *     [0:max] -> [-1:1] for each component, since most image file
 *     formats are unsigned.
 *
 *   beta_texture: name of file containing 1-channel texture
 *     modulating beta across the patch.
 *
 *   eta: Index of refraction of surface finish. Used to modulate
 *     highlight and subsurface with varying angle. eta=0 used to
 *     signal absence of overcoat.
 *
 *   color, fiberColor: fallback diffuse and directional colors if
 *     texture is missing
 *
 *   fiberAxis: fallback fiber direction if texture is missing
 *
 *   beta: width of subsurface highlight if texture is missing
 *
 *   roughness: width of surface (white) highlight
 *
 *   Ka, Kd, Ks: normal Renderman coefficients. Ka and Kd modulate the
 *     diffuse component (parameter "color"), and Ks is a fudge factor
 *     on the surface (white) highlight.
 *
 * ANTIALIASING: provided by texture lookup
 *
 * REFERENCE: Stephen R. Marschner, Stephen H. Westin,
 *              Adam Arbree, and Jonathan T. Moon,
 *            "Measuring and Modeling the Appearance of
 *               Finished Wood", SIGGRAPH 2005
 *
 * AUTHOR: written by Stephen H. Westin,
 *                    Cornell University Program of
 *                    Computer Graphics
 *         last modified by $Author: westin $
 *
 * VERSION: $Revision: 1.2 $
 *
 * HISTORY:
 * $Log: woodreflectance.sl,v $
 * Revision 1.2  2005/05/10 20:02:15  westin
 * Modified to use 4 TIFF texture maps rather than a single
 *  10-channel map.
 *
 * Revision 1.1  2005/05/09 21:10:18  westin
 * Working version of shader; used for animation on Proceedings DVD-ROM.
 *
 */

surface
woodreflectance ( float Ka = 1.0,
                        Kd = 1.0,
                        Ks = 1.0;
                  float eta = 1.5;
                  vector fiberAxis = ( 1, 0, 0 );
                  float beta = .1745; /* 10 degrees -> radians */
                  color fiberColor = color ( 1, .6, .4 );
                  string diffuse_texture = "",
                         fiber_texture = "",
                         axis_texture = "",
                         beta_texture = "";
                  float minU = 0, maxU = 1,
                  minV = 0, maxV = 1,
                  roughness = 0.2; )
{

  uniform float sqrt2pi = 2.5066283;

  vector local_z;        /* Surface normal in "world" space */
  vector local_x, local_y; /* Unit vector in "u" and "v" directions */

  normal Nf = faceforward (normalize(N), I); /* Forward-facing normal */
  vector V = normalize(I);                 /* Normalized eye vector */

  color diffuseColor, highlight;
  vector axis;
  float tx_beta;

  vector ssInDir, ssOutDir; /* Light and eye vector, possibly refracted */
  float thInPrime, thOutPrime;
  float halfAngle, diffAngle;
  float fiberFactor, geometryFactor;

  float Kr, Kt;                          /* for output of fresnel() */
  float ssAtten; /* Attenuation from going through the smooth interface twice */

  /* Get local coordinate system in terms of native
     parameters (u,v). We should really use (s,t). */
  local_z = Nf;
  /* Get unit vector in "u" parameter direction */
  local_x = normalize ( dPdu );
  /* Get final local basis vector y perpendicular to x and z. */
  local_y = local_z^local_x;

  /* If there is a clear overcoat, calculate refraction direction and
     attenuation. */
  if ( eta != 1.0 ) {
    vector Rdir;                     /* Dummy */
    fresnel ( V, Nf, 1.0/eta, Kr, Kt, Rdir, ssOutDir );
    ssOutDir = -ssOutDir;
    // Use (1-Kr) rather than Kt, because we are dealing with power,
    // not radiance.
    ssAtten = 1 - Kr;
  } else {
    ssOutDir = -V;
    ssAtten = 1.0;
  }
  normalize(ssOutDir);

  color axisTemp;
  float ourS = minU + u * (maxU - minU),
    ourT = minV + v * (maxV - minV);

  // Get parameters locally from texture maps, if available

  if ( diffuse_texture != "" )
    diffuseColor = color texture ( diffuse_texture, ourS, ourT );
  else
    diffuseColor = Cs;

  if ( fiber_texture != "" )
    highlight = color texture ( fiber_texture, ourS, ourT ) * 20;
  else
    highlight = fiberColor;

  if ( axis_texture != "" ) {
    axisTemp = color texture ( axis_texture, ourS, ourT )
                                   *2 - 1.0;
    /* Transform to local coordinate system */
    axis = comp ( axisTemp, 0 ) * local_x
         - comp ( axisTemp, 1 ) * local_y
         + comp ( axisTemp, 2 ) * local_z;
  }
  else
    axis = comp ( fiberAxis, 0 ) * local_x
         + comp ( fiberAxis, 1 ) * local_y
         + comp ( fiberAxis, 2 ) * local_z;
  normalize(axis);

  if ( beta_texture != "" )
    tx_beta = float texture ( beta_texture, ourS, ourT );
  else
    tx_beta = beta;

  thOutPrime = asin ( ssOutDir.axis );

  /* Calculate anisotropic highlight for each light */
  Ci = 0;
  illuminance ( P, Nf, PI/2 /* Hemisphere */ ) {
    float dummy, ssAttenOut;
    vector Ln = normalize ( L );

    /* Refract at smooth surface */
    if ( eta != 1.0 ) {
      vector Rdir;                           /* dummy */
      fresnel ( -Ln, local_z, 1.0/eta, Kr, Kt, Rdir, ssInDir );
      // Use (1-Kr) rather than Kt, because we are dealing with power,
      // not radiance.
      ssAttenOut = 1 - Kr;
    } else {
      ssInDir = -Ln;
      ssAttenOut = 1.0;
    }

    float ssFactor = max ( 0, -ssInDir.local_z ) * ssAtten*ssAttenOut;
    thInPrime  = asin ( -ssInDir.axis );
    halfAngle = thOutPrime + thInPrime;
    diffAngle = thOutPrime - thInPrime;
    // Compute value of Gaussian at this angle
    fiberFactor = tx_beta * exp ( -pow(halfAngle/tx_beta,2)/2 )
                                      / sqrt2pi;
    float cosIncline = cos(diffAngle / 2);
    geometryFactor = 1 / pow ( cosIncline, 2 );
    fiberFactor *= geometryFactor;
    // Add in diffuse term, attenuated by surface term.
    Ci += Cl * Kd * diffuseColor * ssFactor;
    // Add in fiber highlight, also attenuated.
    Ci += Cl * fiberFactor * highlight * ssFactor;
    /* Second Fresnel call is for strength of surface highlight */
    vector H = normalize ( -V + Ln );
    fresnel ( V, H, 1.0/eta, Kr, Kt );
    // Blinn/Phong highlight with Fresnel attenuation
    Ci += Cl * Ks * Kr
      * pow ( max ( 0, H.local_z ), 1/roughness );
  }

  Ci += Ka * diffuseColor * ambient();
}


Post a reply to this message

From: And
Subject: Re: Wood pattern and v4.0.
Date: 21 Sep 2023 06:45:00
Message: <web.650c1df978885d7672bedd41aa81652d@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
> On 9/19/23 04:52, And wrote:
> > Are you have facebook? I have searched(a little) people on this newsgroup. I
> > have found you. I think that I ought to add people on facebook, otherwise I
> > cannot imagine any character about people here.
>
> There is probably an old facebook account out there that I created years
> ago. However, I have long not used it. It got far too noisy for this old
> man. :-)
>
> Bill P.

OK.


Post a reply to this message

From: And
Subject: Re: Wood pattern and v4.0.
Date: 21 Sep 2023 07:00:00
Message: <web.650c216e78885d7672bedd41aa81652d@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> https://www.cs.cornell.edu/~srm/publications/SG05-wood-lr.pdf
>
> https://www.cs.cornell.edu/~srm/publications/SG05-wood.html
>
> has a link to a tar/gz archive with code.   :)
>
>

https://www.youtube.com/watch?v=FG57kqn7GC8

https://arxiv.org/pdf/1511.04224.pdf

I think this is doable, just need to figure out how to implement it, and perhaps
get a bit of help with the Jacobian and outer product (tensor product)
functions.

- BW


Thank you.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.