POV-Ray : Newsgroups : povray.general : Smooth blending question Server Time
18 Nov 2024 05:12:37 EST (-0500)
  Smooth blending question (Message 1 to 10 of 10)  
From: How Camp
Subject: Smooth blending question
Date: 7 Oct 2002 15:55:27
Message: <3da1e6af@news.povray.org>
I think I already know the answer to this, but I figure I should ask, just
to be sure:

I want to create an orthographic scene (looking at the xy-plane) in the
following manner.  With a black background, I want to scatter some specific
xy points around the scene, each with a corresponding grayscale color (black
to white).  No problem.  However, if two points are 'close' to each other,
I'd like their proximity to affect the color blending in some smooth
fashion.

You could think of this as creating a heightfield based on these points - if
a white point is very close to a dark gray point, the color should fall off
smoothly and rapidly between the two.  In some sense, I guess it would be
rather like defining a 3D gradient pigment_map where the color falls of in
each direction from the indicated point.  In my case, I don't need it to be
a volumetric pigment, just some planar representation will suffice.

I've attempted this using various methods and came close via blobs, but it
still looks pretty poor...  Any idea how to achieve this?

- How


Post a reply to this message

From: Shay
Subject: Re: Smooth blending question
Date: 7 Oct 2002 17:47:04
Message: <3da200d8@news.povray.org>
How Camp <kro### [at] hotmailcom> wrote in message
news:3da1e6af@news.povray.org...

Make a mesh and assign different values to each of the vertices.

 -Shay


Post a reply to this message

From: How Camp
Subject: Re: Smooth blending question
Date: 7 Oct 2002 18:05:33
Message: <3da2052d@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message
news:3da200d8@news.povray.org...
>
> Make a mesh and assign different values to each of the vertices.


Yes, the problem comes in making the mesh.  I cannot seem to come up with a
proper way of taking a set of xyz coordinates and interpolating them into
some sort of mesh surface data.  Any simple way of doing this?  I have seen
information regarding 'natural neighbor interpolation', 'Delauney
Triangulation', etc. but have yet to find an example of using these methods
to convert a set of points.  A bit of code would be helpful to the
uninitiated, such as myself.

So, this is the opposite approach.  If I can generate a pigment map with the
right blends, I can use the resultant image as a heightfield, and thus
convert xyz data points into an interpolated surface (which is really my end
goal).

- How


Post a reply to this message

From: Shay
Subject: Re: Smooth blending question
Date: 8 Oct 2002 10:09:46
Message: <3da2e72a$1@news.povray.org>
How Camp <kro### [at] hotmailcom> wrote in message
news:3da2052d@news.povray.org...

I think that we could help you more if you gave a more specific description
of your problem. What exactly are you trying to do and with what data? How
will you be generating the points and how many of them will there be?

There are a few easy ways to do this slowly with a few points, but doing so
with a large number of points will be complex.

You can get a better effect than you got from the blobs by using the crackle
pattern. This may be all you need.

 -Shay


Post a reply to this message

From: How Camp
Subject: Re: Smooth blending question
Date: 8 Oct 2002 12:20:40
Message: <3da305d8@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message
news:3da2e72a$1@news.povray.org...
>
> I think that we could help you more if you gave a more specific
description
> of your problem. What exactly are you trying to do and with what data? How
> will you be generating the points and how many of them will there be?
>
> There are a few easy ways to do this slowly with a few points, but doing
so
> with a large number of points will be complex.
>
> You can get a better effect than you got from the blobs by using the
crackle
> pattern. This may be all you need.


Alrighty...  Here's the short version:

We have momentum collision data from an experiment we've run that shows
charge-transfer (single electron capture) from a projectile ion onto an
ionized (recoil) target.  The recoil ion longitudinal momentum distribution
is what we wish to plot - and we have the data in the form of xyz
coordinates.  Usually, we're talking about roughly thousands of points to
plot.  Some will be more.  Our current commercial software allows us to plot
this in a 2D manner, with various colors representing high/low momentum
distribution.

But it looks pretty crummy for any sort of publication.  So, we're looking
at using POV-Ray to plot the data.  We can easily plot each of the
coordinate points as spheres, and we get a discontinuous distribution
scattered around.  This turns out to be somewhat difficult to read.

