POV-Ray : Newsgroups : povray.newusers : Random texture? Server Time
23 Nov 2024 21:05:40 EST (-0500)
  Random texture? (Message 1 to 9 of 9)  
From: Micke
Subject: Random texture?
Date: 24 Dec 2011 18:55:01
Message: <web.4ef66606e554bddb9c6257010@news.povray.org>
I am trying to randomise a texure in a while-loop.Is this possible,and how can I
achive this please.


Post a reply to this message

From: Alain
Subject: Re: Random texture?
Date: 26 Dec 2011 21:57:26
Message: <4ef93416$1@news.povray.org>

>
> I am trying to randomise a texure in a while-loop.Is this possible,and how can I
> achive this please.
>
>
First, you initiate a random stream: #declare Rand = seed(0);
seed() takes any integer value as it's argument.

Then, in your loop, you use that stream to randomly create some pigment 
or switch between patterns and create random colour_map, also using your 
random stream.

You can create a stream to sellect your pattern and another for the colours.
You can create a random pigment like this: 
pigment{rgb<rand(Rand),rand(Rand),rand(Rand)>}
pigment{rgbft<rand(Rand),rand(Rand),rand(Rand),rand(Rand)/2,rand(Rand)/2>} 
will generate pigments that are transparent to various degrees.

You can use the #switch() #case()/#range() #break #end statement to 
sellect between various patterns. Read the documentation about the 
#switch() statement. The #break is mandatory.


Alain


Post a reply to this message

From: Micke
Subject: Re: Random texture?
Date: 6 Jan 2012 21:40:01
Message: <web.4f07b056dda100949c6257010@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:

> >
> > I am trying to randomise a texure in a while-loop.Is this possible,and how can I
> > achive this please.
> >
> >
> First, you initiate a random stream: #declare Rand = seed(0);
> seed() takes any integer value as it's argument.
>
> Then, in your loop, you use that stream to randomly create some pigment
> or switch between patterns and create random colour_map, also using your
> random stream.
>
> You can create a stream to sellect your pattern and another for the colours.
> You can create a random pigment like this:
> pigment{rgb<rand(Rand),rand(Rand),rand(Rand)>}
> pigment{rgbft<rand(Rand),rand(Rand),rand(Rand),rand(Rand)/2,rand(Rand)/2>}
> will generate pigments that are transparent to various degrees.
>
> You can use the #switch() #case()/#range() #break #end statement to
> sellect between various patterns. Read the documentation about the
> #switch() statement. The #break is mandatory.
>
>
> Alain

Thankyou for your reply, but still no success. Here is my code.
 #declare Rand = seed(1);
 #declare Count = 0;
 #while (Count <10)
 object{My_Column translate-x*12
//   texture {My_Marble rotate <rand(Rand),rand(Rand),rand(Rand)>}
  *Count  rotate - 100*y
     }
  #declare Count=Count+1;

 #end
All works untill I add the texture line, then this error:No matching } in
object',: found instead. What am I doing wrong,please.


Post a reply to this message

From: Jim Holsenback
Subject: Re: Random texture?
Date: 6 Jan 2012 22:26:40
Message: <4f07bb70@news.povray.org>
On 01/06/2012 09:39 PM, Micke wrote:
> Alain<aze### [at] qwertyorg>  wrote:

>>>
>>> I am trying to randomise a texure in a while-loop.Is this possible,and how can I
>>> achive this please.
>>>
>>>
>> First, you initiate a random stream: #declare Rand = seed(0);
>> seed() takes any integer value as it's argument.
>>
>> Then, in your loop, you use that stream to randomly create some pigment
>> or switch between patterns and create random colour_map, also using your
>> random stream.
>>
>> You can create a stream to sellect your pattern and another for the colours.
>> You can create a random pigment like this:
>> pigment{rgb<rand(Rand),rand(Rand),rand(Rand)>}
>> pigment{rgbft<rand(Rand),rand(Rand),rand(Rand),rand(Rand)/2,rand(Rand)/2>}
>> will generate pigments that are transparent to various degrees.
>>
>> You can use the #switch() #case()/#range() #break #end statement to
>> sellect between various patterns. Read the documentation about the
>> #switch() statement. The #break is mandatory.
>>
>>
>> Alain
>
> Thankyou for your reply, but still no success. Here is my code.
>   #declare Rand = seed(1);
>   #declare Count = 0;
>   #while (Count<10)
>   object{My_Column translate-x*12
> //   texture {My_Marble rotate<rand(Rand),rand(Rand),rand(Rand)>}
>    *Count  rotate - 100*y
>       }
>    #declare Count=Count+1;
>
>   #end
> All works untill I add the texture line, then this error:No matching } in
> object',: found instead. What am I doing wrong,please.
>
>
hmmm ... first off the line *Count rotate - 100*y just looked strange 
before I even started. After satisfying My_Column and My_Marble (my own 
simple definition) I get this error:

