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 Professional Discussion / Writing a Shader for anaglyph 3D glasses (red and blue). Help / Discussion / etc

Author
Message
Butter fingers
19
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 15th Apr 2009 18:38
Hey. I recently went to a developer conference in the UK where I played a game that was real 3D. You wore a pair of red and cyan 3d glasses:



And, having spoken to the developers it turns out they didn't do anything particularly special, except write a full screen shader that splits the red and cyan elements of the objects on screen and shifts them horizontally to create the 3D look.

So. Here's the thing. I have a game in dev at the moment that would suit this style SO well. I really want to write a shader that can do it. I found a great you tube tutorial for making 3D images in photoshop
that you can find here:
http://www.youtube.com/watch?v=g3ZXFHuriXw

Really what I need is a shader that can replicate the effect the tutorial creates, but obviously it would be doing it at runtime, to the info coming from the camera.

My issue is that dispite doing a few tutorials and tweaking many of the available shaders, I really have no idea what I'm doing. Let alone actually starting to use new commands in shaders rather than editing current ones.

I'd really like to work with someone on this, it's not a team request, its more a community project. Anyone interested?

I want robotic legs.
Mobiius
Valued Member
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 15th Apr 2009 18:42
DBpro has this command built in!

I believe it's set camera to stereoscopic. You can just position a coloured plain in front of the relevant cameras to tint the screen to the required colours, then combine it and display it.

Your signature has been erased by a mod because it is way too awesome!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Apr 2009 18:43
It really is time I got that "Shader Challenges" thread going.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 15th Apr 2009 19:11
return float4( tex2D( left, UV ).r, tex2D( right, UV ).gba ); ?

Butter fingers
19
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 15th Apr 2009 19:16 Edited at: 15th Apr 2009 19:17
Now, DC, I don't know if you're either giving me an answer or just gibbin' me but... um... what does that mean?

Oh, and Yay for my first ever Green Gandalf reply.... it's like I touched ghandi or something.

I want robotic legs.
Math89
21
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 15th Apr 2009 19:26
I don't think it's enough, I think you need to take 2 renders of the scene from 2 different points of view (one for each eye) with one of the two colours.

CuCuMBeR
22
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 15th Apr 2009 19:32
The built in stereoscopic camera thing works great. You should try it first.

There is always one more imbecile than you counted on.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Apr 2009 19:37 Edited at: 15th Apr 2009 19:39
Quote: "Oh, and Yay for my first ever Green Gandalf reply"


I haven't been ignoring you deliberately.

I've just written a simple "quick and dirty" object shader to do what you want - but can't test it because I ain't got the right glasses.

Even without that test I can see it has a problem - something to do with "Z fighting" or "Z depth" I suspect.

I guess DC's solution is a clean one using two cameras slightly offset from each other to produce two full-screen images which are then combined as he suggests in a full-screen shader.

Anyway, here's a preview of my first attempt. It's quite possible I've got the colours the wrong way round, in which case you'll have to switch round your glasses. You'll also see the problem - the solely red coloured area on the lower left of the cube.

Attachments

Login to view attachments
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Apr 2009 23:25
The inbuilt commands work perfectly, and were developed alongside iZ3D who make this technology. You can do the red/cyan thing, and also switch to use the 3D hardware alternative, all with one parameter.

I tried it with an explosion I made with the cloth & Particles pack, it was impressive.

http://www.thegamecreators.com/data/newsletter/newsletter_issue_67.html#9

TechLord
22
Years of Service
User Offline
Joined: 19th Dec 2002
Location: TheGameDevStore.com
Posted: 16th Apr 2009 03:29 Edited at: 16th Apr 2009 03:29
Stereoscopic View Built-in, AWESOME! I love DBPro.

Butter fingers
19
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 16th Apr 2009 11:28
Green Gandalf:

Thanks so much for trying to do that (and with a little tweaking it would work i think), I had no idea that DB could do anaglyph on it's own. I'd read that news letter article before but I thought it was only for special monitors, I didn't know it could do it for 3D glasses!

