POV-Ray : Newsgroups : povray.general : Transforming an image_pattern{} Server Time
24 Nov 2024 14:06:06 EST (-0500)
  Transforming an image_pattern{} (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Thomas de Groot
Subject: Transforming an image_pattern{}
Date: 29 May 2018 07:50:28
Message: <5b0d3e84$1@news.povray.org>
I keep bumping into a conundrum concerning image_patterns.

I have the following texture block:

//--------------------------------------------------------------
   #declare MyTex =
   texture {
     image_pattern {png "MyPattern.png" gamma 1.0 use_alpha
       map_type 0
       interpolate 2
       once
     }
     texture_map {
       [0.0 pigment {rgbft <0,0,0,1,1>}]
       [1.0 pigment {
              bozo turbulence 1 lambda 3
              color_map {
                [0.0 rgbft <1,1,1,0,0>]
                [1.0 rgbft <1,1,1,1,1>]
              }
            }
            normal {crackle 0.15}
            finish {
              emission 1.0
              conserve_energy
              diffuse albedo 0.2
              specular albedo 0.2
              roughness 0.001
              reflection {
                0.0, 0.2
                fresnel on
                metallic off
              }
            }
       ]
     }
   }
//--------------------------------------------------------------

To get the image_map used in the image_pattern in the right place and in 
the correct orientation, I need to submit it/the texture to the 
following transformation:

//--------------------------------------------------------------
     translate <-0.5, 0, -0.5>
     rotate 90*x
     scale My_scale
     translate -My_scale.z/2*z
//--------------------------------------------------------------

This is not a problem /per se/ if I apply the transformation to the 
whole texture. However, for reasons I do not want to go into here 
presently and to simplify the question, I would like to apply the 
transformation /only/ to the image_pattern{} part of the texture. This 
seems not to be possible, or am I wrong?

Thanks indeed for any thought on the matter.

-- 
Thomas


Post a reply to this message

From: clipka
Subject: Re: Transforming an image_pattern{}
Date: 29 May 2018 10:01:04
Message: <5b0d5d20$1@news.povray.org>
Am 29.05.2018 um 13:50 schrieb Thomas de Groot:

> This is not a problem /per se/ if I apply the transformation to the
> whole texture. However, for reasons I do not want to go into here
> presently and to simplify the question, I would like to apply the
> transformation /only/ to the image_pattern{} part of the texture. This
> seems not to be possible, or am I wrong?

I would naively expect the following to work:

    texture {
      image_pattern { ... }
      translate <...>
      ...
      texture_map {
        ...
      }
    }

but I suspect you tried that already.

The source code isn't immediately obvious about whether this would have
the desired effect or not, so my naive expectation might be out of touch
with reality.

If that doesn't work, I'm pretty sure no other construct will - except
of course for individually un-doing the transformation for each
component in the texture map:

    #local Trans = transform {
      translate <...>
      ...
    }

    texture {
      image_pattern { ... }
      texture_map {
        [0.0 pigment { ... transform { Trans inverse } ]
        [1.0 pigment { ... transform { Trans inverse } ]
      }
      transform { Trans }
    }


Post a reply to this message

From: Kenneth
Subject: Re: Transforming an image_pattern{}
Date: 29 May 2018 19:40:00
Message: <web.5b0de3eb14fd3a80a47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
>
> If that doesn't work, I'm pretty sure no other construct will - except
> of course for individually un-doing the transformation for each
> component in the texture map:
>
>     #local Trans = transform {
>       translate <...>
>       ...
>     }
>
>     texture {
>       image_pattern { ... }
>       texture_map {
>         [0.0 pigment { ... transform { Trans inverse } ]
>         [1.0 pigment { ... transform { Trans inverse } ]
>       }
>       transform { Trans }
>     }

Yes, it seems that something very similar (identical?) to that construction is
required.

Thomas, try this example; it *looks* like it works-- the image_map or
image_pattern IS transformed, whereas the colors/pattern in the texture map are
NOT (or rather, they are inverse-transformed to bring them back to the original
look. I think!)  I made some simplifications to your code, so I could understand
what I was seeing. And the 'use-alpha' feature is something I haven't played
around with, until now.

Aside: In your code example, you have emission at 1.0. Are you actually seeing
any effects of the NORMAL that way? I thought such an emission value would
eliminate the normal's appearance (due to it being a 'lighting-based' effect.)
----

#declare My_scale = 1*<.7,.5,.7>;

#declare TRA =
transform{
     translate <-0.5, 0, -0.5>
     scale My_scale
     }

#declare MyTex =
   texture {
     image_pattern {
       png "My_Pattern.png" gamma 1.0 use_alpha
       map_type 0
       interpolate 2
      // once
                   } // end of image_pattern
     transform{TRA}
     texture_map {
       [0.0 pigment {rgbft <0,0,0,1,1>}]
       [1.0 pigment {
              bozo // turbulence 1 lambda 3
              color_map {
                [0.4 rgb <1,0,0>]
                [0.6 rgb <0,1,0>]
                        }
                    } // end of pigment
            normal {crackle 0.15}
            finish {
              emission 1.0
              conserve_energy
              diffuse albedo 0.2
              specular albedo 0.2
              roughness 0.001
              reflection {
                0.0, 0.2
                fresnel on
                metallic off
                         } // end of reflection
                    } // end of finish
             transform{TRA inverse}
       ]
                 } // end of texture_map
         }

box{0,<3,3,.01>
texture{MyTex}
}


Post a reply to this message

From: Thomas de Groot
Subject: Re: Transforming an image_pattern{}
Date: 30 May 2018 02:54:48
Message: <5b0e4ab8$1@news.povray.org>
On 29-5-2018 16:01, clipka wrote:
> Am 29.05.2018 um 13:50 schrieb Thomas de Groot:
> 
>> This is not a problem /per se/ if I apply the transformation to the
>> whole texture. However, for reasons I do not want to go into here
>> presently and to simplify the question, I would like to apply the
>> transformation /only/ to the image_pattern{} part of the texture. This
>> seems not to be possible, or am I wrong?
> 
> I would naively expect the following to work:
> 
>      texture {
>        image_pattern { ... }
>        translate <...>
>        ...
>        texture_map {
>          ...
>        }
>      }
> 
> but I suspect you tried that already.

You will laugh, but no. I did not try that :-/ The heat must have addled 
my braincells...

That works of course but...

> 
> The source code isn't immediately obvious about whether this would have
> the desired effect or not, so my naive expectation might be out of touch
> with reality.

the resulting effect is not entirely what I expected but that probably 
is another hurdle I need to take next. Nothing to worry about. New 
testing session in operation now.

> 
> If that doesn't work, I'm pretty sure no other construct will - except
> of course for individually un-doing the transformation for each
> component in the texture map:
> 
>      #local Trans = transform {
>        translate <...>
>        ...
>      }
> 
>      texture {
>        image_pattern { ... }
>        texture_map {
>          [0.0 pigment { ... transform { Trans inverse } ]
>          [1.0 pigment { ... transform { Trans inverse } ]
>        }
>        transform { Trans }
>      }
> 

Yes, that was something I tested, especially for the normal where the 
result was crucial.

Thanks for putting me back on track! :-)

-- 
Thomas


Post a reply to this message

From: Thomas de Groot
Subject: Re: Transforming an image_pattern{}
Date: 30 May 2018 03:01:37
Message: <5b0e4c51$1@news.povray.org>
On 30-5-2018 1:37, Kenneth wrote:
> clipka <ano### [at] anonymousorg> wrote:
>>
>> If that doesn't work, I'm pretty sure no other construct will - except
>> of course for individually un-doing the transformation for each
>> component in the texture map:
>>
>>      #local Trans = transform {
>>        translate <...>
>>        ...
>>      }
>>
>>      texture {
>>        image_pattern { ... }
>>        texture_map {
>>          [0.0 pigment { ... transform { Trans inverse } ]
>>          [1.0 pigment { ... transform { Trans inverse } ]
>>        }
>>        transform { Trans }
>>      }
> 
> Yes, it seems that something very similar (identical?) to that construction is
> required.
> 
> Thomas, try this example; it *looks* like it works-- the image_map or
> image_pattern IS transformed, whereas the colors/pattern in the texture map are
> NOT (or rather, they are inverse-transformed to bring them back to the original
> look. I think!)  I made some simplifications to your code, so I could understand
> what I was seeing. And the 'use-alpha' feature is something I haven't played
> around with, until now.

The first suggestion by Christoph was correct and I somehow was blinded. 
;-) I still need to get to what I want precisely though, which needs 
more blood, sweat & tears from my part.

When satisfied, I shall post the image.

> 
> Aside: In your code example, you have emission at 1.0. Are you actually seeing
> any effects of the NORMAL that way? I thought such an emission value would
> eliminate the normal's appearance (due to it being a 'lighting-based' effect.)

That emission is still an on/off addition from my part about which I 
have not yet made up my mind. Not important for now.

Thanks for the thoughts!

[snip]

-- 
Thomas


Post a reply to this message

From: Kenneth
Subject: Re: Transforming an image_pattern{}
Date: 30 May 2018 19:40:01
Message: <web.5b0f358e14fd3a80a47873e10@news.povray.org>
Thomas de Groot <tho### [at] degrootorg> wrote:
> On 30-5-2018 1:37, Kenneth wrote:
> > clipka <ano### [at] anonymousorg> wrote:
> >>
> >>      #local Trans = transform {
> >>        translate <...>
> >>        ...
> >>      }
> >>
> >>      texture {
> >>        image_pattern { ... }
> >>        texture_map {
> >>          [0.0 pigment { ... transform { Trans inverse } ]
> >>          [1.0 pigment { ... transform { Trans inverse } ]
> >>        }
> >>        transform { Trans }
> >>      }
> >
> >
> > Thomas, try this example; it *looks* like it works--
>
> The first suggestion by Christoph was correct...

Yes, you're right (although with a slight change.) I had to do some more
experimenting, to see what I did wrong.

EACH index-entry in the texture_map needs the inverse transform, as Clipka
suggested. (I included only one, after your 2nd index-entry.) My way of coding
the entire construct is *slightly* different, though:

#declare MyTex =
   texture {
     image_pattern {
       png "My_pattern.png" gamma 1.0 use_alpha
       ....
       } // end of image_pattern

     transform{TRA} // THE MAIN TRANSFORM HERE

   texture_map {
       [0.0  texture{...} or pigment{...} etc
       transform{TRA inverse}
       ]
       [1.0 texture{...} or pigment...} etc
        transform{TRA inverse}
       ]
               }
           }

Thanks for giving me a 'push' to test this stuff (and to play around with the
use_alpha feature-- it may have some important implications for my 'city
buildings' scene.)


Post a reply to this message

From: Thomas de Groot
Subject: Re: Transforming an image_pattern{}
Date: 31 May 2018 02:48:49
Message: <5b0f9ad1$1@news.povray.org>
On 31-5-2018 1:36, Kenneth wrote:
> Thomas de Groot <tho### [at] degrootorg> wrote:
>> On 30-5-2018 1:37, Kenneth wrote:
>>> clipka <ano### [at] anonymousorg> wrote:
>>>>
>>>>       #local Trans = transform {
>>>>         translate <...>
>>>>         ...
>>>>       }
>>>>
>>>>       texture {
>>>>         image_pattern { ... }
>>>>         texture_map {
>>>>           [0.0 pigment { ... transform { Trans inverse } ]
>>>>           [1.0 pigment { ... transform { Trans inverse } ]
>>>>         }
>>>>         transform { Trans }
>>>>       }
>>>
>>>
>>> Thomas, try this example; it *looks* like it works--
>>
>> The first suggestion by Christoph was correct...
> 
> Yes, you're right (although with a slight change.) I had to do some more
> experimenting, to see what I did wrong.
> 
> EACH index-entry in the texture_map needs the inverse transform, as Clipka
> suggested. (I included only one, after your 2nd index-entry.) My way of coding
> the entire construct is *slightly* different, though:
> 
> #declare MyTex =
>     texture {
>       image_pattern {
>         png "My_pattern.png" gamma 1.0 use_alpha
>         ....
>         } // end of image_pattern
> 
>       transform{TRA} // THE MAIN TRANSFORM HERE
> 
>     texture_map {
>         [0.0  texture{...} or pigment{...} etc
>         transform{TRA inverse}
>         ]
>         [1.0 texture{...} or pigment...} etc
>          transform{TRA inverse}
>         ]
>                 }
>             }
> 

This is a bit different! What you do here is (1) transform the 
image_pattern, then, (2) and separately, inverse transform the 
texture_map. That will give something very different I believe. The 
transform should be moved down to the complete texture level, e.g.:

texture {
   image_map {}
   texture_map {
     [0.0 texture {} transform {TRA inverse}]
     [1.0 texture {} transform {TRA inverse}]
   }
   transform {TRA}
}

Be sure too that all the transformations do the right thing when 
'inverse' is used. In this case, unexpected results might occur I believe.

My original intention was to be able to transform the image_pattern I 
needed, without touching the texture_map I had already defined for the 
scene. Tunnel vision prevented me from seeing the obvious way to do that 
(elementary truly). ;-)

In the mean time, I have ironed out most of the remaining problems and, 
as the dust is slowly settling, I will soon be able to show the results.

> Thanks for giving me a 'push' to test this stuff (and to play around with the
> use_alpha feature-- it may have some important implications for my 'city
> buildings' scene.)

Always happy to stimulate people. Thoughts, try-outs, conundrums from 
the community are always most stimulating experiences for me, even when 
I do not understand one iota from them :-)


-- 
Thomas


Post a reply to this message

From: clipka
Subject: Re: Transforming an image_pattern{}
Date: 31 May 2018 03:33:49
Message: <5b0fa55d$1@news.povray.org>
Am 31.05.2018 um 08:48 schrieb Thomas de Groot:

>> #declare MyTex =
>>     texture {
>>       image_pattern {
>>         png "My_pattern.png" gamma 1.0 use_alpha
>>         ....
>>         } // end of image_pattern
>>
>>       transform{TRA} // THE MAIN TRANSFORM HERE
>>
>>     texture_map {
>>         [0.0  texture{...} or pigment{...} etc
>>         transform{TRA inverse}
>>         ]
>>         [1.0 texture{...} or pigment...} etc
>>          transform{TRA inverse}
>>         ]
>>                 }
>>             }
>>
> 
> This is a bit different! What you do here is (1) transform the
> image_pattern, then, (2) and separately, inverse transform the
> texture_map. That will give something very different I believe. The
> transform should be moved down to the complete texture level, e.g.:
> 
> texture {
>   image_map {}
>   texture_map {
>     [0.0 texture {} transform {TRA inverse}]
>     [1.0 texture {} transform {TRA inverse}]
>   }
>   transform {TRA}
> }

To the best of my knowledge, there is effectively no difference between
the two constructs. I would consider the latter more intuitive though,
for the very same reason you'd expect them to differ in effect.


Post a reply to this message

From: Kenneth
Subject: Re: Transforming an image_pattern{}
Date: 31 May 2018 04:55:01
Message: <web.5b0fb7b514fd3a80a47873e10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

>
> To the best of my knowledge, there is effectively no difference between
> the two constructs. I would consider the latter more intuitive though...

Yeah, I eventually came to the same conclusion (and the two rendered results do
look identical; I don't see any difference at all.) The thing that seemed wierd
to me was placing *inverse* transforms before the 'regular' transform, in the
overall code. That looked... backwards (only from a 'linear-programming'
perspective-- or maybe just aesthetically!) But I was thinking in too 'linear' a
way ;-)

To answer Thomas's comment: The image_pattern construct seems to be a special
kind of 'thing' in POV-Ray-- composed of two *almost*-distinct parts (the
image_pattern part, and the texture_map part.) That's how I see it, anyway. Yet,
the fact that the main transform{} CAN go in either place-- and with the same
result-- is rather strange and interesting.


Post a reply to this message

From: Thomas de Groot
Subject: Re: Transforming an image_pattern{}
Date: 31 May 2018 06:57:44
Message: <5b0fd528$1@news.povray.org>
On 31-5-2018 10:52, Kenneth wrote:
> clipka <ano### [at] anonymousorg> wrote:
> 
>>
>> To the best of my knowledge, there is effectively no difference between
>> the two constructs. I would consider the latter more intuitive though...
> 
> Yeah, I eventually came to the same conclusion (and the two rendered results do
> look identical; I don't see any difference at all.) The thing that seemed wierd
> to me was placing *inverse* transforms before the 'regular' transform, in the
> overall code. That looked... backwards (only from a 'linear-programming'
> perspective-- or maybe just aesthetically!) But I was thinking in too 'linear' a
> way ;-)
> 
> To answer Thomas's comment: The image_pattern construct seems to be a special
> kind of 'thing' in POV-Ray-- composed of two *almost*-distinct parts (the
> image_pattern part, and the texture_map part.) That's how I see it, anyway. Yet,
> the fact that the main transform{} CAN go in either place-- and with the same
> result-- is rather strange and interesting.
> 

I have learned something new then. I thought putting the transforms 
/before/ the texture would /not/ affect the latter. Seems I am wrong in 
this.

Hmm.... I have to reconsider some of my code then....

-- 
Thomas


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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