POV-Ray : Newsgroups : povray.general : Blobs help : Blobs help Server Time
30 Jul 2024 16:16:58 EDT (-0400)
  Blobs help  
From: SharkD
Date: 10 Nov 2008 12:55:01
Message: <web.4918748ab3c4f15b1f5ffef0@news.povray.org>
The example blob function at the end of the isosurface tutorial behaves
differently at different scales, as can be seen in the example below. This is
not a problem with the built-in blob object. I was wondering if anyone could
provide a better formula for when using isosurfaces? Thanks!

// Begin

#version 3.6;

#include "colors.inc"
#include "functions.inc"
#include "math.inc"
#include "Axes_macro.inc"

#declare Scene_scale = frame_number;

global_settings
{
 assumed_gamma 1.0
 max_trace_level 5
}

// ----------------------------------------

#declare screen_scale = 1;
camera
{
 #local CameraDistance = 10;
 #local ScreenArea = 6;
 #local AspectRatio = image_width/image_height;
 orthographic
 location -z*CameraDistance
 direction z*CameraDistance
 right     x*ScreenArea*AspectRatio
 up        y*ScreenArea
 rotate x*asind(tand(30))
// rotate x*90
 rotate y*45
 scale Scene_scale
}


background { color rgb <0.6,0.7,1.0> }

light_source
{
 <0, 0, 0>            // light's position (translated below)
 color rgb <1, 1, 1>  // light's color
 translate <-30, 30, -30>
 shadowless
 scale Scene_scale
}

light_source
{
 <0, 0, 0>            // light's position (translated below)
 color rgb <1, 1, 1>  // light's color
 translate <-30, 30, -30>
 rotate y * 90
 shadowless
 scale Scene_scale
}

plane { y,0 pigment {color rgbt 1/2}}

// ----------------------------------------

#declare Blob_threshold = 0.5;
#declare Blob_start = 1;
#declare fn_A = function { pow(x+Scene_scale/2,2) + pow(y+Scene_scale/2,2) +
pow(z+Scene_scale/2,2) - pow(Scene_scale,2) };
#declare fn_B = function { pow(x-Scene_scale/2,2) + pow(y-Scene_scale/2,2) +
pow(z-Scene_scale/2,2) - pow(Scene_scale,2) };
#declare fn_C = function { Blob_start + Blob_threshold }

difference
{
 isosurface
 {
  function
  {
   fn_C(x,y,z)
   - pow(Blob_threshold, fn_A(x,y,z))
   - pow(Blob_threshold, fn_B(x,y,z))
  }
  threshold 0
  accuracy 0.001*Scene_scale
  max_gradient 4
  contained_by { sphere { 0, 2 * Scene_scale } }
 }
 pigment {color rgb x}
}

// End


Post a reply to this message

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