|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
I'm trying to find a website: it had an excellent tutorial on turning flat
bitmaps of rocks into heightfields. The guy also had an image gallery
with pictures of an indoor swimming pool (POV-Ray generated).
Sorry, that's really all I have to go on... anybody know this site?
- Doug Eichenberg
http://www.getinfo.net/douge
dou### [at] nlsnet
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Doug Eichenberg wrote:
>
> with pictures of an indoor swimming pool (POV-Ray generated).
> Sorry, that's really all I have to go on... anybody know this site?
I know this site. There is also that teapot picture from pov Hall of Fame.
http://www.kivisalo.net
K.K.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Kari Kivisalo wrote:
>Doug Eichenberg wrote:
>>
>> with pictures of an indoor swimming pool (POV-Ray generated).
>> Sorry, that's really all I have to go on... anybody know this site?
>
>I know this site. There is also that teapot picture from pov Hall of
>Fame. http://www.kivisalo.net
I like your Level Connector.
It makes me wonder, would something like this also be possible in 3d-
space? A level_connect warp? It would be nice in combination with Chris'
object pattern and other colour list pigments.
Ingo
--
Photography: http://members.home.nl/ingoogni/
Pov-Ray : http://members.home.nl/seed7/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
ingo wrote:
>
> I like your Level Connector.
> It makes me wonder, would something like this also be possible in 3d-
> space?
I like to think this as a simple electrical potential, so it can
be extented to 3d. Time and memory consumption would be too high
with the iterative method currently used. FFT would be more efficient
way to solve the potential field. I have to think about this :)
Just as in 2d the input and solution would be discrete. In 3d
that would be discrete volumes of densities. I can see this
had media applications but not sure if it can be used for surface
generation, maybe with isosurface functions.
Can someone lend me a Cray for the 3D FFT calculations :)
K.K.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
That's the one Kari! (Nice site, BTW). Thanks!
- Doug Eichenberg
http://www.getinfo.net/douge
dou### [at] nlsnet
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <39954523.5752D334@kivisalo.net>, Kari Kivisalo
<kar### [at] kivisalonet> wrote:
> I like to think this as a simple electrical potential, so it can
> be extented to 3d. Time and memory consumption would be too high
> with the iterative method currently used. FFT would be more efficient
> way to solve the potential field. I have to think about this :)
>
> Just as in 2d the input and solution would be discrete. In 3d
> that would be discrete volumes of densities. I can see this
> had media applications but not sure if it can be used for surface
> generation, maybe with isosurface functions.
This looks like it could be a useful enhancement for the proximity
pattern(it could solve the grainyness problem)...or something to be
applied to any pattern. Could you give more details on how you calculate
it? I didn't see an in-depth explanation on the site.
--
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Chris Huff wrote:
>
> Could you give more details on how you calculate
> it? I didn't see an in-depth explanation on the site.
Here is the theory on 2d electrical potential and how to obtain numerical
approximation using difference equations and iterations. This can be solved
with FFT also but I don't yet know how. Should be easy enough to find:
"solving poisson with fft". Numerical Recipes has nice code for 3D FFT
which calculates the solution in-place saving memory.
Laplace: u(xx) + u(yy) = 0
u(xx) = 2nd derivative of u over variable x
Here u is potential (hf height). x and y are hf coordinates.
Resulting difference formula in free areas (x,y) + 1 pixel boundary:
u(x+1,y) + u(x,y+1) + u(x-1,y) + u(x,y-1) = 4*u(x,y)
So basically the procedure is: Take surrounding 4 pixels and put
the average in the middle. Repeat for all free pixels (x,y). If
there are n free pixels the resulting linear system is n*5. I solve
this with Gauss-Seidel iteration.
More on this method in Advanced Engineering Mathematics by Kreyszig
in section Numerical methods for differential equations.
I sent this uncleaned code to the Terragen guy and he made it a new filter.
------------------------------------------------------------------
LevelConnector uses these pseudo functions to communicate with the
rest of the app.
SetHeight(x, y, hv);
hv=GetHeight(x, y);
Sel=GetSelValue(x, y); // is pixel selected
PixV=HVToFloat(hv); // convert from internal type to float
hv=FloatToHV(PixV); // convert to internal type
//def for the compare func used by bsearch
typedef int (*fptr)(const void*, const void*);
int compare(const int *a,const int *b)
{
return(*a - *b);
}
// The main calculations. Processes data in u[].
// Solves this Laplace's 2nd order differential
// equation using Gauss-Seidel iteration.
//
// d2u d2u
// --- + --- = 0 + (force, not used)
// dx2 dy2
//
// Can be solved by FFT also but this iterative method lets user control
// the accuracy of the solution. If all pixels are selected then this works
// like smooth with variable radius. Basically it just averages 4 adjacent
// pixels into the middle pixel :) Note however that one iteration pass uses
// uses 2 values per pixel already computed in that pass so it's a kind of
// cumulative smooth.
void SolveEquations(int **s, float *h, float *u, int Nodes, int maxiter)
{
int i,c,dir=1,Node;
float sum;
for(i=0;i<maxiter;i++)
{for(Node=(Nodes-1)*(1-dir)/2;dir*Node<=(Nodes-1)*(1+dir)/2;Node=Node+dir)
{ sum=h[Node];
for(c=1;c<=s[Node][0];c++)
sum=sum+u[s[Node][c]];
u[Node]=0.25*sum;
}
dir=-dir; // toggle direction
}
}
// Prepares data for SolveEquations
void LevelConnector(int width,int height, int maxiter)
{
int xo[4]={1,-1,0,0},yo[4]={0,0,1,-1};
int c,Nodes=0,*NodeP,Node,PixN;
int x,y,xt,yt,i,j,*Pos,**s;
float *h,*u,Sel,PixV,k;
// Count selected pixels
for(y=0;y<height;y++)
{for(x=0;x<width;x++)
{if(GetSelValue(x, y) == SELECTED)
Nodes++;
}
}
u=(float *)malloc(Nodes*sizeof(float)); // This is the actual height data
h=(float *)malloc(Nodes*sizeof(float)); // aux data for equations
Pos=(int *)malloc(Nodes*sizeof(int)); // Stores pixel positions of nodes
s=(int **)malloc(Nodes*sizeof(int *)); // aux data for equations
// clear arrays
for(Node=0;Node<Nodes;Node++)
{
s[Node]=(int *)malloc(5*sizeof(int));
if (s[Node] == NULL) {perror("memory error");exit(1);}
for(j=0;j<5;j++)
s[Node][j]=0;
u[Node]=0;
h[Node]=0;
Pos[Node]=0;
}
// Fill position table
Node=0;PixN=0;
for(y=0;y<height;y++)
{for(x=0;x<width;x++)
{Sel=GetSelValue(x, y);
if(Sel == SELECTED)
{Pos[Node]=PixN;
Node++;
}
PixN++;
}
}
// Make equations
Node=0;PixN=0;
for(y=0;y<height;y++)
{for(x=0;x<width;x++)
{if(GetSelValue(x, y) == SELECTED)
{k=0;c=0;
for(i=0;i<4;i++)
{yt=y+yo[i];
xt=x+xo[i];
if (yt == -1) yt=height-1;
if (yt == height) yt=0;
if (xt == -1) xt=width-1;
if (xt == width) xt=0;
hv=GetHeight(xt, yt);
PixV=HVToFloat(hv);
if(GetSelValue(xt, yt) != SELECTED)
k=k+PixV;
else
{c++;
PixN=yt*width+xt;
NodeP=(int *)bsearch(&PixN,Pos,Nodes,sizeof(int),(fptr)compare);
if(NodeP == NULL)
{perror("error in bserch");
exit(1);
}
s[Node][c]=(int)(NodeP-Pos);
}
}
hv=GetHeight(x, y);
u[Node]=HVToFloat(hv);
h[Node]=k;
// h[Node]=k-force; past experiment
s[Node][0]=c;
Node++;
}
}
}
SolveEquations(s,h,u,Nodes,maxiter);
free(h);
// Write data in u[] back to hf
for(Node=0;Node<Nodes;Node++)
{
free(s[Node]);
hv=FloatToHV(u[Node]);
x=Pos[Node]%width;
y=Pos[Node]/width;
SetHeight(x, y, hv);
}
free(s);
free(Pos);
free(u);
}
K.K.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3995801A.AC206C81@kivisalo.net>, Kari Kivisalo
<kar### [at] kivisalonet> wrote:
> Here is the theory on 2d electrical potential and how to obtain
> numerical approximation using difference equations and iterations.
> This can be solved with FFT also but I don't yet know how. Should be
> easy enough to find: "solving poisson with fft". Numerical Recipes
> has nice code for 3D FFT which calculates the solution in-place
> saving memory.
Thanks...it looks like it will take a while to analyze this and convert
it to 3d, though. I guess it would help if I had some calculus...and
don't expect a FFT solving method from me. :-)
--
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Kari Kivisalo" <kar### [at] kivisalonet> wrote in message
news:3995801A.AC206C81@kivisalo.net...
> Chris Huff wrote:
> >
> > Could you give more details on how you calculate
> > it? I didn't see an in-depth explanation on the site.
>
> Here is the theory on 2d electrical potential and how to obtain numerical
> approximation using difference equations and iterations. This can be
solved
> with FFT also but I don't yet know how. Should be easy enough to find:
> "solving poisson with fft". Numerical Recipes has nice code for 3D FFT
> which calculates the solution in-place saving memory.
>
> Laplace: u(xx) + u(yy) = 0
> u(xx) = 2nd derivative of u over variable x
>
> Here u is potential (hf height). x and y are hf coordinates.
> Resulting difference formula in free areas (x,y) + 1 pixel boundary:
>
> u(x+1,y) + u(x,y+1) + u(x-1,y) + u(x,y-1) = 4*u(x,y)
>
> So basically the procedure is: Take surrounding 4 pixels and put
> the average in the middle. Repeat for all free pixels (x,y). If
> there are n free pixels the resulting linear system is n*5. I solve
> this with Gauss-Seidel iteration.
>
> More on this method in Advanced Engineering Mathematics by Kreyszig
> in section Numerical methods for differential equations.
>
>
> I sent this uncleaned code to the Terragen guy and he made it a new
filter.
>
> ------------------------------------------------------------------
> LevelConnector uses these pseudo functions to communicate with the
> rest of the app.
>
> SetHeight(x, y, hv);
> hv=GetHeight(x, y);
> Sel=GetSelValue(x, y); // is pixel selected
> PixV=HVToFloat(hv); // convert from internal type to float
> hv=FloatToHV(PixV); // convert to internal type
>
>
> file://def for the compare func used by bsearch
> typedef int (*fptr)(const void*, const void*);
>
> int compare(const int *a,const int *b)
> {
> return(*a - *b);
> }
>
>
> // The main calculations. Processes data in u[].
> // Solves this Laplace's 2nd order differential
> // equation using Gauss-Seidel iteration.
> //
> // d2u d2u
> // --- + --- = 0 + (force, not used)
> // dx2 dy2
> //
> // Can be solved by FFT also but this iterative method lets user control
> // the accuracy of the solution. If all pixels are selected then this
works
> // like smooth with variable radius. Basically it just averages 4 adjacent
> // pixels into the middle pixel :) Note however that one iteration pass
uses
> // uses 2 values per pixel already computed in that pass so it's a kind of
> // cumulative smooth.
>
> void SolveEquations(int **s, float *h, float *u, int Nodes, int maxiter)
> {
> int i,c,dir=1,Node;
> float sum;
>
> for(i=0;i<maxiter;i++)
>
{for(Node=(Nodes-1)*(1-dir)/2;dir*Node<=(Nodes-1)*(1+dir)/2;Node=Node+dir)
> { sum=h[Node];
> for(c=1;c<=s[Node][0];c++)
> sum=sum+u[s[Node][c]];
> u[Node]=0.25*sum;
> }
> dir=-dir; // toggle direction
> }
> }
>
>
> // Prepares data for SolveEquations
>
> void LevelConnector(int width,int height, int maxiter)
> {
> int xo[4]={1,-1,0,0},yo[4]={0,0,1,-1};
> int c,Nodes=0,*NodeP,Node,PixN;
> int x,y,xt,yt,i,j,*Pos,**s;
> float *h,*u,Sel,PixV,k;
>
> // Count selected pixels
> for(y=0;y<height;y++)
> {for(x=0;x<width;x++)
> {if(GetSelValue(x, y) == SELECTED)
> Nodes++;
> }
> }
>
> u=(float *)malloc(Nodes*sizeof(float)); // This is the actual height
data
> h=(float *)malloc(Nodes*sizeof(float)); // aux data for equations
> Pos=(int *)malloc(Nodes*sizeof(int)); // Stores pixel positions of
nodes
> s=(int **)malloc(Nodes*sizeof(int *)); // aux data for equations
>
>
> // clear arrays
> for(Node=0;Node<Nodes;Node++)
>
> s[Node]=(int *)malloc(5*sizeof(int));
> if (s[Node] == NULL) {perror("memory error");exit(1);}
> for(j=0;j<5;j++)
> s[Node][j]=0;
> u[Node]=0;
> h[Node]=0;
> Pos[Node]=0;
> }
>
>
> // Fill position table
> Node=0;PixN=0;
> for(y=0;y<height;y++)
> {for(x=0;x<width;x++)
> {Sel=GetSelValue(x, y);
> if(Sel == SELECTED)
> {Pos[Node]=PixN;
> Node++;
> }
> PixN++;
> }
> }
>
>
> // Make equations
> Node=0;PixN=0;
> for(y=0;y<height;y++)
> {for(x=0;x<width;x++)
> {if(GetSelValue(x, y) == SELECTED)
> {k=0;c=0;
> for(i=0;i<4;i++)
> {yt=y+yo[i];
> xt=x+xo[i];
> if (yt == -1) yt=height-1;
> if (yt == height) yt=0;
> if (xt == -1) xt=width-1;
> if (xt == width) xt=0;
> hv=GetHeight(xt, yt);
> PixV=HVToFloat(hv);
> if(GetSelValue(xt, yt) != SELECTED)
> k=k+PixV;
> else
> {c++;
> PixN=yt*width+xt;
> NodeP=(int *)bsearch(&PixN,Pos,Nodes,sizeof(int),(fptr)compare);
> if(NodeP == NULL)
> {perror("error in bserch");
> exit(1);
> }
> s[Node][c]=(int)(NodeP-Pos);
> }
> }
> hv=GetHeight(x, y);
> u[Node]=HVToFloat(hv);
> h[Node]=k;
> // h[Node]=k-force; past experiment
> s[Node][0]=c;
> Node++;
> }
> }
> }
>
> SolveEquations(s,h,u,Nodes,maxiter);
> free(h);
>
> // Write data in u[] back to hf
> for(Node=0;Node<Nodes;Node++)
>
> free(s[Node]);
> hv=FloatToHV(u[Node]);
> x=Pos[Node]%width;
> y=Pos[Node]/width;
> SetHeight(x, y, hv);
> }
>
> free(s);
> free(Pos);
> free(u);
> }
>
> K.K.
Aaaaaaaargh!!! You've frightened the s**t out of me now
Kari!! Whats a man to do?? (Need new specs after that! Me 'eads gone all
dizzy!! ;o)
~Steve~
PS, how do I save an image as .jpg, *in POV-Ray*, to 'send' to you very
'NICE' people to perooooose over? Simple question, I know, but I'M sure that
you can handle it, Kari............thanx.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
In article <3995c067@news.povray.org>, "25ct" <25c### [at] lineonenet> wrote:
> PS, how do I save an image as .jpg, *in POV-Ray*, to 'send' to you
> very 'NICE' people to perooooose over? Simple question, I know, but
> I'M sure that you can handle it, Kari............thanx.
You don't. You have to use an external program to convert an image
generated by POV(in PNG or TGA format, for example) to JPEG. The next
version may include JPEG *input*, but JPEG, as a "lossy" format, won't
be available for output.
--
Christopher James Huff - Personal e-mail: chr### [at] maccom
TAG(Technical Assistance Group) e-mail: chr### [at] tagpovrayorg
Personal Web page: http://homepage.mac.com/chrishuff/
TAG Web page: http://tag.povray.org/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|