POV-Ray : Newsgroups : povray.newusers : threshold df3 media Server Time
28 Jul 2024 16:23:27 EDT (-0400)
  threshold df3 media (Message 1 to 5 of 5)  
From: Frank
Subject: threshold df3 media
Date: 26 Feb 2008 08:25:01
Message: <web.47c412976ea871fc7597f0180@news.povray.org>
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.

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.

Frank


Post a reply to this message

From: Mike Williams
Subject: Re: threshold df3 media
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

From: Frank
Subject: Re: threshold df3 media
Date: 26 Feb 2008 10:15:00
Message: <web.47c42bb62190f9b2863570b30@news.povray.org>
Mike Williams <nos### [at] econymdemoncouk> wrote:
> That should all work.
YES! It does!

Thank you very much, worked out of the box, and makes everything much easier.

Since I don't want to keep asking: Is there a book you can recommend that
describes techniques like this for volume rendering with PovRay?

Thanks again,

Frank


Post a reply to this message

From: Jan Dvorak
Subject: Re: threshold df3 media
Date: 26 Feb 2008 10:16:57
Message: <47c42d69$1@news.povray.org>
Frank napsal(a):
> 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.
> 
> 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.
> 
> Frank
> 
> 
> 
use a waveform for the density

-- 
You know you've been raytracing too long when...
you start thinking up your own "You know you've been raytracing too long 
when..." sigs (I did).
-Johnny D


Post a reply to this message

From: Alain
Subject: Re: threshold df3 media
Date: 26 Feb 2008 13:03:08
Message: <47c4545c@news.povray.org>
Frank nous apporta ses lumieres en ce 2008/02/26 08:23:
> 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.
> 
> 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.
> 
> Frank
> 
> 
> 
Very simple, and without ever altering your data.
Just add a color_map like:

color_map{[clock rgb 0][clock rgb 1][clock+0.1 rgb 1][clock+0.1 rgb 0]}

The media is now only visible in the range of clock to clock + 0.1. Everywhere 
else, it's density will be zero, whitch is equivalent to no media.
I used "clock" as you mentioned an animation, but you can use any variable you want.
You can use another variable to set the width of the visible part. You can also 
use a colour of your choice instead of white as in my example.

-- 
Alain
-------------------------------------------------
The tree of liberty must be refreshed from time to time with the blood of
patriots and tyrants.
Thomas Jefferson


Post a reply to this message

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