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

UE4 IBL / shading confusion

5 posts in this topic

Few months back I had a thread here on trying to implement their approach of IBL using this so called split-sum-approximation and I thought I understood what it was trying to do (same with other aspects of their paper)...I guess I was wrong and I'm even more confused now.

 

For anyone who doesn't know which paper I'm refering to: http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf

 

1. Metallic shading parameter: I'm still unsure if I get what this parameter actually does. What I thought it does is have some value [0-1] that just attenuates the diffuse term like so:

Diffuse *= 1.0f - metallic;

Because if we want the material to be more metallic the diffuse term needs to decrease until it's fully gone for an actual metal. Just attenuating the fresnel reflectance does not completely remove that. Looking more closely at the pictures in the paper it looks as if they control the actual FresnelReflectance with it, something like:

FresnelReflectance = lerp(0.04, 1.0f, metallic);

Does anyone know what the parameter actually does ?

 

2. Cavity Map: They describe this as small-scale shadowing...so is this just an AO map ? But then they talk about this being a replacement for specular (do they mean specular intensity?)

 

3. Split-sum-approxmation: Now this is the most confusing thing to me. My understanding of this was that they additionally precompute a 2D texture that handles the geometry and fresnel portion of the BRDF and that this is a lookup texture that is used during the realtime lighting pass to attenuate the FresnelReflectance so that it looks more realistic(?) / e.g. removes the glowing edges at high roughness. Am I wrong ?

I've generated this 2d lookup texture and it look almost precisely like the picture in his paper except that it's rotated 45 degrees for some odd reason ? I've tried rotating it so it looks the same as in the paper using photoshop but the result of looking up the values seems completely wrong (did he just artificially rotate the texture just for the paper ??) while the original texture does produce reasonable(?) results in that if applied to a sphere the edges become increasingly stronger the smoother it is.

Let me give you a few screenshots:

 

This is the texture generated by me:

zB8UF1G.png?1

 

This is the texture shown in his paper:

 

TDb6Dhh.png?1

And here's a quick video showing how the fresnel reflectance looks like using the formula described in the paper:

FresnelReflectance * EnvBRDF.x + EnvBRDF.y

https://www.youtube.com/watch?v=bdY1rvDPCB8&feature=youtu.be

 

 

Also what does he mean by can only afford a single sample for each (why would you have more ?):

 

Even with importance sampling, many samples still need to be taken. The sample count can be
reduced significantly by using mip maps [3], but counts still need to be greater than 16 for sufficient
quality. Because we blend between many environment maps per pixel for local reflections, we can only
practically afford a single sample for each

 

In his sample code he uses a sample_count of 1024 which in my tests produces lots of dots on the env map from the random distribution and it only gets better using at least 5k samples. I don't see how he does that. Is this just a case of making the precomputation faster because of hundreds/thousands of probes ?

Edited by lipsryme
2

Share this post


Link to post
Share on other sites

3) Not sure about the precomputed textures - are your inputs mapped differently to his? I've used an empircal EnvironmentBRDF for playing around at home (similar to the one in http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf) and haven't tried that approach yet (it's on my list though). The 1024 samples he takes in the sample code is (I assume) for generating the reference version so he can see how close the split-sum approximation gets. 

 

0

Share this post


Link to post
Share on other sites

Hi,

 

1) As far as I can tell, the metallic parameter controls how the primary colour is used i.e. whether it goes into diffuse (metallic == 0) or into specular (metallic == 1) or a mix somewhere in between. When metallic == 1, the diffuse colour is black (0), when metallic == 0, the specular colour is assumed to be 0.04 (which is typical for the majority of non-metals as they tend to lie between 0.02 and 0.05 for common things). Perhaps something similar to this in shader terms:
 

vec3 diffuse = mix(colour, vec3(0, 0, 0), metallic);
vec3 specular = mix(vec3(0.04, 0.04, 0.04), colour, metallic);

 

2) I *think* the cavity map is multiplied by the resulting specular value to help darken it - light from an environment map tends to look a little too bright in small creases without proper occlusion being taken into account, so this is a reasonable work around for it. They no longer need a separate specular input (except for special cases) as it's handled by the single colour input and the metallic parameter.

Thanks for clearing it up for me. That seems to make the most sense...

Is this cavity map just a single channel 8bit texture ? If they use the base color as the specular color I guess this only needs to be greyscale, right ?

Can't think of a reason otherwise...

 

3) Not sure about the precomputed textures - are your inputs mapped differently to his? I've used an empircal EnvironmentBRDF for playing around at home (similar to the one in http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf) and haven't tried that approach yet (it's on my list though). The 1024 samples he takes in the sample code is (I assume) for generating the reference version so he can see how close the split-sum approximation gets. 

But 1024 samples don't come close to being enough to produce an image that has no dots on it (errors from random distribution). As I said it gets better starting at 5k+

The explanation parts in that paper are really confusing as to what he is actually doing. He seems to compare his approximation with a full approximation (N == L) and an importance sampled reference...but...isn't what he is doing here importance sampling ?

 

I'm using the exact same code to compute the 2d texture with the only exception being G_Smith(Roughness, NdotV, NdotL) which he didn't have code for.

So I looked at his blog and figured it to be this:

float GGX(float NdotV, float a)
{
	float k = (a * a) / 2;
	return NdotV / (NdotV * (1.0f - k) + k);
}

// http://graphicrants.blogspot.com.au/2013/08/specular-brdf-reference.html
float G_Smith(float a, float nDotV, float nDotL)
{
	return GGX(nDotL, a) * GGX(nDotV, a);
}
Edited by lipsryme
0

Share this post


Link to post
Share on other sites

Metallic works like Tessellator wrote, but it's also has an additional specular parameter (which is equal 0.5 by default). Mentioned specular parameter is driven by a cavity map (single channel).

BaseColor = Cavity * OldBaseColor
Specular = Cavity * 0.5

DiffuseColor = lerp( BaseColor, 0, Metallic )
SpecularColor = lerp( 0.08 * Specular, BaseColor, Metallic )

https://forums.unrealengine.com/archive/index.php/t-3869.html

https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/PhysicallyBased/index.html

 

As for split sum aproximation try comparing with an reference shader, which takes hundreds of samples per pixel in real time.

Edited by Krzysztof Narkowicz
2

Share this post


Link to post
Share on other sites

Thanks for those links, that answers it.

I find the FresnelReflectance(they call it Specular) * 0.5 peculiar...

I guess they did it to limit the range of non-metals to something that was foolproof.

Edited by lipsryme
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