POV-Ray : Newsgroups : povray.newusers : How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture= b? Server Time
4 Nov 2024 23:19:38 EST (-0500)
  How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture= b? (Message 1 to 10 of 10)  
From: D  H  Berlin
Subject: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture= b?
Date: 3 Sep 2004 11:25:01
Message: <web.41388c77579d5a0c43ad080a0@news.povray.org>
I hope the title says all :)

I have tried with a function and an declare:
#declare myfu =
 function(py,pz) {
  #if ((py>0.8) & (pz>1-0.1))
    1
  #else
    0
  #end
 };

#declare stufe_holz_metal =
    texture {
      function { myfu(y,z) }
      texture_map {
        [ 0.0 tex_a ]  // tex_a and tex_b are declared elsewhere
        [ 1 tex_b ]
      }
    };

But that doesn't work.

Greetgins
Dieter


Post a reply to this message

From: Josh
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture= b?
Date: 3 Sep 2004 11:32:17
Message: <41388e81$1@news.povray.org>
You might try using an object-texture texture map.  Object textures are
block based, so you specifiy two pigments or textures, for for the object
and one for outside the object.  Once you've done that you can position the
"object" at the coordinates you specified.


Post a reply to this message

From: Josh
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture= b?
Date: 3 Sep 2004 11:45:48
Message: <413891ac$1@news.povray.org>
Heres an example of what I meant...

#include "colors.inc"

camera {
  location  <5, 5, -10> look_at   <0, 0,  0>
}

light_source {<200, 1000, -400> White}

#declare myObject = box     {
        <-1,-1,-1>,
        <1,1,1>
        };

#declare texture1 = texture {
        pigment {
                Red
                }
        };

#declare texture2 = texture {
        pigment {
                White
                }
        };

#declare myTexture = texture {
        object  {
                myObject
                texture { texture1 }
                texture { texture2 }
                }
        };

box     {
        <-2,-2,-2>,
        <0,0,0>
        texture {
                myTexture
                }
        }


Post a reply to this message

From: D  H  Berlin
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> tex=
Date: 3 Sep 2004 12:10:00
Message: <web.41389675682bae3f43ad080a0@news.povray.org>
Hi!

This looks like it would work. I will try. Thank you!

But i would be nice, if there is a way to use functions like i have tried
for texture maps. It would great to write an own function where all kinds
of mathematical and _logic_ operations would be useable. The function would
just have to give back a value which could determine the entry to use of
the texturemap.
Is this possible?
Maybe i just have to use a macro instead of a declaration for the function?

Greetings
Dieter


Post a reply to this message

From: Josh
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> tex=
Date: 3 Sep 2004 12:22:58
Message: <41389a62$1@news.povray.org>
> But i would be nice, if there is a way to use functions like i have tried
> for texture maps. It would great to write an own function where all kinds
> of mathematical and _logic_ operations would be useable. The function
would
> just have to give back a value which could determine the entry to use of
> the texturemap.
> Is this possible?

Yes it is if your mad enough to try, I was after something like this a while
back.

But you cant write a function with #IF's (and other SDL ) very easily, the
function syntax is designed for maths gurus.

I gave up on it and went for the object pattern I've described, which allows
you to build a CSG object to cover the area you wantquite easily, with the
advantage of you can make the object visible for alignment etc.


Post a reply to this message

From: Slime
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture= b?
Date: 3 Sep 2004 16:00:53
Message: <4138cd75$1@news.povray.org>
>  function(py,pz) {
>   #if ((py>0.8) & (pz>1-0.1))
>     1
>   #else
>     0
>   #end
>  };

Anything that starts with a # is run at parse-time, not during the render.
Functions are evaluated during the render.

If that actually parsed without a syntax error, then you essentially defined
the function

function(py,pz) {0}

because the #if was parsed through during the function's *definition*, not
while it runs.

If you want to use logical branching in a function, you must use the
select() function (check the documentation for details):

