POV-Ray : Newsgroups : povray.general : Mapping Textures on irregular shapes Server Time
3 May 2024 18:52:03 EDT (-0400)
  Mapping Textures on irregular shapes (Message 28 to 37 of 47)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Bald Eagle
Subject: Re: Mapping Textures on irregular shapes
Date: 30 Apr 2020 20:50:01
Message: <web.5eab717d72e01857fb0b41570@news.povray.org>
"Josh" <nomail@nomail> wrote:

> > #include "functions.inc"
> > #declare Fnct00 = function {
> >     pattern { density_file df3 "aster1.df3" interpolate 0
> >     }
> > }
> > #declare Fnct01 = function (x,y,z) {
> >     0.025-Fnct00(x,y,z)
> > }
> > #declare BaryteGreen = srgb <0.6157,0.7686,0.3725>;
> > #declare Iso00 = isosurface {
> >     function { Fnct01(x,y,z) + f_noise3d(x,y,z)*2}
> >     contained_by { box { -5,5 } }
> >     threshold 0
> >     accuracy 0.0005
> >     max_gradient 6
> >     all_intersections
> >     texture {
> >       pigment { color BaryteGreen }
> >       finish { ambient <0.03,0.02,0.0> diffuse 0.8,0.4 phong 0.7 }
> >     }
> > }

You're in the realm of "very tricky" - and I get lost there all the time.   ;)

My best suggestion is to apply the shotgun approach and try to diagnose the
problem in a number of ways.

You should be able to decrease the accuracy in the simple df3 scene until it's
still ok but not abhorrent - that will speed things up.
Maybe employ the evaluate equations in the isosurface docs and see if that helps
any too.

Make sure your camera is far enough away so you're not "in" the isosurface, use
a simple color, and a sky_sphere to make sure you're lighting the whole object.

Then you can try keywords like open and inverse
make the box bigger (slow)
use a wider thinner box - take only a slice, and see what shows up
change the threshold
use function { Fnct01(x,y,z) + f_noise3d(x,y,z)*2 - 0.01}

write a pseudo-isosurface code block to cycle through X, Y, and Z and have the
function evaluate those, and plot tiny spheres if the function evaluates to +/-
some small value close to 0 pick a good step value for your loops so it doesn't
take FOREVER
--------->  X, Y, and Z - NOT x, y, and z
graph a strip of Fnct01(X, 0, 0) in the same way.
try graphing Y and Z as well

See if any of that works.   That's usuallly everything I go through.

and bookmark:   http://www.econym.demon.co.uk/isotut/index.htm
You'll use it a LOT


Post a reply to this message

From: Alain Martel
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 12:01:57
Message: <5eac47f5$1@news.povray.org>
Le 2020-04-30 à 20:10, Josh a écrit :
> "Josh" <nomail@nomail> wrote:
>> I've found a way to create and use a df3 file as an isosurface. Works well. I'm
>> trying now to add noise to it and it makes the shape disappear. Any ideas? The
>> shape shows up fine without the +f_noise3d(x,y,z)*2 statement... Does anyone
>> know what is happening?
>>
>> #include "functions.inc"
>> #declare Fnct00 = function {
>>      pattern { density_file df3 "aster1.df3" interpolate 0
>>      }
>> }
>> #declare Fnct01 = function (x,y,z) {
>>      0.025-Fnct00(x,y,z)
>> }
>> #declare BaryteGreen = srgb <0.6157,0.7686,0.3725>;
>> #declare Iso00 = isosurface {
>>      function { Fnct01(x,y,z) + f_noise3d(x,y,z)*2}
>>      contained_by { box { -5,5 } }
>>      threshold 0
>>      accuracy 0.0005
>>      max_gradient 6
>>      all_intersections
>>      texture {
>>        pigment { color BaryteGreen }
>>        finish { ambient <0.03,0.02,0.0> diffuse 0.8,0.4 phong 0.7 }
>>      }
>> }
>>
>> Josh
> 
> Just to clarify, I've tried adding f_noise3d, subtracting it, nothing seems to
> allow me to perturb the surface of my df3 shape like I can if my function is
> just a simple sphere...
> 
> Josh
> 
> 

Play with the coordinates passed to the function and see what happen.

A starting point :
function { Fnct01(x+sin(y*2+z*3),y-cos(x*7),z+cos(y*5)) }


