POV-Ray : Newsgroups : povray.advanced-users : UV Repeat in image_map Server Time
22 Dec 2024 03:52:03 EST (-0500)
  UV Repeat in image_map (Message 1 to 10 of 10)  
From: Roland Melkert
Subject: UV Repeat in image_map
Date: 30 Jan 2018 14:50:01
Message: <web.5a70cb2bb38cac61c949581a0@news.povray.org>
Hi all,

For an OpenGL based export I need to sometimes repeat only the u or v dimension
of a texture.

I've been searching but it seems you can only disable repeat for both u and v
combined using the "once" keyword in the concerning image_map block.

Is there any way / work around to toggle the repeat for u or v separately?

I'm using this macro as a place holder

--------
#macro getPngMapType(idx)
  //POV-Ray does not support u or v only repeat.
  // for the time being use repeat for both in all cases.
 #if (getPngNeedsURepeat(idx) | getPngNeedsVRepeat(idx))
  map_type 0
 #else
  map_type 0 once
 #end
#end


Post a reply to this message

From: Bald Eagle
Subject: Re: UV Repeat in image_map
Date: 30 Jan 2018 15:20:00
Message: <web.5a70d2b212d0a639c437ac910@news.povray.org>
I think there ought to be a way.

Not sure if there's a more elegant way, but look at
a) making a texture that's the u&v repeat of the image_map
b) making a texture where there's a u-strip of texture a, and the rest is clear

I think b might be accomplished with a function based pigment where you'd use
select() and abs (x [or y]) to switch between the image part and the clear part.

That's the best I can do off the top of my head without POV-Ray in front of me.


Post a reply to this message

From: Bald Eagle
Subject: Re: UV Repeat in image_map
Date: 30 Jan 2018 16:05:01
Message: <web.5a70dd0912d0a639c437ac910@news.povray.org>
I think I'm trying to pair up a u,v repeating image map with:

3.6.2.1.20 Planar Pattern

The planar pattern creates a horizontal stripe plus or minus one unit above and
below the X-Z plane. It is computed by:  value =1.0- min(1, abs(Y)) It starts at
1.0 at the origin and decreases to a minimum value of 0.0 as the Y values
approaches a distance of 1 unit from the X-Z plane. It remains at 0.0 for all
areas beyond that distance. This pattern was originally created for use with
halo or media but it may be used anywhere any pattern may be used.



.... if that's any help


Post a reply to this message

From: Bald Eagle
Subject: Re: UV Repeat in image_map
Date: 30 Jan 2018 21:30:01
Message: <web.5a7129e112d0a6395cafe28e0@news.povray.org>
Tried a bunch of things, and this is the best I could get.
I still suck at this.  :D

#version 3.71;
global_settings {
    assumed_gamma 1.0
}

#include "colors.inc"

sky_sphere {pigment {rgb <1, 1, 1>}}
plane {y, 0 pigment {srgb <1, 0.7, 0.5>}}

light_source {<48, 36, -50> color White}

camera {
  location <24, 24, -96>    // position & direction of view
  look_at  <24, 12,  0>
  right    x*image_width/image_height
  up y

}

#declare Pic = texture {pigment {image_map {png "POV-Ray_icon.png"} scale 2} }
#declare None = texture {pigment {rgbt 1}}

#declare YY = texture {pigment {function {0.5-min(0.5, abs(x))}}}

#declare Uonly =
texture {
 cylindrical

 texture_map {
 [0 None]
 //[0 Pic]
 [1 Pic translate -x]
 }
}

#declare Vonly =
texture {
 cylindrical
 rotate z*90
 translate y*12
 texture_map {
 [0 None]
 //[0 Pic]
 [1 Pic rotate -z*90 translate y*2]
 }
}

box {<-24, 0, 0> <24, 48, 0.1> texture {Uonly}}

box {<24, 0, 0> <72, 48, 0.1> texture {Vonly}}


Post a reply to this message

From: William F Pokorny
Subject: Re: UV Repeat in image_map
Date: 31 Jan 2018 08:45:53
Message: <5a71c891$1@news.povray.org>
On 01/30/2018 02:45 PM, Roland Melkert wrote:
> 
> Is there any way / work around to toggle the repeat for u or v separately?
> 
> I'm using this macro as a place holder
> 
> --------
> #macro getPngMapType(idx)
>    //POV-Ray does not support u or v only repeat.
>    // for the time being use repeat for both in all cases.
>   #if (getPngNeedsURepeat(idx) | getPngNeedsVRepeat(idx))
>    map_type 0
>   #else
>    map_type 0 once
>   #end
> #end
> 

