Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / 3D glasses

Author
Message
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 10th Feb 2010 22:19 Edited at: 10th Feb 2010 22:22
Hi everyone!

I decided to give my game the option to play it in REAL 3d by wearing coloured glasses. What I thought of was sticking a negative ghosted plain in front of the camera, and coloring it red and green every loop to filter out the colors.

The only problem is, that when I filter the scene to green and then to red 60 times a second, the image gets all screwed up and the filtered scenes overlap, leaving a horrible scrape across the screen like when you try to film an old TV with a camera. How could I fix this? Is there a way to fuse the filtered scenes over each other with memblocks and then print that to the screen?

The project is attached.

TheComet


Make the paths of your enemies easier with WaypointPro!

Attachments

Login to view attachments
chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 11th Feb 2010 14:51 Edited at: 11th Feb 2010 14:53
This code is Not mine !, I found it somewhere, and I think it can help you. You need red and blue glasses.


cheers.



RE-EDITED
Sorry, I forgot to say that is for Dbpro...I`m not sure it works on DBC

learning every day
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 11th Feb 2010 17:06
Two problems with that and dbc. Make Camera and Set Camera to image. other then that it looks like it would run if you find some work arounds for those commands

New Site! Check it out \/
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 11th Feb 2010 22:01
I ran your code, Comet, it works pretty well on my computer.

I'm not getting any "horrible scrape across the screen like when you try to film an old TV with a camera".

However, the screen does flicker quite a bit and there is an occasional red flash every few second. The red flashing seems to be a bit random so I can't immediately think what it could be.

I also don't have any 3D glasses so I don't know how good the 3D effect is but I'll see if I can find some as this looks really interesting.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Feb 2010 02:20
I DO get the weird flickery thing you spoke of.

New Site! Check it out \/
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 12th Feb 2010 08:07 Edited at: 12th Feb 2010 08:09
Quote: "I also don't have any 3D glasses so I don't know how good the 3D effect is but I'll see if I can find some as this looks really interesting. "


The 3D effect is actually quite good. I found that the further you position the cameras appart (change variable "part#"), the further the depth of the 3D image becomes, however the more cross-eyed you look.

If you have a monitor capable of refreshing faster than 0.0166666 ms, then you don't get any flashing or scrapes. The problem is that most monitors fade the last image into the next a bit, causing random flashes.

What I propose to do is get the red filtered image and the green filtered image and "ghost" them into each other, like this:



(The image above will appear 3D with glasses)

How could I do this without a great impact on game speed?

TheComet


Make the paths of your enemies easier with WaypointPro!
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2010 19:26
Does this work? (seizure warning)

I tried to copy the screen to bitmaps but annoyingly the gamma doesn't effect the bitmaps. Is there any way you can grab an image with the gamma alteration intact?

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 12th Feb 2010 23:01
I think gamma changes the overall graphics card display - the color intensities displayed on the monitor so pixel values aren't really changed.

I found some dll code I made for an anaglyph display in DBC. Unfortunately there's not a remark anywhere in it that explains what my goal was or what does what!

Looking through it though, using bitmap 0 captured to 2 memblocks, the code looks at every pixel on the screen. If the pixel color is above a certain threshold of red, it changes the pixel to red for the first memblock, if the pixel color is above a certain threshold of cyan then it changes the pixel to cyan in the second memblock. All other pixels are set to black (for transparency).

2 planes are ghosted, and textured with each of the images from the memblocks and offset a little to either side of the camera. It functions pretty much on the same premise as TheComet's except the transparent areas allow the main screen to show through completely so the whole image isn't colored cyan or red - just highlights and edges generally. Also, it is so ridiculously slow I think it may be why I didn't continue to work on it. The idea is sound, but the way I executed it isn't that great. But, no flicker!

Now that I'm writing this, I wonder if it would be possible create a camera view that is a little smaller than the screen (bitmap 0) and use a blending routine for either half of the screen for the two colors, but the pixels are offset to the left or right depending on which side of the screen they are on. This would all be done on the back buffer. I don't know how fast it would be but it would probably eliminate the flicker.

The main problem with solving the flicker, is that the whole screen has to be drawn at once. When the camera is shifted or colors/panels are swapped, the redraw is visible from the multiple view changes (thus the flicker). So, if the screen can be built with the red and cyan anaglyph and then redrawn at once, then there shouldn't be flicker.

Enjoy your day.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Feb 2010 09:06
Don't the two views have to be from slightly different angles?
I don't think moving the same image to either side would make it look 3D.
This is quite an interesting subject. If you could make a real-time action game in 3D it would be pretty impressive.

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 13th Feb 2010 10:57 Edited at: 13th Feb 2010 10:57
Very interesting - it's also had me thinking about the DBPro anaglyph demo, I think that actually produces a triple image. PseudoCode here only, I haven't time at the moment to test it properly though I would like to:



This'll take care of the flicker, although rendering the camera view three times will slash the frame rate by a factor of three - maybe not a problem for the latest computers, but still quite a challenge overall.

Set Gamma won't really solve the problem, as I don't think it works in DBC unless you've set it to full screen mode (in which case, the Sync-Sleep screen-FPS hike won't work).

Hope this helps!

[Edit] P.S. I'm back...

"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 14th Feb 2010 12:07 Edited at: 14th Feb 2010 14:16
@ chafari

Thanks for the code For some reason I couldn't get any 3D effect from it though... Maybe the images are not far enough apart...

@ OBese87

If I set eyew#=0.3, and concentrate hard enough, I get a 3D image. I also noticed that you switched the left eye with the right, so I had to wear the glasses upside-down to get it.

@ all

Is there a way to render the screen to any other bitmap than 0?

TheComet


Make the paths of your enemies easier with WaypointPro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 15th Feb 2010 11:18
Quote: "Is there a way to render the screen to any other bitmap than 0?"

I don't think so.

Enjoy your day.
Robert The Robot
17
Years of Service
User Offline
Joined: 8th Jan 2007
Location: Fireball XL5
Posted: 16th Feb 2010 11:19
Actually, I thought you could. I'm sure I read omewhere that rendering to an offscreen bitmap and then copying the bitmap contents to the screen (bitmap 0) was slightly faster than drawing to the screen directly.



"I wish I was a spaceman, the fastest guy alive. I'd fly you round the universe, in Fireball XL5..."
TheComet
16
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 16th Feb 2010 19:54
Looks promising, I'll test it. But why would that be faster than drawing it directly?

TheComet


Make the paths of your enemies easier with WaypointPro!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 16th Feb 2010 22:09
Quote: "Actually, I thought you could. I'm sure I read omewhere that rendering to an offscreen bitmap and then copying the bitmap contents to the screen (bitmap 0) was slightly faster than drawing to the screen directly."

You can't render to an offscreen bitmap. Rendering in this case (I'm pretty sure) would be drawing the DirectX surface area to an assigned back buffer and front buffer. When you create an offscreen bitmap, you are only creating a compatible 2d memory area with the display screen. The 3d surface is not being redirected to draw there. However, the 2d commands are redirected to draw there - but not the 2d display that is being rendered to bitmap 0.

It regards to drawing on an offscreen bitmap and copying that to bitmap 0, that is faster than drawing on bitmap 0 directly. But there is a difference between rendering the screen and drawing on another bitmap. DBC doesn't allow you to render to another bitmap.

Quote: "But why would that be faster than drawing it directly?"

It has to do with how video memory and system memory are managed. Also, drawing offscreen doesn't "turn on" any pixels. Drawing offscreen just sets a color value to a location that is comparable to the screen position stored in memory. When that information is copied to the viewable screen (bitmap 0), the color information is blitted to the memory locations of the viewable screen and those pixels are turned on. Block memory transfers of this sort are faster than directly changing a color value on the screen, 1 value at a time. Memory transfers usually involve pointer redirections or manipulations. Pointers hold the memory address where memory data is stored. Screen 0 will have a memory address and the offscreen bitmap will have a memory address. It is faster for the processor to point to where to get information than it is to directly fill bytes with information through input or direct code while also turning pixels on and off.

Enjoy your day.
Xeridox
20
Years of Service
User Offline
Joined: 19th May 2003
Playing: Scrap Mechanic
Posted: 22nd Feb 2010 20:11
I had coded some 3d into my game, but it's dbpro, not dbc...

Anyway, while coding 3d is fun, you can always download the 3d anaglyph driver from iz3d.com and use it with almost any game, as long as it uses directx, not opengl.

Just my 2 cents!

Phenom - MP FPS WIP - With bot support, even online!
Official Website -> http://xeridox.com
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 1st Mar 2010 14:50 Edited at: 1st Mar 2010 14:57
Quote: "But there is a difference between rendering the screen and drawing on another bitmap"


Quite. You can paste an image or draw a box on a hidden bitmap (screen), but try using sprites. They can only be rendered on Bitmap 0.

But, the real reason for posting this was the fact that I have a set of those 3D shutter glasses (the type that you connect between the VGA output on the GFX card and the VGA cable to the monitor).

In the past, I've been able to use them with pretty much any game I wanted to - even those not specifically designed to be 3D.

But... they only worked on nVidia GFX cards because you needed to install the nVidia drivers which supported 3D.

Anyone else got any of these 3D glasses?

TDK

Medusa
20
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 3rd Mar 2010 21:58
Quote: "Don't the two views have to be from slightly different angles?
I don't think moving the same image to either side would make it look 3D."

Correct!
Magenta/Cyan anaglyth is for static pictures and both have to be from slightly different viewpoints to simulate human eyes.
All games are already in 3D and have all the same things you see in normal life; things get bigger and smaller depending on distance and line of vision changes as you alter your player's position etc etc etc
3D games as being pushed lately is just the industry's latest con.
Don't get sucked in!

mpc
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Mar 2010 03:43
Quote: "I don't think moving the same image to either side would make it look 3D."

Actually it will change the depth perception. The left and right colored offsets ace what will make the image seem to drop into the background. A third image, called the subject image is the original untainted version that is dead in the center. The subject image is what is "popping out" in the foreground. If you create the anaglyph with only the red/cyan portions, you'll get mostly the dropping back effect.

To prove my point of using the same image and just shifting it left or right, I put together 2 anaglyphs based on one of the default photos that came on my DBC disk. You'll need the red/cyan glasses to see these.

The first anaglyph is just the red/cyan offsets without the subject. The picture should appear to drop backwards.



The next image contains the subject - the original image dead in the center. You should see the effect of the first image standing out against the background



Of course if you start with an actual stereoscopic set of photos the effect is more dramatic, but it still can be achieved for the most part with a single view with a single angle and just shifting it.

Enjoy your day.
Medusa
20
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 4th Mar 2010 21:10
Quote: "Latch 'it will change the depth perception'"

Valid point. Yes, it tricks the colour cones of the eye into transmitting a false image within the brain. The medical result of doing this on a daily basis as in computer games is severe migraine headaches.
The red/green system was used by the cinema since the 1950's and abandoned because most you got was a shimmer effect plus the headache afterwards.
The black and white polaroid process was successful but doesn't work in colour. Two same films are shown on the screen with one polarised horizontally and one vertically and the audience wear polarised lenses with one lense polarised vertical and the other horizontal. It's almost correct but omits the middle portion which is normally shared by both eyes.
Cinerama solved this and provided true 3D using three cameras.
Picture a clock face.
camera 1 is aimed from the right - 9 to 11 o'clock.
camera 2 is aimed from the left - 1 to 3 o'clock.
camera 3 is aimed from the centre - 11 to 1 o'clock.
The result gives true depth perception and without the need for special glasses to ruin your eyesight or give you headaches.
A db multiplayer demo did exist that split the screen into two camera views. This same code could be used to create three cameras.
With a bit of experimentation you could create 'cinerama games'.

mpc
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Mar 2010 01:55
Quote: "The medical result of doing this on a daily basis as in computer games is severe migraine headaches."

But isn't it worth the fun - and the bleeding from the ears?

Enjoy your day.
Medusa
20
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 5th Mar 2010 21:37
Another valid point!
I have a multitude of 3d type progs all over the computer from years back so I loaded one up and did a test between true anaglyph i.e. two photos from slightly different viewpoint and false anaglyph - same photo moved slightly.
There's a jpg attached showing a cheetah, tiger and a marine.
The false one - the marine - is not too bad.
See what you think.
You need the red and green glasses.

mpc

Attachments

Login to view attachments
Medusa
20
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 5th Mar 2010 21:44
Should never spam but here's a wobbly gif demo of the tiger's two images

mpc

Attachments

Login to view attachments
Medusa
20
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 5th Mar 2010 21:48
I just wish to apologise for spamming my last post.
Here's the free program that creates all these wonderful 3D things.
Side by side
Red Green anaglyph
Grey anaglyph
Flicker
etc.

mpc

Attachments

Login to view attachments
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 7th Mar 2010 04:30
Quote: "I just wish to apologise for spamming my last post."


That's what the Edit button on the left is for.

TDK

Medusa
20
Years of Service
User Offline
Joined: 7th Sep 2003
Location:
Posted: 7th Mar 2010 21:35
TDK Moderator
Still can't grasp why a person of your talent hasn't produced his own 3D game builder.
I still have Matedit 1_6g
Never liked the windows version.
Still produces stunning landscapes.

Had an idea today about Comet's whole 3D thing.
I might not be into the red green headache thing but grey anaglyph has it's merits.
You could use Gimp to create a grey anaglyph which is a combine depth map or even a bump map and apply it to the actual texture.
This would allow you to use more cubes in the game instead of full 3D buildings.
sample attached

mpc

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-20 06:55:27
Your offset time is: 2024-04-20 06:55:27