POV-Ray : Newsgroups : povray.general : Height_field help Server Time
4 Dec 2024 21:22:37 EST (-0500)
  Height_field help (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Leroy
Subject: Height_field help
Date: 5 Mar 2023 11:50:00
Message: <web.6404c75bf7444c077917166bf712fc00@news.povray.org>
For all those playing with height_fields here a mac I wrote long ago to help
load the image for a height field

#macro Image(File)
 #local L=strlen(File);
 #local Out=-1;
 #local Cnt = L;
 #while (Cnt >0)
  #if(strcmp(substr(File,Cnt,1),".")=0)
   #local Out=Cnt;
   #local Cnt =0;
  #end
 #local Cnt = Cnt-1;
 #end
 #if(Out<0) #debug concat ("\nFile :: "File," :: Failed\n\n") #error "Image_Map
File bad" #end
 #local Cnt =L-Out;
 #local Bs=strlwr(substr(File,Out+1,Cnt)) //#debug concat("\n__",Bs,"___\n")

 #if(Bs="tga") tga File #end
 #if(Bs="bmp") bmp File #end
 #if(Bs="pgm") pgm File #end
 #if(Bs="png") png File #end
 #if(Bs="ppm") ppm File #end
 #if(Bs="jpg") jpeg File  #end
 #if(Bs="exr") exr File #end
 #if(Bs="hdr") hdr File #end
 #if(Bs="gif") gif File #end
 #if(Bs="iff") iff File #end
 #if(Bs="tif") tiff File  #end
#declare Image_Type=Bs;// Type string that can be used else where
#end

How to use:

#declare FileStr="Image.tga"

height_field{Image(Filestr} ...
        or
#declare PigFnc=function{pigment{image_map{Image(FileStr)}}}
height_field {function 400,400{ PigFnc(x,y) }

Hope this can be some help.

I have tested all the files except the "iff" type. I have nothing that can
produce them. Does any one use 'iff' any more?
The 'gif' & 'tif' files where hard to find in my files as I rarely use them any
more. All the rest where made with POV.

Have Fun!


Post a reply to this message

From: Kenneth
Subject: Re: Height_field help
Date: 5 Mar 2023 14:50:00
Message: <web.6404f1843575e8099b4924336e066e29@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
>
> #macro Image(File)
>  #local L=strlen(File);
>  (etc) ...

> How to use:
>
> #declare FileStr="Image.tga"
>
> height_field{Image(Filestr} ... // ending parenthesis missing?
>

[Windows 10, running v3.8.0 beta 1]
I like the idea. But substituting my own .png image_map...

#declare FileStr="test image for hf png.png"
height_field{Image(Filestr)} // parenthesis added

...I get a fatal error at the last line: "Cannot pass uninitialized identifier as
non-optional macro parameter."


Post a reply to this message

From: Leroy
Subject: Re: Height_field help
Date: 5 Mar 2023 15:20:00
Message: <web.6404f9483575e8097917166bf712fc00@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Leroy" <whe### [at] gmailcom> wrote:
> >
> > #macro Image(File)
> >  #local L=strlen(File);
> >  (etc) ...
>
> > How to use:
> >
> > #declare FileStr="Image.tga"
> >
> > height_field{Image(Filestr} ... // ending parenthesis missing?
> >
>
> [Windows 10, running v3.8.0 beta 1]
> I like the idea. But substituting my own .png image_map...
>
> #declare FileStr="test image for hf png.png"
> height_field{Image(Filestr)} // parenthesis added
>
> ...I get a fatal error at the last line: "Cannot pass uninitialized identifier as
> non-optional macro parameter."

Sorry about the typo.I copied the example from working code & delete one space
to much.

I hope your problem is the another typo
  height_field{Image(Filestr)}  FileStr

Have Fun!


Post a reply to this message

From: Kenneth
Subject: Re: Height_field help
Date: 5 Mar 2023 16:00:00
Message: <web.640502993575e8099b4924336e066e29@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
>
> Sorry about the typo.I copied the example from working code & delete one space
> to much.
>
> I hope your problem is the another typo
>   height_field{Image(Filestr)}  FileStr
>
I am not having any luck with the code. :-(

Out of curiosity, which version of POV-ray are you using? There are certain
situations where v3.8xxx has either reverted to older code OR has 'tightened up'
some of the underlying rules of syntax usage. Sometimes, it is very difficult to
locate where the subtle 'change' has occurred.


Post a reply to this message

From: Bald Eagle
Subject: Re: Height_field help
Date: 5 Mar 2023 16:20:00
Message: <web.640506743575e8091f9dae3025979125@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

>  #if(Bs="tga") tga File #end
>  #if(Bs="bmp") bmp File #end
>  #if(Bs="pgm") pgm File #end
>  #if(Bs="png") png File #end
>  #if(Bs="ppm") ppm File #end
>  #if(Bs="jpg") jpeg File  #end
>  #if(Bs="exr") exr File #end
>  #if(Bs="hdr") hdr File #end
>  #if(Bs="gif") gif File #end
>  #if(Bs="iff") iff File #end
>  #if(Bs="tif") tiff File  #end

AFAIK, you don't need any of this stuff any more, because POV-Ray automatically
determines the file type, and so those keywords can be omitted.

https://news.povray.org/povray.advanced-users/message/%3C5ba3b5f9%241%40news.povray.org%3E/#%3C5ba3b5f9%241%40news.povr
ay.org%3E


Post a reply to this message

From: Kenneth
Subject: Re: Height_field help
Date: 5 Mar 2023 17:05:00
Message: <web.640511d63575e8099b4924336e066e29@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Leroy" <whe### [at] gmailcom> wrote:
>
> >  #if(Bs="tga") tga File #end
> > [snip]
> >  #if(Bs="tif") tiff File  #end
>
> AFAIK, you don't need any of this stuff any more, because POV-Ray automatically
> determines the file type, and so those keywords can be omitted.
>
I was just about to say, "But what about for users of older versions of
POV-ray?"

But I just ran my own simple image_map test in v3.7.0 and without the preceding
file prefix, and it does work there as well. I had forgotten about this
simplification myself.

I wonder if the same trick has *always* been the case? In v3.6? 3.5? As far back
as I can recall, the documentation has always(?) specified that the prefix was
required.  But wait: The docs that I downloaded (separately) for v3.8xx indicate
that the prefix IS optional:

3.6.2.6.1 Specifying an Image Map--
[BITMAP_TYPE] "filename" [gamma GAMMA] [premultiplied BOOL]
     [IMAGE_MAP_MODS...]

So I guess it has always been that way. I should re-read the docs now and then!


Post a reply to this message

From: Leroy
Subject: Re: Height_field help
Date: 6 Mar 2023 18:40:00
Message: <web.640678e43575e8097f7263c5f712fc00@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Leroy" <whe### [at] gmailcom> wrote:
>
> >  #if(Bs="tga") tga File #end
> >  #if(Bs="bmp") bmp File #end
> >  #if(Bs="pgm") pgm File #end
> >  #if(Bs="png") png File #end
> >  #if(Bs="ppm") ppm File #end
> >  #if(Bs="jpg") jpeg File  #end
> >  #if(Bs="exr") exr File #end
> >  #if(Bs="hdr") hdr File #end
> >  #if(Bs="gif") gif File #end
> >  #if(Bs="iff") iff File #end
> >  #if(Bs="tif") tiff File  #end
>
> AFAIK, you don't need any of this stuff any more, because POV-Ray automatically
> determines the file type, and so those keywords can be omitted.

I do! my version 3.7.0.RC7.mevc10.sse.win323.7 will let you do this

plane{z,0 pigment{image_map{"Uimage.tga"}} finish{ambient 1}}

but not this :

#declare I_File="Uimage.pgm";

plane{z,0 pigment{image_map{I_File}} finish{ambient 1}}
             OR
#declare PigM=function{pigment{image_map{I_File once}}}
             OR
#declare PigM=function{pigment{image_pattern{I_File}}}

I'm comparing function to image_map height_fields. I needed the macro so I would
have to rewrite the file I'm using for each height_field.

My version 3.7 for my 64bit running on win10 Acts the same.

I can write the file string directly into both of the functions above, But I was
trying  not to do that.


Post a reply to this message

From: Leroy
Subject: Re: Height_field help
Date: 6 Mar 2023 18:55:00
Message: <web.64067cab3575e8097f7263c5f712fc00@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > "Leroy" <whe### [at] gmailcom> wrote:
> >
> > >  #if(Bs="tga") tga File #end
> > > [snip]
> > >  #if(Bs="tif") tiff File  #end
> >
> > AFAIK, you don't need any of this stuff any more, because POV-Ray automatically
> > determines the file type, and so those keywords can be omitted.
> >
> I was just about to say, "But what about for users of older versions of
> POV-ray?"
>
> But I just ran my own simple image_map test in v3.7.0 and without the preceding
> file prefix, and it does work there as well. I had forgotten about this
> simplification myself.
>
> I wonder if the same trick has *always* been the case? In v3.6? 3.5? As far back
> as I can recall, the documentation has always(?) specified that the prefix was
> required.  But wait: The docs that I downloaded (separately) for v3.8xx indicate
> that the prefix IS optional:
>
> 3.6.2.6.1 Specifying an Image Map--
> [BITMAP_TYPE] "filename" [gamma GAMMA] [premultiplied BOOL]
>      [IMAGE_MAP_MODS...]
>
> So I guess it has always been that way. I should re-read the docs now and then!

I just found this in my docs...

3.4.7.6.1 Specifying an Image Map
IMAGE_MAP:
  pigment {
    image_map {
      [BITMAP_TYPE] "bitmap[.ext]" [gamma GAMMA] [premultiplied BOOL]
 If the BITMAP_TYPE is not given, the same type is expected as the type set for
output.
I think this might be wrong. I think it should be '.ext' it's talking about.
What we(I) have to do is test it.

Have Fun!


Post a reply to this message

From: William F Pokorny
Subject: Re: Height_field help
Date: 6 Mar 2023 23:21:35
Message: <6406bbcf$1@news.povray.org>
On 3/6/23 18:36, Leroy wrote:
>> AFAIK, you don't need any of this stuff any more, because POV-Ray automatically
>> determines the file type, and so those keywords can be omitted.
> I do! my version 3.7.0.RC7.mevc10.sse.win323.7 will let you do this
> 
> plane{z,0 pigment{image_map{"Uimage.tga"}} finish{ambient 1}}
> 
> but not this :
> 
> #declare I_File="Uimage.pgm";
> 
> plane{z,0 pigment{image_map{I_File}} finish{ambient 1}}

Yes, this one of the changes v3.7 to v3.8. Christoph made updates so 
more often POV-Ray can find and digest the input image file without an 
explicit type.

It remains true, you do occasionally need to specify the file type in 
both versions depending upon run time options and the image file naming.

To re-fresh my own memory of the status in both versions(a), I created 
the attached test scene.

Bill P.

(a) - The v4.0 master branch on github currently matches v3.8 beta 2.


Post a reply to this message


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

From: Kenneth
Subject: Re: Height_field help
Date: 7 Mar 2023 01:55:00
Message: <web.6406df0c3575e8099b4924336e066e29@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:
>
> I just found this in my docs...
>
> 3.4.7.6.1 Specifying an Image Map
> IMAGE_MAP:
>   pigment {
>     image_map {
>       [BITMAP_TYPE] "bitmap[.ext]" [gamma GAMMA] [premultiplied BOOL]
>  If the BITMAP_TYPE is not given, the same type is expected as the type
>  set for output.

For my previous test, I glanced over that last sentence but didn't pay
attention.

So I ran a bunch more simple tests in official v3.8.0 beta 1, with various
image_map and file-type suffixes, and intentionally mis-matched my render-file
output type-- JPEG image_map vs. Output_File_Type=N, etc. The tests all ran OK,
so it seems that the last sentence is no longer a requirement in v3.8xx.

But about the original macro here: I still cannot get it to run, despite
fiddling with various parts. I don't know if the following experiment is
helpful, but for the very beginning of the code, I added a few things to see
what would happen:

#macro Image(File)
 #local L=strlen(File);
 #debug concat("\n","L = ",str(L,0,3),"\n")
 #error
....
#end

Then, same as before...
#declare FileStr= "test image for hf png.png"
height_field{Image(Filestr)}

I half-way expected to at least get a #debug output for L=strlen(File), then a
halt to the whole process-- but no #debug message shows up, just the previous
error of "Cannot pass unitialized identifier as macro parameter..."

Leroy, does your macro *as written in this newsgroup thread* run OK on your own
system? (with the minor fix of the added parentheses, that is)


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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