
Show HN: A raycaster that renders to random dot stereogram (like Magic Eye) - ammon
https://github.com/ammonb/stereogram-raycaster
======
noneeeed
A quick suggestion that would help people to "lock-on" to the effect, add two
small coloured dots the distance of the stereo separation. It makes it easier
to work out if you've managed to uncross your eyes the right amount.

------
Y_Y
If you want actual doom as a magic eye thingy, someone else made it already:

[https://blogum.itch.io/omdo](https://blogum.itch.io/omdo)

~~~
ammon
Super cool, and more impressive than what I did! :)

~~~
Y_Y
I didn't mean to dimish your achievement. It just rang a bell with me and I
thought people might want to literally try doom.

I haven't tried your one, but OMDO (linked in GP) is an unplayable nightmare
dizziness-inducing headache.

~~~
nneonneo
Getting shot at in OMDO really ruins the effect, especially since it's nigh-
impossible to spot them quickly. I wish you could just play it without
enemies.

------
strenholme
OK, is it just me or does the stereogram render backwards: The more distant
stuff (the skyline) looks closer, while the floor and walls looks more
distant? I cross my eyes to see these because I can’t do the “focus on the
horizon” trick.

Perhaps have a mode where the close/far stuff is swapped so it looks right to
those of us who cross our eyes to see these.

~~~
jeffwass
What always annoyed me is why they devised these to _diverge_ your eyes and
not cross them.

Crossing your eyes is much more natural, and you can easily do it by looking
at something close to your face.

Diverging is much harder, at least for me and most other people I’ve talked
to.

So I can see these by crossing my eyes but everything is inverted. It comes
out as a front layer with stuff cut out of it and behind.

~~~
ambrop7
I agree, and diverging gets practically impossible if the image is farther
away, like on a TV screen. There is no natural scenario when one's eyes would
diverge, which is what would usually be necessary in such cases.

~~~
WhiteSage
Looking at something behind the screen (if transparent) or reflected on the
screen (if slightly reflective) should do the trick.

~~~
ambrop7
This only gets you there if the physical distance between the stereo images on
the display is <= the distance between the eyes. If it is greater, you would
need to look at something more than infinitely away / behind you (your eyes
would have to diverge). In particular if the screen is already quite far away
(e.g. a few meters), there's not much more far away you can focus anyway,
since there's not much difference in angle between a few meters and infinity.

~~~
loco5niner
I have to admit I don't understand your argument, but in my experience:

Stereograms are NOT meant to be enjoyed from across a room.

It's REALLY hard to 'catch' a stereogram from far away, so why are you even
trying?

However, the "focusing on-or-through a transparent thing" that WhiteSage
mentions works well at slightly further distances and can be used to help you
figure this stuff out.

------
phkahler
Always wanted to try this with my ray tracer. Some thoughts:

1) Higher frame rate will probably help - it will look even more like old TV
snow wrapped around things.

2) Color per object should be possible but it will bleed. This may or may not
help the effect.

3) Possibly change the dot size based on distance (some dots are seen at two
different distances, so average them? This would be similar to how color might
be done. Advantage would be that the snow would be more like a texture that
gets smaller further away.

4) I'm not sure about the notion of "base image" I always assumed a method of
rendering that may not be what others do.

