Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Maes

Real-time anaglyph Doom

Recommended Posts

With Avatar's all-new pimping of the good old Anaglyph technology (even if now they prefer calling it IMAX or whatever) I recalled this here thread: Doom in 3D.

Now, quite honestly, those images are undecipherable to me lest I use some stereoscope to completely separate my eyes, howvever I can view autostereogram and anaglyph movies just fine, with just the glasses....

I also recalled that some older titles like Rad Rader had a built-in Anaglyph 3D mode: at the press of a button, the game would "split" stuff real-time on the screen, for an effortless 3D effect using just your everyday B-movie 3D paper red & blue glasses. And that was on the fuckin' 8-bit NES, FFS.

So I thought that Doom, with all those super-duper highly efficient source ports, could very well implement a similar realtime anaglyph 3D mode, and furthermore, it would be trivial:

Technically, it would require no more than rendering two screens with cameras placed slightly apart (user selectable distance preferably), tinting them red/blue or green/red (user selectable, once again), and mixing them in real-time (this can be done really efficiently), so the additional CPU overhead, at least for software-rendered ports, would be rendering one extra frame + 1 linear frame mixing. With 4-digit timedemos possible in software more, surely some power can be spared for a little anaglyph...

OpenGL/Direct3D ports would be more complex than that, as the rendering pipelines would be taxed and the scene would have to be rendered as two transparent ones, but it could also be done.

Doom is the ideal game for such an extension because it has:

  1. Extremely fast 3D engine (even in software mode) yet capable of impressive environments.
  2. Much more action than your modern run-of-the-mill shooters
  3. There's a hyper-active source port dev. community and a more than eager fan base...
...so I can so see a ZDoom or prBoom "3D Anaglyph" branch. If it's done, it will beat the gaming industry at its own game, and in the most user-friendly way possible ;-)

Share this post


Link to post

Yes, I was hoping Randy or Graf might see that thread and be really impressed by the screens so they'd want to see if ZDoom could do it :D

There would be 3 options needed that I can think of:

3D viewing mode (Cross-eyed, parallel, or 3d glasses)
Eye separation distance
Gun sprite offset distance (to make the gun seem right in front of you, not really far away. I showed this in the first set of screens.)

With cross-eye/parallel viewing, you could just render two 320x240 screens side-by-side in a 640x480 window (black bars above and below). Combining the screens for 3D glasses would be more complex, maybe, but should still perform good at lower resolutions.

I guess the HUD elements would have to be dealt with, too. I guess the same way that the gun sprite is dealt with. But I'd gladly play with no hud if it was in 3D.

And to repost, fraggle posted this youtube video in that thread: http://www.youtube.com/watch?v=3rA2TpcKmZM
He recorded a 2 videos of the same demo in 2 modified (chocolate?) doom buids with the camera positioning to the side in each build, I think. It's too blurry for me to get a good 3D effect, but I think I can tell that a fireball is in 3D.
EDIT: And I think the images are switched in the vid. To view it cross-eyed, select 'parallel' and vice-versa.

Share this post


Link to post
Maes said:

Doom is the ideal game for such an extension because it has:

  1. 2D sprites
;)

The chromatic goggles for anaglyphs are kinda horrible. I prefer polarized goggles, like those used for the 3D version of Avatar. The issue being, of course, that computer screens don't output polarized light.

Share this post


Link to post

Yeah, 2d sprites are sort-of ill-suited, but at least you can tell which actor is closer and which is farther away. But GL engines always slow down too much for me when I use models, so rendering a GL engine with models in anaglyph would probably bee pretty slow.

Of course, map geometry would display well in 3D, and seeing environments in 3D is much more cool than seeing animate objects in 3D, for me, at least.

Example: http://www.youtube.com/watch?v=dwzO4YWJ-FY
A video of scenes from the series "Planet Earth" in 3D. Doom maps don't approach this beauty, though, but an interactive 3D environment is something I would love (without buying a new display/computer for the Avatar game)

Share this post


Link to post

http://en.wikipedia.org/wiki/Polarized_3D_glasses#On_TV_and_computer_screens :-p

DO IT

Seriously though, the AVGN is shown playing rad racer just with an ordinary TV and disposable 3D glasses (here, near 8:00), so unless he's pulling our leg...I recall there are even Anaglyph 3D color albums for children.

Edit: apparently not. There are what appear to be legitimate pics of the official Rad Racer 3D glasses, and they are just passive tinted glasses to be used with a normal TV (and there are anaglyph movies too). These should work fine with CRT screens, but LCD/TFT are already polarized and would probably interfere.

Share this post


Link to post

I have done this for ZDoom before out of curiosity. Rendering the two images was not hard at all, but I was not able to get the palette colored correctly to minimize bleeding. Also, since I spent a grand total of 5 minutes on it the 2D graphics (status bar, menus, etc) were not drawn and it crashed when the level changed.

Share this post


Link to post

I have no idea if ZDoom still uses a pure 8-bit display, but it would be better to use at least a hi-color (or better, truecolor) one for this job. You may render the two images as 8-bit, but the blending should not be done using an indexed palette, it will look butt-ugly. It may take some extra time though:

