Shop OBEX P1 Docs P2 Docs Learn Events
Okay, boys and girls, grab your 3D glasses and gather 'round the TV (or VGA). . — Parallax Forums

Okay, boys and girls, grab your 3D glasses and gather 'round the TV (or VGA). .

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2009-07-01 03:10 in Propeller 1
... It's time for Dr. Tongue's Evil House of Pancakes! (Oooooh! Pretty scary, kids!)*

Okay, first a confession: I'm supposed to be writing documentation for a new product. The doing isn't that onerous, really, it's just the getting started. And that's where avoidance activity comes in. I thought, "I can do this in a day or two. It'll be okay; I won't lose that much time, and it'll be fun!" Fun! Yes, indeed: that's the best part of being bad! smile.gif

Well, that was more than a week ago, I've been staying up late, and my writing and other commitments are way behind schedule; but it sure has been fun! And now it's finished — for the time being.

What I'm so giddy about is a new 3D graphics driver that produces anaglyphic stereo output on a TV screen. You need red(L)/blue(R) -O^O- 3D glasses to view the output, and it can display wireframe models of solid objects. I started with Chip's Graphics.spin driver and, like Yoda with Luke's provisions locker, started pitching stuff out. Arcs? Gone. Text? Nope: gotta make some room. Basically what was left were points and lines. And even those got modified (by weeding out some ANDNs) to allow transparency between the left and right views.

From there, I could add the 3D->2D projection math, along with some math for a transformation matrix (scaling, rotations, translations). Then came a macro function for displaying entire wireframes in assembly.

The demo archive is attached. I'm not going to post any photos of the output. That can be a surprise. It can work with a mouse or without. With the mouse you can manipulate the image in real time; without it, the image changes by itself.

The software is optimized for a 12" TV screen. There are two parameters that could use better handling: eye separation and observer distance from the screen. I accommodated both with shifts instead of multiplies and divides. This helps with speed, but doesn't do much for flexibility, so it's something I need to get back to. Picking the colors was a bit tricky, too. NTSC doesn't give you very exquisite control over which phosphors get lit up and where. So you have to find color combinations that separate well and don't leave much ghosting. Even picking a background color can be a challenge (black doesn't work). It needs to camoflage the blues through the red filter, and vice versa, so you don't see shadows or auras where they don't belong.

For those wishing to try their hand at programming, here are the specs:
  • Point (0, 0, 0) is at the center and on the surface of the screen. X and Y directions are as you'd expect. +Z is towards you; -Z, into the screen.
  • Coordinate scaling for drawing points and lines directly (to fill the screen) is, roughly: X from -30000 to 30000 and Y from -22000 to 22000, give or take, depending on Z.
  • Coordinates for packed wireframe points can run from -1023 to 1023 in all directions and are automatically scaled up by 16 before being drawn.
  • Transformations include scaling, rotation (pitch, roll, and yaw) and translation. These are applied to the subject, not to the observer.
  • Transformations should be applied before sending drawing data. Do scaling first, then rotations, with translations being last.
  • You can incrementally accumulate transformations from frame to frame, but it's better to start each frame anew and to apply the accumulated transformations in aggregate to avoid round-off issues during the matrix multiplications.
  • The "color" routine takes one of two values: 0 = erase; 1 = draw. It defaults to "draw".
The file 3D_NTSC_Graphics.spin is just a user-friendly frontend for 3D_Graphics.spin. All you have to specify is the pin number, and it takes it from there. On my avoidance activity to-do list is a similar 3D_VGA_Graphics.spin. I should just do it now and get it over with, but duty calls.

I'm always happy to entertain suggestions and questions. In the meantime, "Would you like some more syrup?"*

-Phil

* For anyone not familiar with SCTV's Count Floyd, here's a link to the now-classic House of Pancakes skit:

····www.karcreat.com/SCTV-CountFloyd.mp4

Update: Added a VGA driver and consolidated the demos. Note: Zip is no longer a full archive, but just the 3D stuff.
_

