POV-Ray : Newsgroups : povray.general : Creating 16-bit HFs from C++ Server Time
2 Aug 2024 02:19:59 EDT (-0400)
  Creating 16-bit HFs from C++ (Message 1 to 10 of 18)  
Goto Latest 10 Messages Next 8 Messages >>>
From: scott
Subject: Creating 16-bit HFs from C++
Date: 21 Feb 2005 05:57:12
Message: <4219be88$1@news.povray.org>
I'm writing some code in C++ (on windows) to generate some 16-bit height
field data.  What is going to be the easiest way for me to export the
numbers to use in POV?  The PNG file format looks pretty complex (compared
to BMP which is what I'm used to).

Is there any way to make POV use red+256*green or something like that from a
BMP file?  Or some software that will make red+256*green into 16-bit grey
PNG?

Thanks

Scott


Post a reply to this message

From: Vincent LE CHEVALIER
Subject: Re: Creating 16-bit HFs from C++
Date: 21 Feb 2005 07:18:38
Message: <4219d19e$1@news.povray.org>
scott wrote:
> I'm writing some code in C++ (on windows) to generate some 16-bit height
> field data.  What is going to be the easiest way for me to export the
> numbers to use in POV?  The PNG file format looks pretty complex (compared
> to BMP which is what I'm used to).
> 
> Is there any way to make POV use red+256*green or something like that from a
> BMP file?  Or some software that will make red+256*green into 16-bit grey
> PNG?
> 
> Thanks
> 
> Scott
> 
> 
Hi Scott

You could use TARGA to export your data. There is an introduction to 
this format here :
http://astronomy.swin.edu.au/~pbourke/dataformats/tga/

I did write a piece of C++ some years ago that handled the 
reading/writing of TGA images, but I fear it's not terribly well 
coded... And it is badly commented, and in french... I could give a try 
at cleaning it up if you wish, but I think you'd be better off writing 
it yourself ;-) Anyway the format is rather easy to understand.

Hope this helps

-- 
Vincent


Post a reply to this message

From: Warp
Subject: Re: Creating 16-bit HFs from C++
Date: 21 Feb 2005 09:45:33
Message: <4219f40d@news.povray.org>
scott <sco### [at] spamcom> wrote:
> I'm writing some code in C++ (on windows) to generate some 16-bit height
> field data.  What is going to be the easiest way for me to export the
> numbers to use in POV?  The PNG file format looks pretty complex (compared
> to BMP which is what I'm used to).

  The png format is not intended to be read/written directly (unless you
are a really hardcore programmer... :P ) but there are libraries for
that purpose. Of course at least the most common png library is pretty
hard to use all on itself, but that's another issue... ;)

> Is there any way to make POV use red+256*green or something like that from a
> BMP file?  Or some software that will make red+256*green into 16-bit grey
> PNG?

  From http://povray.org/documentation/view/3.6.1/279/

"The TGA and PPM file formats may be used as a storage device for 16
bit numbers rather than an image file. These formats use the red and
green bytes of each pixel to store the high and low bytes of a height
value."

  The raw TGA file format is extremely simple. It has a 18-byte header
(which format is fixed) and then the raw image data.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: scott
Subject: Re: Creating 16-bit HFs from C++
Date: 21 Feb 2005 10:31:25
Message: <4219fecd@news.povray.org>
>   From http://povray.org/documentation/view/3.6.1/279/
>
> "The TGA and PPM file formats may be used as a storage device for 16
> bit numbers rather than an image file. These formats use the red and
> green bytes of each pixel to store the high and low bytes of a height
> value."
>
>   The raw TGA file format is extremely simple. It has a 18-byte header
> (which format is fixed) and then the raw image data.

Thanks, raw TGA is exactly what I need.  Cheers.


Post a reply to this message

From: Christopher James Huff
Subject: Re: Creating 16-bit HFs from C++
Date: 21 Feb 2005 14:27:59
Message: <cjameshuff-F0941A.14280321022005@news.povray.org>
In article <4219be88$1@news.povray.org>, "scott" <sco### [at] spamcom> 
wrote:

> I'm writing some code in C++ (on windows) to generate some 16-bit height
> field data.  What is going to be the easiest way for me to export the
> numbers to use in POV?  The PNG file format looks pretty complex (compared
> to BMP which is what I'm used to).

PNG would be the best option. libpng is really not that hard to use, 
just follow the examples in the documentation. You get lossless 
compression and files that are widely supported.

Alternatively, you could encode the data as 16 or 24 bit fixed point 
float values split into 8 bit chunks among the RGB channels, and either 
use POV-Ray's built in red-green "16 bit grayscale TGA" feature or 
combine the channels manually using a function to generate the height 
field. I would suggest the latter...it seems most flexible.

-- 
Christopher James Huff <cja### [at] gmailcom>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

From: Peter Duthie
Subject: Re: Creating 16-bit HFs from C++
Date: 23 Feb 2005 01:13:19
Message: <421c1eff$1@news.povray.org>
Have you considered writing the data out as a mesh2?  Since you're 
writing a C++ program anyway, it's probably a lot easier to write a few 
floating point numbers out in text format than to write out a specific 
image file format.  Plus you get to have a greater degree of precision 
than with a 16 bit image file.  Also you can control the mesh smoothing 
if you calculate a few normal vectors.

I wrote a C++ program (win32 command line) that takes a raw 32bit 
floating point output file from World Machine, calculates the mesh, does 
a non linear transform (cylindrical wrapping), calculates the normal 
vectors, then spits out a mesh.  Email me if you'd like the source and 
you can feel free to use it however you like.

Peter D.

scott wrote:
> I'm writing some code in C++ (on windows) to generate some 16-bit height
> field data.  What is going to be the easiest way for me to export the
> numbers to use in POV?  The PNG file format looks pretty complex (compared
> to BMP which is what I'm used to).
> 
> Is there any way to make POV use red+256*green or something like that from a
> BMP file?  Or some software that will make red+256*green into 16-bit grey
> PNG?
> 
> Thanks
> 
> Scott
> 
>


Post a reply to this message

From: Warp
Subject: Re: Creating 16-bit HFs from C++
Date: 23 Feb 2005 05:53:01
Message: <421c608d@news.povray.org>
Peter Duthie <pd_### [at] warlordsofbeercom> wrote:
> does a non linear transform (cylindrical wrapping)

... to the vertex points, you mean?

  (Technically a mesh is more than just its vertex points, and performing
a transformation on the vertex points is not the same thing as performing
a transfromation on the mesh.)

-- 
plane{-x+y,-1pigment{bozo color_map{[0rgb x][1rgb x+y]}turbulence 1}}
sphere{0,2pigment{rgbt 1}interior{media{emission 1density{spherical
density_map{[0rgb 0][.5rgb<1,.5>][1rgb 1]}turbulence.9}}}scale
<1,1,3>hollow}text{ttf"timrom""Warp".1,0translate<-1,-.1,2>}//  - Warp -


Post a reply to this message

From: Sebastian H 
Subject: Re: Creating 16-bit HFs from C++
Date: 23 Feb 2005 12:04:57
Message: <421cb7b9$1@news.povray.org>
Christopher James Huff schrieb:
> In article <4219be88$1@news.povray.org>, "scott" <sco### [at] spamcom> 
> wrote:
> 
> 
>>I'm writing some code in C++ (on windows) to generate some 16-bit height
>>field data.  What is going to be the easiest way for me to export the
>>numbers to use in POV?  The PNG file format looks pretty complex (compared
>>to BMP which is what I'm used to).

Aha, me too, but linux is my choice.
As Christopher mentioned libpng is not that hard to use.
Just yesterday I took a look at the manpage (man libpng) and there are
several examples on how to write the image data.
I didn't try it yet, but it didn't look too complicated.
Maybe within the next week I'll have some C++ code.

> 
> PNG would be the best option. libpng is really not that hard to use, 
> just follow the examples in the documentation. You get lossless 
> compression and files that are widely supported.

Regards,
Sebastian H.


Post a reply to this message

From: Slime
Subject: Re: Creating 16-bit HFs from C++
Date: 23 Feb 2005 13:01:13
Message: <421cc4e9$1@news.povray.org>
> Have you considered writing the data out as a mesh2?

I believe height fields trace considerably faster than their equivalent
meshes.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: Christopher James Huff
Subject: Re: Creating 16-bit HFs from C++
Date: 23 Feb 2005 13:19:25
Message: <cjameshuff-99376F.13180923022005@news.povray.org>
In article <421cc4e9$1@news.povray.org>, "Slime" <fak### [at] emailaddress> 
wrote:

> > Have you considered writing the data out as a mesh2?
> 
> I believe height fields trace considerably faster than their equivalent
> meshes.

Have you tried it? (I haven't...I'm really wondering if there's much of 
a difference.)
A mesh has other advantages as well. You could create overhangs and 
other structures, make it higher resolution tessellation in areas that 
are more important, use a tessellation that doesn't produce artifacts 
that are as obvious, etc. You can also compute the normals more 
precisely while you're generating the mesh, rather than estimating them 
from the triangle data. Look at the height field macros to see the 
difference this can make...they compute the normal by looking at the 
slope of the height function.

On the other hand, an image-based height field is easier to 
edit...though you really need something that can handle 16 bit images.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: <chr### [at] tagpovrayorg>
http://tag.povray.org/


Post a reply to this message

Goto Latest 10 Messages Next 8 Messages >>>

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