So, we want to represent the data in the form of an interpolated mesh, which
we can apply a general gradient pigment showing various density information.
Again, we have the xyz data points, and now we just need a simple way to
convert them into a mesh of some sort.

I've tried finding algorithms that will do this, but quickly got in over my
head with references to various interpolative methods - the methods make
sense mathematically, but... well, I stink at programming.

So that's the short version.  I've posted related questions to the group in
the past, but no one had any grand ideas, either.  And hence, my 'new'
question.  If I can find a way to take a black pigment, and identify a
singly point on the xy plane to represent the position of my xyz information
(z being represented by a gray/white pigment color), then I can create a
bitmap to apply to a heightfield (I think).  At least, this seems to make
sense in my mind.

I started out playing with bezier patches, etc. but we need the mesh to pass
through our data points (or close to it), and so treating our data as
control points yielded strange results.  Blobs were an idea, but I couldn't
seem to find a consistent way of setting the parameters.

Hope this helps clarify where I'm headed.  Thanks, Shay, for your interest.

- How


Post a reply to this message

From: Shay
Subject: Re: Smooth blending question
Date: 8 Oct 2002 14:10:11
Message: <3da31f83@news.povray.org>
How Camp <kro### [at] hotmailcom> wrote in message
news:3da305d8@news.povray.org...
>
> Hope this helps clarify where I'm headed.  Thanks, Shay, for your
interest.
>

I think so. Let me verify. I am assuming that each of the thousands of
points has a strength at it's point of impact and then has a sphere around
it of decreasing strength. Is this correct? If so, here is your solution:

You do not need to mesh this data. A PoV-Ray isosurface will solve this
problem easily. You could combine all of the points into one giant equation,
but that would be the slow, hard way, and I believe that PoV-Ray has a limit
to the number of terms in an equation anyway. So the solution is to make a
disk with a pigment which is rgb 1 with a transmit value of 1/10K in the
center and blends towards completely transparent at the edges. The pigment
blend can be linear or based off of any equation you may have for the
falloff of the strength of each point. Just place one of these disks at each
point where you placed your spheres and place a black plane beneath the set
of disks. Make an orthographic rendering of this set and use it as a
displacement map of the isosurface. Apply a gradient pigment if you like and
you are done.

If I misunderstood the problem or, more likely, if my solution doesn't make
any damn sense (I don't speak math), let me know.

 -Shay


Post a reply to this message

From: How Camp
Subject: Re: Smooth blending question
Date: 8 Oct 2002 16:55:51
Message: <3da34657@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message
news:3da31f83@news.povray.org...
>
> I think so. Let me verify. I am assuming that each of the thousands of
> points has a strength at it's point of impact and then has a sphere around
> it of decreasing strength. Is this correct? If so, here is your solution:

More or less.  Our xyz data set has no inherent strength information - only
varying densities of particles.  Here's a real example of some of our data:
We have a grid of values, 51x21.  Each gridpoint has a height associated
with it.  We simply want to plot each of these xyz points, and smoothly
connect them in some sort of surface.

So, applying your approach sounds very good - this was what I attempted to
do with blobs.  Each disc represents particle's xy position, while the color
(some shade of gray) would represent the color's height.  The highest z
value in our 51x21 grid would be given the color rgb <1,1,1> etc.  The trick
comes in properly blending these multi-shaded discs from one grid position
to another.  Here's my sad attempt at a graphical explanation (which will,
of course, show up as garbage in a non-fixed-width-font newsreader):

+-+-+-+
|0|0|0|
+-+-+-+
|1|0|2|
+-+-+-+
|3|2|3|
+-+-+-+
|5|1|1|
+-+-+-+


Hence, the lower left-hand corner presents a problem of blending from a high
peak (color value 5) to a low peak (color value 1) as we move horizontally.
If we put two discs of varying intensity, I don't believe the pigments will
properly blend.

