Implicit and Parametric Surfaces for POV-Ray

by Daniel Skarda and Tomas Bily (Tuh0r Team)


Note: This patch is no more updated because it became part of Isosurface patch for POV-Ray 3.0. All new features such us noise function or octrees will be only in this new patch.

Examples of noise3d(x,y,z) fuction


This patch is an unofficial version of POV-Ray and it is not supported by POV-Ray Team. It enxtends POV-Ray 2.2 with implicit functions F(x,y,z)=0 and parametric surfaces x(u,v),y(u,v),z(u,v).

parimp-0.92.tar.gz includes modified POV-Ray files and Makefile for Linux/GCC.

For solving intersection between ray and surface we use interval arithmetic. It requires C0 continuity for find correct solution of equality and C1 continuity for correct shading. Normals (partial derivates) are computed by numeric methods.

What does work now?

Future

Examples - Implicit Surfaces

Sphere

implicit {
   function sqr(x) + sqr(y) + sqr(z) - 1 
   < -1.5, -1.5, -1.5>,   <1.5, 1.5, 1.5>
   accuracy 0.001
   .
   .
   .
   
}

sphere




Blob

Classical blob (Jim Blinn) - no polynomial aproximation!

#declare delta= 1.1
#declare BLOB= function exp(1-sqr(x)-sqr(y+delta)-sqr(z)) 
                       + exp(1-sqr(x)-sqr(y-delta)-sqr(z)) - 1

implicit {
  function BLOB
  < -2,-2,-2>, < 2,2,2>
  accuracy 0.01
   .
   .
   .

 }

Blinn's blob


Torus as blob component

#declare Ro=0.4
#declare Ri=1.8

#declare P=Ri*Ri+Ro*Ro
#declare M=Ri*Ri-Ro*Ro
#declare MM=M*M

/*
#declare TORUS=
  function x^4+2*sqr(x)*(sqr(y)+sqr(z)-P)+y^4+2*sqr(y)*(sqr(z)+M)+
               z^4-2*sqr(z)*P+MM
*/
implicit
 { 
  function exp(-(x^4+2*sqr(x)*(sqr(y)+sqr(z)-P)+y^4+2*sqr(y)*(sqr(z)+M)+
           z^4-2*sqr(z)*P+MM)) +
           exp(-(x^4+2*sqr(x)*(sqr(z)+sqr(y)-P)+z^4+2*sqr(z)*(sqr(y)+M)+
           y^4-2*sqr(y)*P+MM)) +
           exp(-(y^4+2*sqr(y)*(sqr(x)+sqr(z)-P)+x^4+2*sqr(x)*(sqr(z)+M)+
           z^4-2*sqr(z)*P+MM)) - .7


  <-Ro-2*Ri,-Ro-2*Ri,-Ro-2*Ri>, <Ro+2*Ri,Ro+2*Ri,Ro+2*Ri>
  accuracy .01

  pigment { color rgb <0,1,1> } 
 }

Three toruses


Heart

6th order polynomial

#declare HEART= function cub(2*sqr(x)+sqr(y)+sqr(z)-1) - 
                               (0.1*sqr(x)+sqr(y))*cub(z)
   .
   .
   .

Heart


Klein Botte

#declare KLEINE=function (sqr(x)+sqr(y)+sqr(z)+2*y-1)*(sqr(sqr(x)+sqr(y)+sqr(z)
                           -2*y-1)-8*sqr(z))+16*x*z*(sqr(x)+sqr(y)+sqr(z)-2*y-1)

Kleine bottle


Goniometric functions

function_xy {
 function cos(10*(sqrt(sqr(x)+sqr(y))))
 <-2,-2,-2>,<2,2,2>
 accuracy 0.01
   .
   .
   .

}

cos( 10* |X| )


CSG - Difference

#declare SPHERE = implicit {
  function sqr(x)+sqr(y)+sqr(z)-1
  accuracy 0.01
  all_intersections
  <-1.5,-1.5,-1.5>, <1.5,1.5,1.5>
  pigment { color rgb <1,1,0> }
 }

#declare BOX = 
  box {
    <-0.75,-0.75, -0.75>, <0.75,0.75,0.75>
    pigemnt { color rgb <1,1,1> }
  }

difference {
  object {BOX}
  object {SPHERE}
  pigment { color rgb <1,1,1> }
  finish { ambient 0.7 }
}

Difference



Examples - Parametric Surfaces



Plane

Just another plane.

parametric {
  function u,0,v
  <-1,-1>, <1,1>                  /* range of u and v */         
  <-1.5,-1.5,-1.5>,<1.5,1.5,1.5>  
  accuracy 0.01
    .
    .
    .

Difference


Cylinder

There appears strange bug with this cone - can you notice it?

7/1/96 - this bug is fixed.

#declare PI=3.14159265358979323

parametric {
  function  sin(v), u, cos(v)
  <-1,-PI>, <1,PI>     
    .
    .
    .

Cylinder with bug


map_type 8
This is another parametetric surface ...

#declare PI=3.14159265358979323

parametric {
  function  v*cos(4*u), u, v*sin(4*u)
  <-PI/2,-1>, <PI/2, 1>     
 
  pigment {
    image_map {
      tga "bv17.tga"
      map_type 8
    }
  }
  finsih { ambient 0.7 }
}

map_type 8





POV-Ray releated links


(c) 1996 Daniel Skarda and Tomas Bily
Last update: 11/24/1996