POV-Ray : Newsgroups : povray.advanced-users : WIP: Sterograms of a cube : Re: WIP: Sterograms of a cube Server Time
29 Jul 2024 04:26:38 EDT (-0400)
  Re: WIP: Sterograms of a cube  
From: gimi
Date: 5 Jan 2003 15:14:10
Message: <3E1891F2.4070209@psico.ch>
[i posted to p.b.i already, i repeat this here just in case.
- new stuff was added at the end:]

hi Andrew, hi Jaap (this is your first name, i guess?)

Jaap Frank wrote:
 > Your are mixing up two different Stereograms systems.
 > 1. "magic eye pictures"
 > For this you must stare at the picture, that will say you look
 > behind the picture.

[...]

 > 2. Crossing eye method.
 > By crossing your eyes you look before the picture and your left
 > eye now looks at the right object and your right eye looks at
 > the left object.

which is basically the same method to obtain the same effect,
the only difference is the "point of view" (POV.. duh ;), which
is either in front or behind the image. this difference in turn
results in the "image" (that you perceive) being flipped
back-to-front, for the reasons Jaap explained well already.

but there is another main difference you did not make clear:
there are (real) stereograms consisting of two separate images
to be viewed by either eye, and "Single Image [Random] Dot
Stereograms" (SI[R]DS), which, as the name implies, result
from a single picture - which contains information for both
of your eyes.

the pictures that Andrew posted, including the ascii example,
are SIDS, whereas Jaap posted a (double image) stereogram
combined in a single picture file..

i like your pictures very much, no matter if i have to cross
my eyes or look thru them ;) , and i was reminded of the many
experiments i have done. but i must admit that it did not occur
to me that i could also try this using povray..
[-8<-]

new ideas:

now, i made a quick hack in perl, which produces ascii art of
the same kind as the one Andrew gave as an example; i include
this as well to show how it works:

--- perl on ---
#!/usr/bin/perl -w

#   \_   _/ object
#     \_/         ^
#     |\ <-alpha  dist_point
# ----x-x-------- v ^    <-- image plane
#     |  \          |
#     |   \         dist_image
#     |    \        |
#     o     o eyes  v
#     < - - > dist_eyes

use strict;
use Math::Trig;

# as shown above
my $dist_eyes   = 20;
my $dist_image  = 20;

# the set of characters to be used in place of "colors"
my @colors      =  split '', '.:-+xXoO'; # or: ('a'..'z', 'A'..'Z');


sub distancefunction {
     my ($x, $y) = (shift, shift);
     # whatever you want, i.e.:
     return 30 + ( 5 * (cos($x/10) + sin($y/6)) )
     # (mind that the values should all be positive)
}

sub renderline {
     my ($width, $y) = (shift, shift);
     my @line;

     foreach my $x (0..$width-1) {

         # the current point -- already set?
         # otherwise, set to a random "color"
         my $current_color = $line[$x];
         defined $current_color or do {
             $current_color = $colors[rand()*scalar(@colors)];
             $line[$x] = $current_color;
         };

         # get the distance of the current point in focus,
         # relative to the image plane
         # (suppose it is completely behind that)
         my $dist_point = distancefunction($x, $y);
         # angle between rays from current point to left and right eye
         my $alpha = asin($dist_eyes / ($dist_image+$dist_point));
         # index of the current point as seen by the other eye
         my $x2 = $x + int( sin($alpha)*$dist_point );

         # out of range?
         next if ($x2 < $x or $x2 >= $width);

         # set "color" of the same point - but as seen by the
         # other eye - to the same color
         $line[$x2] = $current_color;
     }
     return \@line
}

sub renderimage {
     my ($width, $height) = (shift, shift);

     foreach my $y (0..$height-1) {
         print join '', @{renderline($width, $y)}, "\n";
     }
     return 1
}

renderimage(120,40);

exit 1;

--- perl off ---

you will need some rather large shell window in order to view the
120 x 40 character picture, though.. ;)

of course, the depth resolution is very limited at this "pixel"
size, thus, the distance of the object is strongly quantized(sp?).
but you should be able to see some squares and circles in the image.

anyway, you can add some code to write the image to a .png or
.tga image file instead; then you can watch the SIRDS in high
resolution and real colors..! ;)

ok, now here is the interesting (read: on-topic :) part:
i was thinking of some kind of user defined function in povray
which would implement this algorithm to produce some kind of
imagemap. then just put it on a plane and render that.

obviously, this is not as simple as it may sound. you would
have to calculate the whole imagemap first!

OTOH, the other way round, you could try to render images
using povray, but output them as a SIRDS. - this would
require some kind of Z-buffer to be filled and dumped to
the hard disk, then one could use it as a replacement for
the "distancefunction" in the code above!

is this possible? it is in no way related to things like
"HF_gray_16", which just produces 16-bit images from
brightness values.. - maybe somebody wrote a patch which
makes povray able to write a "Z image" with pixel values
corresponding to the distance from the camera?

- or maybe someone of you can think of a better way to
use it? - i would be very interested indeed..!


HTH,

g.

-- 
mailto:gim### [at] psicoch
http://www.psico.ch/ 
http://psico.servehttp.com/


Post a reply to this message

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