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.

Newcomers DBPro Corner / Save image without green background

Author
Message
BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 9th Apr 2012 10:15
Hi all,
I'm trying to get a 3d scene with "save image" command but green backgorund appears in the background, behind the objects.
I'm using png as file format.
Any body knows how can I remove the green background from the saved image? I'm tried cange all the green pixels by pixels with alpha value 0 but "dot" command doesn't support alpha, just rgb colors.
Thanks in advance.

Regards
Penfold
20
Years of Service
User Offline
Joined: 3rd Dec 2003
Location: RED postbox houses of parliment
Posted: 9th Apr 2012 11:27
do you mean you have a 3d scene in DB and your trying to grab an image of it? so that it shows up in something else(like an art package,or reinported into DB?) with an alpha channel?

'Ooh 'eck chief'...'crumbs'
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 9th Apr 2012 11:51 Edited at: 9th Apr 2012 11:55
Green is the default backdrop of all "created" cameras. So whatever the camera's backdrop colour is will be your file's background. Unfortunately it seems DBPro cannot save with alpha channels included (Maybe I'm missing something too????)

Here's an example code (You may have problems saving if you've security and permissions and junk so disable first or set the code to a permitted directory)



I suppose you could use GIMP/PhotoShop to exclude that colour but a problem arises from the edge interpolation when using AA which gives it that "cut-out" look.

<EDIT> Wait, do you mean you want to remove the green backdrop on your camera or on the actual image that you've saved?</EDIT>

BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 9th Apr 2012 11:56
Hi Penfold, sorry for the prior bad explained post.
Yes, I'm trying to get snapshoots from some 3d models and FPSC scenes I made. I'm using "get image" command but the green background appears as backdrop and I want to save the image as png with all the background erased or with alpha 0.
Thanks!

Regards.
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 9th Apr 2012 12:30
Not really a Blender user but I think Blender - http://www.blender.org/ - has the option to export snaps with a transparent background. There may actually also be a few dedicated freeware apps out there for this too (maybe try Softpedia/Sourceforge). Good luck.

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Apr 2012 14:50 Edited at: 9th Apr 2012 14:52
Change the background to black? I don't think you can save layered PNG's.

Ramon156
13
Years of Service
User Offline
Joined: 13th Jul 2011
Location: Netherlands
Posted: 9th Apr 2012 15:21
If you want to update this real-time I'd say change the backdrop color to any color you want. Use a RGB color chart to see what color you'd like to have.

Otherwise you can use photoshop to change the green background to a color you want, or transparent. After making the backdrop transparent in photoshop you could paste the image to any background you want.

Also you can create a second camera that exactly follows your original camera, with a different backdrop. So you can can keep your backdrop of your main camera as green and change the second camera to something else.

Hope it helps.
Penfold
20
Years of Service
User Offline
Joined: 3rd Dec 2003
Location: RED postbox houses of parliment
Posted: 9th Apr 2012 15:43
Quote: "Otherwise you can use photoshop to change the green background to a color you want, or transparent. After making the backdrop transparent in photoshop you could paste the image to any background you want."


This is what I'd do. If you plan to do it all from your program I think your going to have problems. If your doing it for media for your game, I'd export to imaging software and add the alpha channel manually. Then when you drop it back into DB texture a plain object and set the transparency to off on the object so you dont see it under the texture.

'Ooh 'eck chief'...'crumbs'
BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 9th Apr 2012 18:46
The main idea is to make something like sprite-me or model-2-sprite applications, so the green backdrop must be remove in the application itself to avoid a frame by frame manual post processing.
Thanks all for the advices.
Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 9th Apr 2012 20:35
Yeah, but it doesn't have to be saved that way. You can use...

SET IMAGE COLORKEY Red Value, Green Value, Blue Value


To make any colour transparent ... after you have loaded it.

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 9th Apr 2012 21:20
Quote: "To make any colour transparent ... after you have loaded it."


Pincho, you're onto something

Which made me think how to incorporate that into a single process and I came up with a re-work on the earlier code I posted.

OP, I believe this solves your problems!


This isn't very elegant but it actually saves the image with a 00 alpha background!! You'll have to customize it to your requirements but you've got the theory now.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 11th Apr 2012 02:23
nonzero, you're right Blender will render images with transparent background (plus anti aliasing )
also, GIMP has a nice color to alpha function.
seems like you have this solved though (and is now noted in my list of how to's - thanks!!!

BraindeaD
16
Years of Service
User Offline
Joined: 30th Mar 2008
Location:
Posted: 11th Apr 2012 07:35
Hi all,
Pincho thanks for your code, I'm working with in... I hope get it soon ready.
Regards
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 11th Apr 2012 12:34
@Naphier: You're welcome, always glad to contribute my 5 yen.

Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 26th Apr 2012 05:34 Edited at: 26th Apr 2012 05:36
I posted a wonderful solution to this problem last year.

The minute you start using anti-aliasing or transparency you are ruined.
Your colorkey won't work properly. Here's a better solution.



My method supports all colors without the need of a background colorkey, transparency, and with imagekit can also support animation.

Thread Link:
http://forum.thegamecreators.com/?m=forum_view&t=184514&b=1

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 30th Apr 2012 23:40
Isn't there a command in the newest version that lets you render all objects in a solid color? If you rendered white on black, that would give you an alpha channel image.

The update notes from 7.5 say...

* Added new parameter to COLOR BACKDROP CamID,Back,ForeColorWipe
* NOTE: Use above extra parameter to replace all textures/effects with single color
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 1st May 2012 22:31 Edited at: 1st May 2012 23:14
Quote: "Rich Dersheimer: Isn't there a command in the newest version that lets you render all objects in a solid color? If you rendered white on black, that would give you an alpha channel image.

The update notes from 7.5 say...

* Added new parameter to COLOR BACKDROP CamID,Back,ForeColorWipe
* NOTE: Use above extra parameter to replace all textures/effects with single color "


Rich Dersheimer's Method:


That's really amazing thanks. I had no idea that they added that. Unfortunately it doesn't actually work here. As you can see above, it doesn't do a complete job.

Transparency is not preserved. So in the image above for example the character's hair doesn't taper off. Also it seems MATRIX terrain is unsupported, a lesser issue. (I shouldn't be using MATRIX in this day and age.)

Also: I had to turn off the HDR Shader effect to get it to work. This should be easy to work around, but I thought it should be mentioned.


Rich Dersheimer's Method - Why Do This:
The whole point of drawing the screen as pure white object on a black background is to steal the black and white values and use them as Alpha levels in a "real" screenshot (that would otherwise have no transparency) of the exact same scene much like using a mask in photoshop. The white in this image is a character(foreground) and walls (background). The ground and ceiling should be white. If you could see the sky then it would appear black and if all went well it would appear transparent in the final image. Any transparency overlapping the transparent background won't display correctly with this method.

Everyone Else's Method - Everything So Far Using ColorKey
Quick and easy. However like Rich Dersheimer's Method, any transparency overlapping the background will look absolutely horrible. Also any color in the image exactly the same as the colorkey will be improperly made transparent.

Mage's Method - The Method I Posted Previously:
It will take two screenshots. The same scene with a black and a white background. It then compares the images and produces the full transparent background effect properly.



See the link I posted previously for the thread.

In most cases you don't have to use any of these methods more than the other. The biggest issue is whether your scene is using transparencies. If is then I'd recommend my method, if it isn't then I would recommend the COLORKEY methods unless you are commonly seeing abnormalities.

Login to post a reply

Server time is: 2024-11-23 20:26:04
Your offset time is: 2024-11-23 20:26:04