• 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
bzroom

G Buffer

13 posts in this topic

Here's my format so far

RGBA8: diffuse RGB 8 bits each, shininess 7 bits, is emissive 1 bit*
RGBA8: normal xyz 8 bits each, spec value 8 bits.
Depth 24f s8: depth 24 bits, stencil unused*

The problem is that I'm not storing both emission and diffuse. so an object must be one or the other. Unfortunately the artists will not accept this.

I could:
Add a render target (seems excessive for such a simple emission effect)
Some how use the stencil or existing channels differently (material id?)
Render emissive stuff in the transparent/blending pass afterwords.
Somehow modulate diffuse and emmision together and store some kind of unpacking ratio. (thats what I'm doing right now, except the ratio is binary)

What are your thoughts?
0

Share this post


Link to post
Share on other sites
[quote name='bzroom' timestamp='1324031308' post='4894441']
What are your thoughts?
[/quote]
Start looking for an other artist ...:cool:

To be honest, talk to your artist, why does he need this requirement ? When he needs it, because he wants to deliver textures in a certain format (he delivers diffuse,normal,emissive textures) , you could still write a little converter to transform his textures in your format. It this requirement for some killer feature of your game/engine, or is it just a theoritically feature which might be useful in the future ? Which would be a useful usecase ? (a green wall with emissive blue light ? :blink: )
0

Share this post


Link to post
Share on other sites
If majority of your objects are *not* emissive, I would recommend rendering emissive (as well as other effects like environment mapping) in another pass after the deferred light rendering. The Z-buffer will already be primed, so you should get early-Z rejection for occluded objects.
2

Share this post


Link to post
Share on other sites
[quote name='AgentC' timestamp='1324035432' post='4894460']
If majority of your objects are *not* emissive, I would recommend rendering emissive (as well as other effects like environment mapping) in another pass after the deferred light rendering. The Z-buffer will already be primed, so you should get early-Z rejection for occluded objects.
[/quote]
Very workable. You can even recycle your actual illumination buffers for this purpose, and then draw light contributions in on top of the emissive. It's some extra draw calls, sure, but that shouldn't be too bad unless you have a *lot* of emissive objects.

0

Share this post


Link to post
Share on other sites
The most notable case is that we want the armor to sort of glow in the dark.

We want it to always glow, and yet react to light. Some swords have animated glowing regions. Like cracks with lava in them. We could easily separate these into two draw calls.
But a glowing green armor is going to be harder to "split up."


So a characters entire body suit would need to be rendered twice.

If i did render them in a second pass, i could skip the whole "1 bit is emissive" packing stuff which would be nice.
0

Share this post


Link to post
Share on other sites
To be honest, I suggest going straight to four G-buffers and stretching your legs a bit. You're probably still in the exploratory phase here for features, performance, etc and playing packing games right from the beginning is not going to be fun. Be generous with resources, find out what works and how real scenes look, and then strip it back down from there as necessary.
1

Share this post


Link to post
Share on other sites
I'm targetting the xbox 360. Memory consumption and texture fetching is at a premium. Performance asside, we're already well into production and the scope of our art is pretty well known. At this point, besides emissive materials, the rendering methods are indistinguishable. In other words we dont really need any more features. What we need most is performance and memory.

I'm going to investigate drawing them in a separate pass.
0

Share this post


Link to post
Share on other sites
Have you considered doing pre-pass lighting? It's basically the same as what you conclude, but for all objects in the scene. It uses less render targets (usually just one if you have hardware support for reading depth buffer) that classic deferred rendering, and also enables more variety in the materials (which is sorta that problem you're having).

Probably drawing the emissive mesh a second time is a nice thing (if there aren't too many of them), as it gives you the most flexibiltity. Imagine extruding the triangles and using some fancy-pants shader, you could probably have a volumetric glow rather than a flat emissive.
0

Share this post


Link to post
Share on other sites
[quote name='harveypekar' timestamp='1324082815' post='4894666']
Have you considered doing pre-pass lighting? It's basically the same as what you conclude, but for all objects in the scene. It uses less render targets (usually just one if you have hardware support for reading depth buffer) that classic deferred rendering, and also enables more variety in the materials (which is sorta that problem you're having).

