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 / Can cameras do this?

Author
Message
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 23rd Apr 2007 12:52
Finally I think I have an idea that might work but I'm not sure if the commands exist or even what they are After I get this working though, I intend to post a tutorial and example project for the entire community. Warp zones are just so freaking fun and let you do lots of fun and crazy non-euclidean stuff that'll drive everything mere mortals insane.

1: Is it possible to shade that one object so that it's fully bright white while everything else is black? Then to render it to a texture.

2: Is it then possible to take another camera off in some arbitrary other part of the 3D level that's rendering to texture and then apply the above resulting black and white image as an alpha channel.

3: Finally, paste the resulting image -- the one that's had portions of itself made totally transparent by the alpha channel generated from step 1 -- straight to the screen, just plaster it like a blue screen matte composite in the movies.

If the above three steps work, it should be fairly seemless and create non-euclidean fun like http://www.angelmapper.com/tutorials/warpzone.htm
or better yet, the doors to a TARDIS, which is actually one of the things I want to do. Not a TARDIS by name, but the same basic idea as an affectionate nod to The Doctor.
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Apr 2007 16:27
Well your probably looking at this in quite a complex manor, but in DBPro I think it could be pretty easy.

You can create dummy cameras that render to images or textures rather than the screen.

It's possibly to do a live UV map in a shader - so rather than texture an object with a texture, you could texture a 'hole' with the camera output from another scene.

I'd have the 'hole' as a seperate limb, apply a shader to it to live texture it with the dummy cameras output, so then looking at the hole limb would look like it was a tardis, just like you say.

I think this was discussed a few months ago, I think someone actually made a demo that works like that Portal game from Valve.


Good guy, Good guy, Wan...
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 23rd Apr 2007 16:53
I've worked up something that demonstrates generating an alpha channel the way I mentioned. The problem is that I can't figure out how to use the alpha channel.

Things to do with this, if someone can show me how. I've set up a rotating box with a camera (camera number 3) looking at it. This camera is set to an image. The idea is that we use the alpha channel we're generating (camera number 2) to make the image from camera 3 transparent. Then we paste this transparent image ontop of the screen.

The effect SHOULD make it so that all the randomly scattered boxes act like a crazy sort of view port to the camera looking at the box. Sort of like cutting a hole in space with the rotating box behind the hole.

Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 23rd Apr 2007 16:57
VanB, do you have a link to this game's source or thread? I've done tons of searches on the forums over the last few days and haven't been able to find anything like what I'm trying to do.

I've never worked with limbs or shaders, and uv maps are a little rough for me... I just need a simple little example about how to do this. Nothing complex as a full game.

I really would like to get this going as soon as possible because it's driving me nuts!
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 23rd Apr 2007 22:59
If this is the game you mean:
http://www.gametrailers.com/umwatcher.php?id=23009
That's not what I want at all...

This video is what I want to replicate... It's driving me nuts trying to do it. The top post on this thread describes the way I think is best for doing it. However, there might be better ways... I've got something working where it's making a bitmap that can be used as an alpha channel, but i'm not sure how to apply it to a camera's output. if I could get that part, it'd be as good as done... Then I can move on to actually getting a game going with it.
http://www.youtube.com/watch?v=G0pPL6DW0gE
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 24th Apr 2007 01:46
Lucy

Is this the sort of thing you are after?

The images and objects are rather basic - but you can see the scene of moving spheres beyond the textured screen through several moving "portals".

This uses three cameras and a shader.

Attachments

Login to view attachments
dononeton
19
Years of Service
User Offline
Joined: 12th Jun 2004
Location: Tusaloosa, AL : USA
Posted: 24th Apr 2007 04:17
cool shader. This could be used in a game where you set up a model of a camera and have DBPro camera facing the same direction and the Portal texture ins up on a tv monitor.

AMD Athlon 64 x2 Dual Core Processor 3800+,MMX 3DNOW (2CPUs)
1024 MB RAM
GeForce 7300 GT 512 MB
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 24th Apr 2007 12:34
That looks like it, but I'm going to have to punch in my joypad code so i can fly around and see for sure...

*recompiles and runs*

YES! Well, I don't want to get too excited, I'm going to have to pull it apart and set up a demo kinda like that Quake4 video up there to be absolutely sure.

If this turns out to be precisely what I need, I may have to buy you a drink, Green Gandalf.

Of course I'm going to be pulling it apart to learn more than just how to use it but the logic behind it as well.
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 24th Apr 2007 12:43
Dononeton, there's absolutely no reason to use something like this for a camera and TV unless you want the TV to be 3D... Just use set camera to texture...

I tried that route myself and tried to do some cheap hacks to make it look right. Some of the hacks worked, some of them half worked, and the other I just couldn't get it to work the way it did on paper.

Anyway, to get a camera with a TV just do this (NTSC aspect ratio)

Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 24th Apr 2007 14:09
Green Gandalf, I'm currently trying to decipher what's going on in the code you posted. A few small questions.

1: What do the vector4s do in relation to the shader they're being used with?

2: Is the stage index on the texturing of the plane object related to the shader?

3: Why is the plane being textured with the output of the two cameras?

4: Why two cameras and not 1?

5: What is the plane being used for? It looks like just a backdrop for the portals to hover infront of but that seems to not be the case

6: Would you be possibly be a sweetie and put some comments about the code and repost? Normally I can figure stuff like this out myself but 3d graphics is a very new venue for me.

Thanks a bunch! You've been a wonderful help regardless.

No matter where you are... everyone is always connected.
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 24th Apr 2007 14:22
Actually, after I set the boxes and spheres to stop moving around so much and fixed a bug in my movement code that made it move the wrong camera, it became apparent that this is infact not what I want. It's little more than a multi layered set camera to image effect

My search continues

This is a video of the effect I'm trying to produce.
http://www.youtube.com/watch?v=G0pPL6DW0gE

I do not desire to have anything being flat or at all able to become pixelated. I simply want to take two parts of a 3d scene and link them together in a noneuclidian fashion. A window, a door, a portal... Not in any way shape or form a texture that merely animated. If I have to I'll just resort to using a flat texture rendered with set camera to texture but this is not what I want ideally. That is last resort -- DBPro cannot do what I want under any circumstances -- only.

No matter where you are... everyone is always connected.
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 24th Apr 2007 16:28
Anyway, I'm going to stop obsessing over it, use a cheap camera to image hack and come back at a later date when I understand more about this stuff.

Although I am currently working on making something in C that will take three images. The immediate vicinity camera, the alpha map generator camera that i've posted code to above, and the camera for where the portal goes to. Then it bit blits them together and produces the frame that should be drawn to screen. However, I'm not sure how fast this will be. When I take an image and put it into a memblock, then grab it from the memblock and put it back into an image for pasting to the screen, i get a slowdown from like 300fps to 0.5fps. So I'm not quite sure how to go about doing it in a fast method.

Here's what I'm doing for it to test the performance of what I think will be needed to use said DLL. (By the way I don't have the Dark Basic SDK so all I can do is make C code that can do it and then either compile it when I can buy the SDK or get someone to compile it for me.)



When I do that, it reduces my framerate conciderably. However, if I don't take the memblock and make it back into an image, it runs nice and smooth with just the omission of that one command. Even turning off all the lights and running a loop to turn all portal surfaces white doesn't hit the performance. Just that one "make image from memblock" command does.

No matter where you are... everyone is always connected.
Code Dragon
17
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 30th Apr 2007 03:23 Edited at: 30th Apr 2007 03:30
Lucy I think I might have an idea on how to do portals faster, it should link the two scenes together through a portal seamlessly and realisticly at a fast speed.

The problem is that when you make a memblock from an image, it (I think) copies the bitmap data to a memblock. Then you can edit the memblock and copy it back into the bitmap in VRAM. This copying process is slow especially for large resolutions, so the best way would be to edit the bitmap data directly.

I'm 100% sure about this, but because the set image colorkey command is built into DBP it might edit the bitmap data directly rather than creating a "hidden" memblock to do the job. If it does then using this command to change white to alpha would be very fast. I don't want to promise anything yet because I'm not sure set image colorkey updates an image that a camera renders to, and it's going to need to that every frame.

If the command does what I need it to do (I don't have DBP on this computer so I can't test it) I'll try to make a demo of it soon.

What I'm going to do is create a second camera that looks at other end of the portal wormwhole (image of what you see when you look inside the portal) and set it to render to the screen. Then I take the portal object and set to render as pure white. Then I use the set image colorkey command to turn any white pixels to alpha. Then I set the normal camera to render to an image and paste it over the screen (which is showing what you should see in the portal). The white should be turned transparent by set image colorkey, and when superimposed on the view of the portal it should create the effect of looking through a window to another scene, and it should be fast too.

Of course I could be horribly wrong, but at least it works in theory.

By reading this sentence you have given me brief control of your mind.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 30th Apr 2007 05:32
@Lucy, I just watched the video, and I dont really think it sould be too awful hard to do what you want. Actually It should be really simple, I think. I got my portals working now. I can throw a sphere in one portal and it comes out the opposite portal. Oh ya, "live textures also so you can see it in action.", looks like that vid, but not as fancy.
Lucy
17
Years of Service
User Offline
Joined: 19th Apr 2007
Location: Roanoke, VA USA
Posted: 30th Apr 2007 05:57
I already have something working, made a shader that fairly successfully replicates the effect in that video. Now I just need to figure out how to rotate and align the cameras properly for portals that are arbitrarily rotated

Nothing I say is intended to be rude. My autism means that I do not know what is rude and what isn't rude. I apologize if I seem rude. It is not my intention.
Code Dragon
17
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 1st May 2007 02:08
Well, my idea didn't work. It turns out the set image colorkey commmand only works when an image is loaded or captured from the screen.

If someone wants to hack it into working here's my code:



If anyone would like to petiton for the ability to make part of an image made by set camera to image transparemt, here's a feature request thread I found.

http://forum.thegamecreators.com/?m=forum_view&t=75563&b=15&p=0

By reading this sentence you have given me brief control of your mind.
david w
18
Years of Service
User Offline
Joined: 18th Dec 2005
Location: U.S.A. Michigan
Posted: 1st May 2007 03:32
I think we need to think around the problem and try to come up with a sloution......What is a camera exactly, is there really even a camera.....anyways, here is something for you to think about, maybe it will help maybe not....good luck



Thank you.

Login to post a reply

Server time is: 2024-05-03 09:54:38
Your offset time is: 2024-05-03 09:54:38