POV-Ray : Newsgroups : povray.newusers : Blobs functions : Re: Blobs functions Server Time
29 Jul 2024 16:19:43 EDT (-0400)
  Re: Blobs functions  
From: Mike Williams
Date: 22 Jun 2005 12:13:38
Message: <4$4dQHAm4YuCFwH1@econym.demon.co.uk>
Wasn't it Oleguer Vilella who wrote:
>Hi Mike,
>
>And using more than two colors?
>
>I was reading the documentation about that. They say that:
>"When the gradient x function returns values from 0.0 to 0.3 the red 
>highlighted texture is used. From 0.3 to 0.6 the texture identifier T_Wood11 
>is used. From 0.6 up to 0.9 a blend of T_Wood11 and a shiny DMFWood4 is 
>used. From 0.9 on up only the shiny wood is used."
>
>I thought that number is used to divide the object in different parts, for 
>exemple if your are using 3 colors you can put 1/3 before the pigment 
>instead of the 1/2 that you've put the divide the object. But I obtain some 
>strange results.
>
>======================================
>texture {gradient x
> texture_map {[0.3  pigment {rgb <0,0,1>}]
>               [0.6  pigment {rgb <1,0,0>}]
>              [0.9 pigment { rgb <0, 1, 0>}] }
>  //translate <-0.5,0,0>   // move transition point to the origin
>  scale 100              // scale up the texture_map
>  translate <0.95/2,0,0> // move the transition point to half way
>======================================
>
>Well, I'm not understanding it properly.
>
>Thanks for the anwers,
>Oleguer

One of the significant things is that you should get rid of the 
"scale 100" if you want more than two bands. I just put that there so
that you wouldn't see more than two bands unless you made the blob
extremely large.

Texture_maps work just like colour_maps, so try reading that
documentation and see if it's any easier.

The basic idea is that "gradient x" sets up a *pattern* that takes the
value (x - floor(x)) at all points in space. E.g. at the point <0,1,2>
the pattern takes the value 0, and at <2.45,4,6> it takes the value 0.45
(that's 2.45 - 2.0). The pattern doesn't care where your object is, it
only concerns itself with points in space.

So, lets suppose that POVRay is tracing some object and finds a point on
the surface at <2.45,4,6>, it works out that the value of the pattern is
0.45, and looks that up in the texture_map. In your example above, 0.45
comes exactly half way between these two entries
   [0.3  pigment {rgb <0,0,1>}]
   [0.6  pigment {rgb <1,0,0>}]
so it renders a 50-50 blend of those two textures giving pigment 
{rgb <0.5,0,0.5>}

However, when it finds a point like <3.1,3,3>, the pattern evaluates to
0.1 and that's below the first entry in the map, so POV uses the first
entry in the map.

So for three equally spaced hard-edged bands you might use

pigment {gradient x
  pigment_map {[1/3  rgb <0,0,1>]
               [1/3  rgb <0,1,0>]
               [2/3  rgb <0,1,0>]
               [2/3  rgb <1,0,0>]}
  translate <-0.5,0,0>   // move transition point to the origin
  scale 0.95*2           // scale up the texture_map to show 3 bands
  translate <0.95/2,0,0> // move the mid point texture to half way along 
                         // the blob
  }

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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