POV-Ray : Newsgroups : povray.newusers : many identical object with different textures Server Time
14 Nov 2024 00:17:35 EST (-0500)
  many identical object with different textures (Message 1 to 10 of 10)  
From: Sander
Subject: many identical object with different textures
Date: 7 Sep 1999 15:52:03
Message: <37d56ce3@news.povray.org>
Hello,
I would like to render many identical objects having non-identical textures.
To explain: object is a union of several primitives, one of which has a
marble texture.
When I place 1000 of those objects on a plane, they all have an identical
marble outlook.
I would like to them to be different: still the same marble, but  a
different pattern.
Of course I could make 1000 different textures, but this doesn't seem to be
the best solution. I tried to make a macro that produces a texture, but that
obviously cannot be done. ... What to do?
Thanks for any help.        Sander


Post a reply to this message

From: Chris Huff
Subject: Re: many identical object with different textures
Date: 7 Sep 1999 16:38:28
Message: <37D5780A.ADB59818@compuserve.com>
Your best bet would be to make a macro to create the object itself,
which translates the textures by a random amount. Use a variable outside
the macro to store the random number generator's seed.

#declare myObjectRS = seed(456123);
#macro MakeMyObject()
    union {
        //blah blah
        texture {
            //blah blah
            translate < rand(myObjectRS)*100, rand(myObjectRS)*100,
rand(myObjectRS)*100>
        }
    }
#end

Or you could declare your object as untextured, and texture it for each
version. This would only work if the object only has one texture,
though.


Post a reply to this message

From: Mr  Art
Subject: Re: many identical object with different textures
Date: 7 Sep 1999 16:44:19
Message: <37D578FA.4E7E2285@gci.net>
This could be of help...
#declare R1 = seed(12345);
#declare name_of_shape  = the shape without a texture here
#macro Place( name_of_shape)
    object{name_of_shape   texture{some_predefined_texture translate
<rand(R1),rand(R1),rand(R1)}}
#end

then you could use
Place {name_of_shape }

The texture will be translated by some randome amount each time that the
macro is called.

Let us know if that helped.

Mr. Art
Sander wrote:

> Hello,
> I would like to render many identical objects having non-identical textures.
> To explain: object is a union of several primitives, one of which has a
> marble texture.
> When I place 1000 of those objects on a plane, they all have an identical
> marble outlook.
> I would like to them to be different: still the same marble, but  a
> different pattern.
> Of course I could make 1000 different textures, but this doesn't seem to be
> the best solution. I tried to make a macro that produces a texture, but that
> obviously cannot be done. ... What to do?
> Thanks for any help.        Sander


Post a reply to this message

From: Peter Popov
Subject: Re: many identical object with different textures
Date: 7 Sep 1999 17:39:08
Message: <4oDVN=l6V3Tl2wckz0dYcKbsGKAQ@4ax.com>
There are two main cases of identically looking objects:

1. You declare the object *with* the texture amd make some copies of
it. Obviously they will be absolutely identical

2. You union all your objects and apply a texture to them. In this
case you get the "chopped out of same block of marble" syndrome. For
example, if you make a temple as a union and apply a marble texture to
it, it will look as if made of the same piece of stone, and this is
very unrealistic.

In both cases you'd have to apply an individual texture to every
object. Well, for case 1 you could turn each object a random amount
but this only works for spheres, columns, vases etc. But you'll
generally need individual textures. The easiest way to apply them is
via the seed() and rand() functions. First, declare a seed:

#declare Seed=seed(42);

Then, in your while loop responsible for placing the objects, use
something like this:

...
object { MyObject texture { MyTexture translate 100*rand(Seed1) } }
...

Of course, the value is dependant on the scale of the scene.

The problem with this approach is that each texture eats memory. You
can cheat a bit in the case that your objects are aligned in rows
and/or columns. Consider this (unchecked!) example:

#declare Row=0;
#declare Column=0;

union
{
  #while (Row<100)
    #while (Column<100)
      sphere { <Row-50,0.8,Column-50>, 0.8 }
      #declare Column=Column+1;
    #end
    #declare Row=Row+1;
  #end

  pigment
  {
    marble scale 0.25
    warp { repeat x offset 2*y}
    warp { repeat z offset 2*y}
  }
}

You'll save memory this way as only one texture is used, but this
approach is only applicable for ordered patterns of objects.

I hope this helps some.


Peter Popov
ICQ: 15002700


Post a reply to this message

From: Ken
Subject: Re: many identical object with different textures
Date: 7 Sep 1999 17:50:12
Message: <37D58838.49975187@pacbell.net>
Peter Popov wrote:
> 
> There are two main cases of identically looking objects:
> 
> 1. You declare the object *with* the texture amd make some copies of
> it. Obviously they will be absolutely identical
> 
> 2. You union all your objects and apply a texture to them. In this
> case you get the "chopped out of same block of marble" syndrome. For
> example, if you make a temple as a union and apply a marble texture to
> it, it will look as if made of the same piece of stone, and this is
> very unrealistic.
> 
> In both cases you'd have to apply an individual texture to every
> object. Well, for case 1 you could turn each object a random amount
> but this only works for spheres, columns, vases etc. But you'll
> generally need individual textures. The easiest way to apply them is
> via the seed() and rand() functions. First, declare a seed:
> 
> #declare Seed=seed(42);
> 
> Then, in your while loop responsible for placing the objects, use
> something like this:
> 
> ...
> object { MyObject texture { MyTexture translate 100*rand(Seed1) } }
> ...
> 
> Of course, the value is dependant on the scale of the scene.
> 
> The problem with this approach is that each texture eats memory. You
> can cheat a bit in the case that your objects are aligned in rows
> and/or columns. Consider this (unchecked!) example:
> 
> #declare Row=0;
> #declare Column=0;
> 
> union
> {
>   #while (Row<100)
>     #while (Column<100)
>       sphere { <Row-50,0.8,Column-50>, 0.8 }
>       #declare Column=Column+1;
>     #end
>     #declare Row=Row+1;
>   #end
> 
>   pigment
>   {
>     marble scale 0.25
>     warp { repeat x offset 2*y}
>     warp { repeat z offset 2*y}
>   }
> }
> 
> You'll save memory this way as only one texture is used, but this
> approach is only applicable for ordered patterns of objects.
> 
> I hope this helps some.
> 
> Peter Popov
> ICQ: 15002700

