POV-Ray : Newsgroups : povray.newusers : threshold df3 media : Re: threshold df3 media Server Time
28 Jul 2024 18:24:08 EDT (-0400)
  Re: threshold df3 media  
From: Mike Williams
Date: 26 Feb 2008 09:34:53
Message: <NBjIykCNHCxHFwus@econym.demon.co.uk>
Wasn't it Frank who wrote:
>Hi,
>
>I have a large .df3 file I visualize by using it as a media density. I want to
>postprocess that density after loading it into povray. For example, set
>everything in the density that is smaller (or larger) than a threshold to zero
>and rescale the rest.
>
>Effectively, I want to visualize only density values in the interval from
>[0.2,0.3], say. Of course, I could do this outside and save a scaled .df3 right
>away, but since this is part of a movie and the interval changes (it is used as
>a lens to let you go through the materials in the volume), it would mean a lot
>of wasted diskspace - the .df3 is really big.

That should all work.

The clue is that anything that can be used as a density pattern for
media can also be used as a function; and any function cam be used as a
media density pattern.

So create a function from your density file
#declare F=function{ pattern{
     density_file df3 "foo.df3"
     interpolate 1 }
}

Then consider a transfer function of that pattern function
  select( abs(F(x,y,z)-0.25)-0.05, 1, 0)
That transfer function returns 1 if F(x,y,z) is between 0.2 and 0.3, and
0 otherwise.

Then use that transfer function to control your media

media {
  scattering {1, 0.7}
  density {
    function {
      select( abs(F(x,y,z)-0.25)-0.05, 1, 0)
    }
  }
}

>Ideally, I would like to specify a transfer function that maps a density value
>in a voxel to an emission value in that voxel. Any ideas how I can do this in
>povray? I'm using the latest beta.

You can add select clauses together.

      select( abs(F(x,y,z)-0.25)-0.05, 1, 0)
    + select( abs(F(x,y,z)-0.35)-0.05, 0.5, 0)
    + select( abs(F(x,y,z)-0.45)-0.05, 0.2, 0)

Or you can use any mathematical operators that are allowed for pattern
expressions to write a transfer function.

Hints: Pattern values outside the range 0.0 to 1.0 behave like mod(p,1)
Patterns derived from df3 files behave as if centred around <.5,.5,.5>

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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