Post Edited (Phil Pilgrim (PhiPi)) : 6/14/2009 9:29:20 PM GMT


«1

Comments

  • RossHRossH Posts: 5,512
    edited 2009-06-11 07:26
    Wow, cool.

    Got some 3D glasses at home (from seeing "My Bloody Valentine" - a terrible movie, but now I feel absolutely justified in having gone to see it!)

    Can't wait to get home and try it out.

    Ross.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Catalina - a FREE C compiler for the Propeller - see Catalina

    Post Edited (RossH) : 6/11/2009 7:32:23 AM GMT
  • LeonLeon Posts: 7,620
    edited 2009-06-11 08:47
    I remember being taken to see one of the very first 3D films, a western, in the early 1950s. I don't think it was much good as a film but some sequences made me jump, like a bullet hitting the ground in front of my face and a striking rattlesnake that seemed to come right out at me.

    Some people can't see in 3D, BTW. We were using 3D techniques where I once worked, so I tested everyone in our group for stereo perception.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle

    Post Edited (Leon) : 6/11/2009 8:53:55 AM GMT
  • Clock LoopClock Loop Posts: 2,069
    edited 2009-06-11 08:49
    Awesome, I had a similar idea the other day for some reason, However I thought about doing it on a small LCD. TV's are better, no driver rework.

    Combine this with some kind of accellerometer, and or a laser scanner, and you have a virtual interactive 3D interface.

    And now we have the beginnings of the first propeller TV 3D Interactive Interface.

    Anyone interested?

    Can you say minority report?

    [noparse]:o[/noparse]
    An interesting project would be to have a prop output to 2 TV's and input 2 laser scanners, you have the first 3D PONG game.

    Each player on one tv, with their own scanner.

    Can the prop do 2 TVs?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    TERMS OF USE: MIT License

    "Permission is hereby granted, free of charge, to any pers...........................
    ..............................OMITTED FOR FORUM...............................................
    .................. OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. "

    Post Edited (Clock Loop) : 6/15/2009 2:41:53 AM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-06-11 15:54
    Too bad we can't use the Polarized 3D glasses...(I think) ... By interdigitating the vertical pixels you might be able to get something in the way of a 3D effect. A simple experiment using the Polarized 3D glasses looking at yourself in a mirror reveals which eye is your dominant Eye, if you alternately blink your eyes, you can "see" your dominant eye shift. If the interdigitated image you see can be "unzipped" and deminished in quality (contrast/brightness) you might be able to get a 3D effect with the Polarized glasses. ... "might"

    [b]interdigitated image[/b]         [b]slightly "unzipped" interdigitated image[/b] 
    abababababababab               a a abababababab b b
    abababababababab               a a abababababab b b   
    abababababababab               a a abababababab b b
    abababababababab               a a abababababab b b
    abababababababab               a a abababababab b b 
    abababababababab               a a abababababab b b
    abababababababab               a a abababababab b b
    abababababababab               a a abababababab b b 
    abababababababab               a a abababababab b b
    abababababababab               a a abababababab b b 
    abababababababab               a a abababababab b b 
    abababababababab               a a abababababab b b 
    
    



    By increasing/decreasing the contrast of only the 'a' or only the 'b' pixels and shifting them left,right, up,down (I think) you can trick the brain with the dominant eye verses recessive eye into seeing two slightly different images and perceiving the difference as varying depth.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-11 20:31
    Beau,

    'Interesting idea. Do you think the Propeller could do this?

    Another method I saw used a plastic diffraction grating. The glasses were being passed out at Best Buy years ago to promote something called "I Love the 80s 3D". It was done in ChromaDepth and relied on the grating shifting blue and red differentially, which makes the red seem to appear in front the blue. This isn't true binocular vision, but an interesting concept nonetheless.

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-06-11 21:22
    Phil Pilgrim,

    I don't know if the Propeller could do it or not, I'm really not sure... I recently saw the movie "UP" with my daughters, and the 3D glasses used there are the Polar glasses. Now what I've read indicates that there should have been two movie projectors, but I didn't see a second projector at the theater. Looking at the screen with vs. without the glasses showed an image as I tried to describe although I could not see the interdigitation this was an assumption on how you might get a similar effect... just one image super imposed and misaligned over another image with diminishing quality or fading of the secondary image is all that I could observe.

    The limitation of colors and resolution are what might prevent this on the Propeller, but again this is an area I am not familiar with, so I can't say for sure.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-11 21:29
    Here's a sample image of an octahedron that I photographed early in the 3D-Graphics.spin development:

    attachment.php?attachmentid=61506

    You can view it with 3D glasses. The image in the demo is somewhat more complex and includes moving parts.

    -Phil
    800 x 598 - 67K
  • RaymanRayman Posts: 14,844
    edited 2009-06-11 21:42
    Phil:· Looks neat.· I'll have to check it out...

    Beau:· I've wondered about 3D projectors too...· I think it must have something like one of these Z screens inside:

    http://www.reald.com/Content/RealD-LP.aspx

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • WhitWhit Posts: 4,191
    edited 2009-06-12 01:17
    Neat idea Phil!

    Thanks for the Count Floyd flashback!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-12 06:56
    Here's another demo program to use with the archive in the first post. It produces a 3D image of a diamond, which you can manipulate by moving the mouse. Without a mouse connected it rotates itself. Here's a static snapshot of the output:

    attachment.php?attachmentid=61522

    -Phil
  • cgraceycgracey Posts: 14,256
    edited 2009-06-12 07:13
    Man, Phil!

    I really want to see this, but I don't have any glasses with me. I have about 50 pairs back at Parallax.

    A few years ago, I looked into 3D display possibilities for the Propeller. I tried LCD shutter glasses, but they were too dim, and rather pricey. Polarization was out of the question. By a big margin, the red/blue approach was the most promising. The limitation is that you get a monochrome image, but it's very practical to implement. I noticed, too, that you needed·a neutral background on which to draw your red/blue lines, so that your brain would put them together without too much ghosting. I found a source of good plastic glasses for $1 each. I bought a bunch because I was hoping to do what you've done.

    Good job on doing this. I REALLY want to see this run.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Chip Gracey
    Parallax, Inc.
  • HollyMinkowskiHollyMinkowski Posts: 1,398
    edited 2009-06-12 07:33
    This is just so cool!

    I suppose you could also output different images to two monitors and cross your eyes and look at the image in the middle..LoL
    Or output two images on a single screen and rig up some sort of contraption with two cheap lenses that you put up to the screen
    and look through...like an old streopticon slide viewer.

    Maybe take a pair of dark goggles and mount 2 small lcd monitors and 2 lenses and have a real VR headset.
    There are some nice and cheap LCDs from cell phones.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-12 07:37
    Thanks, Chip!

    One thing I've learned in doing this is that, with low-res images, motion helps a lot. It really smooths out the jaggies and gives the impression of higher resolution.

    Several years ago, I bought a bunch of different anaglyphic 3D glasses, both the cheap carboard type and some nice plastic-framed ones, in both red/blue and red/cyan. The red/cyan worked well with color 3D images on a computer screen but not so well with the video stuff. More surprisingly, I got much better color separation with the cheap carboard glasses than with the nice ones. I contacted the outfit that sold them to me, and they said they were aware of the difference but that they were only importing them and didn't have any control over the filter quality.

    I've also tried shutter glasses that switch on the even/odd NTSC field boundaries. They came with a really terrible 3D movie on VHS. Compounding that, they were extremely uncomfortable to wear and gave me a headache. OTOH, I've experienced shutter glasses in an IMAX theater that were simply amazing. I guess it all depends on the frame rate.

    BTW, thanks for providing the code foundation that made this extension possible! smile.gif

    -Phil
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-06-12 14:08
    Dang it Phil!

    I know my cheap 3d glasses are in my shop SOMEWHERE!
    Now I've got to clean my shop.. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.

    Post Edited (Oldbitcollector) : 6/12/2009 2:18:01 PM GMT
  • Chris MerckChris Merck Posts: 55
    edited 2009-06-12 14:41
    Phil,
    Great Job! As soon as I finish my lab (a week?) I'll hook up the ol' demo board and try this out!

    You mentioned motion smoothing out lo-res video. I can't agree more. Especially if you use anti-aliasing/sub-pixel hinting (or have a tv that is so blurry it doesnt matter).

    Take it easy,
    Chris
  • potatoheadpotatohead Posts: 10,261
    edited 2009-06-12 16:36
    Excellent!! Nice work Phil.

    Yes, motion helps a lot. Another thing motion does is all us to see objects as objects, when drawn in wireframe. When an image is static, it can be seen as popping in, or out, or as just a bunch of lines and arcs. If you concentrate on a wireframe image, you can actually flip it as any isometric view results in either the real object, or a mirror image one. I used to do sheet metal wireframe a lot, and once designed a mirror image part because of this. Dynamic viewing was not available at the time this gaffe happened.

    With CAD, moving the display camera also helps with assemblies, in that somehow the brain can sort out individual parts more easily, even if all wireframe entities are the same color! Used to do it all the time before we got cheap solid modeling.

    There is another approach for 3D that makes sense here with an ordinary TV display.

    If the signal is non-interlaced vertically, we get 60 frames per second. Polarized glasses really require two projectors, each delivering a polarized signal. I've got several 3D glasses. Red blue, red green, polarized, and the shutter kind.

    The shutter kind basically uses an LCD sheet to mask each eye, while the display is drawing a display for the other one. To use them, the hardware must toggle the shutters during the blanking period, and draw each view interleaved with the other one. Left, Right, Left, Right, for a 30Hz stereo display. SGI computers used this approach and it worked fairly well, particularly with lower contrast images. It was possible to get wireframe, solids and textured solid 3D images this way.

    I'm pretty sure the shutters are just +5 Volts on each shutter pin, with a ground.

    One thing I always wanted to try was toggling the shutters on the HBLANK period. Don't know if they are fast enough though. 30Hz will give the average Joe a headache after about 15 minutes of continuous viewing. If the shutters were fast enough, perhaps high contrast images would work well, in this mode. Each eye gets one scanline, and the user turns up the brightness to compensate for whatever attenuation results from the faster shuttering. There would be motion tearing when the viewer moves their head, but not the more massive 30Hz flicker.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki: Share the coolness!
    Chat in real time with other Propellerheads on IRC #propeller @ freenode.net
    Safety Tip: Life is as good as YOU think it is!
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-06-12 17:19
    Man!!!!! I just tested it on my Hydra, and it didn't work.

    I even copyed and pasted the pin settings in the DAT from the Hydra Graphics Demo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Toys are microcontroled.
    Robots are microcontroled.
    I am microcontroled.



    If it's not Parallax then don't even bother. :-)

    Propeller SRAM TV driver winner: ==NOT COMPLEATED: 3 WEEKS UNTIL ENDING TIME==
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-12 17:54
    microcontrolled,

    I'm not familiar with the Hydra. Which pins are used for the video and mouse? Did you see any video output at all?

    -Phil
  • jazzedjazzed Posts: 11,803
    edited 2009-06-12 18:02
    Well heck. Guess I have to go find some 3D glasses now [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    --Steve


    Propalyzer: Propeller PC Logic Analyzer
    http://forums.parallax.com/showthread.php?p=788230
  • GiemmeGiemme Posts: 85
    edited 2009-06-12 18:24
    in two weeks I will go with my son to the NASA space center in florida and I will take a couple of 3d glasses to test it smile.gif

    Regards
    Gianni
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-14 21:28
    I've added a VGA driver and consolidated the files into one zip in the top post.

    -Phil
  • RaymanRayman Posts: 14,844
    edited 2009-06-14 21:38
    Did you change the clock setting?· I think the Hydra runs 10Mhz at PLL8X...
    microcontrolled said...

    Man!!!!! I just tested it on my Hydra, and it didn't work.

    I even copyed and pasted the pin settings in the DAT from the Hydra Graphics Demo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    My Prop Info&Apps: ·http://www.rayslogic.com/propeller/propeller.htm
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-14 22:08
    'Forgot to mention: some debug code, which forced pin 12 for TV output, was accidentally left in but has has now been removed. That would definitely have prevented its working with the Hydra.

    -Phil
  • MicrocontrolledMicrocontrolled Posts: 2,461
    edited 2009-06-15 00:45
    Thanks! Well, I just got my demo board yesterday and it worked perfectly fine on it!

    (exept for the fact that I have no 3D glasses!!) :-(

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Toys are microcontroled.
    Robots are microcontroled.
    I am microcontroled.



    If it's not Parallax then don't even bother. :-)

    Propeller SRAM TV driver winner: ==NOT COMPLEATED: 3 WEEKS UNTIL ENDING TIME==
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-06-15 04:32
  • ProcessingData...ProcessingData... Posts: 208
    edited 2009-06-15 17:56
    Hmmmm, wonder if you could do this with the "no glasses needed 3d" effects. you put the picture in front of your face and slowly back up...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Basic Stamp,···· Propeller,·· · SX,·· FUN!


    START:·
    >Proccessing Data. . . .··
    >Task Complete. . .·.
    >Saving Data. . . .
    >Entering SLEEP Mode. . . .
    >Signing OFF


    ·
  • LawsonLawson Posts: 870
    edited 2009-06-15 21:52
    Hm... the old CRT of mine doesn't like 512x380 VGA signals. Any chance of posting a version that signals at 640x480 or higher? I've tried playing with the setup values for the VGA object with no luck.

    Update: the VGA_text demo works fine at a resolution of 512x480. I've edited "3D_VGA_Graphics" to use values found in "VGA_Text" and it's working now. The updated DAT section follows.

    DAT
    
    vgaparams               long    0               'status
                            long    1               'enable
                            long    %010_111        'pins
                            long    %0000           'mode
                            long    0               'videobase
                            long    0               'colorbase
                            long    x_tiles         'hc
                            long    y_tiles         'vc
                            long    2               'hx
                            long    2               'vx
                            long    0               'ho
                            long    0               'vo
                            long    512             'hd
                            long    10              'hf
                            long    75              'hs
                            long    43              'hb
                            long    480             'vd
                            long    11              'vf
                            long    2               'vs
                            long    31              'vb
                            long    20_000_000      'rate
    vgaparams_end
    




    Thanks
    Lawson

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Lunch cures all problems! have you had lunch?
  • DogPDogP Posts: 168
    edited 2009-06-19 04:37
    Very cool! I love 3D... and unlike you guys complaining about not finding your 3D glasses... mine are right next to my computer, about 1 inch from my keyboard [noparse]:)[/noparse] . There's no reason the prop can't do 2 VGA outputs, correct? I've got 2 projectors set up for 3D projection (polarized) and I've been thinking about hooking up a prop to drive both projectors... not really sure what I'd use it for, but it'd be cool [noparse];)[/noparse] .

    DogP
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-06-19 04:42
    Lawson said...
    Any chance of posting a version that signals at 640x480 or higher
    If I fully understood the VGA object, I might be able to help. smile.gif But, frankly, I don't; so I can't. sad.gif

    -Phil
  • kevin101kevin101 Posts: 55
    edited 2009-06-19 07:15
    Does anybody understand the circular polarized light thing? For the new Disney digital 3D thing, the projector somehow produces circularly polarized light. This solves the problem on linearly polarized movies where you tilt your head and the 3D effect is lost.
    I too recently saw the movie up and noticed a great improvement in the quality of the 3D image. There was still only one projector, and I think they use a silver screen to maintain the polarization of the light. I remember reading somewhere some company made a tv that could control the polarization of the displayed image with a 120Hz refresh rate. One of these paired with a propeller would be impressive and it would allow more color and contrast to be viewed with polarized glasses. Just imagine what a prop 2 could do...
Sign In or Register to comment.