POV-Ray : Newsgroups : povray.general : Mapping Textures on irregular shapes Server Time
18 May 2024 15:21:18 EDT (-0400)
  Mapping Textures on irregular shapes (Message 31 to 40 of 47)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 7 Messages >>>
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

From: Alain Martel
Subject: Re: Mapping Textures on irregular shapes
Date: 1 May 2020 21:03:35
Message: <5eacc6e7$1@news.povray.org>
Le 2020-05-01 à 12:53, Josh a écrit :
> 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
> 
> 
You can reduce the intensity of the effect as follow :

function { Fnct01(x+sin(y*2+z*3)/2,y-cos(x*7)/5,z+cos(y*5)/10) }

You can sear the object :
function { Fnct01(x+y/2,y,z) }

Or progressively scale it :
function { Fnct01(x*sin(y*2)*cos(z*3)/2,y*cos(x*7)/5,z*cos(y*5)/10) }


Post a reply to this message

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

> Beautiful! Thanks so much, that works great!

Now here's a neat trick to help you puzzle out some things as well.
Plug your function into a pigment statement, and you can plot a 2D slice in
order to see all the isolines in that plane.
It's also a LOT faster than repeatedly rendering the [developmental] isosurface
until you get the equations right, and you can see a BIG area in case your
isosurface pieces are somehow outside of the contained_by shape.

#declare Map = pigment {function {YourFunction (x,y,z)}}
#declare S2 = 10;
#declare Square2 = union {
 triangle {<-1, 0, -1>*S2, <-1, 0, 1>*S2, <1, 0, -1>*S2}
 triangle {<1, 0, -1>*S2, <-1, 0, 1>*S2, <1, 0, 1>*S2 }
 texture {Map}
}
object {Square2 translate -y*4}

.... or just use a whole plane {}


Post a reply to this message

From: Josh
Subject: Re: Mapping Textures on irregular shapes
Date: 3 May 2020 20:00:00
Message: <web.5eaf5ad572e01857dc1270cd0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Josh" <nomail@nomail> wrote:
>
> > Beautiful! Thanks so much, that works great!
>
> Now here's a neat trick to help you puzzle out some things as well.
> Plug your function into a pigment statement, and you can plot a 2D slice in
> order to see all the isolines in that plane.
> It's also a LOT faster than repeatedly rendering the [developmental] isosurface
> until you get the equations right, and you can see a BIG area in case your
> isosurface pieces are somehow outside of the contained_by shape.
>
> #declare Map = pigment {function {YourFunction (x,y,z)}}
> #declare S2 = 10;
> #declare Square2 = union {
>  triangle {<-1, 0, -1>*S2, <-1, 0, 1>*S2, <1, 0, -1>*S2}
>  triangle {<1, 0, -1>*S2, <-1, 0, 1>*S2, <1, 0, 1>*S2 }
>  texture {Map}
> }
> object {Square2 translate -y*4}
>
> .... or just use a whole plane {}

Thanks so everyone for the advice and hints, I am well on my way now. I have a
couple of questions not directly related to the questions that started this
thread...

1) (How) can I overlay pigment textures? I am envisoning something like the
following where I overlay a bozo pigment on top of an agate pigment, with
transparency on the bozo color map... Ideally, where the bozo map is not
transparent it would replace the pigment of the agate color map, not add to
it...

pigment
{
  agate
  color_map
  {
    [0 Gold]
    [1 Brown]
  }
  bozo
  color_map
  {
    [0 Transparent]
    [1 Red]
  }
}

2) How can I change the seed for builtin functions that use random like agate,
granite, bozo, f_noise3d so that they produce different results?

3) If I have 15 asteroids defined like #declare aster1 = isosurface { ...
transform { Axis_Rotate_Trans( <1, .2, 0>, 360*clock) }}, how would I setup
povray to iterate through them and render a seperate animation for each
asteroid? I'm fine just writing an external program to iterate on them if
needed, but if it's easy I'd like to see the povray way...

Thanks so much!

Josh


Post a reply to this message

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

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