Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: A raycaster that renders to random dot stereogram (like Magic Eye) (github.com)
277 points by ammon 31 days ago | hide | past | web | favorite | 88 comments

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.

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


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

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.

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.

Sadly, it’s basically impossible for me to play. Still awesome.

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.

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.

Your eyes shouldn't be diverging, just not converging (it's often called "parallel" viewing). It is more difficult to learn, and the offset between the images is more sensitive (since, as you say, actually diverging your eyes is near impossible).

However, when you've mastered it, and when the offset (i.e. size) is correct, it's much easier to snap into than the cross-eyed viewing, and much easier to stay in focus while looking at different parts of the image.

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.

>There is no natural scenario when one's eyes would diverge

I like to look out a window at something distant, like a tree or car outside, then adjust my focus on the window pane itself (perhaps the little flecks of dust on it, or better yet one dot of paint on it).

That is a very natural scenario, and at least for me. super easy. I've done it for decades though, so maybe it's just natural for me, lol.

I can FEEL my eyes slightly squeezing to change shape (and thus change focus), and at this point it's simple muscle control, and it's fun.

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

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.

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.

They look much better if they are made to “diverge”, instead of cross, the eyes. Much “larger”, “deeper”... I think one way to describe it is that it’s like you are looking out of a window, instead of looking at an object in your hand, if that makes sense.

As for which one is easier: For some reason, I have always been able to do the “uncrossing” on command, and it feels more natural and more relaxed to me. I sometimes do it to compare almost identical things that are next to each other. Crossing my eyes feels straining.

Everything is blurry if I cross my eyes, but focusing far doesn't do that.

There are 2 ways to see stereograms and I it depends on how exactly you are focusing. One way is the "inverted" version you see.

For me, everything appears as it should.

Here's one place where this is discussed: https://www.reddit.com/r/MagicEye/comments/2u0cc1/inverted_i...

If I cross my eyes I see it the way you describe. If I relax my eyes it goes the other way I see it correctly. It took me a while to figure out how to do this as a kid. Almost like putting my eyes into a far off daydream state.

That just means you're crossing your eyes the wrong way.

It's your head. There are two ways to view the stereogram, if you are seeing a negative, try again.

It's not your head, it's whether you're using your left eye to view the left side of the image or to view the right side of the image.

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.

This is pretty cool. I remember when Magic Carpet came out back in '94 (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.

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.

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 :)

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.

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.

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?

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)

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.

That's what it's supposed to be. The explanation assumes you already know what an "autostereogram" is and know how to look at them. There is a trick involved where you focus your eyes on a point somewhere in space behind the screen instead of on the screen, and it suddenly acquires depth.

https://en.wikipedia.org/wiki/Autostereogram will tell you more about this.

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 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.

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?

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.

Now you're just bringing back memories of the mid 90s and people giving 'helpful' suggestions of how to see the images. I still can't see them.

Could be used for stereogram steganography!

Yes. That's expected. It's a Magic Eye style stereogram. If you make your eyes do the Magic Eye "thing", you can see the 3D shapes in the world and use the arrow keys to move around.

Press 1 or 2, and it will render in normal 3D

I see a sailboat!

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.

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.

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

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

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?

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...

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.

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.

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.

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.

You can see an inverse of the 3D image by simply crossing your eyes until things "line up". It will appear 3D, but things that are intended to jump out at you will sink into the page instead. But that will at least give you a general idea of how it is supposed to work. Then after you get it working this way the whole "unfocus your eyes" approach will make a little more sense.

I'd come across this before, but only just now experienced it. It seems much easier to lock on to the hidden image when it's animated. Also panning your head up/down/left/right with your eyes seems to help too.

Even when your eyes are pointing in the right direction, you eyes' lenses can be incorrectly focused. In order to see the image, you have to hit the correct combination of focus and parallax (which will disagree with what your brain is used to seeing).

> Is there something physically different about my eyes or brain compared to people who can see them?

This is possible, but probably unlikely. If you can't perceive depth, e.g. neurologically incapable, or you have less than two eyes, this won't work for you.

It is possible to have two fully working eyes but for your brain to lack the wiring to combine the two images into a single three dimensional construct in your brain. Your eyes can be fine yet you can have no binocular depth perception. If this is the case you'll not be able to see any Magic Eye pictures or SIRDSs, or get the benefit from going to a 3D showing of a film instead of a 2D showing.

It's a schooner.

you dumb bastard, it's not a schooner, it's a sailboat.

For most of my life it seemed impossible.

But a couple years ago I happened upon a magic eye image while laying with my laptop on my chest putting the display quite close and things just clicked. Now I'll spend hours flipping through magic eye images, it's only gotten easier with practice and the effect is incredible considering there's no drugs involved.

I can't either. My eyes have dramatically different failings (one is nearsighted, one far) and have since I was a child, and it seems like even with glasses on it's just not gonna happen. I'm guessing it's the "since a child" part making my brain bad at stereopsis in general, though I really don't know.

I can cross my eyes, “rattle” them, diverge them, move then semi-independently... and I’ve never seen a Magic Eye picture. I even tried to see the inverted view other people in this thread are describing by intentionally crossing my eyes and bupkis. I could almost believe it’s an Emperor’s New Clothes type of situation.

Give it another try! I wasn't able to see these at all, and I haven't attempted in well over a decade. I was able to see this in under a minute. I wonder if something with the constantly changing image helped me jump the final hurdle…

I don't know the scientific reason, but I was able to see the 3D image roughly around 5% of the times I tried. And after having success in seeing one, I was not able to learn how to do it always. The 5% success rate remained

You could probably get something by crossing your eyes instead... you will get the opposite image of what you would get by doing it properly, meaning that every 3d object will appear as carved out.

It helps if you make a conscious effort to cross your eyes; if you're unable to do that it's probably harder, if not impossible

I couldn’t as a kid but I can now. Not sure why. And unrelated: I still can’t whistle properly.

As a kid, I spent one summer learning to see Magic Eye, one summer learning to whistle (drove the other kids in my summer camp mad, I'm sure), and several months learning to snap my fingers.

I always wondered why other kids could do things that I couldn't, so I guess I spent an excessive amount of time trying to catch up :)

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

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

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


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).

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?

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).

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 [2] https://en.wikipedia.org/wiki/Autostereogram#/media/File:Che...

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.

Interesting! I think this is possible here because the 3D geometry is also horizontally repetitive.

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.

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.

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.

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 !

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).

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 :(

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 :)

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

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.

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

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.

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?

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 :)

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

This has a wonderful bunnyhop :)

now I have to find the easter egg

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

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

oh this is so much fun! love it.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact