Sprite rendering... thingy

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Sprite rendering... thingy // Feature suggestions

1  |  

Post by Alien // Dec 4, 2006, 7:02pm

Alien
Total Posts: 1231
pic
I was just thinking about making animated gifs [I wish Mozilla & MS would get their collective butts in gear & start supporting .MNG (http://en.wikipedia.org/wiki/Multiple-image_Network_Graphics) files! :(], when I remembered the issue of borders to images with transparency relating to anti-aliasing. I remembered about that little prog Tiles made & went & had another read of the thread (http://forums1.caligari.com/truespace/showthread.php?t=1056&highlight=AASpritesharpborder) & saw that Caligari actually make a proper plugin for this situation. The only problem is that it comes as part of a $199 Pak - which is a bit much when all I want is the Spriterender plugin [I think that's what TomG called it].

I have no interest in game development, but there other things I could use that plugin for [animated gifs with transparency, & also icons for progs such as Y'zDock]. Is there any chance you [Caligari] could be persuaded to sell just that plugin seperately? [for hopefully quite a bit less than $199!] Alternatively, if it's actually made by you guys, wouldn't that mean proTeam members ought to get it free? ;) :D


another thought - perhaps expand the now-integrated layer rendering feature to make the background a seperate layer, then users could just delete the background layer [or choose not to export it].

Post by spacekdet // Dec 5, 2006, 8:06pm

spacekdet
Total Posts: 1360
pic
Maybe I'm misunderestimating the question, but can't you render out as a 32 bit TGA; this will automagically put the background in a separate deletable layer.

Post by Tiles // Dec 5, 2006, 10:39pm

Tiles
Total Posts: 1037
pic
And gives you a border around the sprite then. The pixels that are in use for Antialias. GIF doesn't know greyscale transparency nor layers. Either one predefined colour is fully transparent or not. With red background this could mean to have a red border around the sprite then ;)


Nowadays you could use TGA or PNG for games. Looks best with its greyscale transparency. But is a performance question. I have played around with it and skipped it because of this for now. 32bit TGA or PNG uses more ram than just 24 Bit Bitmaps. With my little testgame i had a 1/3 bigger exe file than with just 24 bit bitmaps. And the framerate went down to unplayable. Transparency effects are slowdowners. I have finished this game with just 24 Bit Bitmaps then. Maybe in the future i will have a second look.


Besides that: i would also be happy to have a cheaper look at the spriterender plugin. My little software i have built for that has its limits. Produces not always useful results. Especially when bump mapping or fine structures are involved ...

Post by spacekdet // Dec 5, 2006, 11:00pm

spacekdet
Total Posts: 1360
pic
You've done more with this than I have... but just because it's rendered out as TGA doesn't mean it has to stay that way... it could just as easily be converted to a GIF (after it's rendered by tS) in your 2D editing program of choice, no?

Post by Alien // Dec 6, 2006, 12:16am

Alien
Total Posts: 1231
pic
Maybe I'm misunderestimating the question, but can't you render out as a 32 bit TGA; this will automagically put the background in a separate deletable layer.

I tried that, & as far as I can tell , no, it doesn't. At least not the way I want.


<some time later>

Hmm... after a bit of fiddling about & experimenting in PSP, it seems it [i]might be possible after all.


Steps I followed, for anyone else using PSP [works with 9, should work with higher versions, not sure about lower versions], are as follows:



I rendered an image with the background set to a colour that didn't appear anywhere else in the image [in this case, bright green], to a 32bit TGA.

Load the image into PSP9.

Promote background layer [any image in PSP that has only 1 layer is listed as being just a background layer] to Raster Layer [otherwise when you delete the contents of a selection it will just be changed to the current set background colour].

Selections -> Load/Save selection -> Load Selection from Alpha Channel, make sure the Invert Image option is enabled, & click Load.

Zoom in to an area where you can see the border between object & background

Use Edit -> Clear [or Delete key, or (as I do) a button for it on the toolbar]

You will probably notice that not all of the coloured pixels in the selection area that you want removed will have been cleared, simply press Clear/Delete repeatedly until you're happy with the result [5 or 6 times should be enough to get rid of the background colour, though more will be needed to get rid of anti-aliased pixels of the objects colour].

Note:

Just tried it with PSP7, & it does work, but the load from Alpha Channel dialog doesn't have an invert selection function, so you'll have to do that seperately from the Selections menu.

Either the Alpha Channel mask created by tS, or PSP's converting of it to a selection is imperfect. In some places you may notice the border of the selection being a few pixels + or - of where you would expect it to be. Not sure whether that's PSP's fault or the way tS7 creates the TGA, but it happens with both PSP 7 & 9


Another thing occurred to me, the ability to render to .psd files with seperate layers for different stuff. I looked it up in the manual [marked as page 585, but is actually page 613 if you're using the PDF], & although it says:

Per feature: Each effect/rendering feature is stored as layer in the PSD file. Background: Just a plain background

The image of the relevant dialog in tS which is just before that text does not show an option for Background, & nor does the actual dialog in tS itself. That's rather annoying, as I would have thought that would make background removal easier.


And gives you a border around the sprite then. The pixels that are in use for Antialias. GIF doesn't know greyscale transparency nor layers. Either one predefined colour is fully transparent or not. With red background this could mean to have a red border around the sprite then ;)

Not necessarily, the image below shows the results of the method described above.

http://homepage.ntlworld.com/alien42/images_for_caligari_forum/tga-background-removal-test.png


The image was initially rendered from tS with a bright green background, which was removed [as described above] & just to show off the result better I added another layer underneath in PSP & filled it with bright red. As for the jagginess, well, as you can see it's zoomed to 600% of the original size - at 100% zoom it looks nice & smooth.


Nowadays you could use TGA or PNG for games. Looks best with its greyscale transparency. But is a performance question. I have played around with it and skipped it because of this for now. 32bit TGA or PNG uses more ram than just 24 Bit Bitmaps. With my little testgame i had a 1/3 bigger exe file than with just 24 bit bitmaps. And the framerate went down to unplayable. Transparency effects are slowdowners. I have finished this game with just 24 Bit Bitmaps then. Maybe in the future i will have a second look.

I guess it depends on the specs of the system running the game.


Besides that: i would also be happy to have a cheaper look at the spriterender plugin. My little software i have built for that has its limits. Produces not always useful results. Especially when bump mapping or fine structures are involved ...

Yeah, would make a nice addition to their product lineup. :) In the meantime, what do you think of my solution?

Post by Tiles // Dec 6, 2006, 2:27am

Tiles
Total Posts: 1037
pic
Looks like another valid method. Unfortunately i don't have PSP or PS. Gimp seems not to allow this way. Haven't found one yet. Not the first time i wish that The Gimp would have a better support about editing alpha channels. And there is another letdown. Even when it would work, my sprites typically has around 400-600 single animation pictures. Now go manually fix them ... :D


For the game running dependand of the PC specs, well, with PNG and Alphachanneled it had 5-10 FPS. Without Alphachannel it runs maximum now. 85 FPS. At an AMD 64 3200+ with Radeon 1600, 256 MB ram. Of course you can develop for workstations. But you better take care that a normal state of the art PC runs your games. Even better when two or three generations below also does ;)


But to be fair, i use Multimedia Fusion to create my games. An Authoring Tool. Natively a bit slow anyway compared to a game made with a real language. And especially when it comes to such effects like transparency. It's a pure 2D enviroment. With all its pros and cons.

Post by Alien // Dec 6, 2006, 3:56am

Alien
Total Posts: 1231
pic
Another thing occurred to me, the ability to render to .psd files with seperate layers for different stuff. I looked it up in the manual [marked as page 585, but is actually page 613 if you're using the PDF], & although it says:

The image of the relevant dialog in tS which is just before that text does not show an option for Background, & nor does the actual dialog in tS itself. That's rather annoying, as I would have thought that would make background removal easier.
I've been experimenting more with tS & its PSD output options. Apparently, you can get tS to create a PSD with the background as a seperate layer [Per Geometry Layer mode & Alpha Mask turned on], but when you either hide or delete it you can still see some anti-aliased pixels that are partly based on the background colour. Also, it seems that the alpha channel mask created for PSD files isn't as good as the 1 for TGA files. This means that the results you get from using a selection created from it & then inverted to remove the extra anti-aliased pixels aren't as accurate/thorough as what you'd get working with a TGA file.

Looks like another valid method. Unfortunately i don't have PSP or PS. Gimp seems not to allow this way. Haven't found one yet. Not the first time i wish that The Gimp would have a better support about editing alpha channels.
It does, it's just not as easy to find or use as PSP's. Took me about 1/2 an hour to suss it out. Try this:

Open suitable 32bit TGA file in GIMP.
Select -> Selection Editor.
In the Selection Editor window, click the little triangle button thing near the top of the window that looks greyed out
Add tab -> Channels
Go to Channels tab, r/click Alpha channel -> Channel to Selection
Select -> Invert

To clear the contents of the selection it's exactly the same as PSP [Edit -> clear], but the results aren't quite as accurate as PSP. I think that happens somewhere in the creating selection from Alpha Channel process [just guessing]. From messing around with it a bit more it seems the feather function can be used to get the selection a bit closer to where you'd want it. HTH. :)

And there is another letdown. Even when it would work, my sprites typically has around 400-600 single animation pictures. Now go manually fix them ... :D
*cough* scripting *cough* :p

If you had PSP9 I'd have a go at seeing if I could come up with a suitable script. Doing it on a 1-image basis [e.g. load image yourself, click run script button, save image, repeat until done] wouldn't [I think] be too hard, though I've never tried getting it to do it automatically on multiple files, but that doesn't mean it's impossible.

As for the GIMP - apparently it does have some kind of scripting functionality, but you're on your own with that 1! :D

For the game running dependand of the PC specs, well, with PNG and Alphachanneled it had 5-10 FPS. Without Alphachannel it runs maximum now. 85 FPS. At an AMD 64 3200+ with Radeon 1600, 256 MB ram. Of course you can develop for workstations. But you better take care that a normal state of the art PC runs your games. Even better when two or three generations below also does ;)
For a minute there I thought you meant the system only had 256MB, not the Radeon. :D

Post by TheWickedWitchOfTheWeb // Dec 6, 2006, 4:09am

TheWickedWitchOfTheWeb
Total Posts: 858
pic
I was curious about this so spent a couple of minutes playing and have done it with no problem! Set your AA to Adaptive and render your image out as psd with Alpha mask enabled and also mask as separate layer selected. The Adaptive setting will give you an AA image but without the 'fuzzy' edges.


Take the rendered image into PhotShop/PSP/whatever, promote the background layer to a proper (editable) layer. Select the contents of the Alpha layer and paste it into a mask on the picture layer. Turn off or delete the 'alpha' layer and you're done.


Sounds like a lot of hassle when it's written down but in practice only takes a moment and I'm pretty sure the results are what you are looking for.

Post by daybe // Dec 6, 2006, 4:20am

daybe
Total Posts: 562
pic
Yes this should work fine for you. If you still find that it's not working the way you would like you could also change the background color in TS to be the same as you will be using later on, this way if you have a slight border around the object it won't be noticable, this is what I used to do.

Post by Tiles // Dec 6, 2006, 4:26am

Tiles
Total Posts: 1037
pic
Thanky Alien. Have searched for such a way for eons :)


