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

Light Prepass output color differences

6 posts in this topic

I was considering switching my engine from a deferred shading to a light prepass (deferred lighting) approach. From my initial readings on deferred lighting, it seems that this method will not generate the same ouput as deferred shading since we are not taking into account the diffuse + specular colors of the materials during the light buffer generation. So if an object is affected by multiple lights, it will only apply the surface color to the output once vs the deferred shading approach which multiplies in the surface color for each light (I am talking about the phong model specifically). 

 

I assume that to generate the same output as before, I would have to modify the light properties for each light to generate the same output or modify the deferred shading implementation to only apply the surface color once. Another option is to add surface data to the g-buffer but that brings us back to deferred shading. In my current implementation I can switch between deferred and forward shading and the output is about the same, however this will no longer be the case with deferred lighting.

 

Is there something I am missing or is this indeed the case ? how are other engines which have switched to deferred lighting handling this ? Are you just ignoring the differences and keeping with one lighting method ? or applying some function in the code to modify the light properties in a prepass renderer. I would assume this transition would be a bigger issue in large projects with multiple scenes and lights.

 

 

0

Share this post


Link to post
Share on other sites

Splitting diffuse + specular seems like a good idea. Wouldn't that still produce a different output than deferred shading though. For example, lets just take diffuse into account ignoring specular.

 

my current deferred shading approach (which I believe is how everyone does it ?):

 

float4 color = 0,0,0,0;

for each light

  color += surfaceColor * (NdotL * lightDiffuseColor);

freameBuffer = color

 

deferred lighting approach:

 

lightAccumBuffer = 0,0,0,0

for each light

  lightAccumBuffer += (NdotL * lightDiffuseColor);

 

scene render pass

   framebuffer = lightAccumBuffer * surfaceColor

 

In the examples above, the surfaceColor is multiplied into the lighting contribution for each light and that result is added to the frame buffer. Whereas in deferred lighting, the surface color is only multiplied in once. Wouldn't this produce a different result ?

0

Share this post


Link to post
Share on other sites

I edited my post above at the same time that you replied:

A*x + B*x + C*x == (A + B + C)*x

 

Both of these equations are mathematically equal (just ask wolfram). If you can re-arrange the left one into the right one, then it may be more efficient to implement in a computer because there's less operations.

0

Share this post


Link to post
Share on other sites

Well, now that you put it like that, I can see that they are in fact identical :) (as long as we keep diffuse and specular seperate)

 

I guess I just got tripped up by thinking in terms of lights and passes and missed the simple equation.

 

Thanks!

0

Share this post


Link to post
Share on other sites

Splitting diffuse + specular seems like a good idea. Wouldn't that still produce a different output than deferred shading though. For example, lets just take diffuse into account ignoring specular.

 

my current deferred shading approach (which I believe is how everyone does it ?):

 

float4 color = 0,0,0,0;

for each light

  color += surfaceColor * (NdotL * lightDiffuseColor);

freameBuffer = color

 

deferred lighting approach:

 

lightAccumBuffer = 0,0,0,0

for each light

  lightAccumBuffer += (NdotL * lightDiffuseColor);

 

scene render pass

   framebuffer = lightAccumBuffer * surfaceColor

 

In the examples above, the surfaceColor is multiplied into the lighting contribution for each light and that result is added to the frame buffer. Whereas in deferred lighting, the surface color is only multiplied in once. Wouldn't this produce a different result ?

 

Mathematically the results are the same due to the distributive property, as Hodgman has already pointed out. In practice there can be differences due to precision and conversion behavior of render target formats. If you're using floating-point formats then it's not likely to be a significant issue.

However, I feel I should ask why you're considering using a "light pre-pass" approach in the first place. It can be useful if you *really* don't want to use multiple render targets (which can be beneficial on a certain current-gen console), but outside of that it doesn't really have any advantages. It forces you to render your geometry twice (both times with a pixel shader), it's harder than regular deferred to handle MSAA (at least if you want to do it correctly), and the second pass doesn't really give you much more material flexibility since it happens after applying the BRDF.

Edited by MJP
0

Share this post


Link to post
Share on other sites

The main reason was material flexibility without having to store additional parameters to the GBuffer, but thinking about this more based on what you said, it doesn't seem that much more useful since the BRDF has already been applied as you said. Basically I was just wondering if I were to switch, if there would be any discrepancies in the output. I probably won't switch unless I find a good reason.

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