POV-Ray : Newsgroups : povray.general : random problem : Re: random problem Server Time
14 Nov 2024 19:19:07 EST (-0500)
  Re: random problem  
From: Nathan Kopp
Date: 18 May 1999 19:20:27
Message: <3741E76C.5F723D9B@Kopp.com>
The section "Returning a Value Like a Function" talks about needing the
extra set of parentheses.

-Nathan

Bill DeWitt wrote:
> 
> Nathan Kopp <Nat### [at] Koppcom> wrote in message
> news:3740DC55.26A3866B@Kopp.com...
> > Macros work via text substitution.  Rmm is not really a function returning
> > a number.
> 
>     POVRay documentation says differently, see: "Returning a value from a
> macro" or some such. I'm too groggy to think about his macro but it can be
> made to act like a value in the pigment.
> 
> > Right now, this:
> >     pigment {rgb <0.50,0.10,0.08>*Rmm(Min,Max,Stream)}
> >
> > becomes:
> >     pigment {rgb <0.50,0.10,0.08>*Max+((Min-Max)*rand(Stream))}
> >
> > So, you need to put parentheses in the macro.  Change it to look like
> > this:
> >
> > #macro Rmm(Min,Max,Stream)
> >    (Max+((Min-Max)*rand(Stream)))
> > #end file://macro
> >
> >
> > -Nathan
> >
> > ingo wrote:
> > >
> > > While making some pieces of wood with different colours, using random, I
> ran
> > > into a problem.
> > > Run the scene below.
> > > The first number from the random stream ia always 0.118 .
> > > Now comment out "#declare XX = ....." , "#debug concat(....." and in the
> the
> > > first pigment replace XX by "Rmm(0.1,0.5,Sd)".
> > > Run the scene again.
> > >
> > > Why are the colours different?
> > >
> > > ingo
> > >
> > > --
> > > Met dank aan de muze met het glazen oog.
> > >
> > > #version 3.1; global_settings {assumed_gamma 1.0}
> > > light_source {<500, 500,-500> rgb 1}
> > > camera {location<0, 1.6, -5.0> look_at<0,0,0>}
> > >
> > > #declare Sd=seed(7)
> > >
> > > #macro Rmm(Min,Max,Stream)
> > >    Max+((Min-Max)*rand(Stream))
> > > #end file://macro
> > >
> > > #declare XX= Rmm(0.1,0.5,Sd)
> > > #debug concat("\n XX= ",str(XX,3,3))
> > >
> > > #declare Wood= texture {
> > >    pigment {rgb <0.50,0.10,0.08>*XX}
> > > }
> > > texture {
> > >    pigment {
> > >       wood
> > >       scale 0.05
> > >       color_map {
> > >          [0,rgbf <0.5,0.4,0.4,0.2>*0.5]
> > >          [1,rgbf <0.5,0.4,0.4,0.7>*0.5]
> > >       }
> > >    }
> > > }
> > > box {-1,1 texture {Wood}}


Post a reply to this message

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