POV-Ray : Newsgroups : povray.text.scene-files : ISO-quilt and carpet : ISO-quilt and carpet Server Time
3 Jul 2024 00:23:58 EDT (-0400)
  ISO-quilt and carpet  
From: R  Suzuki
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

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