POV-Ray : Newsgroups : povray.binaries.images : Ripple Tank Sim Server Time
31 Jul 2024 20:18:47 EDT (-0400)
  Ripple Tank Sim (Message 11 to 16 of 16)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: stbenge
Subject: Re: Ripple Tank Sim
Date: 12 Aug 2009 05:34:18
Message: <4a828c9a$1@news.povray.org>
clipka wrote:
> I mainly did it because the C(/++) program I had written earlier only 
> produced ASCII art output, and it did quite well for starters, but I got 
> tired of its limitations, and was too lazy to integrate support for 
> proper image reading and writing ;-)
> 
> And, of course, misusing POV-Ray in this manner was an interesting 
> challenge to do ;-)

I'm all for misusing programs and languages in this way. Heck, I'd go as 
far as to say that the more unique ways you can find to accomplish a 
singular goal, the better! "Unique ways" being the key of course ;)

> Next on the agenda: Game of life.  Should be a piece of cake if done
> properly: Read in last frame, apply a color map according to birth/death 
> rules  overlay with 8 tuned-down displaced copies to add birth/death
> hints for the next step - render.

  Ah, with the #if statement right near the apex of that calculation? 
And with an average pattern instead of a function? Any way, I'd like to 
see it :)


Post a reply to this message

From: clipka
Subject: Re: Ripple Tank Sim
Date: 12 Aug 2009 14:25:18
Message: <4a83090e$1@news.povray.org>
stbenge schrieb:
> I'm all for misusing programs and languages in this way. Heck, I'd go as 
> far as to say that the more unique ways you can find to accomplish a 
> singular goal, the better! "Unique ways" being the key of course ;)

Yeah, I'm in for such stuff, too.


>> Next on the agenda: Game of life.  Should be a piece of cake if done
>> properly: Read in last frame, apply a color map according to 
>> birth/death rules  overlay with 8 tuned-down displaced copies to add 
>> birth/death
>> hints for the next step - render.
> 
>  Ah, with the #if statement right near the apex of that calculation? And 
> with an average pattern instead of a function? Any way, I'd like to see 
> it :)

What #if statement? The code won't need any #if :-) (the color map will 
serve as a kind of #switch statement).


Post a reply to this message

From: stbenge
Subject: Re: Ripple Tank Sim
Date: 12 Aug 2009 16:55:45
Message: <4a832c51$1@news.povray.org>
clipka wrote:
> stbenge schrieb:
>>  Ah, with the #if statement right near the apex of that calculation? 
>> And with an average pattern instead of a function? Any way, I'd like 
>> to see it :)
> 
> What #if statement? The code won't need any #if :-) (the color map will 
> serve as a kind of #switch statement).

Oh, I guess I was surmising based on your previous statements...


Post a reply to this message

From: scott
Subject: Re: Ripple Tank Sim
Date: 18 Aug 2009 05:22:45
Message: <4a8a72e5$1@news.povray.org>
>> Good job! I think I'll stick to C programming for this effect though. 
>> It's easy enough to produce a barrier and generator mask using POV, and 
>> then take it into C to run the sim :/
>
> I mainly did it because the C(/++) program I had written earlier only 
> produced ASCII art output, and it did quite well for starters, but I got 
> tired of its limitations, and was too lazy to integrate support for proper 
> image reading and writing ;-)
>
> And, of course, misusing POV-Ray in this manner was an interesting 
> challenge to do ;-)
>
> Next on the agenda: Game of life. Should be a piece of cake if done 
> properly: Read in last frame, apply a color map according to birth/death 
> rules, overlay with 8 tuned-down displaced copies to add birth/death hints 
> for the next step - render.

What you are doing here is actually very similar to how you write such 
things for the GPU.  I wrote a wave simulator for the GPU a while back and 
it works almost identically, never thought of the GoL on a GPU, should be 
easy to implement.


Post a reply to this message

From: Verm
Subject: Re: Ripple Tank Sim
Date: 18 Aug 2009 12:07:28
Message: <4a8ad1c0$1@news.povray.org>
clipka wrote:
> ...., and was too lazy to integrate support for 
> proper image reading and writing ;-)

