POV-Ray : Newsgroups : povray.general : Random textures Server Time
5 Aug 2024 06:19:38 EDT (-0400)
  Random textures (Message 1 to 5 of 5)  
From: Helen
Subject: Random textures
Date: 10 Dec 2002 15:40:53
Message: <Xns92E0E6D275B2helentrhotmailcom@204.213.191.226>
Is there any way to choose textures for some random objects defined in a 
macro?
I would like the objects to have in random any one from a list of declared 
textures, not really random textures. I can change all other 
characteristics (shape,location, color, scale etc) that depend on numbers 
only.
I have tried select, but it only works with numbers.
I am making an asteroid scene with isosurfaces. I want to introduce some 
variance in the asteroid textures.
Macros is not my strong point, so any help would be appreciated.

Helen


Post a reply to this message

From: ingo
Subject: Re: Random textures
Date: 10 Dec 2002 16:39:58
Message: <Xns92E0E77C971Dseed7@povray.org>
in news:Xns### [at] 204213191226 Helen wrote:

> Is there any way to choose textures for some random objects defined
> in a macro?
> 

Declare the textures you want to choose from, then put the texture-names 
in an array and use the "Rand_Array_Item" from "arrays.inc". See chapter 
7.1 from the docs.

Ingo


Post a reply to this message

From: Helen
Subject: Re: Random textures
Date: 12 Dec 2002 13:47:31
Message: <Xns92E2D399E842Dhelentrhotmailcom@204.213.191.226>
ingo <ing### [at] tagpovrayorg> wrote in news:Xns### [at] povrayorg:

> in news:Xns### [at] 204213191226 Helen wrote:
> 
>> Is there any way to choose textures for some random objects defined
>> in a macro?
>> 
> 
> Declare the textures you want to choose from, then put the texture-names 
> in an array and use the "Rand_Array_Item" from "arrays.inc". See chapter 
> 7.1 from the docs.
> 
> Ingo
> 
> 
Thank you.
The array works (sort of), but I am lost.
I declare the array and put the textures in it, then use the macro 
Rand_Array_Item (#macro Rand_Array_Item(TexArray, stream).
The stream beats me however. I thought it was a number, but it doesn't 
accept numbers or seed(whatever).
It accepts macros and expressions from rand.inc like Rand_Gauss or RdmA, 
but not seed(123).
The problem is that I can't see it work.
I put as texture in the object Rand_Array_Item(.... , it almost looks like 
the textures are used (all the asteroids look brownish in the small preview 
- the look of the first texture in the array), but when I test it using 
intense colors with red/blue green/textures, the objects still look 
brownish, even though there is no brown texture defined anywhere. It seems 
like it keeps the memory of the first texture used and refuses to change 
it. I deleted the RCA file, in case that was causing the problem - no 
change.
I tried it on a new scene and there are no textures - everything is black.
I don't have any error messages, apart from the usual max_gradient ones for 
each of the objects (found too high for some) and a warning "No pigment 
type given" at the end of the object on the 3rd line from the end.
I suspect there is something wrong with the stream, but what? What is a 
stream anyway? Only text streams come to my mind.
Or else, I am getting these strange errors, because of my haziness in macro 
use? The macro is getting too complicated for me and I am not sure if I 
missed something.
Full source, below.

-------------------
#include "colors.inc"	
#include "arrays.inc" 
#include "rand.inc"
#include "Aster-Tex.inc"//texture definitions	

  global_settings
{
  assumed_gamma 1.0
  radiosity {} 
  ambient_light 0 
}
 
light_source {
  <-100,100,-100>    
  color rgb <0.9, 0.8, 0.7>

}
   

camera {
  location  <0, -4.5, -12>
  look_at   <0, 0, 0>
  right     x*image_width/image_height
} 

sky_sphere {
  pigment {
   gradient y
     color_map { [0 color rgb <0.65, 0.75, 0.85> ]
                 [1 color rgb <0.35, 0.45, 0.55> ]
     }   rotate <-50,0,0>
  }}

//----Stone Textures array
#declare TexArray = array[7];
#declare TexArray[0] = texture {Tex1}; 
#declare TexArray[1] = texture {Tex2};  
#declare TexArray[2] = texture {Tex3};
#declare TexArray[3] = texture {Tex4}; 
#declare TexArray[4] = texture {Tex5};
#declare TexArray[5] = texture {Tex6};
#declare TexArray[6] = texture {Tex7};  

#macro Rand_Array_Item(TexArray, RdmA)
 #end

#declare Sphere = function(x,y,z,Radius) {
    pow(x,2) + pow(y,2) + pow(z,2) - pow(Radius,2) 
}
 


#macro MyPebble()
	object { pebble  scale 1}
#end


#declare  Size = seed (6); 

#declare MyPebble_count = 30;
#declare locations1 = seed(3);
#declare locations2 = seed(5);
#declare locations3 = seed(7); 
#declare rotations1 = seed(1);
#declare rotations2 = seed(2);
#declare rotations3 = seed(4);
#declare scales1 = seed(2); 

#while (MyPebble_count > 0)
	#declare x_loc = rand(locations1)*6-1;
	#declare z_loc = rand(locations2)*8-0.5;
	#declare y_loc = rand(locations3)*6-1; 
	#declare x_rot = rand(rotations1)*90-0;
	#declare z_rot = rand(rotations2)*90-0;
	#declare y_rot = rand(rotations3)*90-0; 
	#declare sca1 = rand(scales1)*5-2; 
	#declare MySize = rand (Size)*0.1-1.2; 

	#declare pebble =
                isosurface {
                 function { Sphere(x,y,z,1)- f_noise3d(x,y,z)*MySize
                 } 
                 max_gradient 2 evaluate 5, 1.2, 0.95 
              texture {Rand_Array_Item(TexArray, RdmA)}
                scale 1 } 	
	 
	object { MyPebble() 
	
		translate <x_loc, y_loc, z_loc>
		rotate <x_rot, y_rot, z_rot>
		scale sca1
	}
	#declare MyPebble_count = MyPebble_count - 1;
#end        
-----------------------
Helen


Post a reply to this message

From: Tom Melly
Subject: Re: Random textures
Date: 13 Dec 2002 04:32:26
Message: <3df9a92a@news.povray.org>
"Helen" <rem### [at] nospamhotmailcom> wrote in message
news:Xns### [at] 204213191226...
> ingo <ing### [at] tagpovrayorg> wrote in news:Xns### [at] povrayorg:
>
> > in news:Xns### [at] 204213191226 Helen wrote:
> >
>

Here's your main problem - you're defining Rand_Array_Item as a new macro,
over-riding the macro in rand.inc

> #macro Rand_Array_Item(TexArray, RdmA)
>  #end

This macro doesn't do anything, so no texture is applied to your objects.

Comment out those lines and you should get something. Also, I note that you
haven't included functions.inc - aren't you getting an error from that?

Also, your MyPebble macro is a bit redundent afaics - here's a modified (and
working) version of your code:

