POV-Ray : Newsgroups : povray.general : explicit color mapping f(u,v)->color Server Time
4 Aug 2024 00:23:21 EDT (-0400)
  explicit color mapping f(u,v)->color (Message 1 to 7 of 7)  
From: Fjolsvit
Subject: explicit color mapping f(u,v)->color
Date: 4 Oct 2003 14:31:37
Message: <3f7f1209$1@news.povray.org>
This may be obvious, and I've simply overlooked it, but I can't seem to 
figure out a way to explicitly say what color I want at a specific point 
on a surface.  Basically what I want is a way to draw the u and v 
coordinate lines ...u = -2, u = -1, u = 0, u = 1, u = 2 ...,...v = -2, v 
= -1, v = 0, v = 1, v = 2 ..., etc.

This *seems* like it should be easy.  Suggestions?

STH


Post a reply to this message

From: Mike Williams
Subject: Re: explicit color mapping f(u,v)->color
Date: 4 Oct 2003 20:25:50
Message: <xQeA6JA6P2f$Ew7E@econym.demon.co.uk>
Wasn't it Fjolsvit who wrote:
>This may be obvious, and I've simply overlooked it, but I can't seem to 
>figure out a way to explicitly say what color I want at a specific point 
>on a surface.  Basically what I want is a way to draw the u and v 
>coordinate lines ...u = -2, u = -1, u = 0, u = 1, u = 2 ...,...v = -2, v 
>= -1, v = 0, v = 1, v = 2 ..., etc.
>
>This *seems* like it should be easy.  Suggestions?

If the object is one of those which supports uv_mapping, then you can
use a uu_mapped pigment function something like this:

#declare Spacing = 20;                    
sphere {0,1
  uv_mapping 
  pigment {
    function {min(abs(sin(u*pi*Spacing)),
              abs(sin(v*2*Spacing)))}
    color_map { [0.0 rgb 0]
                [0.05 rgb 0]
                [0.05 rgb 1]
                [1 rgb 1]
    }
  }
}

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: fjolsvit
Subject: Re: explicit color mapping f(u,v)->color
Date: 5 Oct 2003 20:14:51
Message: <3f80b3fb@news.povray.org>
Mike Williams wrote:
> Wasn't it Fjolsvit who wrote:
> 
>>This may be obvious, and I've simply overlooked it, but I can't seem to 
>>figure out a way to explicitly say what color I want at a specific point 
>>on a surface.  Basically what I want is a way to draw the u and v 
>>coordinate lines ...u = -2, u = -1, u = 0, u = 1, u = 2 ...,...v = -2, v 
>>= -1, v = 0, v = 1, v = 2 ..., etc.
>>
>>This *seems* like it should be easy.  Suggestions?
> 
> 
> If the object is one of those which supports uv_mapping, then you can
> use a uu_mapped pigment function something like this:
> 
> #declare Spacing = 20;                    
> sphere {0,1
>   uv_mapping 
>   pigment {
>     function {min(abs(sin(u*pi*Spacing)),
>               abs(sin(v*2*Spacing)))}
>     color_map { [0.0 rgb 0]
>                 [0.05 rgb 0]
>                 [0.05 rgb 1]
>                 [1 rgb 1]
>     }
>   }
> }
> 

Thanks.

It looks as though the answere is 'yes, and no'.  I wanted to do this 
with  a parameterized object or an isosurface.  *6.7.7.1 Supported 
Objects* of the docs is telling me I can't do it.  This *seems* somewhat 
strange since I am already defining the parameterized object in terms of 
UV parameters.  What I've done is to create a composite of areas 
excluding the coordinate line areas, and then create a union of all 
patches and coordinate lines.

This does not render very quickly, but it produces the basic desired 
result.  Now the next trick will be to draw an arbitrary curve on said 
surface.

<scratches head>

STH


Post a reply to this message

From: Mike Williams
Subject: Re: explicit color mapping f(u,v)->color
Date: 5 Oct 2003 21:12:50
Message: <DLFTNAAoCMg$EwEV@econym.demon.co.uk>
Wasn't it fjolsvit who wrote:
>Mike Williams wrote:
>> Wasn't it Fjolsvit who wrote:
>> 
>>>This may be obvious, and I've simply overlooked it, but I can't seem to 
>>>figure out a way to explicitly say what color I want at a specific point 
>>>on a surface.  Basically what I want is a way to draw the u and v 
>>>coordinate lines ...u = -2, u = -1, u = 0, u = 1, u = 2 ...,...v = -2, v 
>>>= -1, v = 0, v = 1, v = 2 ..., etc.
>>>
>>>This *seems* like it should be easy.  Suggestions?
>> 
>> 
>> If the object is one of those which supports uv_mapping, then you can
>> use a uu_mapped pigment function something like this:
>> 
>> #declare Spacing = 20;                    
>> sphere {0,1
>>   uv_mapping 
>>   pigment {
>>     function {min(abs(sin(u*pi*Spacing)),
>>               abs(sin(v*2*Spacing)))}
>>     color_map { [0.0 rgb 0]
>>                 [0.05 rgb 0]
>>                 [0.05 rgb 1]
>>                 [1 rgb 1]
>>     }
>>   }
>> }
>> 
>
>Thanks.
>
>It looks as though the answere is 'yes, and no'.  I wanted to do this 
>with  a parameterized object or an isosurface.  *6.7.7.1 Supported 
>Objects* of the docs is telling me I can't do it.  This *seems* somewhat 
>strange since I am already defining the parameterized object in terms of 
>UV parameters.  What I've done is to create a composite of areas 
>excluding the coordinate line areas, and then create a union of all 
>patches and coordinate lines.
>
>This does not render very quickly, but it produces the basic desired 
>result.  Now the next trick will be to draw an arbitrary curve on said 
>surface.

Have you considered using Ingo Janssen's "param.inc" system? This
generates a mesh2 object which closely approximates a parametric
isosurface. This has the advantages of being very much faster to render,
and supporting uv_mapping.

Ingo's website: <http://members.home.nl/seedseven/>
My tutorial page: <http://www.econym.demon.co.uk/isotut/param.htm>

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: ABX
Subject: Re: explicit color mapping f(u,v)->color
Date: 6 Oct 2003 02:52:28
Message: <9q32ovo8ghf1fldrqs0fmslvfe9ltv4ipv@4ax.com>
On Sun, 05 Oct 2003 20:14:47 -0400, fjolsvit <fjo### [at] netscapenet> wrote:
> This *seems* somewhat 
> strange since I am already defining the parameterized object in terms of 
> UV parameters.

I noticed this very early after 3.5 relase and made a patch
http://abx.art.pl/pov/patches/uvparam.php which was included in MegaPOV 1.0
http://megapov.inetart.net/manual/objects.html#uv_param . AFAIK this 'kind of
bug' will be fixed in 3.5.1.

ABX


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: explicit color mapping f(u,v)->color
Date: 6 Oct 2003 10:04:11
Message: <Xns942AA33B14E90torolavkhotmailcom@204.213.191.226>
...
> Now the next trick will be to draw an arbitrary curve on said
> surface.
...


See my code below for a way to draw simple functions on an
uv-mapped surface.

It shouldn't be very difficult to add a coordinate grid to
the surface pigment too.


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare LW = 0.01; // Line Width

#declare SelFn =
  function(A) {
    select(A, select(A + LW/2, 0, 1), select(A - LW/2, 1, 0))
  }

#declare OneLineFn = function(u, v) { SelFn(v - u) }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare DrawFn =
  function(u) { 0.5 + 0.25*sin(4*pi*u) + 0.25*cos(5*pi*u) }

//#declare DrawFn = function(u) { 0.5 + 0.5*sin(2*pi*u) }


bicubic_patch {
  type 0
  flatness 0.01
  u_steps 4
  v_steps 4

  <0, 0, 0>, <1, 0, 0>, <2, 0, 0>, <3, 0, 0>,
  <0, 1, 0>, <1, 1, 0>, <2, 1, 0>, <3, 1, 0>,
  <0, 2, 0>, <1, 2, 0>, <2, 2, 0>, <3, 2, 0>,
  <0, 3, 0>, <1, 3, 0>, <2, 3, 0>, <3, 3, 0>

  uv_mapping
  texture {
    pigment {
      function { OneLineFn(DrawFn(u), v) }
      color_map {
        [ 0 color rgb <1, 1, 1> ]
        [ 1 color rgb <1, 0, 0> ]
      }
    }
  }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

camera {
  location <1.5, 1.5, -4>
  look_at <1.5, 1.5, 0>
}


light_source {
  <1, 1, -3>*100
  color rgb <1, 1, 1>
  shadowless
}

background { color blue 0.5 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: explicit color mapping f(u,v)->color
Date: 6 Oct 2003 10:34:29
Message: <Xns942AA85E6E329torolavkhotmailcom@204.213.191.226>
Tor Olav Kristensen <tor_olav_kCURLYAhotmail.com> wrote in 
news:Xns### [at] 204213191226:

> 
> ...
>> Now the next trick will be to draw an arbitrary curve on said
>> surface.
> ...
> 
> 
> See my code below for a way to draw simple functions on an
> uv-mapped surface.
...

And here is some code that shows how to draw implicit curves
on such a surface.

(It should be possible to make a function that corrects the
change in line width along the curve.)


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.5;

#include "functions.inc"      

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare LW = 0.02; // Line Width

#declare SelFn =
  function(A) {
    select(A, select(A + LW/2, 0, 1), select(A - LW/2, 1, 0))
  }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare DrawFn =
  function(u, v) { f_sphere(u, v, 0, 0.3 + 0.1*cos(6*f_th(u, 0, v))) }

//#declare DrawFn = function(u, v) { sqrt(u*u + v*v) - 0.4 }

bicubic_patch {
  type 0
  flatness 0.01
  u_steps 4
  v_steps 4

  <0, 0, 0>, <1, 0, 0>, <2, 0, 0>, <3, 0, 0>,
  <0, 1, 0>, <1, 1, 0>, <2, 1, 0>, <3, 1, 0>,
  <0, 2, 0>, <1, 2, 0>, <2, 2, 0>, <3, 2, 0>,
  <0, 3, 0>, <1, 3, 0>, <2, 3, 0>, <3, 3, 0>

  uv_mapping
  texture {
    pigment {
      function { SelFn(DrawFn(u - 0.5, v - 0.5)) }
      color_map {
        [ 0 color rgb <1, 1, 1> ]
        [ 1 color rgb <1, 0, 0> ]
      }
    }
  }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

camera {
  location <1.5, 1.5, -4>
  look_at <1.5, 1.5, 0>
}


light_source {
  <1, 1, -3>*100
  color rgb <1, 1, 1>
  shadowless
}

background { color blue 0.5 }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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