This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Preparing gfx for a game


Preparing gfx for a game

Postby Avatar » Aug 30, 2001 @ 6:36pm

I am involved in the production of an advanture game for the PPC platform and my department is graphics and integration thereof into the game. The following issue has come up and I was wondering if you guys can help me out.<br>A good deal of the graphics are 3d rendered. Now, I want to be able to have good-looking, smooth objects in the game (aka anti-aliased). However, rendering w/ antialiasing produces colour-bleeding around the object's outlines, which is readily visible when using simple masking routines. It has been suggested that I use alpha-blending instead of masks, as those could allow for a range of blending/transparency levels. But no one really clarified what kind of input I should have (ie. should my sprites be already anti-aliased and the a-blending will fix the colour bleeding or should they be simply rendered and somehow smoothed on-the-run?)<br>Finally, I would really appreciate if someone could provide me with code snippets that show how to do what I just described. That is, take a bitmap, a-blend/mask it, and output it to the screen (probably using GAPI).<br><br>Thanks in advance for your help and suggestions.
Avatar
 


Re: Preparing gfx for a game

Postby Avatar » Aug 30, 2001 @ 6:40pm

Hey, I'm not a 'guest'...;)<br><br>Also, to those who are planning to reply to this post:<br>-yes, I have already read the discussion on the board regarding alpha-blending (there's no code there, but some good ideas)<br>-yes, I have already seen EasyCE and its routines<br>
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: Preparing gfx for a game

Postby Moose or Chuck » Aug 30, 2001 @ 7:28pm

My understanding if that you should just create the anti-aliased image like normal, the programmers will ned to alpha-blend out the areas that should be.
Moose or Chuck
 


Re: Preparing gfx for a game

Postby randall » Aug 30, 2001 @ 7:30pm

Then there really shouldn't be a problem. Anti-aliasing only works on an entire image (like the whole screen), rather than individual sprites.<br><br>Alpha channels are supported in most paint programs (even Photogenics on the PPC). Basically it is a greyscale layer that tells the renderer how transparent each pixel is. I can't remember if Black is 100% transparent or 100% opaque.<br><br>Sometimes, the Alpha channel is integrated into the RGB as a FOURTH color.<br><br>Since the alpha takes care of the blending, the sprite doesn't need to have any kind of fade or antialiasing around its edges.
User avatar
randall
pm Insider
 
Posts: 3426
Joined: Feb 23, 2001 @ 4:02pm
Location: Schnoogie


Re: Preparing gfx for a game

Postby randall » Aug 30, 2001 @ 7:31pm

I can also post a pic of what an alpha channel looks like seperated from the composite, since I just did something like that recently.
User avatar
randall
pm Insider
 
Posts: 3426
Joined: Feb 23, 2001 @ 4:02pm
Location: Schnoogie


Re: Preparing gfx for a game

Postby Avatar » Aug 30, 2001 @ 8:31pm

In my case, anti-aliasing effects just the sprite, as it is the picture itself (ie one single animation frame).<br>I would appreciate the example picture.<br>Also, any idea on how I would go about creating alpha-levels in a program like PSPor Photoshop?
Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: Preparing gfx for a game

Postby John Lomax » Aug 30, 2001 @ 8:34pm

Just to clarify. Yes you should render your image<br>with anti-aliasing on. This will obvioulsy produce an anti-aliased alpha (providing you render with an image format that supports alpha channels). This provides the best composite image for sprites, as it reduces the fringing that occurs.<br><br>Some of the highend 3d packages support more advanced anti-aliasing methods, which produce less of a general blur to the image. I recommend turning on highest quality providing your 3d renderer supports this.<br><br>Also, its best to render your sprites at bigger resolution (640x480 for example) then scale down.<br><br>Avoid using bi-linear, or other quicker scaling methods. If you have access to more powerfull tools, (digital fusion is a good example), then using a catmull-rom reducing alogrithm will produce by far the cleanest and less blurred image.<br><br>Good for rendered sprites :)<br><br>John
User avatar
John Lomax
pm Member
 
