POV-Ray : Newsgroups : povray.advanced-users : WIP: Sterograms of a cube Server Time
29 Jul 2024 06:20:24 EDT (-0400)
  WIP: Sterograms of a cube (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Andrew Coppin
Subject: WIP: Sterograms of a cube
Date: 4 Jan 2003 09:35:31
Message: <3e16f133@news.povray.org>
I've posted a couple of images - see povray.binaries.images.

It was about June time last year that I discovered how Single Image
Sterograms ("magic eye pictures") work. You can actually make 'em out of
plain ordinary text! I've done so with Notepad many times...

But I figured you should be able to do it with POV-Ray too - after all, it
IS a 3D program!!!

So that's exactly what I've done today. Sorry about the resulting images
being so dam large... you need big pixel dimensions to get a picture large
enough to use, and lossy compression damages the 3D effect. Still, I managed
to reduce the 2nd image to 256 colours, which seriously reduced the file
size... I won't post any more images, just scene files. (They render real
fast.)

----------

The basic idea is to have similar-but-no-identical repartitions in the
image. If you take a cube and duplicate it across the screen, then owing to
the perspective effect, you see each cube from a slightly different angle.
If you view the thing as a sterogram (i.e., look at it cross-eyed), you get
a 3D effect.

However...

The 3D bit comes out backwards! (That is, the front-most part is at the
back, with the back edges at the front. It looks really odd!) Now, I
discovered that I can use the Reorient_Trans() macro from transforms.inc to
rotate each cube so it faces the camera at the same angle. This results in a
totally flat image. But if you apply that transformation TWICE - i.e.,
_over_ compensate - you again get a 3D effect. But it's the right way round
this time!

Sterogram #1 shows this approach.