FinalScreen.Pixel(x,y)<- (Image1.Pixel(x,y).RGB+Image2.Pixel(x,y).RGB)/2;

Yup, you must add and average the RGB components of the two screens in a true RGB space, and forfeit the indexed palette (the final anaglyph image may contain non-Doom colors).

A way to "cheat" around this is to use a 256x256 look-up table containing indexes to Doom's palette, constructed in such a way that using a pair of palette indexes as the table's indexes, you get an approximate "mixed" color already existing in the Doom palette (is that how you did it?) but it will inevitably look poor, especially with tinting...unless you modify the palette to contain 24-bit colors already compensated for tinting, for use with a 24-bit display (saves a bit of speed compared to doing real-time calculations).

Also you should allow for tinting/colorizing each image. This can be done either by converting each pixel to HSV color space and applying a hue shift (but it's time intensive) or "cheat" and just do some bit shifting at the red/blue or red/green components. Still, you have to do this for every pixel, and in a 24-bit color space.

Share this post


Link to post

Although ZDoom is only has an 8-bit renderer it does render to a true color canvas. I used the gray scale and bit shifting cheat, but as I said I only wanted to see if it was possible.

http://blzut3.maniacsvault.net/anadoom.png (Note: I have no idea if I have the cyan and red on the correct side. All I have are non-standard green-magenta and yellow-blue glasses.)

Share this post


Link to post

I'd say try the look-up palette trick since you're rendering to 24-bit:

First, construct two modified 256-color Doom palettes, with added tint. Since you're only doing this once, you can use a high-quality RGB-to-HSV function (and viceversa). Then precompute the values in the table with the average value for each possible pair between the two palettes (in theory, the diagonal should contain the original Doom palette).

This will only hold true if you set the tints in such a way that they cancel each other upon RGB addition.

If you then render two perfectly aligned pictures (no 3D effect), the index mixing should return you the original Doom palette, while any other shift will render separated and tinted ghost images.

So basically:

  1. You render two 8-bit images as usual
  2. Use the palette indexes to look up the big-ass 65K color palette...
  3. Get a pre-computed RGB value. 65K colors are all the possible combinations, in this case, but don't cheapen out to HiColor.
  4. Draw to 24-bit Canvas.
...yeah, too much DIP has affected me.

Share this post


Link to post
Kagemaru_H said:

I'm pretty sure a graphics replacement WAD would do fine for if you wanted to use regular paper 3D glasses (red/blue or yellow/blue).


It would not help because the issue is in the renderer. You can modify graphics on-the-fly just by transforming the palette ONCE if all you want is tinted graphics, and you can even render 10000 different images with 10000 modified palettes if so you wish. The problem is efficiently mixing those 10000 indexed palette images into a 24-bit one.

Having one or two or 10000 WADs with pre-modified Doom graphics would be just terribly space-inefficient and redundant.

Well OK, maybe just two, but still, no valid reason to use precomputed graphics. It's all in the renderer.

Perhaps OpenGL would help with the mixing here: render two large transparent bitmaps one on top of the other on a black canvas (needs some experimenting on the transparency levels though). I think OpenGL can also auto-tint them in hardware, but I'm not sure. That would make things a tad easier, and would not trash the CPU cache with either a bazillion real-time conversion functions or a big-ass LUT.

Share this post


Link to post

All this talk about mixing and blending two images for 3D glasses, while I am perfectly happy crossing my eyes for side by side images 8^D . I understand though that not everyone can do it effectively.
Granted, it is difficult to do for widescreen images, and it can get tiring or blurry, but there is no color distortion and I think I am building more cross-eyed endurance. And I think you can get glasses, like those horse blinders, that direct each eye to it's corresponding image. That would be goofy looking.

Share this post


Link to post

I am part of the 10% of the population who cannot utilize such technologies that assume that both eyes work in perfect tandem, due to the strabismus I was born with. I am increasingly excluded from being able to watch movies and television programs, and from everything I hear, this is only going to get worse. So I for one lack excitement about this :P

Share this post


Link to post

@Kagemaru_H: now that I think about it, your idea about using additional graphics would make sense for those objects that will never be rendered from sufficiently different angles e.g. the HUD elements (imagine Doomguy's face or status bar numbers with depth) and the weapons, although those would need some redraw.

But even then, pre-coloring wouldn't be needed: I'd let the source port handle that, using a setup screen which would allow you to set the preferred tinging hues and object separation (field depth) to better match your 3D glasses and vision. However there should be new artwork showing e.g. the shotgun "slightly from the two sides". This way, you don't tie the user to one particular tint system, and the resources remain editable and within the Doom palette, no need to use truecolor resources (which as well all know, are still highly problematic).

Also, the depth anaglyph effect would look better on sprites if they had 16 angles instead of just 8, that would require additional artwork too (but again, not necessarily pre-colorized).

Share this post


Link to post

I made this Youtube video a few months back to test Youtube's 3D support. Unfortunately I got the eyes the wrong way round and there are other issues as well (eg. the weapon position should be offset to match the offset in view).

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×