Our Properties: Gamasutra GameCareerGuide IndieGames Indie Royale GDC IGF Game Developer Magazine GAO
My Message close
Latest News
spacer View All spacer
 
February 10, 2012
 
DICE 2012: Activision's Hirshberg believes creative people should lead companies
 
GDC 2012 reveals Super Mario 3D Land, Resident Evil Revelations postmortems
 
What drives the developers of Unity?
spacer
Latest Features
spacer View All spacer
 
February 10, 2012
 
arrow Virtual Goods - An Excerpt from Social Game Design: Monetization Methods and Mechanics
 
arrow Principles of an Indie Game Bottom Feeder [21]
 
arrow Postmortem: CyberConnect 2's Solatorobo: Red the Hunter [1]
spacer
Latest Jobs
spacer View All     Post a Job     RSS spacer
 
February 10, 2012
 
Adhesive Games
Senior Engine Programmer
 
Adhesive Games
General Engineer
 
Capcom Game Studio Vancouver, Inc
Producers & Designers Wanted
 
EEDAR
Business Analyst
 
Rockstar San Diego
Tools Programmer
 
Rockstar San Diego
Gameplay Programmer
spacer
Blogs

  Rendering Plants with Smooth Edges
by David Rosen on 09/09/09 11:06:00 am   Expert Blogs   Featured Blogs
2 comments Share on Twitter Share on Facebook RSS
 
 
  Posted 09/09/09 11:06:00 am
 

When we are rendering many objects on screen at the same time, we only have a few hundred polygons to allocate to each individual plant. We use intersecting alpha-mapped planes to give the impression of much greater detail. Here is a picture of what our desert tree looks like with the alpha channel used for color instead of transparency:

Tree

If we just turn on blending, it starts to look like a tree, but there are serious artifacts around the leaves. The transparent pixels in the nearest leaves are occluding the background leaves. The following pictures are zoomed in ~200% for clarity; click to see the full image.

Tree

We can fix that problem by turning off depth-writing. But now you can see the background leaves in front of the foreground ones!

Tree

We could draw everything in the correct order by sorting each quad from back to front, but this is slow, and intersecting quads would have to be split. In practice, the most common solution is to turn off blending, and turn on alpha-testing. That is, for each pixel it checks if the alpha value is above some threshold, and if so, draws it at 100% opacity.

Tree

Now we have everything drawn in the correct order, and it looks like a very detailed tree, but we have lost the smooth, blended edges. This is especially problematic when viewed from far away. Here is an enlarged distant view with alpha-testing used on the left, and blending on the right.

Alpha Compare

One way to get smooth edges using alpha testing is to use the multisample buffers. By using a different stippling pattern in each alpha buffer, you can combine them to get fairly smooth gradients.

Tree

However, this option is not supported well on many 3D cards and only works well with 4x or more samples per pixel. What we are doing right now in Overgrowth is drawing the plant using alpha testing, and then drawing it again using blending with depth-writing disabled. This is not perfectly accurate, but it is compatible, easy, and fast.

Tree

Please let me know if you have encountered this problem before, or know of a better solution!

Follow us here!
Facebook iconModDB iconSteam iconTwitter iconYouTube icon

 
 
Comments

j kelly
profile image
David,

Thank you so much for writing a detailed code oriented blog, complete with pictures! Is it possible when testing for distance, that you switch rendering modes for turning blending on or off?

mik fig
profile image
Thank you for an excellent article :D,

Mikfig


none
 
Comment:
 




 
UBM Techweb
Game Network
Game Developers Conference | GDC Europe | GDC Online | GDC China | Gamasutra | Game Developer Magazine | Game Advertising Online
Game Career Guide | Independent Games Festival | Indie Royale | IndieGames

Other UBM TechWeb Networks
Business Technology | Business Technology Events | Telecommunications & Communications Providers

Privacy Policy | Terms of Service | Contact Us | Copyright © UBM TechWeb, All Rights Reserved.