Parse Error: No matching } in 'object', * found instead

that confirms my suspicion about the *Count line, so perhaps there is 
something in one of those other definitions thats causing the problem 
... since I'm not sure of your intent, that's my best guess.


Post a reply to this message

From: Jim Holsenback
Subject: Re: Random texture?
Date: 6 Jan 2012 22:37:05
Message: <4f07bde1@news.povray.org>
On 01/06/2012 10:26 PM, Jim Holsenback wrote:
> On 01/06/2012 09:39 PM, Micke wrote:
>> Alain<aze### [at] qwertyorg> wrote:

>>>>
>>>> I am trying to randomise a texure in a while-loop.Is this
>>>> possible,and how can I
>>>> achive this please.
>>>>
>>>>
>>> First, you initiate a random stream: #declare Rand = seed(0);
>>> seed() takes any integer value as it's argument.
>>>
>>> Then, in your loop, you use that stream to randomly create some pigment
>>> or switch between patterns and create random colour_map, also using your
>>> random stream.
>>>
>>> You can create a stream to sellect your pattern and another for the
>>> colours.
>>> You can create a random pigment like this:
>>> pigment{rgb<rand(Rand),rand(Rand),rand(Rand)>}
>>> pigment{rgbft<rand(Rand),rand(Rand),rand(Rand),rand(Rand)/2,rand(Rand)/2>}
>>>
>>> will generate pigments that are transparent to various degrees.
>>>
>>> You can use the #switch() #case()/#range() #break #end statement to
>>> sellect between various patterns. Read the documentation about the
>>> #switch() statement. The #break is mandatory.
>>>
>>>
>>> Alain
>>
>> Thankyou for your reply, but still no success. Here is my code.
>> #declare Rand = seed(1);
>> #declare Count = 0;
>> #while (Count<10)
>> object{My_Column translate-x*12
>> // texture {My_Marble rotate<rand(Rand),rand(Rand),rand(Rand)>}
>> *Count rotate - 100*y
>> }
>> #declare Count=Count+1;
>>
>> #end
>> All works untill I add the texture line, then this error:No matching } in
>> object',: found instead. What am I doing wrong,please.
>>
>>
> hmmm ... first off the line *Count rotate - 100*y just looked strange
> before I even started. After satisfying My_Column and My_Marble (my own
> simple definition) I get this error:
>
> Parse Error: No matching } in 'object', * found instead
>
> that confirms my suspicion about the *Count line, so perhaps there is
> something in one of those other definitions thats causing the problem
> ... since I'm not sure of your intent, that's my best guess.

follow up ... forgot to mention that commenting out the *Count line and 
it parses just fine, so maybe if you could clarify the intent of that 
line it might give us another clue ... does the *Count line belong 
inside the texture definition?

This parses fine:
#declare My_Column = cylinder {<0,0,0>, <0,1,0>, 0.5 pigment { Green}}
#declare My_Marble = texture {pigment {Blue}}

#declare Rand = seed(1);
  #declare Count = 0;
  #while (Count <10)
  object{My_Column translate-x*12
    texture {My_Marble rotate <rand(Rand),rand(Rand),rand(Rand)>//}
   *Count  rotate - 100*y}
      }
   #declare Count=Count+1;

  #end


Post a reply to this message

From: Christian Froeschlin
Subject: Re: Random texture?
Date: 6 Jan 2012 22:40:56
Message: <4f07bec8$1@news.povray.org>
Micke wrote:

> All works untill I add the texture line, then this error:No matching } in
> object',: found instead. What am I doing wrong,please.

It looks like you accidentally inserted the texture
within the expression -x*12*Count. Such things are easier
to spot if you use more consistent spacings and indents:

#declare Rand = seed(1);
#declare Count = 0;
#while (Count <10)
   object
   {
     My_Column
     translate -12*Count*x
     texture {My_Marble rotate <rand(Rand),rand(Rand),rand(Rand)>}
     rotate -100*y
   }
   #declare Count=Count+1;
#end


