- Render it in opaque pass, using alpha test to discard transparent pixels
- Render it in transparent pass, using true alpha blending
Here is the transparent pass render of small test scene, as a reference:
![]() |
A patch of Dactylis glomerata, rendered in transparent pass |
Even small patch of forest or meadow will have tens of thousands of polygons. Something like realistic landscape simply is not doable using transparency on current generation hardware.
This leaves us with the other option - opaque rendering.
While writing foliage shaders for Shinya the biggest problem was, that scaled down textures (i.e. higher mipmap levels) looked totally crappy. Whatever was the original shape of plant - looking at it from distance it morphed into rounded blob.
The reason for it was the minimization algorithm, that averaged alpha. Thus the parts of foliage where there were only few "holes" - i.e. central parts - became completely opaque. And the parts, where there were only few leaves - i.e. outer regions - became fully transparent.
The "original" opaque render, using default mipmap generation (box filer):
![]() |
The same image, rendered in opaque pass with box-filtered mipmaps |
While messing with textures and trying to find the best alpha cutoff value, I finally got the right idea - we do not want to get the average image but want to preserve "features" of image in minimization. Features being both "holes" and "patches" (i.e. leaves). This can be done by increasing high frequencies of image. I.e. we want to replace the standard mipmap generation filter (normally box filter) with something better.
Fortunately I was already composing mipmaps by hand while creating packed textures. Thus I added very simple edge-detection filter with 3x3 kernel to the foliage mipmap generation (after the minimization with box filer). And the results were really good.
The "enhanced" opaque render with edge detection filter:
![]() |
The same image, rendered in opaque pass with edge-detection filter |
As you can see, edge detection successfully preserves the general features of the texture - stems and narrow leaves, while simple box filter tends to smear these out.
The kernel for edge-detection was:
-1 -1 -1 -1 9 -1 -1 -1 -1
And here is a screenshot of the foliage shader in action. The meadow size is about 40x40 meters, grass is about 50000 instanced polygons.
![]() |
Sara in meadow |
You can download the Dactylis glomerata texture from my DeviantArt gallery.
Have fun!
شركة الصفرات لتنظيف المنازل بالرياض
ReplyDeleteشركة مكافحة النمل الابيض بالقطيف
Thank you for sharing the wounderful Article
ReplyDeleteشركة نقل عفش بينبع
نقل الاثاث بالمدينة المنورة
http://www.transferfurnituremedina.com/
http://www.transferfurnituremedina.com/yanbu-movers/
Smilearrow Find best products values got thousands of online top most bought items key points, rankings, price, photos lot of cool stuff to get from
ReplyDeleteSearching for the Best Convertible Car Seat? Want to get a reliable place? need a detailed review? Browse here, you will get a list of 10 best convertible car seat to choose yours spending a very short time. A complete and easy to read buying guide is also available for you here
ReplyDeleteBestHandheldMassager the best handheld back massager Reviews site. You should know about handheld massager’s size, price range etc. How each of them can benefit you.
ReplyDeleteIt is important for history coursework writing service students to seek History Essay Writing Services from a reputable history research paper service provider for their custom history paper writing help services.
ReplyDelete