POV-Ray : Newsgroups : povray.text.scene-files : ISO-quilt and carpet Server Time
23 Dec 2024 02:54:12 EST (-0500)
  ISO-quilt and carpet (Message 1 to 2 of 2)  
From: R  Suzuki
Subject: ISO-quilt and carpet
Date: 15 Nov 2001 06:16:07
Message: <3bf3a3f7@news.povray.org>
// Source for the image I posted on p.b.i.

// Persistence of Vision Ray Tracer Scene Description File
// File: 011112b1.pov
// Vers: 3.5 beta 7
// Desc: ISO quilt and carpet - Example
// Date: 11/15/2001
// Auth: Ryoichi Suzuki  < r-s### [at] aistgojp >
//
#version 3.5;
#include "functions.inc"

#declare FOCAL_BLUR = 0;   // Focal blur  0:off, 1: on

camera {
  location  <-2.0, 3.2, -6.0>
  direction 3.7*z
  right     x*image_width/image_height
  look_at   <0.0, 0.2,  0.0>

//-- focal blur
#if (FOCAL_BLUR)
  aperture 0.07
  blur_samples 10
  focal_point <0,0,-0.6>
  confidence 0.90
  variance 1/100
#end
}

light_source { 0  color rgb 1.8 translate <-30, 40, -30>}

#declare Minor_R=0.15;
#declare Major_R=0.75;
#declare Max_R=Major_R+Minor_R;

#declare QuiltCol= color <0.9,0.65,0.6>;
#declare QuiltFin= finish{ ambient 0.3  diffuse 0.5 specular 0.3 };

#declare Freq1=160; // frequency of threads for x-axis
#declare Freq2=120; // frequency of threads for z-axis

//  function F_quilt1
//            unit cell:small trancated cones
// F1: frequency of threads for x-axis
// F2: frequency of threads for z-axis
// SLOPE1: slope of the cone
// Trunc: Truncating height
#declare F_quilt1=function(x,y,z,F1,F2,SLOPE1, Trunc){
    f_r((mod((x+1)*F1 +f_noise3d(x*F1/4,0,z*Freq2/4)*0.5,1)-0.5)/F1,
      0,
      (mod((z+1)*Freq2 -f_noise3d(x*F1/4,0,z*F2/4)*0.5,1)-0.5)/F2)
    *0.5*(1+f_noise3d(x*F1,y,z*F2))
    +y/SLOPE1
    & (y+Trunc)
}

#declare FN2 = function {pigment { quilted } }
#declare F_quilt3
=function{FN2(x*Freq1+f_noise3d(x*40,y*2,z*30)*0.5,y,z*Freq2

+f_noise3d(x*40,y*2,z*30)*0.5).gray*(1+f_noise3d(x*Freq1,y,z*Freq2))}


// Left torus  :  F_quilt1 on f_torus
isosurface {
    function{F_quilt1(
           atan2(x,z)/pi*2,
           f_torus(x,y,z,Major_R,Minor_R),
           atan2(y,f_r(x,0,z)-Major_R)/pi*0.5,
           Freq1,Freq2,1,0.0001)}
        contained_by { box {<-Max_R,-Minor_R,-Max_R> <Max_R,Minor_R,Max_R>}}
        threshold 0.0
        accuracy 0.0002
        max_gradient 1.5
        texture { pigment{color QuiltCol} finish{ QuiltFin } }
        rotate z*90
        translate x*-0.75
}

// Center torus  :  f_mesh1 on f_torus
isosurface {
      function {f_mesh1(
          atan2(x,z)/pi*2,
          f_torus(x,y,z, Major_R,Minor_R),
          atan2(y,f_r(x,0,z)-Major_R)/pi*0.5,
          1/Freq1,1/Freq2,1,0.5/Freq1,1)
        }
        contained_by { box { <-Max_R-0.01,-Minor_R-0.01,-Max_R-0.01>,
                             <Max_R+0.01,Major_R+0.01,Max_R+0.01> } }
        threshold 0.5/Freq1
        accuracy 0.0001
        max_gradient 1.2
 texture { pigment{color QuiltCol} finish{ QuiltFin } }
        rotate z*90
}