Of course, applying the rotation twice gives you a fairly extreme 3D effect;
the sides of the cubes look more like parallelagrams than squares. But
still, it's very good to look at. Adding lights is a bit of a problem - the
lights show up differently on each cube! But if you put them in a
light_group with each cube, and transform them the same way as the cube...
it works just fine! (That's how I did it anyway.)

BTW - I didn't realise that objects outside the light_group can still cause
shadows! Would be nice to turn this off...

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

The other method is to put the camera at the origin, the object at a
distance, and **rotate** them from side to side (i.e., rather than translate
them). Since the camera is at the origin, they now all point at the camera
at the same angle. If you rotate them around a point that isn't the camera,
you get a 3D effect (negative or positive, depending on whether the point is
in front of or behind the camera).

Sterogram #2 shows this approach.

Well, sort of. Actually, I rotate each cube a bit, then translate it away,
and rotate round the camera. I think that's why the image looks "bowed". It
does give a very slight curve to the 3D image - but not very much! I will
try truely rotating round a different point in a bit.

Does anyone understand what I'm chatting about? And would anyone be
interested in me posting the scene file?

Thanks!
Andrew.

PS. Can anyone here see sterograms btw? Kinda pointless if you can't :P


Post a reply to this message

From: Christoph Hormann
Subject: Re: WIP: Sterograms of a cube
Date: 4 Jan 2003 09:40:41
Message: <3E16F269.48A0B168@gmx.de>
Andrew Coppin wrote:
> 
> 
> Does anyone understand what I'm chatting about? And would anyone be
> interested in me posting the scene file?

Yes, best if you could make it a macro taking the object to display as
parameter...

> 
> PS. Can anyone here see sterograms btw? Kinda pointless if you can't :P

Sure.

Christoph

-- 
POV-Ray tutorials, include files, Sim-POV,
HCR-Edit and more: http://www.tu-bs.de/~y0013390/
Last updated 31 Dec. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

From: Christopher James Huff
Subject: Re: WIP: Sterograms of a cube
Date: 4 Jan 2003 10:17:08
Message: <cjameshuff-ECF2C2.10130804012003@netplex.aussie.org>
It looks like you are making things overly complex, and I really can't 
see your method ever working very well. It is much simpler to just 
render two images with the camera at each eye point, and combine the 
images in an editor.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Andrew Coppin
Subject: Re: WIP: Sterograms of a cube
Date: 4 Jan 2003 12:14:02
Message: <3e17165a@news.povray.org>
> Yes, best if you could make it a macro taking the object to display as
> parameter...

My thoughts exactly. (Would probably need to say what size the object is
too - plus the intensity of the 3D effect to apply...) Btw, can you treat a
light_group as an object?

> > PS. Can anyone here see sterograms btw? Kinda pointless if you can't :P
>
> Sure.

Cool.

I once heard someone claim that magic eye pictures were really a conspiricy,
like the emporer's magic suite...

Andrew.


Post a reply to this message

From: Patrick Elliott
Subject: Re: WIP: Sterograms of a cube
Date: 4 Jan 2003 18:00:55
Message: <MPG.188112d0b3d696339896fb@news.povray.org>
In article <3e16f133@news.povray.org>, orp### [at] btinternetcom says...
> I've posted a couple of images - see povray.binaries.images.
> 
> It was about June time last year that I discovered how Single Image
> Sterograms ("magic eye pictures") work. You can actually make 'em out of
> plain ordinary text! I've done so with Notepad many times...
> 
> But I figured you should be able to do it with POV-Ray too - after all, it
> IS a 3D program!!!
> 
> So that's exactly what I've done today. Sorry about the resulting images
> being so dam large... you need big pixel dimensions to get a picture large
> enough to use, and lossy compression damages the 3D effect. Still, I managed
> to reduce the 2nd image to 256 colours, which seriously reduced the file
> size... I won't post any more images, just scene files. (They render real
> fast.)
> 
> ----------
> 
> The basic idea is to have similar-but-no-identical repartitions in the
> image. If you take a cube and duplicate it across the screen, then owing to
> the perspective effect, you see each cube from a slightly different angle.
> If you view the thing as a sterogram (i.e., look at it cross-eyed), you get
> a 3D effect.
> 
> However...
> 
> The 3D bit comes out backwards! (That is, the front-most part is at the
> back, with the back edges at the front. It looks really odd!) Now, I
> discovered that I can use the Reorient_Trans() macro from transforms.inc to
> rotate each cube so it faces the camera at the same angle. This results in a
> totally flat image. But if you apply that transformation TWICE - i.e.,
> _over_ compensate - you again get a 3D effect. But it's the right way round
> this time!
> 
> Sterogram #1 shows this approach.
> 
> Of course, applying the rotation twice gives you a fairly extreme 3D effect;
> the sides of the cubes look more like parallelagrams than squares. But
> still, it's very good to look at. Adding lights is a bit of a problem - the
> lights show up differently on each cube! But if you put them in a
> light_group with each cube, and transform them the same way as the cube...
> it works just fine! (That's how I did it anyway.)
> 
> BTW - I didn't realise that objects outside the light_group can still cause
> shadows! Would be nice to turn this off...
> 
> -------------
> 
> The other method is to put the camera at the origin, the object at a
> distance, and **rotate** them from side to side (i.e., rather than translate
> them). Since the camera is at the origin, they now all point at the camera
> at the same angle. If you rotate them around a point that isn't the camera,
> you get a 3D effect (negative or positive, depending on whether the point is
> in front of or behind the camera).

> Sterogram #2 shows this approach.

> Well, sort of. Actually, I rotate each cube a bit, then translate it away,
> and rotate round the camera. I think that's why the image looks "bowed". It
> does give a very slight curve to the 3D image - but not very much! I will
> try truely rotating round a different point in a bit.

> Does anyone understand what I'm chatting about? And would anyone be
> interested in me posting the scene file?

> Thanks!
> Andrew.

> PS. Can anyone here see sterograms btw? Kinda pointless if you can't :P

It should be noted that 99.99% of people can cross there eyes, but only 
about 50% can view so called 'magic eye pictures' the right way without 
developing eye strain and a case of extreme frustration. lol One book I 
saw on the subject showed some that worked the 'right' way and others 
that used crossed eyes. Other than perhaps intentionally making it 
harder, I could never understand why they used the method people have 
problems with instead.

My holly grail of single image stereogram methods is one that includes 
the option of reversing the bloody thing, so I don't have to dim my 
monitor to half normal, turn on an overhead lamp and fiddle with a sheet 
of paper to get my eyes to focus on the correct field depth. ;) 
Ironically your first attempt seems to actually do this (or so it would 
appear from your description of the result). Also.. I assume you must be 
using jpg, since you talk about the need for a large image to compensate 
for lossyness. My advice.. don't use jpg. Try PNG instead. JPG was never 
intended to handle detailed images that where not converted from photos 
(close to 3000x2000 pixels or more minimum), where the loss of detail is 
barely noticeable.

