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 / Image from camera with transparency?

Author
Message
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 8th Apr 2011 02:42
Is it possible to set a camera to an image and then texture a plane with this image, but with transparency?

If I set the camera backdrop to bright green or something, can I make the textured plane not show the green?

I don't think 'set color key' works, I have tried that alot.

Thanks.

Mr Bigger
21
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 8th Apr 2011 08:02
SET CAMERA TO IMAGE Camera Number, Image Number, Width, Height, Alpha Mode

With the Alpha Mode flag set to 1,
Set Color Key to black.

Should work.

AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 8th Apr 2011 15:16
Thanks alot Mr Bigger, I never knew that transparency flag exists, you have helped alot

Although in DarkGDK, setting this flag crashes the program, I will look more into it and report back, thamks again.

Mr Bigger
21
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 8th Apr 2011 23:09
It was never documented nor supported. I think it was one of those things Lee was toying with and never got working good enough.
It's extremely slow and would not be practical in real time.
You have to use a workaround for that. A search on the command should yield examples.

I doubt it made it to DarkGDK.

AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Apr 2011 23:28
Quote: "It's extremely slow and would not be practical in real time."


Is it? Can you give an example where the alpha flag slows things up significantly?
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 8th Apr 2011 23:37
If it is very slow then this is a deal breaker for my project, and I can't test it as its bugged in GDK, it seems.

I have come some way in creating an imposter system, but the billboards really need to have transparency.

@Green Gandalf - When I set my camera to an image then texture my plane with that image, is there a way to move my camera, set it to another image and then texture a second plane with the new image?

I find that once I set the camera to an image and texture my plane, if I move the camera, the first plane loses that original image(from the first camera position. Meaning I would need to use a camera for each plane, I dont think thats possible is it, what is the limit on cameras?

I ask you as I know shaders use these techniques alot.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Apr 2011 01:19 Edited at: 9th Apr 2011 01:19
I'm not sure but I think the limit is 32 cameras so if you can work within that you should be OK.

Quote: "When I set my camera to an image then texture my plane with that image, is there a way to move my camera, set it to another image and then texture a second plane with the new image?"


You might be able to reuse the same image by making different copies of it at different points in your program. The memblock commands might help with this. Not sure though.
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 9th Apr 2011 01:57
Thanks Green Gandalf.

32 cameras means a max of 30-31 imposters, probably not worth while as the idea is to possibly have hundreds of trees etc far away with only a couple of hundred triangles.

Manipulating and copying the images in real time will probably be too slow also.

If anyone has any ideas let me know, although this project is starting to look unlikely which is a pity because I have the complicated math stuff all done and it works great.

Mr Bigger
21
Years of Service
User Offline
Joined: 31st Jan 2005
Location: was here!
Posted: 9th Apr 2011 13:52
Quote: "Is it?"


Yes, it is. For me its as slow as the image to memoryblock workaround.

Quote: "Can you give an example where the alpha flag slows things up significantly?"


I could but i don't see how that would help matty.

After further review however i discovered that a flag setting of 2 takes care of the lag. It could be that i'm using DBP 6.6.

AMD 2600+/1GB ram/GeForce 6600oc 256MB/W2KPro/DBPro 6.6.b
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Apr 2011 00:36
I solved the camera issue, you can sync the camera and then if you delete it and make a new one with the same ID number you can set it to a new image, not sure if this affects performance.

Here is a snippet for future searchers:


If you have used the image to texture an object then be sure to set the texture to image 0 before you delete the camera, otherwise it crashes(after a few times), in GDK anyway.

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 10th Apr 2011 19:13
For the Alpha part, you could use memblocks, or the ImageKit plugin and search through the pixels for a specific color, then set the alpha channel color for that pixel and use the resulting image. It would be slow for larger images, but for something like 512x512 it might be fast enough.

Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 10th Apr 2011 21:03
Thanks KISTech, I am going another direction with this now, I'm trying to write it in raw directX and render the billboards myself, its far from guarenteed to work though.

If it does work, would you like to test it for me? Large ambitious games are what I need for testing, to see how much of a speed boost I can achieve, if any lol.

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 10th Apr 2011 23:34
Sure. I do tend to pick "Large" and "Ambitious" projects don't I...

Login to post a reply

Server time is: 2026-07-17 17:23:53
Your offset time is: 2026-07-17 17:23:53