Note that it can also be relevant when to apply the
texture with respect to transformations.


Post a reply to this message

From: Jim Holsenback
Subject: Re: Random texture?
Date: 6 Jan 2012 22:56:56
Message: <4f07c288$1@news.povray.org>
On 01/06/2012 10:40 PM, Christian Froeschlin wrote:
> It looks like you accidentally inserted the texture
> within the expression -x*12*Count. Such things are easier
> to spot if you use more consistent spacings and indents:

yes ... being a bit religious about indents etc DOES make things easier. 
I fall into that trap from time to time and lining things up ALWAYS 
makes things stand out better.


Post a reply to this message

From: Bald Eagle
Subject: Re: Random texture?
Date: 28 Jul 2013 13:40:01
Message: <web.51f556f6dda1009473fc9ebb0@news.povray.org>
Jim Holsenback <nom### [at] nomailcom> wrote:
> On 01/06/2012 10:40 PM, Christian Froeschlin wrote:
> > It looks like you accidentally inserted the texture
> > within the expression -x*12*Count. Such things are easier
> > to spot if you use more consistent spacings and indents:
>
> yes ... being a bit religious about indents etc DOES make things easier.
> I fall into that trap from time to time and lining things up ALWAYS
> makes things stand out better.

When editing complex, nested equations in Excel, whenever you cursor past a
parentheses, it highlights it, and its matching counterpart.  Something like
this would be useful - not sure how tough it would be to implement.

Changing the color of defined variables would be useful for spotting misspelled
variable names.
Which brings me a question I had - POV-Ray highlights sind(theta) in purple,
even though I hadn't included the math.inc file.  Why?  It confused the heck out
of me!
I wound up using degrees ( sin (theta) ) until I found the problem!  Arrrrgh.

I suppose that it might be possible to write a separate "spell checking" script
to check for syntax - at least the "obvious" stuff.

I almost got snagged by an extra /*
it was nested inside another /* ... */  block, and POV-Ray wanted the second */.

Concerning the original topic, the solutions proposed seem like sort of a
"cheat" or workaround.  Is there a way to actually _specify_ random or varying
_textures_ rather than defining textures with random _pigments_?

It would be nice to cycle through all of the P_WoodGrain_XX textures on blocks
by varying XX.

This might be potential solution.
http://news.povray.org/518c3b60%241%40news.povray.org

and I remember coming across this:
http://news.povray.org/povray.text.tutorials/thread/%3C3f13449b$1@news.povray.org%3E/

which seemed like there could be a way to "sanitize" the string-nature of WoodA
in something like or else "fool" POV-Ray into thinking it's not a string
anymore.
#declare WoodA = concat ("P_WoodGrain", str (X, 0, 0), "A")
#declare WoodA = texture { WoodA }


Post a reply to this message

From: clipka
Subject: Re: Random texture?
Date: 29 Jul 2013 01:06:30
Message: <51f5f856$1@news.povray.org>
Am 28.07.2013 19:37, schrieb Bald Eagle:

> When editing complex, nested equations in Excel, whenever you cursor past a
> parentheses, it highlights it, and its matching counterpart.  Something like
> this would be useful - not sure how tough it would be to implement.

It's a common feature in modern text editors geared towards software 
developers and has proven its value a thousand times over, so it 
shouldn't be a question of how tough it is - the POV-Ray GUI should have 
it, period.

That said, the current Windows GUI - and especially the editor component 
- is scheduled for demolition anyway, so it doesn't make sense to invest 
any energy into implementing that feature for the old GUI.

Thorsten Froehlich has been working on an official Mac OSX GUI for quite 
some time now, and I understand it is nearing completion; as it is based 
on a toolkit available on Windows as well (and also Linux of course), I 
suspect it will form the basis for the next generation Windows GUI.

Not sure if that GUI already has "brace matching", but I suspect it does.

> which seemed like there could be a way to "sanitize" the string-nature of WoodA
> in something like or else "fool" POV-Ray into thinking it's not a string
> anymore.
> #declare WoodA = concat ("P_WoodGrain", str (X, 0, 0), "A")
> #declare WoodA = texture { WoodA }

There is a macro in strings.inc that does exactly this:

#declare WoodA = concat ("P_WoodGrain", str (X, 0, 0), "A")
#declare WoodA = texture { Parse_String(WoodA) }

(The macro's trick is to create a temporary file, write the contents of 
the string to it, and then #include it ;-))


Post a reply to this message

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