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 05:32:30 EDT (-0400)
  Re: Is it possible to warp the UV coordinates of a 2D texture map?  
From: Tor Olav Kristensen
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

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:


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.


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

Tor Olav

Post a reply to this message

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