Anyway, I've had a play with Lee's example and it's totally true, it works perfectly already in DBpro. So I guess that means my idea for a shader that can create the effect is redundant, because it's a bit like re-inventing the wheel.

Thanks for looking in here though guys, I appreciate the contributions.

GG, I'm going to download the shader anyway, because I think it may have a use anyway ( creating certain objects with a stronger red/cyan outline).

Peas.

I want robotic legs.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Apr 2009 11:51
Quote: "I'd read that news letter article before but I thought it was only for special monitors, I didn't know it could do it for 3D glasses!"


Me too. But I wasn't sure you were using DBPro so it seemed worth a try anyway. My "quick and dirty" shader doesn't need two cameras - but isn't working quite right yet.

Quote: "GG, I'm going to download the shader anyway, because I think it may have a use anyway ( creating certain objects with a stronger red/cyan outline)."


I haven't posted it yet! I'll try to iron out the bugs first though - which would be much easier if I had the right glasses.

By the way, could you tell from that screenshot whether or not I had the colours the right way round? Also, the horizontal displacement looked too great to me - but without the glasses it's hard to tell. It's simple to swap the "left" and "right" colour masks and fiddle with the displacement if necessary.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Apr 2009 12:29
@GG
The colours were the wrong way round

You can't do it well without two cameras, because if you have a small cube aligned with the camera, the red should show one side of the cube as well as the front, and the blue should show the other side as well as the front. One camera can't render both the left, right and front sides of a cube.

You could possible do an OK emulation by using a fullscreen shader which reads from the depth buffer, and takes the red component from a pixel (CONSTANT / depth-value) to the left, and the blue and green (CONSTANT / depth-value) to the right.

A better idea for a shader would be one that used two cameras, but the shader then combined them. (You have to use an add operation)

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Apr 2009 13:01 Edited at: 16th Apr 2009 13:02
Diggsey

Quote: "The colours were the wrong way round"


Doesn't surprise me at all. Thanks.

Quote: "You can't do it well without two cameras, because if you have a small cube aligned with the camera, the red should show one side of the cube as well as the front, and the blue should show the other side as well as the front. One camera can't render both the left, right and front sides of a cube."


Explain this screenshot then.



Quote: "You could possible do an OK emulation by using a fullscreen shader which reads from the depth buffer, and takes the red component from a pixel (CONSTANT / depth-value) to the left, and the blue and green (CONSTANT / depth-value) to the right.

A better idea for a shader would be one that used two cameras, but the shader then combined them. (You have to use an add operation)
"


It's funny how many people believe that.

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Apr 2009 13:19
The built in technique takes a little bit of experimentation, but it does work quite nicely. For one thing it's easy to adjust the colours to suit whatever glasses you have, because the effect is done with 2 sprites, so setting the diffuse colour is enough to tweak it.

The ultimate question is if a shader will be faster than the built in system with it's 2 cameras - I hate using extra cameras so I'm hoping GG get's it working .


Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Apr 2009 13:31 Edited at: 16th Apr 2009 13:32
Quote: "The ultimate question is if a shader will be faster than the built in system with it's 2 cameras "


Indeed - and I hope to find out after a few tests this morning. I guess it might not be faster because it uses 4 passes with clipping to overcome the Z depth problem illustrated by my first screenshot.

Quote: "I hate using extra cameras"


Me too.

Quote: "so I'm hoping GG get's it working"


Possibly. Here's the latest screenshot. Anyone got the right glasses so they can test this for me?

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Apr 2009 14:10
It certainly looks like it will work, the far corner seems to combine the channels closer than the left and right sides, which is always a good sign.

I'm not sure how clear it will be though, it might be a little tricky to guage it as it's textured - I would suggest posting a screenie of an untextured version as well, then you'll know for sure.


Health, Ammo, and bacon and eggs!
CuCuMBeR
22
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 16th Apr 2009 14:22
Please send a photo which uses red-blue
RED = Rgb(128,0,255)
BLUE = Rgb(128,128,255)

Infact, in the shader, make the colors adjustable for different glass types.

There is always one more imbecile than you counted on.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Apr 2009 14:55 Edited at: 16th Apr 2009 14:55
Quote: "Please send a photo which uses red-blue
RED = Rgb(128,0,255)
BLUE = Rgb(128,128,255)"


