|
 |
Am 28.04.2025 um 20:26 schrieb Bald Eagle:
> Try Mike Williams' isosurface thickening trick:
>
> Thickening
> If we have a function F(x,y,z) we can turn it into two parallel surfaces by
> using abs(F(x,y,z))-C where C is some
> small value. The original function should be one that works with zero threshold.
> The two resulting surfaces are
> what you would get by rendering the original function with threshold +C and -C,
> but combined into a single
> image. The space between the two surfaces becomes the "inside" of the object. In
> this way we can construct
> things like glasses and cups that have walls of non-zero thickness.
> #declare F = function {y + f_noise3d (x*2, 0, z*2)}
> isosurface {
> function {abs (F(x, y, z))-0.1}
> ....
>
>
Obviously this should work. But I run into a problem with this approach.
The yellow object depictes the devils plate function without any thickening:
#declare c=1/10000;
#declare Th=1/10;
#declare Devil = function(x,y,z) {
x*x*x*x+2*x*x*z*z-36/100*x*x-y*y*y*y+25/100*y*y+z*z*z*z }
#declare Devil2 = function(x,y,z) { Devil(x,sqrt(y*y+z*z)-15/10,z) }
#declare IsoExterior = function (x,y,z) { Devil2(x,y,sqrt(x*x+z*z)-15/10) }
isosurface { function { IsoExterior(x,y,z) }
contained_by { box { <-45/10,-25/10,-75/10>,<45/10,45/10,75/10> } }
threshold 0.0
open
max_gradient 2500
pigment { colour Yellow }
}
The red object shows the approach by Abderrahman Taha (MathMod). He
calculates the numerical derivatives to approximate the normals. Then
the shape is shifted a small amount along and against these normals.
Finally, both functions are multiplied to form the sets of points at
which at least one of the functions returns the value zero - the
threshold that is then used in the isosurface:
// numerical derivatives
#declare DFx = function(x,y,z) {
(IsoExterior(x+c,y,z)-IsoExterior(x,y,z))/c }
#declare DFy = function(x,y,z) {
(IsoExterior(x,y+c,z)-IsoExterior(x,y,z))/c }
#declare DFz = function(x,y,z) {
(IsoExterior(x,y,z+c)-IsoExterior(x,y,z))/c }
// normalisation
#declare R = function (x,y,z) { x/sqrt(x*x+y*y+z*z) }
#declare IsoPlus = function (x,y,z) {
IsoExterior( x+Th*R(DFx(x,y,z),DFy(x,y,z),DFz(x,y,z)),
y+Th*R(DFy(x,y,z),DFz(x,y,z),DFx(x,y,z)),
z+Th*R(DFz(x,y,z),DFx(x,y,z),DFy(x,y,z)))
}
#declare IsoMinus = function (x,y,z) {
IsoExterior( x-Th*R(DFx(x,y,z),DFy(x,y,z),DFz(x,y,z)),
y-Th*R(DFy(x,y,z),DFz(x,y,z),DFx(x,y,z)),
z-Th*R(DFz(x,y,z),DFx(x,y,z),DFy(x,y,z)))
}
#declare ThickIsoExterior = function (x,y,z) {
IsoPlus(x,y,z)*IsoMinus(x,y,z) }
#declare DevilsPlate = function (x,y,z) {
select ( -(-24/10-y)*(y-44/10),ThickIsoExterior((10*x/15),y,z), 1)
}
isosurface {
function {
DevilsPlate(x,y,z)
}
contained_by { box { <-45/10,-25/10,-75/10>,<45/10,45/10,75/10> } }
threshold 0.0
open
max_gradient 20000000
pigment { colour Red }
}
The orange object ist nearly the same as the red one but without the
select statement, moving the range condition for y into the bounding box.
This all works very fine, but Mike Williams' approach (dark purple)
looks a little strange:
#declare DevilsPlateD = function (x,y,z) {
select (
-(-24/10-y)*(y-44/10),(abs(IsoExterior((10*x/15),y,z))-0.01) ,1)
}
isosurface {
function {
DevilsPlateD(x,y,z)
}
contained_by { box { <-45/10,-25/10,-75/10>,<45/10,45/10,75/10> } }
threshold 0.0
// open
max_gradient 1000000
pigment { colour DarkPurple }
}
All values for max_gradient are adjusted according to the log.
max_trace_level was at maximum (256).
I have no idea what happens here.
Best regards
Michael
Post a reply to this message
Attachments:
Download 'devilsplate02.png' (173 KB)
Preview of image 'devilsplate02.png'

|
 |