POV-Ray : Newsgroups : povray.advanced-users : particle system Server Time
24 Nov 2024 04:35:32 EST (-0500)
  particle system (Message 1 to 4 of 4)  
From: Kay-Ju
Subject: particle system
Date: 26 Jun 2009 05:00:00
Message: <web.4a448d38b99e86456aaf5a00@news.povray.org>
Can i use an image_map to create a
3D-particle system?

I.e. i have a field consisting of let's say 32
by 32 small spheres and i want them to be translated
along the y-axis according to the map-color.

Can this be done?
In an easy way?


Post a reply to this message

From: Chris B
Subject: Re: particle system
Date: 26 Jun 2009 05:26:31
Message: <4a449447$1@news.povray.org>
"Kay-Ju" <k.j### [at] gmxde> wrote in message 
news:web.4a448d38b99e86456aaf5a00@news.povray.org...
> Can i use an image_map to create a
> 3D-particle system?
>
> I.e. i have a field consisting of let's say 32
> by 32 small spheres and i want them to be translated
> along the y-axis according to the map-color.
>
> Can this be done?
> In an easy way?
>

You can declare a pigment using the image as an image_map in the pigment 
declaration.
You can use two nested loops to work through the grid positions and use the 
'eval_pigment' function in POV-Rays 'functions.inc' to tell you what the 
color is at that point on the image.
You can then use that color as a height value when adding each sphere to the 
scene.

The default image_map is layed on the X-Y plane, so you'll either need to 
rotate it or you'll need to pass the X and Z positions into the eval_pigment 
function to represent the X and Y coordinates.
By default the image is scaled to 1 unit high and 1 unit wide, so you'll 
need to scale it or factor that into the positions you pass into 
eval_pigment.

If you want to work with large numbers of spheres (e.g. 1000 by 1000), it's 
worth extracting the SDL from the eval_pigment function and placing it 
inline in your scene. You'll find it declares a function and you only need 
to declare that function once rather than a million times, saving 
significant processing time.

Regards,
Chris B.


Post a reply to this message

From: clipka
Subject: Re: particle system
Date: 26 Jun 2009 06:50:00
Message: <web.4a44a71a816b3b0aa745f7570@news.povray.org>
"Kay-Ju" <k.j### [at] gmxde> wrote:
> I.e. i have a field consisting of let's say 32
> by 32 small spheres and i want them to be translated
> along the y-axis according to the map-color.
>
> Can this be done?
> In an easy way?

There are multiple ways to do this. I guess the easiest is to #define a pigment
from the image, and use eval_pigment() (defined in functions.inc) in a double
loop to retrieve the color at the respective point in the image (note that the
coordinates should normally range from 0 to 1); you can then use the .red,
..green or .blue component of the returned color vector (or .gray for the
brightness) to compute the desired translation.


Post a reply to this message

From: Kay-Ju
Subject: Re: particle system
Date: 27 Jun 2009 11:15:00
Message: <web.4a463673816b3b0aba336aa70@news.povray.org>
"clipka" <nomail@nomail> wrote:
> "Kay-Ju" <k.j### [at] gmxde> wrote:
> > I.e. i have a field consisting of let's say 32
> > by 32 small spheres and i want them to be translated
> > along the y-axis according to the map-color.
> >
> > Can this be done?
> > In an easy way?
>
> There are multiple ways to do this. I guess the easiest is to #define a pigment
> from the image, and use eval_pigment() (defined in functions.inc) in a double
> loop to retrieve the color at the respective point in the image (note that the
> coordinates should normally range from 0 to 1); you can then use the .red,
> ..green or .blue component of the returned color vector (or .gray for the
> brightness) to compute the desired translation.

Thank you both.
That is perfectly the information i have been
questing for.

cu
Kay-Ju


Post a reply to this message

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