POV-Ray : Newsgroups : povray.advanced-users : arbitrary remapping : Re: arbitrary remapping Server Time
28 Jul 2024 22:23:19 EDT (-0400)
  Re: arbitrary remapping  
From: Mike Williams
Date: 30 Sep 2003 01:45:47
Message: <cnN7HBAzgRe$EwlL@econym.demon.co.uk>
Wasn't it Anton Sherwood who wrote:
>I want to remap a texture (say something from stones.inc) so that what 
>you see is not a function of <x,y,z> but rather of <f(x,y,z), g(x,y,z), 
>h(x,y,z)>, i.e. some substitute for the actual coordinates which is 
>still a (nonlinear) function of those coordinates.  How hard is that to do?

Here's some code that remaps a single-layer pigment in this way. If you
really want to remap complex stone textures, then you'd have to do the
same to each of the pigment layers.

The basic trick is to make a function from the pigment, and then make a
pigment from that function. When you make a pigment from the function
you can specify an arbitrary remapping.

The sphere on the left has the original stone pigment.

The sphere on the right has the arbitrarily remapped pigment.

The lower sphere has a remapped pigment, using the identity mapping. if
the procedure works correctly, then this should look identical to the
original sphere.

>If this is unclear, I'll try to rephrase.
>
>(What I have in mind is to illustrate the various point symmetry groups 
>with seamless pigments that show the relevant symmetries.)

Now you've lost me.


global_settings {
 assumed_gamma 1.0
}

camera { orthographic location  <0,-0.8,-4> look_at <0, -0.8, 0>}

light_source {<-200,400,-200> colour rgb 1}

// Declare the original pigment

#declare C =   color_map
    { [0.0, 0.3 color rgb 1 color rgb 0.4]
      [0.3, 0.4 color rgb 0.4 color rgb 0.6]
      [0.4, 0.6 color rgb 0.6 color rgb 0.3]
      [0.6, 1.0 color rgb 0.3 color rgb 0.6]
    }
#declare P = pigment {granite turbulence 0.5 color_map {C}}
#declare Fin = finish {phong 0.5 phong_size 6}

// Make a pigment function from its structure (but skip the colour map)
                    
#declare PF=function{pigment{granite turbulence 0.5}}

// Three non-linear functions

#declare f = function{x*x + y}
#declare g = function{sin(3*y)}
#declare h = function{z*3 + cos(x)}

// A sphere with the original pigment

sphere {<-1,0,0> 1 pigment {P} finish{Fin}}

// A sphere with the transformed pigment (put the colour map back in)
                    
sphere {<1,0,0>,1
  pigment { function { PF(f(x,y,z),g(x,y,z),h(x,y,z)).grey }
    color_map {C}
  }
  finish{Fin}
}

// a sphere using the same technique, but with the identity
transformation
// to check that this procedure really does 

sphere {<-1,0,0>,1
  pigment { function { PF(x,y,z).grey }
    color_map {C}
  }
  finish{Fin}
  translate <1,-1.7,0>
}


Post a reply to this message

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