I think i'll nevertheless stick to my method. It's simply too much when you have to edit hundrets of pictures manually. And i would have to. I am lost with scripting :D

Post by Alien // Dec 6, 2006, 5:22pm

Alien
Total Posts: 1231
pic
I was curious about this so spent a couple of minutes playing and have done it with no problem! Set your AA to Adaptive and render your image out as psd with Alpha mask enabled and also mask as separate layer selected. The Adaptive setting will give you an AA image but without the 'fuzzy' edges.

If only that were true - still fuzzyness, but not to quite the same degree, but still I have to thank you for prompting me to try Adaptive AA as it seems it can achieve results almost as good as 4xAA with less rendering time. :)


Take the rendered image into PhotShop/PSP/whatever, promote the background layer to a proper (editable) layer. Select the contents of the Alpha layer and paste it into a mask on the picture layer. Turn off or delete the 'alpha' layer and you're done.


Sounds like a lot of hassle when it's written down but in practice only takes a moment and I'm pretty sure the results are what you are looking for.

I can't comment on Photoshop, but I can say that having tried your suggested method with PSP, anyone wanting to do this with PSP will get better results with a 32bit TGA & the method I described previously. Whether that's to do with PSP, or the way tS outputs the different file types... http://homepage.ntlworld.com/alien42/smilies/dunno.gif


Thanky Alien. Have searched for such a way for eons :)


I think i'll nevertheless stick to my method. It's simply too much when you have to edit hundrets of pictures manually. And i would have to. I am lost with scripting :D

That's fair enough. Still, were you to get PSP9 (http://www.amazon.de/Franzis-Grafik-Suite-CD-ROMs-Windows/dp/3772399061/sr=1-5/qid=1165440860/ref=sr_1_5/028-6788564-2094918?ie=UTF8&s=software) [I don't speak German, & Babelfish doesn't want to translate that page, but it looks like a full version, & for under €20 :)], the offer of help still stands. Also consider that with my PSP method you'd only need 1 render per frame, not 2.
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn