POV-Ray : Newsgroups : povray.bugreports : Bad cylinder warp causes crash Server Time
21 Dec 2024 20:19:51 EST (-0500)
  Bad cylinder warp causes crash (Message 1 to 10 of 10)  
From: Bald Eagle
Subject: Bad cylinder warp causes crash
Date: 30 Nov 2018 17:25:01
Message: <web.5c01b8a81374e197765e06870@news.povray.org>
I was trying to work out how to create a paneled cylindrical tank, like at an
old petroleum refinery - riveted panels of sheet metal, and decided that an
image map with a cylinder warp would be the way to go.

When done improperly, POV-Ray crashes.
A slight change, and it works fine.

The image map I am using is 960 x 480, but I'm sure any image map you use for
testing ought to be fine, as it's the construct / syntax that breaks it, not the
image file.

I can post the image map and the screen shot of the error if necessary.


#version 3.8;
#declare SDL = true;

global_settings {assumed_gamma 1.0}

#declare Origin = <0, 0, 0>;
#declare Feet = 12;
#declare Meters = 39.37;
#declare Miles = 5280*Feet;

light_source { <0, 50*Miles, -1*Miles>  color rgb <1, 1, 1>}


  #declare Location = <0, 30*Feet, -30*3*Feet>;
  #declare LookAt = <0, 12*Feet, 0>;


#declare Camera_Aspect_Ratio = image_width/image_height;
#declare Camera_Zoom = 1;

camera {
  location Location
 look_at  LookAt
 right x*image_width/image_height
 up y // vertical size of view
}

#declare TankTex =
texture {
 pigment {image_map {png "_Riveted_Panel.png"}
  //translate -0.5
  //rotate x*90
  //scale <.3/pi, 1, 90>
  //translate -z*40
  warp {
   cylindrical
   orientation y
   dist_exp 300
  }
 }
}

#declare TankH = 24*Feet;
#declare TankR = 27*Feet;

cylinder {Origin, y+<0, TankH, 0> 1
scale <TankR, 1, TankR> // scaling before texture causes crash
texture {TankTex}
//scale <TankR, 1, TankR> // after is fine
}


Post a reply to this message

From: green
Subject: Re: Bad cylinder warp causes crash
Date: 30 Nov 2018 22:00:02
Message: <web.5c01ea617cc280088dbe9e30@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> I was trying to work out how to create a paneled cylindrical tank, like at an
> old petroleum refinery - riveted panels of sheet metal, and decided that an
> image map with a cylinder warp would be the way to go.
>
> When done improperly, POV-Ray crashes.
> A slight change, and it works fine.
>
> The image map I am using is 960 x 480, but I'm sure any image map you use for
> testing ought to be fine, as it's the construct / syntax that breaks it, not the
> image file.
>
> I can post the image map and the screen shot of the error if necessary.
>
>
> #version 3.8;
> #declare SDL = true;
>
> global_settings {assumed_gamma 1.0}
>
> #declare Origin = <0, 0, 0>;
> #declare Feet = 12;
> #declare Meters = 39.37;
> #declare Miles = 5280*Feet;
>
> light_source { <0, 50*Miles, -1*Miles>  color rgb <1, 1, 1>}
>
>
>   #declare Location = <0, 30*Feet, -30*3*Feet>;
>   #declare LookAt = <0, 12*Feet, 0>;
>
>
> #declare Camera_Aspect_Ratio = image_width/image_height;
> #declare Camera_Zoom = 1;
>
> camera {
>   location Location
>  look_at  LookAt
>  right x*image_width/image_height
>  up y // vertical size of view
> }
>
> #declare TankTex =
> texture {
>  pigment {image_map {png "_Riveted_Panel.png"}
>   //translate -0.5
>   //rotate x*90
>   //scale <.3/pi, 1, 90>
>   //translate -z*40
>   warp {
>    cylindrical
>    orientation y
>    dist_exp 300
>   }
>  }
> }
>
> #declare TankH = 24*Feet;
> #declare TankR = 27*Feet;
>
> cylinder {Origin, y+<0, TankH, 0> 1
> scale <TankR, 1, TankR> // scaling before texture causes crash
> texture {TankTex}
> //scale <TankR, 1, TankR> // after is fine
> }

if you scale the texture too it will render.

cylinder {Origin, y+<0, TankH, 0> 1
scale <TankR, 1, TankR> // scaling before texture causes crash
texture {TankTex scale <TankR, 1, TankR> }
//scale <TankR, 1, TankR> // after is fine

i have absolutely no idea what this implies.


Post a reply to this message

From: jr
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 07:30:01
Message: <web.5c027e807cc2800e43b71790@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> I was trying to work out how to create a paneled cylindrical tank, ...

> When done improperly, POV-Ray crashes.
> A slight change, and it works fine.
> ...
> cylinder {Origin, y+<0, TankH, 0> 1
> scale <TankR, 1, TankR>
> texture {TankTex}
> //scale <TankR, 1, TankR> // after is fine
> }

sort of works for me.  your version renders the cap but no walls (maybe because
I use a wrong image?), green's version renders cap and solid (blue) wall.
strange.  v3.8.0-alpha.9945627.unofficial.


regards, jr.


Post a reply to this message

From: green
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 08:40:02
Message: <web.5c028de27cc2800d0c6faf90@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> hi,
>
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > I was trying to work out how to create a paneled cylindrical tank, ...
>
> > When done improperly, POV-Ray crashes.
> > A slight change, and it works fine.
> > ...
> > cylinder {Origin, y+<0, TankH, 0> 1
> > scale <TankR, 1, TankR>
> > texture {TankTex}
> > //scale <TankR, 1, TankR> // after is fine
> > }
>
> sort of works for me.  your version renders the cap but no walls (maybe because
> I use a wrong image?), green's version renders cap and solid (blue) wall.
> strange.  v3.8.0-alpha.9945627.unofficial.
>
>
> regards, jr.

i used povray-3.8.0-x.tokenizer.9945666-av627-Win64.  with the non-crashing
versions i show a very dark wall (gray), not my image.  i messed around with it
a little while and concluded i know nothing about 'warp'.  i also do not know
why putting scale before texture would work, or not work.  but recasting the
image_map as map_type 2 (no warp) works (shows the image), but crashes when the
scale is before texture.


Post a reply to this message

From: jr
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 09:50:01
Message: <web.5c029e767cc2800e43b71790@news.povray.org>
hi,

"green" <rov### [at] gmailcom> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > sort of works for me.  your version renders the cap but no walls (maybe because
> > I use a wrong image?), green's version renders cap and solid (blue) wall.
> > strange.  v3.8.0-alpha.9945627.unofficial.
>
> i used povray-3.8.0-x.tokenizer.9945666-av627-Win64.

I just tried on a different machine (same x.tokenizer version but compiled from
source).

