POV-Ray : Newsgroups : povray.general : Is it possible to warp the UV coordinates of a 2D texture map? Server Time
28 Mar 2024 08:33:05 EDT (-0400)
  Is it possible to warp the UV coordinates of a 2D texture map? (Message 1 to 6 of 6)  
From: tutki
Subject: Is it possible to warp the UV coordinates of a 2D texture map?
Date: 14 Jan 2022 15:15:00
Message: <web.61e1d8a1565413375c8e85ceb98f01db@news.povray.org>
I have a sphere that I want to apply a 2D texture to, using UV mapping.  But I
want to distort the UV coordinates such that the texture looks like it's pushed
away from a hole that I'm CSG-subtracting from the sphere.  Basically, given
some (u,v) that povray generates when a ray intersects with the sphere, is it
possible to "post-process" the coordinates with some functions f, g, so that the
texture is looked up at coordinates (f(u), g(v)) instead of (u,v)?

Is it possible to do this, or do I have to somehow distort the texture itself?


Post a reply to this message

From: Le Forgeron
Subject: Re: Is it possible to warp the UV coordinates of a 2D texture map?
Date: 15 Jan 2022 03:04:35
Message: <61e28013$1@news.povray.org>
Le 14/01/2022 à 21:11, tutki a écrit :
> I have a sphere that I want to apply a 2D texture to, using UV mapping.  But I
> want to distort the UV coordinates such that the texture looks like it's pushed
> away from a hole that I'm CSG-subtracting from the sphere.  Basically, given
> some (u,v) that povray generates when a ray intersects with the sphere, is it
> possible to "post-process" the coordinates with some functions f, g, so that the
> texture is looked up at coordinates (f(u), g(v)) instead of (u,v)?
> 
> Is it possible to do this, or do I have to somehow distort the texture itself?
> 
> 
> 

As per the sphere object itself, the UV mapping are hard-coded (not even
in memory, just computed when needed)
But I wonder if there is something that would stop you from applying
warp to the texture.


Post a reply to this message

From: tutki
Subject: Re: Is it possible to warp the UV coordinates of a 2D texture map?
Date: 17 Jan 2022 14:50:00
Message: <web.61e5c77838c4a65d5c8e85ceb98f01db@news.povray.org>
Le_Forgeron <jgr### [at] freefr> wrote:
> > I have a sphere that I want to apply a 2D texture to, using UV mapping.  But I
> > want to distort the UV coordinates such that the texture looks like it's pushed
> > away from a hole that I'm CSG-subtracting from the sphere.  Basically, given
> > some (u,v) that povray generates when a ray intersects with the sphere, is it
> > possible to "post-process" the coordinates with some functions f, g, so that the
> > texture is looked up at coordinates (f(u), g(v)) instead of (u,v)?
> >
> > Is it possible to do this, or do I have to somehow distort the texture itself?
> >
> >
> >
>
> As per the sphere object itself, the UV mapping are hard-coded (not even
> in memory, just computed when needed)
> But I wonder if there is something that would stop you from applying
> warp to the texture.

Warping the texture would also be an option... is there a way to specify an
arbitrary mapping function to remap texture values?  What I have in mind is to
use maybe a standard texture pattern as the basis, but have some kind of
function on top of it to distort it in specific ways.

Is this possible?


Post a reply to this message

From: Kenneth
Subject: Re: Is it possible to warp the UV coordinates of a 2D texture map?
Date: 17 Jan 2022 19:00:00
Message: <web.61e6015138c4a65d4cef624e6e066e29@news.povray.org>
"tutki" <nomail@nomail> wrote:
> Le_Forgeron <jgr### [at] freefr> wrote:

> >
> > As per the sphere object itself, the UV mapping are hard-coded (not even
> > in memory, just computed when needed)
> > But I wonder if there is something that would stop you from applying
> > warp to the texture.
>
> Warping the texture would also be an option... is there a way to specify an
> arbitrary mapping function to remap texture values?  What I have in mind is to
> use maybe a standard texture pattern as the basis, but have some kind of
> function on top of it to distort it in specific ways.
>
> Is this possible?

I'm no expert at using functions, but from simple syntax tests, it looks like a
'bare' function cannot be used to distort a pigment pattern. I.e., this
simplistic example does not work, fatal error:

#declare FUNC =
function(x){6*sin(2*pi*x)}; // *this* works OK