Perhaps something like:

#declare PigImgMap0 = pigment {
     image_map { "mapUrpt.png" once map_type 0 interpolate 2 }
     warp { repeat x }
}

will work for you?

Bill P.


Post a reply to this message

From: Bald Eagle
Subject: Re: UV Repeat in image_map
Date: 31 Jan 2018 13:00:01
Message: <web.5a72033512d0a639c437ac910@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:

> Perhaps something like:
>
> #declare PigImgMap0 = pigment {
>      image_map { "mapUrpt.png" once map_type 0 interpolate 2 }
>      warp { repeat x }
> }
>
> will work for you?
>
> Bill P.

Dark Magic.  So much Kung-fu.
Masterful with the SDL he is.
Become one with the pattern warp he has.


Post a reply to this message

From: Roland Melkert
Subject: Re: UV Repeat in image_map
Date: 31 Jan 2018 14:20:00
Message: <web.5a7215a312d0a639c949581a0@news.povray.org>
Thanks Bald Eagle / William.

Using warp is genius, and so logical when you think about it, I'm thinking too
much in OpenGL terms :)

I'm now using this, which seems to work fine.
-----------
#macro getPngMapType(idx)
 #if (getPngNeedsURepeat(idx) & getPngNeedsVRepeat(idx))
  map_type 0
 #else
  map_type 0 once
 #end
#end

#macro getPngWarp(idx)
  #local doU=getPngNeedsURepeat(idx);
  #local doV=getPngNeedsURepeat(idx);

  #if (doU | doV)
   #if (doU)
     warp { repeat x }
   #else
     warp { repeat y }
   #end
  #end
#end

#macro ldrawBuildTex(basePigment, baseNormal, baseFinish, pngIdx)

 #if (pngIdx<0)
  pigment { basePigment }
  normal { baseNormal }
  finish { baseFinish }
 #else
  #local texPigment=
   pigment {
    uv_mapping
    image_map {
     png getPngName(pngIdx)
     getPngMapType(pngIdx)
     interpolate 2
    }
    getPngWarp(pngIdx)
   }
  ;

  #local result=
   texture {
    pigment { basePigment }
    normal { baseNormal }
    finish { baseFinish }
   }
   texture {
    pigment { texPigment }
   }
  ;
  result
 #end
#end


Post a reply to this message

From: Roland Melkert
Subject: Re: UV Repeat in image_map
Date: 31 Jan 2018 14:40:01
Message: <web.5a721b4712d0a639c949581a0@news.povray.org>
"Roland Melkert" <nomail@nomail> wrote:
> I'm now using this, which seems to work fine.

Edit: some corrections fyi
---------
#macro getPngWarp(idx)
  #local doU=getPngNeedsURepeat(idx);
  #local doV=getPngNeedsVRepeat(idx);

  #if ((doU | doV) & !(doU & doV)) //xor
   #if (doU)
     warp { repeat x }
   #else
     warp { repeat y }
   #end
  #end
#end


Post a reply to this message

From: Alain
Subject: Re: UV Repeat in image_map
Date: 31 Jan 2018 18:43:17
Message: <5a725495@news.povray.org>
Le 18-01-31 à 14:38, Roland Melkert a écrit :
> "Roland Melkert" <nomail@nomail> wrote:
>> I'm now using this, which seems to work fine.
> 
> Edit: some corrections fyi
> ---------
> #macro getPngWarp(idx)
>    #local doU=getPngNeedsURepeat(idx);
>    #local doV=getPngNeedsVRepeat(idx);
> 
>    #if ((doU | doV) & !(doU & doV)) //xor
>     #if (doU)
>       warp { repeat x }
>     #else
>       warp { repeat y }
>     #end
>    #end
> #end
> 
> 
> 
> 
Now, you can add some changes:

      warp { repeat x flip x}
Alternate the image with it's mirrored version.
or
      warp { repeat x flip y}
Alternating normal and upside down.


Post a reply to this message

From: Roland Melkert
Subject: Re: UV Repeat in image_map
Date: 1 Feb 2018 15:50:01
Message: <web.5a737d5712d0a639c949581a0@news.povray.org>
Alain <kua### [at] videotronca> wrote:
> Now, you can add some changes:
>
>       warp { repeat x flip x}
> Alternate the image with it's mirrored version.
> or
>       warp { repeat x flip y}
> Alternating normal and upside down.

Yes using warp opens up a boatload of possibilities, but for this project I only
need to mimic the OpenGL fixed pipeline u/v repeat behavior.


Post a reply to this message

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