interestingly (if that's the word :-)), I get no crash but now both your and
Bald Eagle's version render just the cap, the wall has gone.

>  with the non-crashing
> versions i show a very dark wall (gray), not my image.  i messed around with it
> a little while and concluded i know nothing about 'warp'.  i also do not know
> why putting scale before texture would work, or not work.  but recasting the
> image_map as map_type 2 (no warp) works (shows the image), but crashes when the
> scale is before texture.

I used the code unmodified, except for image and #if(0) guards.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 10:00:02
Message: <web.5c02a1057cc2800765e06870@news.povray.org>
"green" <rov### [at] gmailcom> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > hi,
> >
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > I was trying to work out how to create a paneled cylindrical tank, ...
> >
> > > When done improperly, POV-Ray crashes.
> > > A slight change, and it works fine.
> > > ...
> > > cylinder {Origin, y+<0, TankH, 0> 1
> > > scale <TankR, 1, TankR>
> > > texture {TankTex}
> > > //scale <TankR, 1, TankR> // after is fine
> > > }
> >
> > sort of works for me.  your version renders the cap but no walls (maybe because
> > I use a wrong image?), green's version renders cap and solid (blue) wall.
> > strange.  v3.8.0-alpha.9945627.unofficial.
> >
> >
> > regards, jr.
>
> i used povray-3.8.0-x.tokenizer.9945666-av627-Win64.  with the non-crashing
> versions i show a very dark wall (gray), not my image.  i messed around with it
> a little while and concluded i know nothing about 'warp'.  i also do not know
> why putting scale before texture would work, or not work.  but recasting the
> image_map as map_type 2 (no warp) works (shows the image), but crashes when the
> scale is before texture.

I'll have to see if I can install the new tokenizer and executable this weekend.
I started off by copy-pasting the cylinder warp example code from the wiki,
using the hexagon pigment pattern and going from there.

My theory, based upon my difficulty orienting and scaling the image_map,
crashing, and fixing it is this:
The docs describe that the warp has to terminate _somewhere_ and not be
infinite, which is what the distance exponent is.  So when that's very large and
it tries to extend the pattern way out to encompass the edges of the very large
cylinder, some source code internal math / memory thing happens and it crashes.
Switching over to where the cylinder is a 1-unit radius, the texture is applied,
and THEN it is scaled avoids the math/memory issue with the warp, and then the
textured cylinder is subjected to a simple problem-free scaling.

I haven't yet tried scaling the texture - in the way suggested - to see what
combination simply render, actually work (proper final results), or crash.

Anyway - for now, this is just a cautionary notice, and the solution will likely
be to develop such an object at a small scale and then enlarge it AFTER it is
properly textured with the warp.

In the future, it would likely be a huge time-saver to have a macro that takes
the image_map size (or pigment pattern square size), cylinder radius, and number
of desired repeats around the circumference and returns the proper scaling of
the texture.
My personal preference is to write such macros with a flag to trigger some data
to be sent to the debug stream showing the calculations and resulting values....
  Work it out once, have it be available to everyone for decades.

Thanks for looking into this - so many things to do IRL.


Post a reply to this message

From: jr
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 15:25:01
Message: <web.5c02ed1f7cc2800e43b71790@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> My theory, based upon my difficulty orienting and scaling the image_map,
> crashing, and fixing it is this:
> The docs describe that the warp has to terminate _somewhere_ and not be
> infinite, which is what the distance exponent is.  ...

like green, I know nothing about warp.  but wrt termination, would loading the
image "once" not automatically provide a/the limit(s)?


regards, jr.


Post a reply to this message

From: jr
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 15:45:00
Message: <web.5c02f2b97cc2800e43b71790@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > ...
> > cylinder {Origin, y+<0, TankH, 0> 1
> > scale <TankR, 1, TankR>
> > texture {TankTex}
> > //scale <TankR, 1, TankR> // after is fine
> > }
>
> sort of works for me.  your version renders the cap but no walls (maybe because
> I use a wrong image?),

uh, wrong.  your version too has a wall, albeit so faint I missed it until I
"massaged" the PNG.  sorry for the noise.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 16:35:01
Message: <web.5c02fdf77cc2800765e06870@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:


> like green, I know nothing about warp.  but wrt termination, would loading the
> image "once" not automatically provide a/the limit(s)?

A warp is just a modification of a pattern.  Rather than just straight mapping
it to Cartesian 3D space, it bends, wraps, folds, repeats, or otherwise changes
how the pattern is evaluated based on the <x, y, z> you're at.

If you look at the wiki entry (about 3/4 down the page),

http://wiki.povray.org/content/Reference:Warp

you'll see

Although these warps do 3D mapping, some concession had to be made on depth.

The distance exponent is controlled by using the dist_exp keyword. When using
the default value of 0, imagine a box from <0,0> to <1,1> stretching to infinity
along the orientation vector.

The distance keyword is evaluated as follows:

sphere: distance from origin
cylinder: distance from y-axis
torus: distance from major radius
The planar warp was made to make a pattern act like an image_map, of infinite
size and can be useful in combination with other mapping-warps. By default the
pigment in the XY-plane is extruded along the Z-axis. The pigment can be taken
from an other plane, by specifying the optional vector (normal of the plane) and
float (distance along the normal). The result, again, is extruded along the
Z-axis.

The cubic warp requires no parameters, and maps an area in the x-y plane between
<0,0> and <1,1> around the origin in the same way as uv-mapping an
origin-centered cube-shaped box would. The cubic warp works with any object
whereas the uv-mapping only works for the box object. See the section on box
uv-mapping for details.

----------------------------------------------------------------------

So I can only imagine that the problem lies in exceeding / overflowing the
memory used in extending the pattern out along a radial path.


Post a reply to this message

From: Bald Eagle
Subject: Re: Bad cylinder warp causes crash
Date: 1 Dec 2018 20:35:02
Message: <web.5c0336237cc2800765e06870@news.povray.org>
OK, so I fought with this for far longer than I should have had to.
I've worked out most of it.
The vertical scaling doesn't seem to be quite right yet.

Just call the macro using the aspect ratio of the pattern/image, the number of
times to make it wrap around the cylinder, and the radius of the base cylinder
(before scaling).

Pattern gets changed between lines 15 & 16 so you can test with a built-in
pattern.


I think jr was having an orientation problem - I changed orientation from y to z
so the pattern didn't have to get rotated when using the wiki code.

Haven't tried to crash it yet.  :)
------------------------------------------------------------------------


#version 3.8;
#declare SDL = true;

global_settings {assumed_gamma 1.0}

#declare Origin = <0, 0, 0>;
#declare Feet = 12;
#declare Meters = 39.37;
#declare Miles = 5280*Feet;

light_source { <0, 15, -10>  color rgb <1, 1, 1>}

#declare Camera_Aspect_Ratio = image_width/image_height;

#declare Image = pigment {image_map {png "_Riveted_Panel.png"}}
//#declare Image = pigment {checker}


//###########################################################################################
#macro WrapTexture (_Aspect2, _n, _CR)
 // Apparently the cylindrical warp already compensates for the 2*pi in the
circumference
 // so treat the circumference as 1 unit around
 // Scale in y direction to adjust for aspect ratio of image
 #local _Circumference = 1;
 //#local _Rscale = <_Circumference*_CR/_n, _Aspect2, _Circumference*_CR/_n>;
 #local _Rscale = <_Circumference*_CR/_n, _Aspect2/(2*pi*_CR/_n),
_Circumference*_CR/_n>;
 pigment {
  Image
  warp {
   cylindrical
   orientation z
   dist_exp 1
  }
  scale _Rscale
 }
#end // end macro WrapTexture
//###########################################################################################

#declare L = 0.25;
#declare T = 0.01;
#declare S = 0.8;
#declare Arrow = union {
 cone {Origin, 0, <L, 0, 0>, T*3 pigment {rgb 1} translate <0, 1.125, 0>}
 cylinder {<L, 0, 0>, <(pi)*S, 0, 0> T pigment {rgb 1} translate <0, 1.125, 0>}
}

