Page 1 of 2

[April Fools] 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 12:13 am
by PyTom
Disclaimer: Some variants of this feature have lead to friends of mine getting headaches. Also, _this_ has been rumored to happen. If you feel yourself having trouble, stop trying to view the images.

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:
bwanaglyph.jpg
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.
coloranaglyph.jpg
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.
sidebyside.jpg
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?!"
A transform is applied to the Characters as well, to put it them at a depth of 0.0. In practice, I'd expect the depth to be placed into transforms, so one would write code like:

Code: Select all

    show lucy happy at right, back
    show eileen happy at left, front
There's a config variable, config.max_separation, that controls how far Ren'Py is willing to separate images. The greater this is, the greater the 3d effect. The user can then pick any separation from 0 to config.max_separation, so they can choose the amount of 3d that is right for them. Generally, one only wants things with no separation (that is, a depth of 1.0) to touch the edges of the screen. So it's necessary to avoid using the config.max_separation pixels on the left and right sides of the screen.

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.

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 1:39 am
by sake-bento
Yes! FINALLY, I can make that first person shooter I've always wanted to make. Thank you! This is perfect!

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 2:11 am
by Mihara
I hope that there is an option to account for the reduction of apparent object size with distance in the math somewhere without manually calculating zoom for everything.

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 2:21 am
by PyTom
It isn't in the current version.

Honestly, I'm not sure that's something we want to do - certainly not by default. As a character gets further from the viewer, you would expect to see more of her. I think you'd want to change the sprite to compensate - like when a character is close, you see her from the waist up, but towards the back, you get a three-quarters view.

My feeling is that it's something for people to experiment with, and if best practices show up, then I'll add them to Ren'Py.

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 4:52 am
by Samu-kun
Woww..... I need to redraw all the H scenes in Homeward to make the best use of this technology!

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 5:00 am
by Aleema
It's like the words are really there! :shock:
I always hated how much the sprites looked like they belonged in the background, like they were in a game or something. Finally, my fake boyfriend can come to life.

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 6:01 am
by DaFool
Not too long ago I actually asked for this feature. Don't dash my hopes!

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 7:01 am
by Mihara
PyTom wrote:Honestly, I'm not sure that's something we want to do - certainly not by default. As a character gets further from the viewer, you would expect to see more of her. I think you'd want to change the sprite to compensate - like when a character is close, you see her from the waist up, but towards the back, you get a three-quarters view.
Not by default, certainly. However, drawing full body sprites and scaling them down is not that uncommon, (encountered in about 10% of all commercial titles I took apart) so in my opinion there should be a ready option. A hook for a function that would take depth and maybe some more scene-dependent parameters and return a zoom modifier to be applied to zoom that is declared otherwise would be the most flexible approach and allow for an easier evolution of best practices.

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 10:58 pm
by J. Datie
I applaud the effort to apply new technology where it should be applied: everywhere possible. It warms my heart to see this cutting-until-it's-bleeding-edge technology available to the general public, instead of just in high budget movies that spent all their budget on the special effects. That's right, move over, Jaws 3-D, there's new competition in town! I will immediately switch to Ren'Py for this feature, as soon as I overcome my fear of decimals.

Re: 6.12.1: 3D Support

Posted: Fri Apr 01, 2011 11:04 pm
by Spiky Caterpillar
THIS. IS. AWESOME.

Re: [April Fools] 6.12.1: 3D Support

Posted: Sat Apr 02, 2011 1:00 am
by PyTom
So, this was my April fool's joke - I'm pretty sure it didn't actually fool anyone, this time around. That being said, I am actually kind of curious what people would think of a feature like this, since it would be technically easy to implement, at least in OpenGL mode. I wouldn't expect to do this anytime soon - but if the current trend towards 3D displays takes off, would people be interested in making games that take advantage of them?

It's kind of interesting - what started off as a joke turned into a halfway reasonable design.

Re: [April Fools] 6.12.1: 3D Support

Posted: Sat Apr 02, 2011 2:04 am
by LVUER
Other than gimmicky feature, I don't really know a "real" usage of 3D VN. Even a real game play still have no benefit from 3D, other than nice visuals and immersion. Still, it will be a cool feature to have.

Re: [April Fools] 6.12.1: 3D Support

Posted: Sat Apr 02, 2011 4:56 am
by Aleema
PyTom wrote:So, this was my April fool's joke - I'm pretty sure it didn't actually fool anyone, this time around.
Ya always fool me for at least a little while, and ya always give me a good laugh. The "side by side" option had me tearing up.

Re: [April Fools] 6.12.1: 3D Support

Posted: Sat Apr 02, 2011 6:05 am
by luminarious
I am in some serious like with this idea! It adds some work when putting the game together, but hell, it looks so much better than 3D graphics (there's some sort of irony in that.. :P).

Re: [April Fools] 6.12.1: 3D Support

Posted: Sat Apr 02, 2011 12:08 pm
by Mihara
Many of my best ideas ever have been born as jokes taken seriously in a "why not" fashion, often someone else's jokes. I am of the concrete opinion that this joke is also of this class, a "ha ha only serious", and firmly believe it should be implemented.

People will buy 3D-capable hardware eventually one way or another, and it's not particularly developmentally costly for the individual developer to adapt a project to use it if this feature is available. I want this feature, I'd even buy anaglyph glasses just for debugging. In the world of 2D art and visual novels this is certainly something novel and fresh, something no engine currently has. Sure, it may sound as a gimmick now, but that's until someone makes an "omg, cool!" use of it, and we can't know when that happens.