POV-Ray : Newsgroups : povray.advanced-users : Editing or creating an image or heightfield in POV-Ray Server Time
9 May 2024 03:01:12 EDT (-0400)
  Editing or creating an image or heightfield in POV-Ray (Message 1 to 10 of 20)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Bald Eagle
Subject: Editing or creating an image or heightfield in POV-Ray
Date: 10 Sep 2023 12:05:00
Message: <web.64fde8724fc784d81f9dae3025979125@news.povray.org>
With regard to TdG's interest in erosion, I was thinking about doing a quick
test with an image map converted to a height_field.

The only problem here is that I don't recall if there was a way to edit the
pixel data in the image_map, or in the height_field, or to somehow use a
function {} or a 2D array to create an image or heightfield...

Or maybe a way to add/subtract / overlay onto the base image.
I can't use arrays in functions, otherwise I could do image_map {function
{array}}

It would be useful to not have to load an image, convert that to an array, use
that array to create a mesh, then use the algorithm I'm experimenting with to
edit the mesh.....

Does anyone have any ideas?

- BW


Post a reply to this message

From: ingo
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 10 Sep 2023 13:10:00
Message: <web.64fdf7ee5742124017bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> Does anyone have any ideas?
>
> - BW

Not elegant, but you can abuse splines as arrays in functions.

In a distant past we've had several discussions on erosion. I had a look but
can't find it (my archive is lost). I then made an animation or images using
DF3's. Not in POV-Ray it self but in Python.

I randomly dropped rain drops on the DF3. Every rain drop had a strength. The
density of the DF3 was the density/hardness of the stone. When eroding the
raindrop lost some strength and the stone lost some density. The harder the rock
the more costly it was for the drop.

Then, if there was still some 'life' in it, the raindrop would move to the
nearest neighbor with the lowest density and repeat the process until the drops
strength was zero.

I also did it with a combination of Hf and DF3, the HF was the landscape and the
DF3 the rock/soil. Then I eroded the HF away.

Christoph Hormann, ABX were also working on this, i.i.r.c.

ingo


Post a reply to this message

From: ingo
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 10 Sep 2023 13:45:00
Message: <web.64fe002a5742124017bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> Does anyone have any ideas?
>
> - BW

Does the starting point have to be an image? You can use a function in a HF.
https://wiki.povray.org/content/Reference:Function_Pattern#Function_Image

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 10 Sep 2023 14:10:00
Message: <web.64fe0616574212401f9dae3025979125@news.povray.org>
"ingo" <nomail@nomail> wrote:

> Does the starting point have to be an image? You can use a function in a HF.
> https://wiki.povray.org/content/Reference:Function_Pattern#Function_Image

Good to know, sorry that you lost your archive.

I've (ab)used splines in functions, but I don't know if I could do that in 2D to
get a heightfield.

I could use a function to make the HF, but I'm still presently at a loss for how
I'd modify the values at each <x, y> position, since I still can't make discrete
modifications, due to the nature of functions, etc.  Going around in circles.

It seems like we _should_ have a way to "write" to the <x,y> pixel data stored
in memory after POV-Ray loads an image file, but we don't.
It also seems like we _should_ have a way to make images and HF's from a 2D
array, but we don't.

I guess I'll just bite the bullet and remember how to make a mesh, calculate the
normals, make smooth triangles..... {sigh}.

I was just hoping for an easier, lazier way.

- BW


Post a reply to this message

From: Bald Eagle
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 10 Sep 2023 17:30:00
Message: <web.64fe3522574212401f9dae3025979125@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> I guess I'll just bite the bullet and remember how to make a mesh, calculate the
> normals, make smooth triangles..... {sigh}.

I abandoned an A* driven method in favor of using existing algorithms instead of
starting from scratch with no real idea what I'm doing.  (A* might be useful for
filling in the terrain with water cascading downhill via the erosion paths.)

So, I made the meshes, calculated the normals, made the smooth_triangles, edited
a small erosion algorithm, ran it a few times (which took longer that it should
have), and then added some elapsed time code.
Had to hack the algorithm to get rid of the deep pitting.

My meshes look terrible, my color_map is all off, etc.

I'm using a tiny 358 x 358 image for my terrain.  That's 128164 pixels or 256328
triangles (maybe a few less).

I then drop 20,000 raindrops that undergo a max of 50 erosion/deposition cycles.

No idea what the parameter values ought to be.


Building HeightField array ...
Took 2.47 sec to build the HeightField array.
Making starting mesh ...
Took 59.70 sec to build the starting mesh.
Took 1.43 min to erode starting mesh.
Making eroded mesh ...
Took 1.08 min to make the Eroded mesh.


Parser Time
  Parse Time:       0 hours  3 minutes 32 seconds (212.499 seconds)
Elapsed time 215.84 seconds.


That's an awful damned long time to build a stinking mesh, especially since the
array gets populated in 2.47 sec.

Anyway, it's a start, and I'm sure there are improvements to be made, for those
interested in having a go at it.

- BW


Post a reply to this message