object {Arrow}
object {Arrow scale <-1, 1, 1> translate <2*pi, 0, 0>}
text{ttf "cyrvetic.ttf" "2 * pi" 0.01, 0 scale 0.25 translate x*pi  translate
<-0.25, 1.125, 0> pigment {rgb 1} no_shadow}
box {<0, 0, 0>, <2*pi, 1, 0.1> texture {Image scale <2*pi/4, 1, 1>}}

#declare TankH = 6;
#declare TankR = 1;
#declare Crad = 2;
#declare C =
 cylinder {Origin, y Crad
 //scale <TankR, 1, TankR> // scaling before texture causes crash
 texture {WrapTexture (480/960, 4, Crad) finish {ambient 0.5}}
 scale <TankR, TankH, TankR> // after is fine
 no_shadow
}

object {C rotate y*  0 translate <-TankR*Crad*2, 2, 0>}
object {C rotate y* 90 translate < TankR*Crad*1, 2, 0>}
object {C rotate y*180 translate < TankR*Crad*4, 2, 0>}
object {C rotate y*270 translate < TankR*Crad*7, 2, 0>}


#declare Location = <(TankR*5/2)*Crad, TankH, -(TankR*20/2)*Crad>;
#declare LookAt = <(TankR*5/2)*Crad, TankH/4, 0>;

camera {
  location Location
 look_at  LookAt
 right x*image_width/image_height           // horizontal size of view
 up y // vertical size of view
}


Post a reply to this message

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