Posts: 185
Joined: May 16, 2001 @ 6:04pm


Re: Preparing gfx for a game

Postby Avatar » Aug 30, 2001 @ 8:59pm

Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: Preparing gfx for a game

Postby Avatar » Aug 30, 2001 @ 9:00pm

Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: Preparing gfx for a game

Postby Digby » Aug 30, 2001 @ 11:53pm

Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: Preparing gfx for a game

Postby Avatar » Aug 31, 2001 @ 12:19am

Avatar
pm Member
 
Posts: 59
Joined: Aug 16, 2001 @ 8:32pm


Re: Preparing gfx for a game

Postby Digby » Aug 31, 2001 @ 1:19am

Well that format can certainly handle 8-bits of alpha, so it must be something else.<br><br>Lomax,<br><br>If you render your 3D image on a solid black background and then enable anti-aliasing, what you'll end up with is an image that has been pre-multiplied by the alpha component.  You can create an alpha mask by re-rendering after cranking the ambient lighting up to solid white, then make the color of your polys white, and leave anti-alias enabled.  Depending on how your engine performs alpha blending, you might want to invert the resulting alpha mask.<br><br>From the canonical equation for alpha blending:<br><br>dC = (sC * A) + dC * (1 - A)<br><br>Since we have pre-multiplied the alpha by the source color (sC), and we're storing the inverse alpha in the mask, the equation above becomes:<br><br>dC = sC + dC * A<br><br>I think I went over all of this in some previous posts about how to implement alpha blending efficiently, but I never thought about it from an artist's perspective on how to create those alpha masks and pre-multiplied source images.  Turns out it's easier than I thought.  One of these days I should write the code to do this and see if it actually works.<br><br>Here's some test images I created quickly with Rhino3D (don't laugh, I'm a programmer, not an artist)<br><br>Image<br>Source image (sprite)<br><br>Image<br>Alpha mask<br><br>Image<br>Inverse alpha mask<br><br>Grab the images and then zoom-in to view the anti-aliased edges.<br><br><br><br>
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Re: Preparing gfx for a game

Postby randall » Aug 31, 2001 @ 3:26am

there ya go.<br><br>that is very similar to the alpha channel work I was just doing. It is kind of difficult to see the blending along the edges. It looks strictly b/w but it isn't - there are definately a couple shades of grey in there.
User avatar
randall
pm Insider
 
Posts: 3426
Joined: Feb 23, 2001 @ 4:02pm
Location: Schnoogie


Re: Preparing gfx for a game

Postby John Lomax » Aug 31, 2001 @ 5:39am

File formats that support alpha channels are .tga, .tiff as examples. you really need a 32 bit image format (like targa, which most 3d packages support anyway).<br><br>There is no need to re-render with the ambient light turned up, or re-color the polys etc, virtually all 3d software supports alpha channels (its vital for compositing work). I cant remember if you put down what 3d software you use but simply render to a file format that supports it, with anti-aliasing enabled.<br><br>Targas are my prefered format.<br><br>Sometimes other 3d packages have options to enable alpha channels etc in the render process, so check with that first.<br><br>On argentum Wiro used max (rendering to 32bit tiffs). I uses maya (rendering to 32bit targas), worked fine using ag's alpha blending.<br><br>The images are 8bit palletized, and then a seperate 8bit alpha image. (extracted from the 32bit targa)<br>
User avatar
John Lomax
pm Member
 
Posts: 185
Joined: May 16, 2001 @ 6:04pm


Re: Preparing gfx for a game

Postby John Lomax » Aug 31, 2001 @ 5:52am

Actually just checked in rhino3d and the .tga<br>it renders out is 24bit no alpha.<br><br>Doesnt suprise me as rhino is mainly a nurbs modelling package, with very limited rendering capability. Kick-ass modeller though.<br><br>So if you are using rhino then you will have to do what digby says. Unless rhino has an incandescence material, then just make it pure white and assign that to the surface.<br><br>Would work just as good.<br><br>John.
User avatar
John Lomax
pm Member
 
Posts: 185
Joined: May 16, 2001 @ 6:04pm


Next

Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron