POV-Ray : Newsgroups : povray.newusers : gradient question Server Time
5 Sep 2024 10:31:41 EDT (-0400)
  gradient question (Message 3 to 12 of 12)  
<<< Previous 2 Messages Goto Initial 10 Messages
From: Lothar Esser
Subject: Re: gradient question
Date: 19 Sep 2001 14:45:43
Message: <3BA8E804.27D68319@helix.nih.gov>
Trevor Quayle wrote:

> I think the gradient vector gets normalized, it is only used as a direction,
> not a scale.
> You should therefore, add a scale statement (and probably translate the
> pattern to the base of the cylinder)

   Yes. This is alright. I scaled and translated it. This example works, there
may however be a problem with scale also. What does not work is any non-trivial
vector. If scale and translate is not right, one should at least see that the
pattern being permendicular to the axis of the cylinder. However this is not
the case.
Try

  camera {
    right x
    up y
    location <0,0,-3>
    look_at < 0,0,0>
  }
  light_source {
    <0,100,-10>
    color rgb <1,1,1>
  }
  background {color rgb 1}

  cylinder {

    <-0.1,-1,0>, <0.1,1,0>, 0.2

    texture {
      pigment {
        gradient <0.2,2,0>
        color_map {
           [ 0.0  color rgb <1, 1, 1> ]
           [ 0.5  color rgb <1, 0, 0> ]
           [ 1.0  color rgb <0, 0, 1> ]
        }
      }
    //  scale 4
    //  translate <-0.1,-1,0>
      finish {
        ambient 0.8
        diffuse 0.5
        specular 0.1
        roughness 0.01
      }
    }
 }


Post a reply to this message

From: Trevor Quayle
Subject: Re: gradient question
Date: 19 Sep 2001 14:57:16
Message: <3ba8ea8c$1@news.povray.org>
The gradient should be perpendicular to the axis, I think what you are
seeing is an effect of perspective view and your aspect ratio. your aspect
ratio is 1:1, is your output image 1:1?


try this camera instead

camera {
  up y
  right x*image_width/image_height
  location <0,0,-3>
  look_at < 0,0,0>
}

it makes the aspect ratio of your camera and output image
(I think this is for 3.5 only though, if using 3.1 replace terms
"image_width" and "image_height" with the width and height of your image in
pixels)

-tgq


--
camera{location z*13look_at 0}light_source{15 15looks_like{sphere{0 10
}pigment{rgb 1}finish{ambient 15}}}union{torus{3,0.5rotate x*90}cone{y
*4,.5,-y*8,0}cone{-x*4,.5,x*8,0}pigment{rgb<.7,.6,.4>}finish{ambient 0
diffuse 0reflection{1fresnel on metallic 1}}interior{ior 25}rotate 15}
plane{y,-7pigment{checker rgb 0rgb 1scale 4}finish{diffuse.1}}//   TGQ


Post a reply to this message

From: Lothar Esser
Subject: Re: gradient question
Date: 19 Sep 2001 15:24:27
Message: <3BA8F118.538A3034@helix.nih.gov>
Trevor Quayle wrote:

> The gradient should be perpendicular to the axis, I think what you are
> seeing is an effect of perspective view and your aspect ratio. your aspect
> ratio is 1:1, is your output image 1:1?
>
> try this camera instead
>
> camera {
>   up y
>   right x*image_width/image_height
>   location <0,0,-3>
>   look_at < 0,0,0>
> }

Image_width = Image_height in my case. Try to run the example and plug in
different gradients with "odd" values: In my hand they look all *exactly* the
same until you use gradient x or x+y or something simple like this. Unless I
really do something stupid this looks to me like a real bug.
LE.


Post a reply to this message

From: Trevor Quayle
Subject: Re: gradient question
Date: 19 Sep 2001 15:38:47
Message: <3ba8f447$1@news.povray.org>
I'm not sure what you see as the problem

if you use gradient x the gradient is perpendicular to the x-axis, the color
map runs from 0 to 1 and then repeats (without scaling)

'x' is an internal operator which expands to <1,0,0>

using x+y gets you <1,0,0>+<0,1,0> = <1,1,0>
here the gradient would run in this direction, the color map would start at
the origin and run to distance of 1 in the <1,1,0> direction.

any vector that you put in for the orientation of the gradient represents
the direction of the gradient pattern.  The color_map will always run from 0
to a distance of 1 no matter how large the vector is. for <1,1,0> the color
map runs in the <1,1,0> direction but repeats at  the point <0.707,0.707,0>
(the length of this is 1) and so on.

-tgq



--
camera{location z*13look_at 0}light_source{15 15looks_like{sphere{0 10
}pigment{rgb 1}finish{ambient 15}}}union{torus{3,0.5rotate x*90}cone{y
*4,.5,-y*8,0}cone{-x*4,.5,x*8,0}pigment{rgb<.7,.6,.4>}finish{ambient 0
diffuse 0reflection{1fresnel on metallic 1}}interior{ior 25}rotate 15}
plane{y,-7pigment{checker rgb 0rgb 1scale 4}finish{diffuse.1}}//   TGQ


Post a reply to this message

From: Lothar Esser
Subject: Re: gradient question
Date: 19 Sep 2001 15:56:38
Message: <3BA8F8A3.1E33AF8B@helix.nih.gov>
Trevor Quayle wrote:

> I'm not sure what you see as the problem
>

I don't seem to be able to make myself clear:
My observation is that gradient apparently does not work at least in the way I
use it. It appears to be working for
gradients x and y and so on but not when the gradient is < 0.1, 1, 0 > . I
cannot tell for sure what happens but a
cylinder with the ends <-0.1,-1,0>, <0.1,1,0> does not get colored correctly
with such a gradient. Apart from scaling and translation effects, the pattern
should at least run perpendicular to the axis. More surprising is the fact that
no matter what I put in for a gradient vector it does not change the pattern.
Again simple things seem to work.
Maybe I put it into a challenge: I give you two points which represent the end
points of a cylinder and I ask you to
color it with a gradient going from say with at point 1 to blue at point 2.
Would you use something like this : ?
#declare p1 = <-0.1,-1,0>
#decalre p2 = <0.1,1,0>
cylinder { p1, p2, 0.2  texture { pigment { gradient (p2-p1) color_map { [][] }
} scale vlength ( p2-p1 ) translate p1 finish{} } }

Not having tried this exact scheme yet I predict that it works if p2-p1 = x or
y or x+y  etc. but not if it is anything else.
BTW I am not so sure about the scale. I have had some problems with it too. For
instance a cylinder of length 2.84 needed to
get a scale of 4. But lets deal with one problem at a time.

LE.


Post a reply to this message

From: Trevor Quayle
Subject: Re: gradient question
Date: 19 Sep 2001 16:12:29
Message: <3ba8fc2d$1@news.povray.org>
I used your code and modified it slightly to run a whole bunch of cylinders
with random endpoints.  I'll post my image in p.b.i for you.  If you can see
your problem with it maybe can can explain it a bit more carefully.  (BTW
the speckles on the ends of the cylinder come from the gradient having
coincident surfaces where it is repeating, multiply the scale factor by
something miniscule like 1.00001 to get rid of it)

code used:

camera {
  up y
  right x*image_width/image_height
  location <0,0,-10>
  look_at < 0,0,0>
}

light_source {
  <0,100,-10>
  color rgb <1,1,1>
}

background {color rgb 1}


#declare R1=seed(1);

#declare i = -5;
#while (i<=5)
  #declare j = -3;
  #while (j<=3)
    #declare p1 = <-1*rand(R1),-1*rand(R1),-1*rand(R1)>*5*(rand(R1)-0.5);
    #declare p2 = <1*rand(R1),1*rand(R1),1*rand(R1)>*5*(rand(R1)-0.5);
    cylinder{
      p1, p2, 0.2
      texture{
        pigment{
          gradient (p2-p1)
          color_map{
             [0.0 color rgb <1, 0, 0>]
             [1.0 color rgb <0, 0, 1>]
          }
        }
        scale vlength(p2-p1)
        translate p1
        finish {
          ambient 0.8
          diffuse 0.5
          specular 0.1
          roughness 0.01
        }
      }
      translate x*i+y*j
    }
    #declare j=j+1;
  #end
  #declare i=i+1;
#end


-tgq


Post a reply to this message

From: Lothar Esser
Subject: Re: gradient question
Date: 19 Sep 2001 17:43:33
Message: <3BA911B3.4D04232E@helix.nih.gov>
Trevor Quayle wrote:

> I used your code and modified it slightly to run a whole bunch of cylinders
> with random endpoints.  I'll post my image in p.b.i for you.  If you can see
> your problem with it maybe can can explain it a bit more carefully.  (BTW
> the speckles on the ends of the cylinder come from the gradient having
> coincident surfaces where it is repeating, multiply the scale factor by
> something miniscule like 1.00001 to get rid of it)

I posted my reply also on the povray binary images server.
Seems like I have a problem. I am running it on an sgi. At the moment I don't
very much feel like trying different compiler options but I will have to do
that I am afraid because this is not working.

LE


Post a reply to this message

From: Lothar Esser
Subject: Re: gradient question
Date: 19 Sep 2001 17:52:02
Message: <3BA913AF.F7223ACB@helix.nih.gov>
>

Now I ran the same script on Compaq Alpha with exactly the same wrong result.
Can you give me more details about your system ?
What is wrong with unix (?) if I may generalize here a bit ?
I am a bit puzzled right now.

LE


Post a reply to this message

From: Trevor Quayle
Subject: Re: gradient question
Date: 19 Sep 2001 19:05:14
Message: <3ba924aa@news.povray.org>
I see what you mean now.  I have been running POV 3.5 in Windows,
unfortunately I don't know much about other OS/s.  Maybe you should post
your problem again with Unix in the subject and someone who knows more about
the other systems can help.
BTW try not posting .tga in p.b.i, they are quite large and someone is
likely to complain.  Use .jpg if you can.
Sory I can't help more.

-tgq


--
camera{location z*13look_at 0}light_source{15 15looks_like{sphere{0 10
}pigment{rgb 1}finish{ambient 15}}}union{torus{3,0.5rotate x*90}cone{y
*4,.5,-y*8,0}cone{-x*4,.5,x*8,0}pigment{rgb<.7,.6,.4>}finish{ambient 0
diffuse 0reflection{1fresnel on metallic 1}}interior{ior 25}rotate 15}
plane{y,-7pigment{checker rgb 0rgb 1scale 4}finish{diffuse.1}}//   TGQ


Post a reply to this message

From: Mike Williams
Subject: Re: gradient question
Date: 20 Sep 2001 00:21:32
Message: <IdxZqBAoEPq7Ew1L@econym.demon.co.uk>
Wasn't it Lothar Esser who wrote:
>Hi,
>   at the risk of embarrassing myself: I have a question about gradient
>in a pigment statement. What I want to do is to colour a cylinder which
>is not necessarily aligned with x,y,z or any simple combination of it
>from one end to the other with a simple gradient. For some reason an
>arbitrary vector in the gradient statement seems to be ignored.
>A statement like
>   cylinder {
>       <-1,-1,0>, <1,1,0>, 0.2
>       texture { pigment { gradient <1,1,0> color_map { [ 0.0 color rgb
>1] [1.0 color rgb <0,0,1>] } } } ... etc
>works but if I have a cylinder with the end points like <-0.1,-1,0>,
><0.1,1,0> then I cannot figure out what the correct
>gradient vector is: gradient <0.2,2,0> does not work.

I think it was a bug. It's fixed in POV_Ray 3.5b2.

In 3.5b2 both <0.1,1,0> and <0.2,2,0> work correctly.

(The only snag is that the gradient pattern is different in 3.5 in that
the colours always cycle in the same direction, whereas in 3.1 and all
previous versions the colours cycle in the opposite direction on the
other side of the origin.)

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

<<< Previous 2 Messages Goto Initial 10 Messages

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