POV-Ray : Newsgroups : povray.general : explicit color mapping f(u,v)->color : Re: explicit color mapping f(u,v)->color Server Time
7 Nov 2024 13:37:14 EST (-0500)
  Re: explicit color mapping f(u,v)->color  
From: Tor Olav Kristensen
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.