------
parksy
This is pretty cool. I remember when Magic Carpet came out back in '94
([https://ultimatehistoryvideogames.jimdo.com/magic-
carpet/](https://ultimatehistoryvideogames.jimdo.com/magic-carpet/))

It had a magic eye feature, which I haven't really seen before or since so
it's neat to see a modern implementation in the browser.

~~~
noneeeed
Hah, came here to make that comment. Love that game. If I remember right there
were a couple of of other modes, including a red/blue glasses version.

~~~
dividuum
Thanks for confirming that was actually a feature. I wanted to post as well
but couldn't find any screenshot of how that looked like back then and
hesitated, fearing that I remembered it wrong :)

~~~
noneeeed
Yeah, I got really into the whole auto-stereo effect when I was a kid, started
drawing them when I was bored in class, so being able to play a computer game
like that was pretty cool at the time.

------
sagebird
This is wonderful. I found it more enjoyable if you add the following css to
the canvas:

canvas{ image-rendering: pixelated; width: 100vw; height: 100vh; object-fit:
cover; position: fixed; top: 0; left: 0; filter: contrast(.3) sepia(405%) hue-
rotate(273deg); }

Then view full screen (F11).

It fills your screen with a red toned version, with less contrast which I
prefer. These things are highly personal so I suggest you experiment to find
settings you like. Setting image rendering to pixelated is really personal as
well, as some will prefer the softer look of blurring, but it helps me lock on
to the stereogram.

------
throwaway1500
First of all: One of the most awesome use of autostereogram i have ever seen!
I always wondered if that was possible. Thank you!

Question, did you experiment how to reduce the flickering? Or use of colors?

~~~
ammon
Thanks! I did try to smooth the flickering. There's a 4th render mode. Press 4
and you'll get a smoothed version of autostereogram. It does look better in
autostereogram. However, you'll notice that the smoothing causes an
"information leak" into the 2D image (you can see the outlines of the walls)

------
montecarl
I get a grey static noise image. Like an old black and white TV that isn't
tuned to a channel. Latest Chrome on Linux with NVIDIA GTX 1060 using
proprietary NVIDIA drivers 410.104.

~~~
sonofgod
That's correct -- if you cross your eyes correctly, you should see some 3D
depth in the static.

[http://www.magiceye.com/faq_example.htm](http://www.magiceye.com/faq_example.htm)
has some helpful instructions (you're looking for a planet with rings)

Would be useful if it had some markers for achieving the correct amount of
focus.

~~~
Aardwolf
I've never been able to see these things.

In this example, I always see two squares when trying to look behind it, never
4 like the instructions require.

How can I let my eyes focus behind the screen? I can focus my eyes in front of
it by looking at my finger, and get 4 squares that way, but that doesn't work
for focusing behind it, for me.

No planet appears when making it 3 squares while looking at finger in front of
it either for me. And if I remove my finger, my eyes immediately change their
focus :/

Any tips?

~~~
NeedMoreTea
No tips - except at a guess 10 or 20% can't and won't ever see them.

I spent ages trying to make these things work in the 80s or 90s whenever the
posters were the craze. Never got close, and there were quite a few others
they simply didn't work on.

------
JeremyHerrman
Super cool!

Does anyone know alternative non-random dot approaches to autostereogram
generation?

Seeing the random dot approach in video highlights the lack of temporal
coherence across frames.

~~~
ammon
You can apply the exact same algorithm to any starting pattern (it does not
have to be random dots). When a pixel is unconstrained by the algorithm, just
pick a pixel from an image (rather than a random value). Of course, to work
well the image needs a lot of small details. I actually tried that here. But
the result "leaks information" into the 2D image (as you move around, the
deformations of the 2D image reflects the 3D geometry). It seemed less
interesting.

------
devrod
It would be nice if the dots didn't change between renders of otherwise
identical frames.

~~~
jordanwallwork
That actually seems to be quite an important property in highlighting what a
cool effect it is. Someone else here posted a link to a similar project they'd
done [1]. If you follow the link and press T to switch on the noise, and then
A to start the box moving, you'll see how obvious it is and the effect just
isn't as cool. However if you then press B to switch on the background
movement the box suddenly become harder to see until you correctly focus your
eyes

1 -
[https://moefh.github.io/stereogram/index.html](https://moefh.github.io/stereogram/index.html)

------
umanwizard
Tangent: I have spent probably at least a few hours total periodically trying,
from when I was a child until now, to see the hidden image in Magic Eye, and
have _never_ been able to see _absolutely anything at all_ , despite reading
guides on how to do it, etc.

Does anyone else have this experience? Is there something physically different
about my eyes or brain compared to people who can see them?

~~~
deathanatos
I did, for many years. It's one of those things that's hard to explain, and
hard to do until you've done it, at which point you understand yourself then
how to do it. My father did magic eyes in the newspaper every week when I was
a child, and I could _never_ do it. I did start to wonder if he made it all
up, but there was an answer key and he was able to figure it out, so there had
to be something to it.

Go to the paper: [https://www.cs.waikato.ac.nz/~ihw/papers/94-HWT-SI-IHW-
SIRDS...](https://www.cs.waikato.ac.nz/~ihw/papers/94-HWT-SI-IHW-SIRDS-
paper.pdf)

Go to figure 7, "Figure 7. Stereogram showing a hemisphere", on page 24. There
are two black dots near the bottom. Cross your eyes: you should now see 4
black dots (2 per eye). Adjust how "crossed" your eyes are such that the
"inner" two dots line up, s.t. there are only "three" dots, like `(dot) (two
overlapping dots) (dot)`. Now, the hard part: your vision likely blurred when
you crossed your eyes; without uncrossing your eyes, and maintaining the
position/overlapping of the dots, bring your vision into focus. (This is, IMO,
the hard bit.)

Once I've got it into focus, I find my vision "stabilizes": I'm able to look
around w/o having to concentrate on keeping my eyes crossed to a particular
amount. At this point, I can look up above the dots, and there is a hemisphere
in the image, as the figure caption says.

This doesn't have to be done w/ magic eye images, either. Two normal 3d
renderings of a landscape side-by-side, where the camera in one rendering
slightly horizontally offset from the other, will also work. The idea is the
same: overlay the images in your visual field, then bring it into focus.

At least, that's what works for me. According to the sibling comment from
chubasco, there's more to it, I guess, but the above is all I know.

~~~
alok99
This is the best instruction I've read so far on seeing them. I'm fine with
cross-eye stereograms, so lining up to 3 dots was easy. What you described as
"stabilizing" your vision once you've focused is what I normally do with
cross-eye images to look around.

In this case, I can stabilize, but I feel like I'm still seeing the inverse of
what I should be seeing. The hemisphere looks like it's carved into the image
(with various bands that I assume are shading). The very center looks like a
hole was cut out and I can see "behind" the hemisphere. I assume this is
supposed to be a highlight and the nearest point to me, but I see it as the
furthest.

~~~
deathanatos
Yeah, it's inverted for me too (hemisphere looks carved into the screen).
chubasco's comment seems to indicate there's a way of looking at it that goes
the other way (and that my technique results in a backwards image), but IDK —
the above is the limits of what I know.

~~~
zeta0134
Firstly: play around with the zoom. I have a _much_ easier time with these at
smaller sizes. Second, lean in close to your monitor, so that your eyes are
straining a bit to keep the image in focus. Let your eyes "relax" out of
focus. At first this might seem the same, but you're getting your eyes to
effectively un-cross. Line up the three dots and you should now see the
hemisphere in front of the plane, rather than as a cutout.

------
classichasclass
Although autostereogram is fun, an additional anaglyph mode (red-cyan) might
be nice for people who have trouble with such images.

------
jonny_eh
The readme is perhaps the best explanation for ray casting that I've ever
read. So succinct!

------
moefh
That's really nice. I did something very similar a few years ago:

[https://github.com/moefh/stereogram/](https://github.com/moefh/stereogram/)

My version shows a simpler scene (a single tumbling cube) and also works with
random-dot rendering, but also supports rendering with a tiled image (I found
that tiled images work better for static 3d scenes while random-dot works
better for animated scenes).

------
pablo1
Don't know much about stereograms, two general questions:

a) Is it possilbe to render color images this way? b) Is it possible to have
the random dots not change all the time? E.g. When I don't move in this
example, I dont see the need to draw new random dots. Also when moving
sideways e.g. would it be possible to keep the dots where they are, relative
to the world?

~~~
ammon
It's possible to use color in that the dots don't have to be black and white,
and don't have to be totally random. The way an autostereogram works is that
there's a repetitively tiled base image (or vertical column repeated
horizontally). The stereographic angle information is encoded in mutations of
the repeating image. That base image can be anything (including a photo).

However, this color image will not correspond in any way to the 3D geometry of
the scene. I don't know of any way to get color information to correspond to
BOTH the 3D geometry and the stereographic information (without using two
images).

~~~
bradyd
In the Wikipedia article on autostereogram [1] there is an example of a chess
set [2] where the 2D image directly corresponds to the 3D autostereogram
image. It is apparently a type of wallpaper autosterogram, instead of random
dot, which requires horizontal repetition for the effect to work.

[1]
[https://en.wikipedia.org/wiki/Autostereogram](https://en.wikipedia.org/wiki/Autostereogram)
[2]
[https://en.wikipedia.org/wiki/Autostereogram#/media/File:Che...](https://en.wikipedia.org/wiki/Autostereogram#/media/File:Chess_Single_Image_Stereogram_by_3Dimka.jpg)

~~~
nneonneo
That picture in particular has a really interesting parallax effect - view it
in stereo and move your head around. For me, the back rank seems to shift a
lot with head position, even though the image itself is (obviously)
stationary.

Regular Magic-Eye pictures do this too, but to a much less noticeable degree.

------
gwbas1c
FYI: It might be easier if I could pause the stereogram until I can get my
eyes focused. With the magic eye images, I usually focus on a point until my
eyes lock in.

With the image constantly changing, there is no point to focus on. I kept
double-crossing my eyes because there was no reference.

------
tbabb
Looks like the parallax is quantized into whole-pixel shifts, leading to flat
planes at discrete depths.

The eye can pick up very small sub-pixel shifts when doing parallax solving.
Good antialiasing would be necessary for a smooth/continuous perception of
depth.

------
jstanley
I wonder if someone could make a terminal emulator that renders to a "magic
eye" view of some hexadecimal characters.

That way we could actually interact with a computer while staring at a screen
of randomly changing characters, just like in the movies.

------
creative-coder
Amazing! didn't think I could get so hooked up to a stereogram renderer....
I'd suggest adding other colorful background variations, apart from random
dots, as well. Thanks for sharing !

------
nneonneo
A hint for anyone looking for the easter egg: you're unlikely to find it in
the stereogram view as it depends on the colour of the tile (use e+left/right
arrows to edit colour).

------
olliej
I wonder how feasible getting some temporal consistency in the dots would be?
(Something similar to what the return of Obra dinn does?)

Alas it does actually make me nauseous :(

------
cpach
I hesitated to upvote this because few things frustrate me as much as
autostereograms (hello childhood memories) ...but it’s a cool project, so have
an upvote :)

------
arduinomancer
Thats so cool! Reminds me of the 3DS sort of 3D feeling.

------
tunnuz
Maybe it's just me, but after using this, the text on hacker news comments
feels like it's placed at various different z-indices.

------
gmiller123456
My trick for seeing these is to shine a flashlight on my face from the side,
then focus on my reflection in the screen.

------
loco5niner
LOVE this! Cool little world to play in.

I enjoyed editing a hole in front of me, falling in and editing a staircase to
get back out.

------
derekdahmer
It's weird but if I zoom, I can't make the magic eye work. Even at 50% or
200%. I wonder why that is?

------
dusted
this is super cool! :) for some reason I can never see gradients in these :(
so it was a bit disorienting until I realized it's literally just a room with
some stairs in the middle. I'd love to see more complex geometry in this :)

------
krueger71
Found it easier to get the correct effect if I removed my computer glasses

------
ozzyman700
This has a wonderful bunnyhop :)

now I have to find the easter egg

------
parf02
very cool, I find it's a bit easier to see these with a bit of alcohol

------
keyle
damnit I looked everywhere for that easter egg and didn't find it.

------
nydel
oh this is so much fun! love it.