object{...
pigment{
    cells
    FUNC(.7).x // this fails; other syntax variations that I tried also fail
....

But it can successfully be used *in* a scale, or a turbulence, or etc:
 scale <1, FUNC(.7).x,1>

Again, these are just syntax tests; the actual results of my examples might
be... questionable, ha.

From your description of what you are trying to accomplish, maybe a 'black hole'
warp would work (with its 'inverse' keyword)?


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Is it possible to warp the UV coordinates of a 2D texture map?
Date: 18 Jan 2022 05:35:00
Message: <web.61e696ea38c4a65db9690bef89db30a9@news.povray.org>
"tutki" <nomail@nomail> wrote:
> Le_Forgeron <jgr### [at] freefr> wrote:
> > > I have a sphere that I want to apply a 2D texture to, using UV mapping.  But I
> > > want to distort the UV coordinates such that the texture looks like it's pushed
> > > away from a hole that I'm CSG-subtracting from the sphere.  Basically, given
> > > some (u,v) that povray generates when a ray intersects with the sphere, is it
> > > possible to "post-process" the coordinates with some functions f, g, so that the
> > > texture is looked up at coordinates (f(u), g(v)) instead of (u,v)?
> > >
> > > Is it possible to do this, or do I have to somehow distort the texture itself?
> > >
> > >
> > >
> >
> > As per the sphere object itself, the UV mapping are hard-coded (not even
> > in memory, just computed when needed)
> > But I wonder if there is something that would stop you from applying
> > warp to the texture.
>
> Warping the texture would also be an option... is there a way to specify an
> arbitrary mapping function to remap texture values?  What I have in mind is to
> use maybe a standard texture pattern as the basis, but have some kind of
> function on top of it to distort it in specific ways.
>
> Is this possible?

Hi tutki

It is possible to distort or remap pigments and patterns with functions before
using them in UV-mapped textures.

There's some relevant code here:

From: Tor Olav Kristensen
Subject: Source code for "Using functions to distort images"
Date: 2006-05-21 18:48:59
http://news.povray.org/povray.text.scene-files/thread/%3C4470ee5b%40news.povray.org%3E

The pigment in the ImageFn() function (also shown below) does not have to be an
image_map; it can be any pigment.

    #declare ImageFn =
       function { pigment { image_map { "Image.png" } } }

You can also have a look at the FunctionsPigmentRGB() macro etc. in the
Gaussian_Blur.inc file, here:

    https://github.com/t-o-k/POV-Ray-gaussian-blur

If you need to distort textures on a sphere it may be possible to make a sphere
shaped "solid mesh" with your own "pre-distorted" UV-coordinates.

    http://www.povray.org/documentation/view/3.7.0/292/

It should then be possible to use that mesh in CSG constructions.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


Post a reply to this message

From: Bald Eagle
Subject: Re: Is it possible to warp the UV coordinates of a 2D texture map?
Date: 18 Jan 2022 06:55:00
Message: <web.61e6a9fb38c4a65d1f9dae3025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> "tutki" <nomail@nomail> wrote:
> > Le_Forgeron <jgr### [at] freefr> wrote:
>
> > >
> > > As per the sphere object itself, the UV mapping are hard-coded (not even
> > > in memory, just computed when needed)
> > > But I wonder if there is something that would stop you from applying
> > > warp to the texture.
> >
> > Warping the texture would also be an option... is there a way to specify an
> > arbitrary mapping function to remap texture values?  What I have in mind is to
> > use maybe a standard texture pattern as the basis, but have some kind of
> > function on top of it to distort it in specific ways.
> >
> > Is this possible?
>
> I'm no expert at using functions, but from simple syntax tests, it looks like a
> 'bare' function cannot be used to distort a pigment pattern. I.e., this
> simplistic example does not work, fatal error:
>
> #declare FUNC =
> function(x){6*sin(2*pi*x)}; // *this* works OK
>
> object{...
> pigment{
>     cells
>     FUNC(.7).x // this fails; other syntax variations that I tried also fail
> ....

Right, because you're just appending a function statement to the pigment
specification.
What you need to do is define a function that uses the cells pattern, and then
using another function that controls the coordinates, pass those coordinates
into the cells pattern fuinction call so that it uses those distorted
coordinates, not the raw basis vector coordinates.

So just to give you the idea:

So #declare F = function {pigment {cells}}

object {
pigment {
function {F (FUNC(x,y,z).x, FUNC(x,y,z).y, FUNC(x,y,z).z}
}
}

(untested, so this probably needs a good bit of tweaking...)


Post a reply to this message

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