#include "colors.inc"
#include "arrays.inc"
#include "rand.inc"
#include "functions.inc"

global_settings{  assumed_gamma 1.0}

light_source {  <-100,100,-100>      color rgb 1}


#declare Tex1 =texture{  pigment{Red}}
#declare Tex2 =texture{  pigment{Green}}
#declare Tex3 =texture{  pigment{Blue}}
#declare Tex4 =texture{  pigment{White}}
#declare Tex5 =texture{  pigment{Yellow}}
#declare Tex6 =texture{  pigment{Cyan}}
#declare Tex7 =texture{  pigment{Gold}}


camera {
  location  <0, -4.5, -12>
  look_at   <0, 0, 0>
}

//----Stone Textures array
#declare TexArray = array[7];
#declare TexArray[0] = texture {Tex1};
#declare TexArray[1] = texture {Tex2};
#declare TexArray[2] = texture {Tex3};
#declare TexArray[3] = texture {Tex4};
#declare TexArray[4] = texture {Tex5};
#declare TexArray[5] = texture {Tex6};
#declare TexArray[6] = texture {Tex7};

#declare Sphere = function(x,y,z,Radius) {
    pow(x,2) + pow(y,2) + pow(z,2) - pow(Radius,2)
}


#declare  Size = seed (6);

#declare MyPebble_count = 30;
#declare locations1 = seed(3);
#declare locations2 = seed(5);
#declare locations3 = seed(7);
#declare rotations1 = seed(1);
#declare rotations2 = seed(2);
#declare rotations3 = seed(4);
#declare scales1 = seed(2);

#while (MyPebble_count > 0)
  #declare x_loc = rand(locations1)*6-1;
  #declare z_loc = rand(locations2)*8-0.5;
  #declare y_loc = rand(locations3)*6-1;
  #declare x_rot = rand(rotations1)*90-0;
  #declare z_rot = rand(rotations2)*90-0;
  #declare y_rot = rand(rotations3)*90-0;
  #declare sca1 = rand(scales1)*5-2;
  #declare MySize = rand (Size)*0.1-1.2;

  #declare pebble =
    isosurface {
      function { Sphere(x,y,z,1)- f_noise3d(x,y,z)*MySize}
      max_gradient 2 evaluate 5, 1.2, 0.95
      texture {Rand_Array_Item(TexArray, RdmA)}
      scale 1
    }

  object {
    pebble
    translate <x_loc, y_loc, z_loc>
    rotate <x_rot, y_rot, z_rot>
    scale sca1
  }
  #declare MyPebble_count = MyPebble_count - 1;
#end


// Oh, and your indentation stinks.... ;)


Post a reply to this message

From: Helen
Subject: Re: Random textures
Date: 16 Dec 2002 17:26:40
Message: <Xns92E749FAF5C2helentrhotmailcom@204.213.191.226>
"Tom Melly" <tom### [at] tomandlucouk> wrote in news:3df9a92a@news.povray.org:

> Here's your main problem - you're defining Rand_Array_Item as a new
> macro, over-riding the macro in rand.inc
> 
><snipped> 
> // Oh, and your indentation stinks.... ;)
> 
Thank you very much for the complete explanation; it works.
Sorry for my indentation - I must learn to hit the tab key more often.

Helen


Post a reply to this message

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