Probably drawing the emissive mesh a second time is a nice thing (if there aren't too many of them), as it gives you the most flexibiltity. Imagine extruding the triangles and using some fancy-pants shader, you could probably have a volumetric glow rather than a flat emissive.
[/quote]

I wouldn't suggest this, overall. A light-prepass renderer would entail rendering *everything* twice for marginal gain. As bzroom stated, things are already in feature lock so I think materials, etc. don't need much more flexibility. As far as I'm aware this approach is considered more or less superceded nowadays and the advantages over straight deferred shading were somewhat dubious even way-back-when.

On topic-- If you can hold off on drawing emissives until the end of the opaque pass, you can probably even get around the second draw call, just bind the illumination buffer as an additional render target and have the shader write out the emissive color; depth rejects will take care of the rest. The one problem I see is that this is going to eat up more EDRAM, and I don't know what your budget for that is.

EDIT: I see you're using unpacked normals, too. As a thought you could switch over to a compressed format (spheremap transform comes recommended) and then have 8 bits left over for a monochrome self-illumination value. I'm unsure if this would be satisfactory for the artists, though.
0

Share this post


Link to post
Share on other sites
Thats a really good idea. That's essentially what i was hoping to do. Store some coefficient that transformed the diffuse into the emissive factor.

Sort of like barycentric light coordinates. Where a 0.25 would indicate that the stored color is 0.25 between diffuse and emissive.
So neither the diffuse nor the emissive value were directly stored, but rather the barycentric value and coordinate were stored.

I'm not sure if that's even possible. But your solution is almost exactly that, assuming the only difference between the two colors was intensity.

Thank you. I'll run that by them.

edit:
I'm using unpacked because each channel is only using 8 bits. :(
I'm pretty sure we could spare another render target. But i would be proud of the implementation if it only needed 2 targets. It would also obviously be significantly better with less render targets. In terms of memory and texture fetches and resolve times.
0

Share this post


Link to post
Share on other sites
[quote name='bzroom' timestamp='1324268527' post='4895181']
Thats a really good idea. That's essentially what i was hoping to do. Store some coefficient that transformed the diffuse into the emissive factor.

Sort of like barycentric light coordinates. Where a 0.25 would indicate that the stored color is 0.25 between diffuse and emissive.
So neither the diffuse nor the emissive value were directly stored, but rather the barycentric value and coordinate were stored.

I'm not sure if that's even possible. But your solution is almost exactly that, assuming the only difference between the two colors was intensity.

Thank you. I'll run that by them.

edit:
I'm using unpacked because each channel is only using 8 bits. :(
I'm pretty sure we could spare another render target. But i would be proud of the implementation if it only needed 2 targets. It would also obviously be significantly better with less render targets. In terms of memory and texture fetches and resolve times.
[/quote]
Well, you want to keep your artist :P Then this is the way I do it my engine:
I support multi-layered, emissive materials, but in the g-buffer I only store the index of the material, in the lighting pass I take this index, get the material vectors and use it to do the calculation. To handle materials more granulary I save 2 indicies and an alpha value per pixel to interpolate between different material. All material vectors are saved in const shader parameters (as said, only needed in the lighting pass). When rendering a model to the g-buffer, I use a uniform parameter per surface to hold the indicies and an alpha value saved in a texture to manage the material distribution.

I would change your current gbuffer like this:
[code]

RGBA8: diffuse RGB 8 bits each, 8 bit material index A
RGBA8: compressed normal xy 8 bits each, 8 bit material index B, 8 bit alpha value


// lighting pass pseudo shader code:
vec4 materialA = materials[material_index_A]
vec4 materialB = materials[material_index_B]
vec4 material = interpolate(materialA,materialB,alpha)

final_light = diffuse * (light_factor * material.diffuse_channel + material.emissive_channel) + diffuse * ( pow(spec_factor,material.spec_exponent) * material.gloss)
[/code]

This way you have some freedom to expand the material properties (I currently use 3 material vectors), while keeping a constant impact on the g-buffer.

An alternative is to save the texture coords and make several texture lookup.

For normal compression take a look here: [url="http://aras-p.info/texts/CompactNormalStorage.html"]clicky[/url]
0

Share this post


Link to post
Share on other sites
Thanks Aras. I have been reading your compression page for a while. I'll be sure to put it to use when i can.

The thing i haven't understood yet about material id systems is how this would work on a per pixel basis.

Specifically if they wanted to have an emissive map (along side their diffuse map.)
Say they want to have a rainbow emission texture mapped onto the surface of a model.
It seems like with the material lookup, there can only be only emission color for the whole surface.

Also, looking at your psuedo light model, it looks like they can also only have one specular intensity per material.
So the interpolation between materials would not be independent for both emission and specular.
Ie: If the material interpolator goes to one side or the other, both the specular and the emission factors will be affected.

Am i understanding correctly?
0

Share this post


Link to post
Share on other sites
Having the g-buffer output emissive as the starting point for light accumulation works out fairly well.

You can't avoid clearing the buffer to black, so you might as well have the g-buffer pass fill it in for you.
0

Share this post


Link to post
Share on other sites
That's what i'm doing now. But we're talking about how the first pass the emissive/depth fill, and future light passes differentiate between diffuse and emissive colors without explicitly storing the two in the G-Buffer.

Feel free to post the format of your G-Buffer for reference.
0

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