• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Telanor

Transparent voxels

15 posts in this topic

Is there a way to properly render layered transparent objects when you can't do depth sorting? Since the terrain is all built up into 2 vertex buffers per region (1 for solid blocks, 1 for transparent blocks), we can't do the typical depth sorting. Are there any alternatives?

This is what its coming out like right now:

[attachment=13842:RuinValor 2013-02-23 21-42-37-02.png]
1

Share this post


Link to post
Share on other sites

Ah.. well i saw some things behind it, here let me give you a better example:

 

gallery_1_8_386976.jpg

gallery_1_8_808132.jpg

 

Added a video so you can see what it looks like more clearly. Should be in 1080p here shortly:

 

[media]http://www.youtube.com/watch?v=93DNZHmqVH8&feature=youtu.be[/media]

Edited by riuthamus
0

Share this post


Link to post
Share on other sites

It looks like simple "sample alpha to coverage". It will give you order independent transparency with antialiasing, but you will have just N levels of transparency, where N equals your (multi)samples count for your framebuffer. Nah I'm not a good teacher, rather see here:

 

Here is a demonstration with brief description - http://www.humus.name/index.php?page=3D&ID=61

2

Share this post


Link to post
Share on other sites

-- Drawing your grass with additive blending and no depth testing, and a write mask of rgb=false, a=true (so that only the alpha channels are summed).

-- Drawing your grass with depth-testing and alpha-testing (no blending), and a write mask of rgb=true, a=false (so that only the color channels are written).

First pass state:
descBlendAlphaOnly.RenderTarget[0].IsBlendEnabled = true;
descBlendAlphaOnly.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.Alpha;
descBlendAlphaOnly.RenderTarget[0].SourceBlend = BlendOption.SourceAlpha;
descBlendAlphaOnly.RenderTarget[0].SourceAlphaBlend = BlendOption.SourceAlpha;
descBlendAlphaOnly.RenderTarget[0].DestinationBlend = BlendOption.One;
descBlendAlphaOnly.RenderTarget[0].DestinationAlphaBlend = BlendOption.One;
Second pass state:
descBlendColorOnly.RenderTarget[0].IsBlendEnabled = false;
descBlendColorOnly.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.Red | ColorWriteMaskFlags.Green | ColorWriteMaskFlags.Blue;
Are these correct?

This is the result I'm getting:
[attachment=13870:RuinValor 2013-02-24 00-33-06-95.png]

I have no alpha testing on the first pass and the 2nd pass uses this:
if(color.a == 0.0f)
	discard;
Edited by Telanor
2

Share this post


Link to post
Share on other sites

I added a dark bg for simple testing purposes. I know that when I am making the final one I need to have something near the color tone of the primary color.

 

Edited by riuthamus
0

Share this post


Link to post
Share on other sites

Actually scratch that, he said he is using a PNG that i made... the png is here. It has no alpha.... so not sure why that would happen

 

gallery_1_8_19068.png

0

Share this post


Link to post
Share on other sites
I had the wrong blend mode. Halos are fixed now. Can we use premultiplied alpha to get rid of the grass-on-grass darkness? Or does that not work?

Edit: Another question: will this work for glass and other transparent blocks without looking terrible? Edited by Telanor
2

Share this post


Link to post
Share on other sites

I had the wrong blend mode. Halos are fixed now. Can we use premultiplied alpha to get rid of the grass-on-grass darkness? Or does that not work?

Edit: Another question: will this work for glass and other transparent blocks without looking terrible?

admittedly, I am not really sure if premultiplied alpha really makes much of a difference. usually what seems to cause this sort of effect IME is the color values within the fully transparent pixels, which some graphics programs I use (such as Paint.NET) seem to automatically replace fully transparent pixels with black.

a trick I have used which mostly fixes the issue in my case, was to have a blurred version of the image in the background with a very low (but not quite zero) opacity, which causes the colors near the edges to "bleed over" into the transparent pixels.

another related trick is to use weighted blending when generating mipmaps.

say, rather than:
r=(r0+r1+r2+r3)>>2;
g=...
a person can use something like:
ta=a0+a1+a2+a3;
af0=(4096*a0)/ta;
...
r=(af0*r0+af1*r1+af2*r2+af3*r3)>>12;
g=(af0*g0+af1*g1+af2*g2+af3*g3)>>12;
...

which is slightly more costly, but oh well...



another thing:
I draw my terrain in front-to-back order for opaque geometry, and back-to-front for alpha blended geometry.

granted, in my case, I render the terrain per-chunk. though not perfect, the use of per-chunk sorting usually draws things in "about the right order". rendering per-chunk also allows omitting chunks which are not visible.

this gives the correct draw order "in general", but by itself may still result in transparent geometry clipping within the same chunk, but this isn't usually as big of an issue IME.

for better sorting, a BSP + index-array or similar can be used. say, a BSP walk is done and used to fill out the contents of an index array. another simpler (but more costly) solution, could be using a variant of QuickSort, and sorting alpha-blended geometry per distance (probably only for chunks near the camera).

likely, if a BSP were used, this could be a small (per-chunk) BSP, probably using a quick-and-dirty algo whenever the geometry for the chunk is rebuilt.

the BSP is probably only needed for blended geometry, whereas for opaque geometry, the exact draw order is less important, and it is much more useful to have everything sorted out by texture/material.
0

Share this post


Link to post
Share on other sites

admittedly, I am not really sure if premultiplied alpha really makes much of a difference. usually what seems to cause this sort of effect IME is the color values within the fully transparent pixels, which some graphics programs I use (such as Paint.NET) seem to automatically replace fully transparent pixels with black.

 

That's the point of using premultiplied alpha - the premultiplication step changes those colour values to zero and because you then use additive blending instead of interpolative blending they contribute nothing to the final image.

 

(The name is misleading - you premultiply the RGB based on the alpha, as well as alter the alpha itself.)

Edited by Kylotan
2

Share this post


Link to post
Share on other sites


admittedly, I am not really sure if premultiplied alpha really makes much of a difference. usually what seems to cause this sort of effect IME is the color values within the fully transparent pixels, which some graphics programs I use (such as Paint.NET) seem to automatically replace fully transparent pixels with black.

 
That's the point of using premultiplied alpha - the premultiplication step changes those colour values to zero and because you then use additive blending instead of interpolative blending they contribute nothing to the final image.
 
(The name is misleading - you premultiply the RGB based on the alpha, as well as alter the alpha itself.)


fair enough. I wasn't entirely sure what premultiplied alpha did exactly (when used for rendering).

as-noted, where relevant, I had generally preconditioned the images.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0