// Right torus  : torus with normal
torus{ Major_R, Minor_R
   texture {
      pigment{color QuiltCol}
      finish{QuiltFin}
      normal{
         function{ F_quilt3(
                  atan2(x,z)/pi*2,
                  f_torus(x,y,z,Major_R,Minor_R),
                  atan2(y, f_r(x,0,z)-Major_R)/pi/2)*0.4}
         slope_map {[0 <0, 1>] [0.5 <1, 1>] [0.5 <1,-1>] [1   <0,-1>]}
      }
   }
   rotate z*90
   translate x*0.75
}


//---------- parameters for the carpet/fur/grass function -----------------
#declare FL_Freq=80;      // frequency
#declare FL_Height=0.053;   // height
#declare FL_S=0.5;         // shape parameter: low value gives thin fibers

// parameters for f_noise3d
 #declare R_Freq_x=7;
 #declare R_Freq_z=5;
 #declare R_PS_x1=0.5;   //phase shift
 #declare R_PS_x2=3;
 #declare R_PS_z1=1;
 #declare R_PS_z2=3;

 #declare R_S_x=2;       // strength
 #declare R_S_z=2;

#declare R_Parm_xx1=15;
#declare R_Parm_xy1=4;
#declare R_Parm_xz1=17;
#declare R_Parm_xx2=49;
#declare R_Parm_xy2=8;
#declare R_Parm_xz2=51;

#declare R_Parm_zx1=12.3;
#declare R_Parm_zy1=5;
#declare R_Parm_zz1=14;
#declare R_Parm_zx2=42;
#declare R_Parm_zy2=8;
#declare R_Parm_zz2=59;


//-----------  Carpet --------------------
object {
  isosurface {
     function  {
       f_r(
        (mod((x+1000)*FL_Freq+sin(y*pi*R_Freq_x
          +f_noise3d(x*R_Parm_xx1,y*R_Parm_xy1,z*R_Parm_xz1)*pi*R_PS_x1
          +f_noise3d(x*R_Parm_xx2,y*R_Parm_xy2,z*R_Parm_xz2)*pi*y*R_PS_x2)
                       *R_S_x,1)-0.5)/FL_Freq,
         0,
         (mod((z+1000)*FL_Freq+sin(y*pi*R_Freq_z
           +f_noise3d(x*R_Parm_zx1,y*R_Parm_zy1,z*R_Parm_zz1)*pi*R_PS_z1
           +f_noise3d(x*R_Parm_zx2,y*R_Parm_zy2,z*R_Parm_zz2)*pi*y*R_PS_z2)
                       *R_S_z,1)-0.5)/FL_Freq)
         +y*y*FL_S
       | y-0.001
      }
      contained_by { box { <-6,0.0,-6> <6,FL_Height,6> } }
      threshold FL_Height*FL_Height*FL_S
      accuracy 0.0005
      max_gradient 2
      rotate y*-5
      texture {
        pigment{
          gradient y
          color_map{[0.0 rgb<0.4,0.5,0.3>] [FL_Height+0.02
rgb<0.89,0.9,0.89>]}
        }
        finish{ambient 0.5 diffuse 0.5 specular 0.2}
      }
  }
}


Post a reply to this message

From: R  Suzuki
Subject: Re: ISO-quilt and carpet
Date: 26 Jan 2002 02:50:11
Message: <3c525fb3@news.povray.org>
Due to the syntax change of the & and | operators, the scene
file of the previous post does not work.
Here is the revised version for v3.5 beta 10.

// Vers: 3.5 beta 10
// Desc: ISO quilt and carpet
// Date: 01/26/2002
// Auth: Ryoichi Suzuki  < r-s### [at] aistgojp >
//
#version 3.5;
#include "functions.inc"

#declare FOCAL_BLUR = off;

camera {
   location  <-2.0, 3.2, -6.0>  direction 3.7*z
   right     x*image_width/image_height
   look_at   <0.0, 0.2,  0.0>
 #if (FOCAL_BLUR)
   aperture 0.07
   blur_samples 6
   focal_point <0,0,-0.6>
   confidence 0.90  variance 1/100
 #end
}

