About a week ago, I found out about how parallax barriers work. These are a technology used in the 3DS and in some upcoming Android phones, that make it possible to have reasonable glasses-free 3D support on phones and other devices, without halfing the resolution for other uses. (I had originally thought that these devices used a lenticular approach, which would have halved the resolution all the time - that they don't is really cool.)
So, I started thinking about how I could add this support to Ren'Py - and it turned out that it wasn't all that hard. What I've done is to add a new property (depth) to Transforms and ATL. This property lets us offset the rendering of a displayable depending on which eye it's being shown to. Ren'Py then renders the display twice, once for each eye, and combines them - and we have 3d.
My current plan is to support 5 kinds of output:
Quad Buffered 3D - This is the sort of output one would use with 3D glasses, or on a device with a parallax barrier-based screen. Basically, Ren'Py will render things into the left and right buffers, as necessary. The hardware then takes care of blinking it onto the screen every other frame, and synchronizing the shutter glasses with the screen.
To be honest, I haven't really tested this out yet, as the hardware hasn't come in yet - it's on back order. I'm hoping to get this tested before 6.12.1 is actually out - the pre-releases won't have this option until I do.
Black and White Anaglyph This is the mode I test the most with - since I have red-blue 3d glasses. Basically, Ren'Py will use a shader to convert the colors to black and white, before offsetting the images sent to the red and blue/green channels. Here's a sample image:
To view this sample image, you'll need red-blue or red-cyan glasses. Place the red lens over your left eye, and look at the screen - the image should quickly become 3d. (For me, it takes about 15 seconds.)
Color Anaglyph This is similar, but without the color conversion. You'll need red-cyan 3d glasses to make this work.
Again, put the red lens over your left eye.
Side-By-Side This method doesn't require any special equipment, but does require nimble eyes. To view this, you need to cross your eyes until the two images below overlap. When they do, the middle image will appear to be in 3d. Be careful - one friend of mine reported that it kind of hurt him to try this. (Several others had it work.) It's also much easier to do this if you shrink the image or step back from the computer, so you may want to try that.
None Finally, we'll have a mode that disables the stereo support, so 3d games can be played as 2d ones.
The 3d support for Ren'Py is fairly simply to enable. Transforms (ATL and otherwise) take a new depth property, which specifies how far back a given image should be. A depth of 0.0 has maximum separation, and so is as close to the user as possible. A depth of 1.0 is at the same level of as the screen - if you take off your glasses, it will look normal. Depths greater than 1.0 will tend to fall into the screen. This doesn't look all that great, IMO.
Code that uses depth looks like:
Code: Select all
label start:
scene bg whitehouse:
depth 1.0
show lucy happy:
xanchor 0.5 xpos 0.6
depth .6
show eileen happy:
xanchor 0.5 xpos 0.33
depth .3
e "Here's a test of the new 3d support in Ren'Py. It allows you to display a three-dimensional game using anaglyphs and side-by-side images."
show lucy mad
l "Hey! Why do I always have to be in the back?!"
Code: Select all
show lucy happy at right, back
show eileen happy at left, front
I'll also note that depth is independent of the order in which images are show. It's possible to have an image with depth of 0.0 below one with a depth of, say, .5. It will look really weird and bad (since the depth cues are conflicting in your brain), but that's not Ren'Py's problem.
Also, as you can see from the images above (if you managed to resolve them), the 3d consists of flat images stacked one over the other. It wouldn't be hard to modify Ren'Py to use a different image for the left and right eyes, at the cost of more image cache pressure - but I'm not sure anyone is actually going to the trouble of drawing stereograms, so I don't plan to support this immediately.