Post a reply to this message

From: Josh
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 12:55:01
Message: <web.5eac540972e01857dc1270cd0@news.povray.org>
Alain Martel <kua### [at] videotronca> wrote:
> Le 2020-04-30 à 20:10, Josh a écrit :
> > "Josh" <nomail@nomail> wrote:
> >> I've found a way to create and use a df3 file as an isosurface. Works well. I'm
> >> trying now to add noise to it and it makes the shape disappear. Any ideas? The
> >> shape shows up fine without the +f_noise3d(x,y,z)*2 statement... Does anyone
> >> know what is happening?
> >>
> >> #include "functions.inc"
> >> #declare Fnct00 = function {
> >>      pattern { density_file df3 "aster1.df3" interpolate 0
> >>      }
> >> }
> >> #declare Fnct01 = function (x,y,z) {
> >>      0.025-Fnct00(x,y,z)
> >> }
> >> #declare BaryteGreen = srgb <0.6157,0.7686,0.3725>;
> >> #declare Iso00 = isosurface {
> >>      function { Fnct01(x,y,z) + f_noise3d(x,y,z)*2}
> >>      contained_by { box { -5,5 } }
> >>      threshold 0
> >>      accuracy 0.0005
> >>      max_gradient 6
> >>      all_intersections
> >>      texture {
> >>        pigment { color BaryteGreen }
> >>        finish { ambient <0.03,0.02,0.0> diffuse 0.8,0.4 phong 0.7 }
> >>      }
> >> }
> >>
> >> Josh
> >
> > Just to clarify, I've tried adding f_noise3d, subtracting it, nothing seems to
> > allow me to perturb the surface of my df3 shape like I can if my function is
> > just a simple sphere...
> >
> > Josh
> >
> >
>
> Play with the coordinates passed to the function and see what happen.
>
> A starting point :
> function { Fnct01(x+sin(y*2+z*3),y-cos(x*7),z+cos(y*5)) }

That produced interesting results. It split the shape up and duplicated it a
bunch of times. I'll have to think about it.

In the meantime, does anyone know what the isosurface function would be for a
rounded box?

Thanks!

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 13:45:00
Message: <web.5eac5fa272e01857fb0b41570@news.povray.org>
"Josh" <nomail@nomail> wrote:

> > A starting point :
> > function { Fnct01(x+sin(y*2+z*3),y-cos(x*7),z+cos(y*5)) }

I honestly can't even begin to imagine what inspired _that_.

> That produced interesting results. It split the shape up and duplicated it a
> bunch of times. I'll have to think about it.

You and me both  :O

> In the meantime, does anyone know what the isosurface function would be for a
> rounded box?

As a matter of fact, I do!  :)

#declare R = 20;
#declare RoundedBox = function {pow(x,R) + pow(y,R) + pow(z,R) - 1} // rounded
cube

I haven't tried making all of the R's different ... yet   ;)

Hope it's going well, and you're making progress.


Post a reply to this message

From: Josh
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 14:50:01
Message: <web.5eac6f3672e01857dc1270cd0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Josh" <nomail@nomail> wrote:
>
> > > A starting point :
> > > function { Fnct01(x+sin(y*2+z*3),y-cos(x*7),z+cos(y*5)) }
>
> I honestly can't even begin to imagine what inspired _that_.
>
> > That produced interesting results. It split the shape up and duplicated it a
> > bunch of times. I'll have to think about it.
>
> You and me both  :O
>
> > In the meantime, does anyone know what the isosurface function would be for a
> > rounded box?
>
> As a matter of fact, I do!  :)
>
> #declare R = 20;
> #declare RoundedBox = function {pow(x,R) + pow(y,R) + pow(z,R) - 1} // rounded
> cube
>
> I haven't tried making all of the R's different ... yet   ;)
>
> Hope it's going well, and you're making progress.

Well, it's interesting. I was hoping that the rounded box would be in the form
of:
float sdRoundBox( vec3 p, vec3 b, float r )
{
  vec3 q = abs(p) - b;
  return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0) - r;
}

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.

Josh


Post a reply to this message

