POV-Ray : Newsgroups : povray.general : Mapping Textures on irregular shapes : Re: Mapping Textures on irregular shapes Server Time
17 May 2024 16:46:03 EDT (-0400)
  Re: Mapping Textures on irregular shapes  
From: Josh
Date: 1 May 2020 17:20:06
Message: <web.5eac91ec72e01857dc1270cd0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Josh" <nomail@nomail> wrote:
>
> > from the Inigo Quilez examples you posted earlier. I'm trying to figure out how
> > to union/merge boxes together and then round them all together. The math is
> > confusing me. I took enough calculus years ago I should be able to figure it
> > out, lol. His SDF functions are very similar to isosurface functions, yet they
> > are different enough I can't get them to match. In his SDF functions he is able
> > to simply subtract r from the function to round a shape, but I can't get the
> > isosurface functions to match that.
>
> Ah, yes.
> That's because POV-Ray doesn't have vector functions, which makes everything a
> giant PITA.
> I had to follow along with his video
> https://www.youtube.com/watch?v=62-pRVZuS5c
> to figure out how to do it, but it works very nicely   :)
>
>
> #declare Rx = 2;
> #declare Ry = 3;
> #declare Rz = 1;
>
> #declare Q = function {sqrt( pow(max(abs(x)-Rx,0),2) + pow(max(abs(y)-Ry,0),2) +
> pow(max(abs(z)-Rz,0),2) )}
> #declare QX = function (x) {max(abs(x)-Rx, 0)}
> #declare QY = function (x) {max(abs(y)-Ry, 0)}
> #declare QZ = function (x) {max(abs(z)-Rz, 0)}
> #declare D = function {Q (x,y,z) + min(max( QX(x), max(QY(y), QZ(z)) ), 0)}
>
> Now here's the tricky part, which I can't really explain very well ATM.
> You either need to subtract an amount equal to the radiusing of the corners from
> the function D, or you need to use that non-zero value as the isosurface
> threshold.  Otherwise you get no visible isosurface.
> Which can drive you insane trying to debug the equations, the code, etc.
>
> If you want a box of a specific size, with a specific radiusing of the edges and
> corners, I think the way to do that is #declare a Radius value and subtract that
> from Rx, Ry, and Rz, so that when you bump out the function by the radiusing
> value - you're back at the original parameters.
>
> Play with what I have right now and you'll see what I mean.
> The isosurface gradient is only about 1.3.

Beautiful! Thanks so much, that works great!


Post a reply to this message

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