This is all great advice and the only thing Peter's explaination does not
account for is if you have placed you objects with some other method than
a while loop. A modeller for instance creates unique locations for each
object and the rand function will not give you any advantage in this case.

-- 
Ken Tyler

See my 850+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Peter Popov
Subject: Re: many identical object with different textures
Date: 7 Sep 1999 19:03:13
Message: <t5jVNzD3qsxfTOidl8cfGBKrMyQi@4ax.com>
On Tue, 07 Sep 1999 14:48:40 -0700, Ken <tyl### [at] pacbellnet> wrote:


>This is all great advice and the only thing Peter's explaination does not
>account for is if you have placed you objects with some other method than
>a while loop. A modeller for instance creates unique locations for each
>object and the rand function will not give you any advantage in this case.

People rarely use a modeller to put 1000 identical objects in a scene
:)


Peter Popov
ICQ: 15002700


Post a reply to this message

From: Ken
Subject: Re: many identical object with different textures
Date: 7 Sep 1999 19:19:44
Message: <37D59D38.3C5DD0A0@pacbell.net>
Peter Popov wrote:
> People rarely use a modeller to put 1000 identical objects in a scene :)

You under estimate the potential of the typical Moray user :)

-- 
Ken Tyler

See my 850+ Povray and 3D Rendering and Raytracing Links at:
http://home.pacbell.net/tylereng/index.html


Post a reply to this message

From: Sander
Subject: Re: many identical object with different textures
Date: 8 Sep 1999 08:08:17
Message: <37d651b1@news.povray.org>
Hello Peter, Chris, Ken and Mr. Art:

I have made and will try out the following files:

1. X.POV ====================================== :

object {KOL(M000) translate < x000, 0, z000 > }
object {KOL(M001) translate < x001, 0, z001 > }
-
-
-
object {KOL(M999) translate < x999, 0, z999 > }


2. Y.INC ====================================== :

#macro KOL(TT)
#declare COLUMNA =
union

  cylinder { <0, 0, 0>,<0, 5.47, 0>, 29.79 texture{ myTexA } }
  object   { OBJECTA texture{ myTexB }  }
  cylinder { <0,14.55,0>, <0,400,0> ,22.5 texture{TT}}

  scale 2
}
COLUMNA
#end


3. Z.INC ======================================= :

#declare M000 = texture{MyMarble translate 0000}
#declare M001 = texture{MyMarble translate 0010}
-
-
-
#declare M999 = texture{MyMarble translate 9990}

===================================================

This works fine and doesn't seem to require very much memory, although I
admit that I only went as far as 100, not 1000 different textures and
columns. It looked great. The difficulty is having easy access to
constructing the KOL-object-lines and the Mxxx-texture-lines. I will use an
appropriate C-program.

You don't think there is a simpler way? Something with #whiles ?

Your comments would be greatly appreciated.

Sander



----- Oorspronkelijk bericht -----
Van: Peter Popov <pet### [at] usanet>
Nieuwsgroepen: povray.newusers
Verzonden: dinsdag 7 september 1999 23:37
Onderwerp: Re: many identical object with different textures


> There are two main cases of identically looking objects:
>
> 1. You declare the object *with* the texture amd make some copies of
> it. Obviously they will be absolutely identical
>
> 2. You union all your objects and apply a texture to them. In this
> case you get the "chopped out of same block of marble" syndrome. For
> example, if you make a temple as a union and apply a marble texture to
> it, it will look as if made of the same piece of stone, and this is
> very unrealistic.


Post a reply to this message

From: Chris Huff
Subject: Re: many identical object with different textures
Date: 8 Sep 1999 08:46:58
Message: <37D65B0B.A6B1B134@compuserve.com>
That is the hard way. :-)
Try something like this:
#declare kolCntr = 0;
#macro KOL()
    union {
      cylinder { <0, 0, 0>,<0, 5.47, 0>, 29.79 texture{ myTexA } }
      object   { OBJECTA texture{ myTexB }  }
      cylinder { <0,14.55,0>, <0,400,0> ,22.5 texture{MyMarble translate
kolCntr*10}}

      scale 2
    }
    #declare k=k+1;
#end

Every time you call KOL(), the variable kolCntr(which in this case
stands for "KOL counter") increases by 1, which makes the next call
translate the texture by 10 units more.


Post a reply to this message

From: Chris Huff
Subject: Re: many identical object with different textures
Date: 8 Sep 1999 08:47:25
Message: <37D65B26.7B603C35@compuserve.com>
Of course, with this, the textures are cut out of a line going in the
direction < 1, 1, 1>, if you used rand() instead, you could have them
cut out of random positions in a cube. This is only important if you are
using repeating patterns or patterns which are only in a certain area,
though.


Post a reply to this message

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