I'm sure you already know this but ascii PPM images are the way forward 
here - a nice easy human readable/writable HDRI image format.

Obviously I admire your abuse of PovRay.


Post a reply to this message

From: clipka
Subject: Re: Ripple Tank Sim
Date: 18 Aug 2009 12:49:39
Message: <4a8adba3$1@news.povray.org>
scott schrieb:
> never thought of the GoL on a GPU, should be easy to implement.

I bet. If it can be done in POV-Ray with textures only...

Here's the full POV-Ray SDL code for a GoL sim starting with a random 
pattern - the only non-linearity in control flow is the #if to care for 
first-frame initialization.

The world is toroidal, though this can be chaned by enabling the "once" 
keyword in the definition of PgNext.

As an interesting side note, the sim does /not/ store the end result of 
each generation, but interim results: The status of the cell itself, 
combined with a count of the surrounding live cells. This allows easy 
use of a color_map for the conditionals.

(The code could be made shorter by using macros, but I reckon this would 
be counter-productive for parsing speed.)

--------------------------------------

// +W100 +H100 +KFI1 +KFF9999 +FE

#version 3.6;

global_settings {
   assumed_gamma 1.0
   ambient_light 1.0
   max_trace_level 15
}

camera {
   orthographic
   location <0,0,100>
   look_at  <0,0,0>
   right   -1*x
   up       1*y
}



default {
   finish { ambient 1.0 diffuse 0.0 }
}

// ----------------------------------------

#local FrameDigits  = int(log(final_frame)) + 1;
#local NumLayers    = 9;
#local Delta        = 1/max(image_width,image_height);

#local NeighborFactor   = 0.05;
#local CellFactor       = 0.50;

#local EPSILON          = 1e-6;

#if (frame_number = 1)
   #local PgNext = pigment { bozo color_map { [ 0.499 rgb 0 ] [ 0.501 
rgb 1 ] } scale Delta }
#else
   #local PgNext = pigment {
     image_pattern { concat("Life", str(frame_number-1,-FrameDigits,0)) 
/*once*/ }
     color_map {
       // dead cell
       [ 0*CellFactor + 2.5*NeighborFactor -EPSILON  rgb 0 ]
       [ 0*CellFactor + 2.5*NeighborFactor +EPSILON  rgb 1 ]
       [ 0*CellFactor + 3.5*NeighborFactor -EPSILON  rgb 1 ]
       [ 0*CellFactor + 3.5*NeighborFactor +EPSILON  rgb 0 ]
       // live cell
       [ 1*CellFactor + 1.5*NeighborFactor -EPSILON  rgb 0 ]
       [ 1*CellFactor + 1.5*NeighborFactor +EPSILON  rgb 1 ]
       [ 1*CellFactor + 3.5*NeighborFactor -EPSILON  rgb 1 ]
       [ 1*CellFactor + 3.5*NeighborFactor +EPSILON  rgb 0 ]
     }
     translate -<0.5,0.5,0>
   }
#end

#local Tx1 = texture { pigment { PgNext translate <-1,-1, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx2 = texture { pigment { PgNext translate <-1, 0, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx3 = texture { pigment { PgNext translate <-1, 1, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx4 = texture { pigment { PgNext translate < 0,-1, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx5 = texture { pigment { PgNext translate < 0, 0, 0>*Delta } 
finish { ambient NumLayers * CellFactor } }
#local Tx6 = texture { pigment { PgNext translate < 0, 1, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx7 = texture { pigment { PgNext translate < 1,-1, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx8 = texture { pigment { PgNext translate < 1, 0, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }
#local Tx9 = texture { pigment { PgNext translate < 1, 1, 0>*Delta } 
finish { ambient NumLayers * NeighborFactor } }

#local TxOutput = texture {
   average
   texture_map {
     [1 Tx1 ]
     [1 Tx2 ]
     [1 Tx3 ]
     [1 Tx4 ]
     [1 Tx5 ]
     [1 Tx6 ]
     [1 Tx7 ]
     [1 Tx8 ]
     [1 Tx9 ]
   }
}

box { <-1.5, -0.5, 0.0>, <1.5, 0.5, 0.0> texture { TxOutput } }

--------------------------------------


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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