function(py,pz) {
select(py-.8,
0,
select(py-.9,
0,
1
)
}

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

From: D  H  Berlin
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> tex=
Date: 3 Sep 2004 17:05:00
Message: <web.4138dbb2682bae3f1c91ccbf0@news.povray.org>
Hi!

Great, this does work.
Thank you all!

Greetings
Dieter

#declare stufe_holz = texture {T_Wood10 scale 1 rotate y*20 finish {
reflection {0.0} ambient 0.5 diffuse 0.1 } };
#declare stufe_metal = texture {T_Silver_3D};
#declare stufe_metal_ab = 0.85;

#declare shm_tex_f =
function(py,pz) {
select(py-stufe_metal_ab,0,select(pz-(1-stufe_metal_ab),1,0) )
}
#declare stufe_holz_metal =
    texture {
      function {shm_tex_f(y,z) }
//      function{y}
      texture_map {
        [ 0.0 stufe_holz ]
        [ stufe_metal_ab stufe_holz ]
        [ stufe_metal_ab*1.0107 stufe_metal ]
        [ 1 stufe_metal ]
      }
    };


Post a reply to this message

From: gonzo
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> texture=b?
Date: 4 Sep 2004 02:11:47
Message: <41395ca3@news.povray.org>
D. H. Berlin wrote:
> I hope the title says all :)
> 
> I have tried with a function and an declare:
> #declare myfu =
>  function(py,pz) {
>   #if ((py>0.8) & (pz>1-0.1))
>     1
>   #else
>     0
>   #end
>  };
> 
> #declare stufe_holz_metal =
>     texture {
>       function { myfu(y,z) }
>       texture_map {
>         [ 0.0 tex_a ]  // tex_a and tex_b are declared elsewhere
>         [ 1 tex_b ]
>       }
>     };
> 
> But that doesn't work.


You can put your textures in an array;

#declare Mytexture = array[2] {
   ...tex_a,
   ...tex_b
}

Then use something like;

object {
   Myobject
   texture {
     Mytexture[ ((py>0.8) & (pz>1-0.1)) ]
   }
}

RG


Post a reply to this message

From: D  H  Berlin
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> tex=
Date: 4 Sep 2004 12:00:01
Message: <web.4139e6222ee2b705a7e1bd0f0@news.povray.org>
>      Mytexture[ ((py>0.8) & (pz>1-0.1)) ]
Do you mean y and z instead of py and pz here?
> RG


Btw: When using x, y or z in an texture-block, does this always mean the x,y
and z used by the texture-calculations, in contrary to the normal meaning
of x,y and z which is <1,0,0>, <0,1,0> and <0,0,1>?  (Would be great.)
Or is this special meaning of x,y and z only in effect in a function
statement as used in the before examples?

Greetings
Dieter


Post a reply to this message

From: gonzo
Subject: Re: How to get a texture like (y>0.8 & z>0.9) -> texture a else -> tex=
Date: 4 Sep 2004 19:55:56
Message: <413a560c@news.povray.org>
D. H. Berlin wrote:
>>     Mytexture[ ((py>0.8) & (pz>1-0.1)) ]
> 
> Do you mean y and z instead of py and pz here?

I just copied the condition you had in your #if() statement.

You can put whatever condition in the parenthesis you want, if the 
condition is true it will use Mytexture[1], otherwise it will use 
Mytexture[0]


> Btw: When using x, y or z in an texture-block, does this always mean the x,y
> and z used by the texture-calculations, in contrary to the normal meaning
> of x,y and z which is <1,0,0>, <0,1,0> and <0,0,1>?  (Would be great.)
> Or is this special meaning of x,y and z only in effect in a function
> statement as used in the before examples?

About the only time I use <x,y,z> in a texture is to scale or rotate so 
that's specific to the texture. Don't know how <x,y,z> in a function 
declared elsewhere would be treated.

RG


Post a reply to this message

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