POV-Ray : Newsgroups : povray.general : Help with macro(s) for simulating weather patterns : Re: Help with macro(s) for simulating weather patterns Server Time
29 Jul 2024 08:13:46 EDT (-0400)
  Re: Help with macro(s) for simulating weather patterns  
From: D103
Date: 16 Apr 2012 10:30:01
Message: <web.4f8c2bffd5742bdd5ae2687f0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
>
> Remember that you need to pass a #declare'd (or #local) object to
> trace(). Note that trace() only probes this single object, and that this
> object isn't visible in the scene unless you also instantiate it with
> "object{MyObjectVariable}". You could use this to trace() a height_field
> of the image.

Of course, why didn't I realise that... *shakes head at himself*

Thanks :D

>
> trace() is comparatively slow for your purposes though. Instead, a
> better alternative is probably to define a "pigment function", which you
> can then directly evaluate to retrieve the pigment's color at any given
> point. The "functions.inc" macro "eval_pigment" encapsulates this in a
> simple macro:
>
> #macro eval_pigment(pigm, vec)
>      #local fn = function { pigment { pigm } }
>      #local result = (fn(vec.x, vec.y, vec.z));
>      result
> #end

That looks exactly what I want. Many thanks clipka :)

>
> You pass it the pigment and the point to be evaluated, and will get a
> color value. (This is one of the few exceptions where functions may
> return colors rather than scalars.)

Probably why I haven't heard of it. ;)

So, a good way to read an image would be something like this?

Identify the image to pov with a #declare or #local, whichever is appropriate.
Pull the x and y resolutions from it using a function (I know there's one around
somewhere, can't find it at the moment).
Use a nested loop to write the values from the image to a two dimensional array.

From there, it's a simple thing to determine if the point in question is water,
or if not, how close to water it is. If the planet in use has no surface water,
then it would be a simple thing to add an "eval_pigment" to the macro, with a
conditional value which returns true or false depending, thus saving
computational time. :)

Any flaws?

Thanks for your time.

Regards
D103


Post a reply to this message

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