The fact that they insist on using jpg or similar lossy formats for 
digital cameras I find completely insane and it isn't all that great for 
rendering either, unless you specifically need to save space. In the case 
of stereograms it is almost certain to be lethal.


Post a reply to this message

From: Jaap Frank
Subject: Re: Sterograms of a cube
Date: 4 Jan 2003 22:23:46
Message: <3e17a542@news.povray.org>
Sorry, I've cancelled several times, but it doesn't disappear!


Post a reply to this message

From: Ken
Subject: Re: Sterograms of a cube
Date: 4 Jan 2003 22:52:28
Message: <3E17ABA1.9E492153@pacbell.net>
Jaap Frank wrote:
> 
> Sorry, I've cancelled several times, but it doesn't disappear!

They did dissapear. It is your newsreaders temporary cache that is
making them still appear on your machine. Try closing your news
reading program and restarting it. You will see that they are gone.

-- 
Ken Tyler


Post a reply to this message

From: Jaap Frank
Subject: Re: Sterograms of a cube
Date: 4 Jan 2003 23:20:29
Message: <3e17b28d@news.povray.org>
"Ken" <tyl### [at] pacbellnet> wrote in message
news:3E17ABA1.9E492153@pacbell.net...
>
>
> Jaap Frank wrote:
> >
> > Sorry, I've cancelled several times, but it doesn't disappear!
>
> They did dissapear. It is your newsreaders temporary cache that is
> making them still appear on your machine. Try closing your news
> reading program and restarting it. You will see that they are gone.
>
> --
> Ken Tyler

That didn't work. I had to delete all the downloaded messages and
reload them fresh.
Is there another way to do this?
I'm using Outlook Express 6.0.

Greetings,

Jaap Frank


Post a reply to this message

From: Andrew Coppin
Subject: Re: WIP: Sterograms of a cube
Date: 5 Jan 2003 06:16:14
Message: <3e1813fe@news.povray.org>
> Also.. I assume you must be
> using jpg, since you talk about the need for a large image to compensate
> for lossyness. My advice.. don't use jpg. Try PNG instead. JPG was never
> intended to handle detailed images that where not converted from photos
> (close to 3000x2000 pixels or more minimum), where the loss of detail is
> barely noticeable.

Ooo, no no NO... That's the point: It *is* PNG, *not* JPEG; the pattern has
to repeat exactly for the 3D effect to work, and JPEG would screw that up
totally. That's why the files are so dam big - they're probably much smaller
with JPEG. But hey, what use is a sterogram that doesn't *work*? ;-)

> The fact that they insist on using jpg or similar lossy formats for
> digital cameras I find completely insane and it isn't all that great for
> rendering either, unless you specifically need to save space. In the case
> of stereograms it is almost certain to be lethal.

Yeah, I know... (But then, *my* digital camera is so lame it probably
doesn't make any odds. *sigh*) And it would kill the sterograms.

Thanks.
Andrew.


Post a reply to this message

From: gimi
Subject: Re: WIP: Sterograms of a cube
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

Goto Latest 10 Messages Next 3 Messages >>>

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