light_source { <-30,40,-30>  color rgb 1.3 }
light_source { <10,50,-30>  color rgb 0.8 shadowless}

//------------------------------------
#declare Minor_R=0.15;
#declare Major_R=0.75;
#declare Max_R=Major_R+Minor_R;

#declare Freq1=160; // frequency of threads for x-axis
#declare Freq2=120; // frequency of threads for z-axis
#declare FreqQ=8;   // frequency of quilt

#declare FN2 = function {pigment { quilted } }
#declare FNC2 = function {pigment { checker } }

#declare QuiltCol1= color <0.9,0.55,0.5>;
#declare QuiltCol2= color <0.85,0.85,0.85>;
#declare QuiltFin= finish{ ambient 0.3  diffuse 0.5 specular 0.3 };
#declare QuiltPigm=pigment{
      function {FNC2(atan2(x,z)/pi*2  *FreqQ
                ,0, atan2(y,f_r(x,0,z)-Major_R)/pi*0.5  *FreqQ).gray}
      color_map{[0.0 QuiltCol1][0.5 QuiltCol1]
                [0.5 QuiltCol2][1.0 QuiltCol2]}     }

//  function F_quilt1
//            unit cell:small trancated cones
// F1: frequency of threads for x-axis
// F2: frequency of threads for z-axis
// SLOPE1: slope of the cone
// Trunc: Truncating height
#declare F_quilt1=function(x,y,z,F1,F2,SLOPE1, Trunc){
  max(
    f_r((mod((x+1)*F1 +f_noise3d(x*F1/4,0,z*Freq2/4)*0.5,1)-0.5)/F1,
        0,
        (mod((z+1)*Freq2 -f_noise3d(x*F1/4,0,z*F2/4)*0.5,1)-0.5)/F2)
    *0.5*(1+f_noise3d(x*F1,y,z*F2))
    +y/SLOPE1
  , (y+Trunc)
  )
  +FN2(x*FreqQ,y,z*FreqQ).gray*0.05
}

#declare F_quilt2=function(x,y,z,F1,F2)
 {f_mesh1(x,y+FN2(x*FreqQ,y,z*FreqQ).gray*0.05 ,z, 1/F1,1/F2,1,0.5/F1,1)}


#declare F_quilt3 =function(x,y,z,F1,F2)
     { FN2(x*F1+f_noise3d(x*40,y*2,z*30)*0.5,y,z*F2
      +f_noise3d(x*40,y*2,z*30)*0.5).gray*(1+f_noise3d(x*F1,y,z*F2))
      -FN2(x*FreqQ,y,z*FreqQ).gray}


// Left torus  :  F_quilt1 on f_torus
isosurface {
    function{F_quilt1(
           atan2(x,z)/pi*2,
           f_torus(x,y,z,Major_R,Minor_R+0.01),
           atan2(y,f_r(x,0,z)-Major_R)/pi*0.5,
           Freq1,Freq2,1,0.0001)}
        contained_by { box {<0,-Minor_R-0.01,-Max_R-0.01>
                            <Max_R+0.01,Minor_R+0.01,Max_R+0.01>}}
        accuracy 0.0002
        max_gradient 1.5
//        evaluate off,1,1
        texture { pigment{QuiltPigm} finish{ QuiltFin } }
        rotate z*90
        translate x*-0.75
}

// Center torus  :  F_quilt2 (f_mesh1+quiled pattern func) on f_torus
isosurface {
      function {
        F_quilt2(
          atan2(x,z)/pi*2,
          f_torus(x,y,z, Major_R,Minor_R),
          atan2(y,f_r(x,0,z)-Major_R)/pi*0.5,
          Freq1,Freq2)
        }
        contained_by { box { <-0.01,-Minor_R-0.01,-Max_R-0.01>,
                             <Max_R+0.01,Major_R+0.01,Max_R+0.01> } }
        threshold 0.5/Freq1
        accuracy 0.0001
        max_gradient 1.2
//        evaluate off,1,1
        texture { pigment{QuiltPigm} finish{ QuiltFin } }
        rotate z*90
}