Attachments:
Download 'a-star heightmap.png' (453 KB)

Preview of image 'a-star heightmap.png'
a-star heightmap.png


 

From: kurtz le pirate
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 11 Sep 2023 05:35:24
Message: <64fedf5c@news.povray.org>
On 10/09/2023 18:01, Bald Eagle wrote:
> 
> With regard to TdG's interest in erosion, I was thinking about doing a quick
> test with an image map converted to a height_field.
> 
> The only problem here is that I don't recall if there was a way to edit the
> pixel data in the image_map, or in the height_field, or to somehow use a
> function {} or a 2D array to create an image or heightfield...
> 
> Or maybe a way to add/subtract / overlay onto the base image.
> I can't use arrays in functions, otherwise I could do image_map {function
> {array}}
> 
> It would be useful to not have to load an image, convert that to an array, use
> that array to create a mesh, then use the algorithm I'm experimenting with to
> edit the mesh.....
> 
> Does anyone have any ideas?
> 
> - BW
> 



Long time ago, I made a code that, given a png image, would plot for
each pixel a box of the original color and store this value in a 2d array.

Code attached


Maybe it can give you some ideas for your problem ?




-- 
Kurtz le pirate
Compagnie de la Banquise


Post a reply to this message


Attachments:
Download 'eval_pigment1.pov.txt' (3 KB)

From: ingo
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 11 Sep 2023 05:45:00
Message: <web.64fee0cc5742124017bac71e8ffb8ce3@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> Does anyone have any ideas?

Tor Olav has, or at least some inspiration:

https://github.com/t-o-k/POV-Ray-gaussian-blur/blob/master/Examples/Blur_Image_Region.png

https://github.com/t-o-k/POV-Ray-gaussian-blur/blob/master/Examples/Blur_Image_Region.pov

ingo


Post a reply to this message

From: Bald Eagle
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 12 Sep 2023 15:20:00
Message: <web.6500b8e3574212401f9dae3025979125@news.povray.org>
"ingo" <nomail@nomail> wrote:

> Tor Olav has, or at least some inspiration:

Hmmmm.... Very interesting.  I'm gonna need a bit of time to dissect that and
see how all the different parts work.
Knowing TOK, I'll probably walk away with some new lessons well worth learning,
which might give rise to some new inspirations and experiments.

Thanks for the links - I would have never made the connection and thought to
look there. (although I did, of course, suspect that he would have some ideas...
;) )

[Now of course, what we need to do is get him some _free time_ to POV!  :D ]

- BW


Post a reply to this message

From: Thomas de Groot
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 13 Sep 2023 02:35:33
Message: <65015835@news.povray.org>
Op 10/09/2023 om 18:01 schreef Bald Eagle:
> 
> With regard to TdG's interest in erosion, I was thinking about doing a quick
> test with an image map converted to a height_field.
> 
> The only problem here is that I don't recall if there was a way to edit the
> pixel data in the image_map, or in the height_field, or to somehow use a
> function {} or a 2D array to create an image or heightfield...
> 
> Or maybe a way to add/subtract / overlay onto the base image.
> I can't use arrays in functions, otherwise I could do image_map {function
> {array}}
> 
> It would be useful to not have to load an image, convert that to an array, use
> that array to create a mesh, then use the algorithm I'm experimenting with to
> edit the mesh.....
> 
> Does anyone have any ideas?
> 
> - BW
> 

Real Time is binding me hands and feet, so a belated comment so far.

What I am personally looking for / interested in is not so much the 
generation of natural-looking heightfields in terms of erosional 
patterns like mountains and valleys which is provided by e.g. World 
Machine. In itself it is an interesting topic and I remember (but cannot 
find again) a series of tests some years ago where the drainage patterns 
on in the heightfields were used to generate down-flowing rivers using a 
trace function. I must have a whole collection of examples somewhere 
under the dust but to date I have not been able to find those.

What I am /really/ interested in is the rockface erosion in cliffs and 
such which enhance the natural aspect of any mountain or landscape. As 
an example I attach a photograph of the Faroe Islands showing a cliff 
face, but what you can see are those (sub-)horizontal layers of more or 
less "competent" (= hard/soft) rocks, in the cliff and in the overlying 
landscape. They account for regions where the rock faces are more or 
less overhanging. This is impossible in classical heightfields but easy 
to achieve with isosurfaces of course.

Could we somehow achieve something similar using functions in POV-Ray, 
without the help of isosurfaces? That would be my question.

-- 
Thomas


Post a reply to this message


Attachments:
Download 'faroe islands.jpg' (112 KB)

Preview of image 'faroe islands.jpg'
faroe islands.jpg


 

From: ingo
Subject: Re: Editing or creating an image or heightfield in POV-Ray
Date: 13 Sep 2023 05:45:00
Message: <web.650183f85742124017bac71e8ffb8ce3@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> Could we somehow achieve something similar using functions in POV-Ray,
> without the help of isosurfaces? That would be my question.
>

Create hight-fields using functions. Then rotate the one with the 'lines' and
intersect it with the one with the horizontal landscape.

ingo


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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