POV-Ray : Newsgroups : povray.newusers : Sponge : Re: Sponge Server Time
28 Jul 2024 18:26:23 EDT (-0400)
  Re: Sponge  
From: Chris B
Date: 23 Dec 2007 05:35:25
Message: <476e39ed$1@news.povray.org>
"Archpawn" <nomail@nomail> wrote in message 
news:web.476d7f72d68f7f9f9c37dbc40@news.povray.org...
> Sherry Shaw <ten### [at] aolcom> wrote:
>> ...
>> Might I ask whether you're going for an actual, natural sponge or a foam
>> rubber spongelike object?  (Which would probably make the difference
>> between (a) an isosurface modeling a rather crinkly thingy and (b) a
>> block of utterly unnatural stuff with holes in it, and possibly a layer
>> of Brillo-like stuff attached to the bottom...)
>> ...
>> Bear in mind that, whichever you choose, a good granite normal will hide
>> a multitude of sins...  ;)
>> ...
> I'm going for b. the unnatural stuff. I'm modeling it somewhat after the 
> sponge
> at
>
http://www.nortonprocleaning.com/Media/Documents/S0000000000000001051/Sponge%20Pads%20-%20Cellulose%20Sponge.jpg
> I tried using a granite normal. It doesn't seem to work. What I'm 
> considering
> doing is using an isosurface for the bigger holes, and surface normals (or
> another isosurface, if possible) for the smaller ones. The problem is, I 
> can't
> find a pattern that works. I might be able to make a function to do it, 
> but it
> wont seem to let me use rand() in them. Specifically, I'd use
> rand(seed(floor(x)), or something to that extent.
>

Hi Arch.,

I think you'll find it difficult to achieve this with a single isosurface. 
You can combine isosurfaces, but you end up with little holes in the 
surfaces of your larger holes, whereas the photo you linked to seems to have 
relatively cleanly formed larger holes.

To get around that, the following example uses a rounded crackle function to 
create an isosurface with large round holes (as suggested by Trevor), then 
it cuts thin layers of smaller holes out of the surface. The hole cutting 
objects (SpongePress2 and SpongePress3) are kept thin by slicing a slightly 
scaled down version of the object out of them so that the smaller holes 
don't penetrate too deeply into the sponge surface. This leaves the larger 
holes looking fairly clean.

This renders reasonably quickly on my machine (a couple of minutes on a dual 
2GHz machine).

Unfortunately, most of the crackly surface effect is attributable to errors 
due to the small scale, with bits of the isosurface missing. Scaling up 
produces a less broken (and IMO less convincing) effect and increases render 
times horendously. Maybe someone who's good at isosurfaces could improve on 
this.

I've also been playing with a macro to distribute different sized holes 
across a surface (using CSG and rand() rather than isosurfaces). Some 
results are looking ok, but I've also got some pretty bad render times with 
that. The main advantage is that it can do different shapes (virtually any 
shape you want) and you get a finer control over the proportion of 
differently sized holes. I'll let you know if that throws up anything good.

Regards,
Chris B.


camera {location <-0.28, 0.44, -0.58> look_at <0.1,0.15,0> angle 40}
light_source {<-5,0.1,-4> color rgb 1}
light_source {<0.4,1,0>    color rgb 0.5}
light_source {<0.5,1,0.1>  color rgb 0.5}
light_source {<0,1,-0.005> color rgb 1}

#declare F=function{pigment{
  crackle
  form <1.5,0,0>
  turbulence 0
  color_map { [0 rgb 1]  [0.9 rgb 0] [1 rgb 0] }
  scale 0.035
  scale 1+x*0.2
  }
}
#declare F1=function{pigment{
  crackle
  form <1.5,0,0>
  turbulence 0
  color_map { [0 rgb 1]  [0.4 rgb 1] [1 rgb 0] }
  scale 0.006
  scale 1+x*0.2
  }
}

#declare F2=function{pigment{
  granite
  turbulence 0.2
  color_map { [0 rgb 1]  [0.2 rgb 1] [1 rgb 0] }
  scale 0.01
  }
}

#declare Transparency = 0;

#declare PrePressedSponge = isosurface {
  function { F(x,y,z).red - 0.6}
  threshold 0.01
  max_gradient 50
  max_trace 10
  contained_by{box{0,<0.37,0.1,0.2>}}
}

#declare SpongePress2 = difference {
  isosurface {
    function { 0.5 - F1(x,y,z).red}
    threshold 0.1
    max_gradient 500
    max_trace 10
    contained_by{box{-0.001,<0.37,0.1,0.2>*1.001}}
  }
  box {0.003,<0.367,0.097,0.197>}
}

#declare SpongePress3 = difference {
  isosurface {
    function { F2(x,y,z).red - 0.6}
    threshold 0.01
    max_gradient 1800
    max_trace 10
    contained_by{box{-0.001,<0.37,0.1,0.2>*1.001}}
  }
  box {0.001,<0.369,0.099,0.199>}
}

#declare Sponge = difference {
  object {PrePressedSponge}
  object {SpongePress3}
}

difference {
  object {PrePressedSponge}
  object {SpongePress2}
  object {SpongePress3}
  texture {
    pigment {
      bozo
      turbulence 0.5
      omega 1
      color_map {
        [0   rgbt <169,115,051,255*Transparency>/255]
        [0.1 rgbt <174,117,053,255*Transparency>/255]
        [0.2 rgbt <179,123,056,255*Transparency>/255]
        [0.3 rgbt <200,145,071,255*Transparency>/255]
        [0.4 rgbt <218,173,104,255*Transparency>/255]
        [0.5 rgbt <232,201,139,255*Transparency>/255]
        [0.6 rgbt <246,221,157,255*Transparency>/255]
        [0.7 rgbt <246,223,166,255*Transparency>/255]
        [0.8 rgbt <199,149,078,255*Transparency>/255]
        [0.9 rgbt <186,132,059,255*Transparency>/255]
        [1   rgbt <174,128,067,255*Transparency>/255]
      }
      scale 0.006
    }


    finish {ambient 0.3}
  }
}

plane {y,0 pigment {rgb 0.4}}


Post a reply to this message

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