// Right torus  : torus with normal
torus{ Major_R, Minor_R
   texture {
      pigment{QuiltPigm}
      finish{ QuiltFin }
      normal{
         function{ F_quilt3(
                  atan2(x,z)/pi*2,
                  f_torus(x,y,z,Major_R,Minor_R),
                  atan2(y, f_r(x,0,z)-Major_R)/pi/2,
                  Freq1,Freq2)*0.4}
         slope_map {[0 <0, 1>] [0.5 <1, 1>] [0.5 <1,-1>] [1 <0,-1>]}
      }
   }
   rotate z*90
   translate x*0.75
}


//---------- parameters for the carpet/fur/grass function -----------------
#declare CarpetCol1=rgb<0.4,0.4,0.4>;
#declare CarpetCol2=rgb<0.2,0.3,0.6>;
#declare CarpetCol3=rgb<0.3,0.5,0.2>;
#declare CarpetColT=rgb<1.0,1.0,1.0>;

#declare FL_Freq=80;      // frequency
#declare FL_Height=0.053;   // height
#declare FL_S=0.5;         // shape parameter: low value gives thin fibers

// parameters for f_noise3d
 #declare R_Freq_x=7;
 #declare R_Freq_z=5;
 #declare R_PS_x1=0.5;   //phase shift
 #declare R_PS_x2=3;
 #declare R_PS_z1=1;
 #declare R_PS_z2=3;

 #declare R_S_x=2;       // strength
 #declare R_S_z=2;

#declare R_Parm_xx1=15;
#declare R_Parm_xy1=4;
#declare R_Parm_xz1=17;
#declare R_Parm_xx2=49;
#declare R_Parm_xy2=8;
#declare R_Parm_xz2=51;

#declare R_Parm_zx1=12.3;
#declare R_Parm_zy1=5;
#declare R_Parm_zz1=14;
#declare R_Parm_zx2=42;
#declare R_Parm_zy2=8;
#declare R_Parm_zz2=59;


//-----------  Carpet --------------------
object {
  isosurface {
     function  {
      min(
       f_r(
        (mod((x+1000)*FL_Freq+sin(y*pi*R_Freq_x
          +f_noise3d(x*R_Parm_xx1,y*R_Parm_xy1,z*R_Parm_xz1)*pi*R_PS_x1
          +f_noise3d(x*R_Parm_xx2,y*R_Parm_xy2,z*R_Parm_xz2)*pi*y*R_PS_x2)
                       *R_S_x,1)-0.5)/FL_Freq,
         0,
         (mod((z+1000)*FL_Freq+sin(y*pi*R_Freq_z
           +f_noise3d(x*R_Parm_zx1,y*R_Parm_zy1,z*R_Parm_zz1)*pi*R_PS_z1
           +f_noise3d(x*R_Parm_zx2,y*R_Parm_zy2,z*R_Parm_zz2)*pi*y*R_PS_z2)
                       *R_S_z,1)-0.5)/FL_Freq)
         +y*y*FL_S
       , y-0.001
       )
      }
      contained_by { box { <-6,0.0,-6> <6,FL_Height,6> } }
      threshold FL_Height*FL_Height*FL_S
      accuracy 0.0005
      max_gradient 2
//      evaluate off,1,1
      rotate y*-5
      texture {
        pigment {
          hexagon
          pigment{
            gradient y
            color_map{[0.0 CarpetCol1] [FL_Height+0.01 CarpetColT]}
          }
          pigment{
            gradient y
            color_map{[0.0 CarpetCol2] [FL_Height+0.01 CarpetColT]}
          }
          pigment{
            gradient y
            color_map{[0.0 CarpetCol3] [FL_Height+0.01 CarpetColT]}
          }
          scale <0.25,1,0.25>
        }
        finish{ambient 0.3 diffuse 0.5 specular 0.2}
      }
  }
}


Post a reply to this message

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