From: Josh
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 15:30:00
Message: <web.5eac77e172e01857dc1270cd0@news.povray.org>
"Josh" <nomail@nomail> wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
> > "Josh" <nomail@nomail> wrote:
> >
> > > > A starting point :
> > > > function { Fnct01(x+sin(y*2+z*3),y-cos(x*7),z+cos(y*5)) }
> >
> > I honestly can't even begin to imagine what inspired _that_.
> >
> > > That produced interesting results. It split the shape up and duplicated it a
> > > bunch of times. I'll have to think about it.
> >
> > You and me both  :O
> >
> > > In the meantime, does anyone know what the isosurface function would be for a
> > > rounded box?
> >
> > As a matter of fact, I do!  :)
> >
> > #declare R = 20;
> > #declare RoundedBox = function {pow(x,R) + pow(y,R) + pow(z,R) - 1} // rounded
> > cube
> >
> > I haven't tried making all of the R's different ... yet   ;)
> >
> > Hope it's going well, and you're making progress.
>
> Well, it's interesting. I was hoping that the rounded box would be in the form
> of:
> float sdRoundBox( vec3 p, vec3 b, float r )
> {
>   vec3 q = abs(p) - b;
>   return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0) - r;
> }
>
> 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.
>
> Josh

In other words, I'm not sure what vector functions povray has. How would I
convert that function to a povray function?

Josh


Post a reply to this message

From: Josh
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 16:50:07
Message: <web.5eac8b5172e01857dc1270cd0@news.povray.org>
"Josh" <nomail@nomail> wrote:
> "Josh" <nomail@nomail> wrote:
> > "Bald Eagle" <cre### [at] netscapenet> wrote:
> > > "Josh" <nomail@nomail> wrote:
> > >
> > > > > A starting point :
> > > > > function { Fnct01(x+sin(y*2+z*3),y-cos(x*7),z+cos(y*5)) }
> > >
> > > I honestly can't even begin to imagine what inspired _that_.
> > >
> > > > That produced interesting results. It split the shape up and duplicated it a
> > > > bunch of times. I'll have to think about it.
> > >
> > > You and me both  :O
> > >
> > > > In the meantime, does anyone know what the isosurface function would be for a
> > > > rounded box?
> > >
> > > As a matter of fact, I do!  :)
> > >
> > > #declare R = 20;
> > > #declare RoundedBox = function {pow(x,R) + pow(y,R) + pow(z,R) - 1} // rounded
> > > cube
> > >
> > > I haven't tried making all of the R's different ... yet   ;)
> > >
> > > Hope it's going well, and you're making progress.
> >
> > Well, it's interesting. I was hoping that the rounded box would be in the form
> > of:
> > float sdRoundBox( vec3 p, vec3 b, float r )
> > {
> >   vec3 q = abs(p) - b;
> >   return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0) - r;
> > }
> >
> > 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.
> >
> > Josh
>
> In other words, I'm not sure what vector functions povray has. How would I
> convert that function to a povray function?
>
> Josh

Here's my attempt to declare that function in povray, but it won't compile...

#macro sq(X) X*X #end

#declare BOX_SHAPE2=
function(x,y,z,k1,k2,k3)
{
  #declare q = <abs(x), abs(y), abs(z)>-<k1,k2,k3>;
  sqrt(sq(max(q.x,0))+sq(max(q.y,0))+sq(max(q.z,0)))

}

Josh


Post a reply to this message

From: Bald Eagle
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 16:55:06
Message: <web.5eac8c0872e01857fb0b41570@news.povray.org>
"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.


Post a reply to this message

From: Josh
Subject: Re: Mapping Textures on irregular shapes
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

From: Bald Eagle
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 17:45:05
Message: <web.5eac981a72e01857fb0b41570@news.povray.org>
"Josh" <nomail@nomail> wrote:

> Here's my attempt to declare that function in povray, but it won't compile...

"Parse".


> #macro sq(X) X*X #end

And that's why.   You can't use a macro in a function.  You CAN use a function
in a macro.

> #declare BOX_SHAPE2=
> function(x,y,z,k1,k2,k3)
> {
>   #declare q = <abs(x), abs(y), abs(z)>-<k1,k2,k3>;
>   sqrt(sq(max(q.x,0))+sq(max(q.y,0))+sq(max(q.z,0)))
>
> }
>
> Josh

I think at this point, with a little experimentation, you can work out why the
above doesn't work.

I'm thinking that there's another, weird way to do this using pigment functions
- then it would be possible to use the dot notation, but the syntax is big,
bulky, and something that I wish could be fixed.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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