Those don't look very red or blue to me. Are those the colours you intended?

Quote: "Infact, in the shader, make the colors adjustable for different glass types."


They already are.

Quote: "I would suggest posting a screenie of an untextured version as well, then you'll know for sure."


Untextured:



Unfortunately there's still a z-fighting issue (not shown in that screenshot), so it's back to the drawing board yet again. The two camera solution is simplest to get right using either DBPro built-in commands or a full-screen shader. However, it would still be nice to get the "one camera" version working smoothly.

Attachments

Login to view attachments
Butter fingers
19
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 16th Apr 2009 15:11
Hey GG,

Sorry for the late postback.
In your above image the colours are the wrong way around. The right lens is blue and the left is red. So the right side of the shaded object needs to be red and visa versa.

Using an UN textured object is definately the best way to test, because a texture contains Red and Blue components and therefore your eyes start to get confused!

THe only suggestion I would make is that the object above appears to not be recieving light. You need it to have basic lighting it get the original 3D effect.

I've started playing with the inbuilt commands, here's a screenie so you can get an idea of the optimal distances for the border colours.

I want robotic legs.

Attachments

Login to view attachments
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Apr 2009 17:03 Edited at: 16th Apr 2009 17:04
@GG

Well how are you doing it then?
(And if you are using two cubes, that's cheating)

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Apr 2009 17:24
Quote: "In your above image the colours are the wrong way around. The right lens is blue and the left is red. So the right side of the shaded object needs to be red and visa versa."


Weird! I'm sure I swapped the colours round. Must be losing it.

Quote: "Well how are you doing it then?"


The basic idea is to use two passes and shift the object in view space, to the left for one pass and to the right for the other. There's rather more to it than that because of the Z depth/render order issues which I still haven't got quite right - but the basic idea seems to work.

I don't yet know whether it is faster to render the whole scene twice using two cameras and then applying a full-screen shader (would simple blendmapping work?), or to use the built-in commands, or the single camera multiple pass shader method. I expect the DBPro method to be fastest - but the shader methods allow more flexibility if needed.

However, there's not much point comparing the speed of this method until I've got it working correctly.

Quote: "THe only suggestion I would make is that the object above appears to not be recieving light. You need it to have basic lighting it get the original 3D effect."


Once the basic method is working you can add all the extra lighting effects you want. Which probably means the two camera methods are easier.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 16th Apr 2009 18:40
@GG
So you fake two cameras by just using two passes, and effectively moving the camera for each pass, and now the problem is how to fake two depth buffers

The other problem with this method is that you have to combine it with every other shader you want to use.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 16th Apr 2009 19:12
Quote: "@GG
So you fake two cameras by just using two passes, and effectively moving the camera for each pass, and now the problem is how to fake two depth buffers"


Yes.

Quote: "The other problem with this method is that you have to combine it with every other shader you want to use."


Yes.

The good news is that I might have a working demo using just two passes - my earlier failed fix required four passes.

I'll try to post a DBPro demo later - must do something else now.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Apr 2009 20:06
There seems to be a thick dark line when looking at those cubes GG, probably the sort of thing you'll have to fix as you see it with the specs on.

Butter, works a treat and looks really nice.

If you want to see an awesome example of 3D specs try Trackmania Nations, the 3D spec mode on that is stunning. In fact heres a screenshot, everything just pops!.


Health, Ammo, and bacon and eggs!

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 00:18 Edited at: 17th Apr 2009 00:18
Quote: "There seems to be a thick dark line when looking at those cubes GG, probably the sort of thing you'll have to fix as you see it with the specs on."


Is this any better? If not, where's the dark line?

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 01:03 Edited at: 17th Apr 2009 01:04
Here's another screenshot. With luck it looks like a yellow cube with bumps in 3D. I find it very hard to tell without the right 3D glasses.

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 17th Apr 2009 01:36
That looks perfect GG, nice work.


Health, Ammo, and bacon and eggs!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 12:56 Edited at: 17th Apr 2009 13:06
Quote: "That looks perfect GG, nice work."


Thanks. It's weird trying to develop a visual effect when you have no means of looking at it properly - I can only rely on the 3D maths involved.

Now that I've got the 3D effect with basic lighting and bumpmapping almost working it'll be worth putting together a demo which I hope to do sometime today.

There is one small niggle which I haven't dealt with to my satisfaction yet. The following sequence of screenshots illustrates the problem using the basic 3D shader without lighting or bumpmapping:



Here's the shader code:



The rendering is done in two passes - once for the left hand cyan image, and then again for the right hand red image. The problem is that each pass puts Z depth information in the depth buffer - this is used to prevent the rendering of polygons (or is it pixels? not sure ) behind previously rendered polygons. In this case the left hand cyan surfaces of the cube are rendered first - and would (without the depth bias) be slightly closer to the camera than the corresponding left hand red surfaces from the second pass. Hence those red surfaces don't get rendered. The depth bias value used in the first pass of the shader is usually sufficient to fool the renderer into thinking that the cyan surfaces are always further away than the red surfaces. This allows the red surfaces to be rendered and blended with the cyan surfaces from the first pass.

So far so good - and that is what is happening in the middle image.

This technique seems to break down when the object is either a long way from the camera or, conversely, too close to it. There may be further related problems when other objects are placed in the scene - I don't know yet, but I expect there will be.

I'm not sure why it breaks down in the first image - I suspect that the bias is sufficient to put the cyan surfaces behind the background so they don't get rendered at all.

I believe the third image is caused by the limited precision available in the depth buffer (one of those irritating technicalities that is hard to track down precisely in the DX9 documentation) - so the bias is having no effect and the red surface is not rendered because the renderer still thinks it would be behind the cyan surfaces. I can minimize that effect by increasing the bias value - which of course makes the other problem worse (depth values are in the range 0 to 1).

Anyone have any ideas on how to solve both problems simultaneously?

The two camera solution is beginning to look far simpler - even though I don't find it aesthetically pleasing.

Attachments

Login to view attachments
Butter fingers
19
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 17th Apr 2009 17:48
Nice work GG, it's bang on in terms of the effect. With the glasses the bumpmapping and the cube look great, I notice that the red/blue of the bumps is reversed from the object, and that seems to work very nicely.. And I put your glasses in the post today..

Quote: "The two camera solution is beginning to look far simpler - even though I don't find it aesthetically pleasing."


I'm not so sure that your technique is redundant. Think about this. A side scrolling 3D platform game. It's greyscale. Now, you don't need everything in the scene to be 3D, maybe just a few platforms and baddies that fly towards the screen say. In this kind of situation I would rate a shader over a screen-shader because you have the flexibility to leave objects out.

I want robotic legs.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 18:18
Quote: "And I put your glasses in the post today.."


Thanks! That should help a lot.

Quote: "I notice that the red/blue of the bumps is reversed from the object, and that seems to work very nicely"


Yes, that is a good example of how 3D glasses would be very useful - it took me quite a while to realise that wasn't a bug and why. If I'd had the glasses I'd have seen it was OK immediately.

The depth bias issue is proving to be the main stumbling block and is irksome when there are several objects in the scene. However, I'm fairly certain of my diagnosis which means I should be able to work around it once I know how the "depth" is calculated. It may just be a matter of adjusting or restricting things like the camera's range or the camera's distance from objects in the scene - in which case it could work well in your application.

Quote: "I'm not so sure that your technique is redundant. Think about this. A side scrolling 3D platform game. It's greyscale. Now, you don't need everything in the scene to be 3D, maybe just a few platforms and baddies that fly towards the screen say. In this kind of situation I would rate a shader over a screen-shader because you have the flexibility to leave objects out."


Thanks for that encouraging comment - I'll keep delving into the depth bias issue till I fully grasp what's going on.

At least the basic idea is working - something to build on.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Apr 2009 19:22
I have an idea
Your shader has two passes, and as well as moving the objects left and right, you could shrink it to half the size horizontally, and put one on the left side of the screen and one on the right (solving the depth buffer issue). Then you could have a fullscreen shader which combined them, stretching them back out. Because each eye sees a different image, the halved level of detail caused by the resizing would be doubled again, and the effect would not be noticable.

The downside is that you would need another camera to do the fullscreen shader. The upside is that only one of the cameras needs to actually move, so you don't need to alter any existing code to add this effect.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 21:01
Interesting idea.

I suspect that it might be tricky to get the projected screen position in the right places on each half of the image - because those rely on interpolated position coordinate values from the vertex shader and the perspective divide isn't linear. Worth a try though - sometimes an anticipated problem isn't a problem after all. There would be some loss of image resolution in the halving - you can't get that back by doubling again.

Quote: "The downside is that you would need another camera to do the fullscreen shader."


I think you need an additional camera to do the split render that you are describing - but putting those together using a full-screen shader should use only camera 0 and a screen quad. Perhaps the new commands simplify this procedure.

Are you going to have a go at this?
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Apr 2009 21:40
Heh, I'm not good at writing advanced shaders

What I meant by gaining the quality back would be because each eye can see a different view, and this doubles the amount of data that you take in (hence why DBPro uses a double width backbuffer). Obviously, with red and blue 3d, this extra resolution is gained by a loss in colour quality.
So, by halving the resolution horizontally for each image, but doubling the resolution because you can see two images, overall there will be very little noticeable difference (because your brain will automatically combine the two images to get the extra detail).

Another example of this is films. If you pause a moving film, the picture looks blurry with lack of detail, but when it's moving, it looks perfectly clear. That's because your brain combines the information from the last few frames, and so it looks sharper.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Apr 2009 22:34 Edited at: 28th Apr 2009 01:05
Quote: "So, by halving the resolution horizontally for each image, but doubling the resolution because you can see two images, overall there will be very little noticeable difference (because your brain will automatically combine the two images to get the extra detail)."


Good point. Actually the sheer fact that the eye/brain will be struggling with stereo 3D is probably enough to make the loss of resolution immaterial.

Quote: "Another example of this is films. If you pause a moving film, the picture looks blurry with lack of detail, but when it's moving, it looks perfectly clear. That's because your brain combines the information from the last few frames, and so it looks sharper."


Another good point.

And if you're playing a frantic PC game fending off hordes of marauding monsters, you probably wouldn't notice anything about the scene.

Anyway, here's a demo of the latest version of the shader in action. I can't test it properly myself till I get the glasses, so feedback would be helpful.

[Edit: A new demo has been posted on 27th April. Van B's screenshot helped me identify one of the things wrong with this demo - and I hope the new demo addresses Diggsey's comment about the executable.]

Attachments

Login to view attachments
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Apr 2009 23:14
Just to warn people who try to test that demo, the 'Executable Name' property is set to nothing, and so DBPro errors when you compile it, unless you change it.

The demo looked alright, but there were some depth problems which I don't think you can fix with this method: The red side of an object obscures the cyan of objects behind it, and vice versa.

Another method which I thought of, would actually solve all these problems and not look too bad, and would only require one camera and 2 passes: You could alternate through each pixel, so for the red pass, you either return a huge z value or transparent if mod(x+y,2) == 0, and for the cyan pass, you do the same if mod(x+y,2) == 1
That way, you get a chequered pattern of red/cyan parts, which (if the resolution is high enough) should blend together to form a 3d image. The effect I described before may also help to make it less noticeable.
Optionally, you could then apply a fullscreen shader which combined adjacent pixels to make the blend even better.

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Butter fingers
19
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 18th Apr 2009 00:06
Diggsey,

this sounds very similar to the method being used by the new panasonic TVs which are 120hz. Unlike old 60hz TVs these 50% left eye images and 50% right eye images and blend the pixels together to 1 image (that looks blurry to the naked eye. Polarised lenses (syncd to the screen) then make sure each eye only sees the correct pixels.

GG, I'm downloading the demo now, but I won't be able to test it until much later.

I want robotic legs.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th Apr 2009 00:58
Quote: "Just to warn people who try to test that demo, the 'Executable Name' property is set to nothing, and so DBPro errors when you compile it, unless you change it."


Another problem with the new editor. I don't recall any similar problems with the old one. Perhaps I'll have to revert to the old one after all.

Quote: "The demo looked alright, but there were some depth problems which I don't think you can fix with this method: The red side of an object obscures the cyan of objects behind it, and vice versa.
"


Probably far better to produce a pair of full colour stereo images side by side and view them through a PokeScope 3D Viewer.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Apr 2009 12:21
@GG
Nobody has a pokescope 3s viewer though
What about my other idea?

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 19th Apr 2009 03:47
Quote: "What about my other idea?"


It's on the list.

I'm not going to do more on this till I have the right glasses. I'm sure my previous demo can be improved - but I'm also sure that I'd be able to see the defects/advantages of various methods far more clearly when I can see the results of my coding. For example, I'd guess that my previous demo looks too dark when viewed through anaglyph glasses and needs tweaking for that if nothing else.
Roxas
19
Years of Service
User Offline
Joined: 11th Nov 2005
Location: http://forum.thegamecreators.com
Posted: 19th Apr 2009 15:37
@Green Gandalf, I sent you a e-mail!

Dr Tank
16
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 23rd Apr 2009 02:52 Edited at: 23rd Apr 2009 02:59
Maybe this will help. Doesn't use shaders. From what i gather, things like the HDR shader do use multiple cameras, so implementing this in a shader wouldn't be too difficult.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 23rd Apr 2009 14:29
Quote: "From what i gather, things like the HDR shader do use multiple cameras, so implementing this in a shader wouldn't be too difficult."


It isn't difficult - we were merely trying to avoid that particular solution.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 25th Apr 2009 23:08 Edited at: 25th Apr 2009 23:11
I made a shader using my idea (It is a modified version of Evolved's per pixel lighting shader)

It works quite well, but the backdrop object must also use the shader or it looks bad
You need to turn on transparency on the objects or it won't work.

Also, it requires SM 3.0

(Shader is attached)

Attachments

Login to view attachments
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Apr 2009 00:29
Quote: "Also, it requires SM 3.0 "


Any particular reason for using SM3? Doesn't seem to be using anything that can't be done in SM2 by changing the code. I could be wrong though.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 26th Apr 2009 00:38 Edited at: 26th Apr 2009 00:39
The semantic VPOS is SM3 only.

I'm trying to improve it by angling both cameras in towards the center slightly (it makes it much easier on the eyes) but I'm having difficulty applying the correct transformation

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Apr 2009 01:27
Quote: "The semantic VPOS is SM3 only."


Yes, but what does it do? Can you emulate it in SM2?

Quote: "I'm trying to improve it by angling both cameras in towards the center slightly (it makes it much easier on the eyes) but I'm having difficulty applying the correct transformation"


Yes, I was thinking of doing that to mimic what the eyes do. Which made me wonder what DBPro does. Since it doesn't know which object the user is trying to focus on it must make a fixed assumption. My guess is that both cameras are looking straight ahead, but I don't know. If you just want one 3D object to jump out at you then you can use that for the focus.

Quote: "but I'm having difficulty applying the correct transformation"


What have you tried so far? I guess you need to multiply the view matrix by one of two rotation matrices which change the XZ coords by a certain angle, one clockwise and the other anticlockwise.
Diggsey
19
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 26th Apr 2009 02:34
I originally tried emulating it, but it wasn't accurate enough.

For the transformation, I tried creating the rotation matrices in DBPro, and then passing them in, and multiplying by them at the same stage as the offset, haven't really tried that hard to fix it yet.

Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Apr 2009 11:19
Quote: "haven't really tried that hard to fix it yet"


I know the feeling - these things can take a lot of time.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 28th Apr 2009 01:12 Edited at: 28th Apr 2009 01:16
Revised demo attached.

You can move the camera backwards and forwards using the up/down arrows.

Adjust the two offsets using "x" or "c" for the image overlap offsets, and "b" or "n" for the camera offsets. I seemed to get best results when they were equal and about 2.

You will need the usual red/cyan 3D glasses for this.

Typical screenshot:

Attachments

Login to view attachments

Login to post a reply

Server time is: 2025-05-19 22:29:09
Your offset time is: 2025-05-19 22:29:09