POV-Ray : Newsgroups : povray.general : Iso-blobbing made easier : Iso-blobbing made easier Server Time
19 Nov 2024 22:52:09 EST (-0500)
  Iso-blobbing made easier  
From: Tor Olav Kristensen
Date: 12 Dec 2001 21:56:52
Message: <3C1816A0.6D6B72C@hotmail.com>
I have tried to write the code below in order to show
how one can both add and subtract "blobbed" components
to a iso-surface.

Please try this at home...
- and tell me what you think of it.

Oded proposed to use a sigmoid for "blobbing" of
iso-surfaces in his post 22. Oct. 2001
"iso-surface polyhedra":
http://news.povray.org/povray.binaries.images/18586/
news://news.povray.org/3bace06b%40news.povray.org

(My method also uses a kind of sigmoid function)

Also see this thread (by me 1. Oct. 2001):
"How to transform and blob together iso-shapes in v3.5":
http://news.povray.org/povray.general/18830/
news://news.povray.org/3BB8D35B.BB527254%40hotmail.com


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Copyright 2001 by Tor Olav Kristensen
// Email: tor### [at] hotmailcom
// http://www.crosswinds.net/~tok
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.5;

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Function needed for the "iso-blobbing"

#declare SquashFn =
function(Fn, S) { select(S, -1, 1)*(1/(1 + exp(-abs(S)*Fn)) - 1) }

// Fn is the function for the shape to be "blobbed"
// A negative S-value "subtracts" the shape
// A positive S-value "adds" the shape
// The magnitude of S is the "blobbing" strength

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7
// Simple iso-surface example

#declare CylRad = 3;
#declare SphRad1 = 10;
#declare SphRad2 = 8;

#declare XcylFn = function { sqrt(y^2 + z^2) - CylRad }
#declare YcylFn = function { sqrt(x^2 + z^2) - CylRad }
#declare ZcylFn = function { sqrt(x^2 + y^2) - CylRad }
#declare Sphere1Fn = function { sqrt(x^2 + y^2 + z^2) - SphRad1 }
#declare Sphere2Fn = function { sqrt(x^2 + y^2 + z^2) - SphRad2 }

isosurface {
  function {
    SquashFn(Sphere1Fn(x, y, z), 3) // Add "outer" sphere
   +SquashFn(XcylFn(x, y, z), -10)  // Subtract X-cylinder
   +SquashFn(YcylFn(x, y, z), 2)    // Add Y-cylinder
   +SquashFn(ZcylFn(x, y, z), -3)   // Subtract Z-cylinder
   +SquashFn(Sphere2Fn(x, y, z), 1) // Add "inner" sphere
  }
  max_gradient 4
  threshold -0.5 // Value to use for this kind of blobbing
  contained_by { sphere { <0, 0, 0>, SphRad1 + 6 } }
  pigment { color Blue + White }
}                                     

// Add an "ordinary" Z-cylinder
cylinder {
  -16*z, 16*z, CylRad
  pigment { color Yellow + White }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

background { color (Blue + Cyan)/4 }

light_source {
  <-2, 3, -2>*100
  color White
  shadowless
}

camera {
  location <-1.8, 0, -1>*20
  look_at <0, 0, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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