>
> You do not need to mesh this data. A PoV-Ray isosurface will solve this
> problem easily. You could combine all of the points into one giant
equation,
> but that would be the slow, hard way, and I believe that PoV-Ray has a
limit
> to the number of terms in an equation anyway. So the solution is to make a
> disk with a pigment which is rgb 1 with a transmit value of 1/10K in the
> center and blends towards completely transparent at the edges. The pigment
> blend can be linear or based off of any equation you may have for the
> falloff of the strength of each point. Just place one of these disks at
each
> point where you placed your spheres and place a black plane beneath the
set
> of disks. Make an orthographic rendering of this set and use it as a
> displacement map of the isosurface. Apply a gradient pigment if you like
and
> you are done.

Okay, I tried this to see if it would help, and I've discovered some strange
things about pigments.  My scene file is shown below (sorry - I should
probably put it in p.b.s-f but it's short).  The problem seems to be the
lack of transparency from one disc to another.  What am I doing wrong?

- How


camera {
  orthographic
  location  <0.0, 0.0, -10.0>
  look_at   <0.0, 0.0,  0.0>
}

background {  Black  }

light_source {  <-30, 30, -30>  color White  }

// ----------------------------------------

#declare TexOn=true ;


#if (TexOn)
        #declare DTex = texture {
                pigment {
                        spherical
                        color_map {
                                [ 0.0 rgbft <1.0, 1.0, 1.0, 1.0, 1.0> ]
                                [ 1.0 rgbft <1.0, 1.0, 1.0, 0.0, 0.0> ]
                        }
                scale 2
                }
        }
#else
        #declare DTex = texture { pigment {color Green} }
#end

#declare DiscRad = 1;

disc { 0 z, DiscRad, 0 texture {DTex} translate <0,0,0.0000>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <1,0,0.0001>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <0,1,0.0002>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <0,2,0.0003>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <3,2,0.0004>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <5,1,0.0005>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <1,6,0.0006>}
disc { 0 z, DiscRad, 0 texture {DTex} translate <2,4,0.0007>}


Post a reply to this message

From: Shay
Subject: Re: Smooth blending question
Date: 8 Oct 2002 17:56:52
Message: <3da354a4$1@news.povray.org>
How Camp <kro### [at] hotmailcom> wrote in message
news:3da34657@news.povray.org...
>
> More or less.  Our xyz data set has no inherent strength information -
only
> varying densities of particles.  Here's a real example of some of our
data:
> We have a grid of values, 51x21.  Each gridpoint has a height associated
> with it.  We simply want to plot each of these xyz points, and smoothly
> connect them in some sort of surface.
>

This may be a lot simpler than I thought. All that is really needed is to
reorganize the data you have into a heightfield type mesh2 formal. I have a
macro at home that can do this. I will post it tomorrow.

The macro is pretty straightforward. The only input needed is a
two-dimensional array of values. like this: array[x position][y position] =
z value.

Smoothing out the surface is another problem. This can be accomplished
easily with a mesh subdivision, but smooth surfaces which travel *through* a
set of points have a tendency to warp and look wavy. Here is an example:
http://news.povray.org/povray.binaries.images/23830/

 -Shay


Post a reply to this message

From: How Camp
Subject: Re: Smooth blending question
Date: 8 Oct 2002 18:20:55
Message: <3da35a47$1@news.povray.org>
"Shay" <sah### [at] simcopartscom> wrote in message
news:3da354a4$1@news.povray.org...

> This may be a lot simpler than I thought. All that is really needed is to
> reorganize the data you have into a heightfield type mesh2 formal. I have
a
> macro at home that can do this. I will post it tomorrow.

Wonderful!  I'd love to see it.

> Smoothing out the surface is another problem. This can be accomplished
> easily with a mesh subdivision, but smooth surfaces which travel *through*
a
> set of points have a tendency to warp and look wavy.

I'll give your macro a go, and see where it gets me.  At this point,
anything is an improvement.  Again, thanks, Shay.

- How


Post a reply to this message

From: Shay
Subject: Re: Smooth blending question
Date: 9 Oct 2002 13:43:09
Message: <3da46aad$1@news.povray.org>
see p.b.i.
 -Shay

"How Camp" <kro### [at] hotmailcom> wrote in message
news:3da35a47$1@news.povray.org...


Post a reply to this message

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