POV-Ray : Newsgroups : povray.general : Is it possible to warp the UV coordinates of a 2D texture map? : Re: Is it possible to warp the UV coordinates of a 2D texture map? Server Time
18 May 2024 06:51:44 EDT (-0400)
  Re: Is it possible to warp the UV coordinates of a 2D texture map?  
From: Bald Eagle
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
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.