POV-Ray : Newsgroups : povray.text.scene-files : Grid texture for bicubic patches and uv-povray Server Time
31 Oct 2024 19:26:29 EDT (-0400)
  Grid texture for bicubic patches and uv-povray (Message 1 to 3 of 3)  
From: Nieminen Mika
Subject: Grid texture for bicubic patches and uv-povray
Date: 9 Jul 1999 07:36:04
Message: <3785dea4@news.povray.org>
Have you ever created a complex object made of bicubic patches (for
example with spatch) and wanted the see the patches? The UV-povray is
very handy for this.

  This macro applies a grid texture to bicubic patches (or any other
object as well, but it may not work very well with other objects) which
makes it easy to see the patches. For an example image, see:
http://www.cs.tut.fi/~warp/gridtest.jpg
or:
http://www.cs.tut.fi/~warp/gridtest.png
  The yellow lines mark the border of the patch and the red lines are
just lines inside the patch (to better see the form of the patch).
  The source code for the image above is this simple:

---------------------------------------------------------------------------
#include "pcm.mcr"
#include "gridtext.mcr"

camera { location <-2,1,-5> look_at 0 angle 35 }
light_source { <100,200,-20> 1 }
light_source { <-100,0,0> x+y }

object
{ read_mesh("spdhead.pcm")

  GridTexture()
  finish { specular .5 }
}
---------------------------------------------------------------------------

  (Although this example uses the pcm macro, you don't need it to use
the grid texture macro; you can apply it to any union of bicubic patches.)

  This macro requires the uv-patched povray.

  Before calling the GridTexture() macro, you can optionally specify any
of the following identifiers:

Grid2Subdivision : Sets how many lines the patch will be subdivided into.
                   Default value: 4
GridBackgroundColor : The color of the background of the texture. Default
                      value: rgb <0,0,1>
                      Tip: If you want a transparent or semi-transparent
                      grid, set the background color to something like
                      rgbt 1 or rgbf <0,0,1,.95>
GridLine1Color : The color of the border of the bicubic patches. Default
                 value: rgb <1,1,0>
GridLine2Color : The color of the subdivision lines. Default
                 value: rgb <1,0,0>
GridLine1Width : The relative width of the border line (relative to the
                 width of the patch; 1 means the width of the patch).
                 Default value: .05
GridLine2Width : The relative width of the subdivision lines. Default
                 value: .025
GridLine1FadeWidth : If you want that the lines fade smoothly to the
                     background color instead of sharp lines, you can set
                     the width of the fade area with this. Default
                     value: 0
GridLine1FadeWidth : Same for the subdivision lines

  And the macro itself:

---------------------------------------------------------------------------

#macro GridTexture()
#ifndef(Grid2Subdivision)    #local Grid2Subdivision = 4;              #end
#ifndef(GridBackgroundColor) #local GridBackgroundColor = rgb <0,0,1>; #end
#ifndef(GridLine1Color)      #local GridLine1Color = rgb <1,1,0>;      #end
#ifndef(GridLine2Color)      #local GridLine2Color = rgb <1,0,0>;      #end
#ifndef(GridLine1Width)      #local GridLine1Width = .05;              #end
#ifndef(GridLine2Width)      #local GridLine2Width = .025;             #end
#ifndef(GridLine1FadeWidth)  #local GridLine1FadeWidth = 0;            #end
#ifndef(GridLine2FadeWidth)  #local GridLine2FadeWidth = 0;            #end

#local Grid =
  texture
  { pigment
    { gradient x color_map
      { [0 GridLine2Color]
        [Grid2Subdivision*GridLine2Width/2 GridLine2Color]
        [Grid2Subdivision*(GridLine2Width/2+GridLine2FadeWidth)
          GridBackgroundColor]
        [1-Grid2Subdivision*(GridLine2Width/2+GridLine2FadeWidth)
          GridBackgroundColor]
        [1-Grid2Subdivision*GridLine2Width/2 GridLine2Color]
        [1 GridLine2Color]
      }
      scale 1/Grid2Subdivision
    }
  }
  texture
  { pigment
    { gradient y/Grid2Subdivision color_map
      { [0 GridLine2Color]
        [Grid2Subdivision*GridLine2Width/2 GridLine2Color]
        [Grid2Subdivision*(GridLine2Width/2+GridLine2FadeWidth) rgbt 1]
        [1-Grid2Subdivision*(GridLine2Width/2+GridLine2FadeWidth) rgbt 1]
        [1-Grid2Subdivision*GridLine2Width/2 GridLine2Color]
        [1 GridLine2Color]
      }
      scale 1/Grid2Subdivision
    }
  }
  texture
  { pigment
    { gradient x color_map
      { [0 GridLine1Color]
        [GridLine1Width/2 GridLine1Color]
        [GridLine1Width/2+GridLine1FadeWidth rgbt 1]
        [1-(GridLine1Width/2+GridLine1FadeWidth) rgbt 1]
        [1-GridLine1Width/2 GridLine1Color]
        [1 GridLine1Color]
      }
    }
  }
  texture
  { pigment
    { gradient y color_map
      { [0 GridLine1Color]
        [GridLine1Width/2 GridLine1Color]
        [GridLine1Width/2+GridLine1FadeWidth rgbt 1]
        [1-(GridLine1Width/2+GridLine1FadeWidth) rgbt 1]
        [1-GridLine1Width/2 GridLine1Color]
        [1 GridLine1Color]
      }
    }
  }

  uv_mapping
  texture { Grid }
#end

---------------------------------------------------------------------------

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Nieminen Mika
Subject: Re: Grid texture for bicubic patches and uv-povray
Date: 9 Jul 1999 07:50:12
Message: <3785e1f4@news.povray.org>
Btw, you can also layer the grid texture over the regular texture in
your bicubic patches. Just set the background color of the grid to
rgbt 1 and add GridTexture() after the regular texture definitions of
your bpatches.
  This way you can see how the object is divided into patches without
removing its texturing, but just adding the grid on top of it.


-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: ingo
Subject: Re: Grid texture for bicubic patches and uv-povray
Date: 9 Jul 1999 15:13:03
Message: <378649bf@news.povray.org>
Nieminen Mika heeft geschreven in bericht <3785dea4@news.povray.org>...
>  Have you ever created a complex object made of bicubic patches (for
>example with spatch) and wanted the see the patches? The UV-povray is
>very handy for this.
>

Thank you,

ingo
--
Met dank aan de muze met het glazen oog.


Post a reply to this message

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