Jump to content
  • Advertisement
Sign in to follow this  
parroteye

Cubemap Reflections Are Too Predominant (Or How To Correctly Apply Environment Reflections)

This topic is 774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

 

I am starting my first renderer (deferred) and I arrived to the point of implement environment reflections. 

 

What I am doing is as follow: 

- Perform my lighting pass normally. 

- Perform a separate additive reflection pass where:

    - I sample my mipchain of the environment map  determining the mip with the roughness of the material and the sampling direction with reflect(N,V). 

 

Now if I do this the reflections are overpowering and the result is very different from what I see from various resources online on PBR rendering.

 

It is quite clear that I am missing something, so I have a couple of questions: 

 

 - Is there a term I am missing that should tone down the reflection depending on some material parameter? From the look of it there should absolutely be, but I don't know what :( Could you point me to a correct solution?

 - The cubemap I use is taken from internet and is not captured in engine. As such another fear I have is that my lights and in general intensities are of a different scale w.r.t the values in the cube map. How can I unify those intensities? I also guess this is a problem only if I use an HDR map... 

 

 

Thank you,

Jacques

 

P.S. Sorry for my English, but is not my first language. 

Edited by parroteye

Share this post


Link to post
Share on other sites
Advertisement

You should be evaluating your BRDF for both spec and diffuse, which should be energy conserving, so the question I see here is: what BRDF are you using? The rougher a material is, the less energy you get from spec term and the more you get from diffuse. It somehow sounds like your total energy is summing to more than it should, a picture of the problem would help.

 

Also PBR is really meant to work with HDR, and make HDR work a lot more smoothly/easier so using HDR cubemaps is the right move.

Edited by Frenetic Pony

Share this post


Link to post
Share on other sites

You should be evaluating your BRDF for both spec and diffuse, which should be energy conserving, so the question I see here is: what BRDF are you using? The rougher a material is, the less energy you get from spec term and the more you get from diffuse. It somehow sounds like your total energy is summing to more than it should, a picture of the problem would help.

 

Also PBR is really meant to work with HDR, and make HDR work a lot more smoothly/easier so using HDR cubemaps is the right move.

 

I am evaluating diffuse and specular BRDF (GGX) in the lighting pass in an energy conserving way ( I think... ) I don't have a pic now, but the issue is with the reflections from the cubemap that I perform as an additional additive full screen pass. How do I evaluate the BRDF on those reflections? I mean how do I scale the sample from the cubemap? 

Share this post


Link to post
Share on other sites

The current state of the art is to pre-convolve your cubemaps using your specular distribution (GGX PDF), and precalculate a 2D texture containing a scale & bias value to try and 'correct' the error between the raw cubemap values and the actual BRDF.

See this for starters, it's basically what everyone's copying these days :)

 http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf

Share this post


Link to post
Share on other sites

The current state of the art is to pre-convolve your cubemaps using your specular distribution (GGX PDF), and precalculate a 2D texture containing a scale & bias value to try and 'correct' the error between the raw cubemap values and the actual BRDF.

See this for starters, it's basically what everyone's copying these days :)

 http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf

 

Thanks I will have a read! Just to make a short summary to make my ideas clear. The steps I need to follow are: 

 

Offline:  I preconvolve my cubemap (I am assuming all the mip maps) with the method there specified in the presentation.

 

-  I shade my objects with my lights normally. 

- AFTER the previous step, I run an additive reflection pass. 

- On this pass, I sample the prefiltered cubemap with the correct mip level based on roughness. 

- Then I sample the scale&bias texture you mentioned and scale the result of the sampled cubemap.

 

This will give me a situation in which: 

 

- Not rough object will gets lots of reflections 

- Very rough object will get almost no contribution of the reflections. 

 

 

Is that it? :) 

Share this post


Link to post
Share on other sites

cut

to hack something together (not wanting correct result, just a rough idea of what was going on) I prefiltered my map with AMD Cubemapgen and used an approximation of Environment BRDF that does not required a LUT (I found it in actual unreal code and is referenced as Lazarov 2013, "Getting More Physical in Call of Duty: Black Ops II"). However, if I have an object of roughness 1 this is what I get: 
 
37cac27f139f475783c0a07cab42d6a3.png

Image that without reflections looks like 
 

ec05ea4bf610473380a7278261c20e66.png

 

 

And that's what I meant by overpowering result :(

 

 

The code is doing roughly what I described above, so stripping bits and pieces it becomes: 


		int mip computemip(roughness);
                 float3 V = normalize(cameraPos - worldPos);

		float3 outRefl = cubemap.SampleLevel(sampler, reflectionVec, mip ).rgb;
                outRefl *= EnvBRDFApprox(roughness, dot(N, V));

Where EnvBRDFApprox is taken from unreal code (so I am assuming is correct, not sure I can copy paste it here) 

 

I am also assuming all other parameters are correct since are used correctly in other shading passes, although I am not certain.. could you see anything obviously wrong? 
 

Although if I output the result of EnvBRDFApprox  it looks like it is almost white in most of the places... I am confused...

Edited by parroteye

Share this post


Link to post
Share on other sites

-  I shade my objects with my lights normally.  - AFTER the previous step, I run an additive reflection pass.  - On this pass, I sample the prefiltered cubemap with the correct mip level based on roughness.  - Then I sample the scale&bias texture you mentioned and scale the result of the sampled cubemap.   This will give me a situation in which:    - Not rough object will gets lots of reflections  - Very rough object will get almost no contribution of the reflections.

Before / after / at the same time, doesn't matter as additive passes can occur in any order and generate the same result.

 

There's two material properties that affect specular -- the specular mask (aka metalness mask) and the roughness (aka glossiness). Rough objects have dim, wide highlights, while smooth objects have bright, sharp highlights. Highly specular/metal materials have brighter specular overall than non-specular/non-metal objects (could be a 50x difference in intensity...).

Share this post


Link to post
Share on other sites

 

-  I shade my objects with my lights normally.  - AFTER the previous step, I run an additive reflection pass.  - On this pass, I sample the prefiltered cubemap with the correct mip level based on roughness.  - Then I sample the scale&bias texture you mentioned and scale the result of the sampled cubemap.   This will give me a situation in which:    - Not rough object will gets lots of reflections  - Very rough object will get almost no contribution of the reflections.

Before / after / at the same time, doesn't matter as additive passes can occur in any order and generate the same result.

 

There's two material properties that affect specular -- the specular mask (aka metalness mask) and the roughness (aka glossiness). Rough objects have dim, wide highlights, while smooth objects have bright, sharp highlights. Highly specular/metal materials have brighter specular overall than non-specular/non-metal objects (could be a 50x difference in intensity...).

 

 

I see thank you! So do you think that the example I posted above gives that result because I am assuming 100% metalness? Also how does the metalness scale the reflection? Is just a multiplicative scale? 

Share this post


Link to post
Share on other sites

to hack something together (not wanting correct result, just a rough idea of what was going on) I prefiltered my map with AMD Cubemapgen and used an approximation of Environment BRDF that does not required a LUT (I found it in actual unreal code and is referenced as Lazarov 2013, "Getting More Physical in Call of Duty: Black Ops II"). However, if I have an object of roughness 1 this is what I get: 

 
37cac27f139f475783c0a07cab42d6a3.png

Image that without reflections looks like 



 

ec05ea4bf610473380a7278261c20e66.png

 

 

And that's what I meant by overpowering result :(

 

 

The code is doing roughly what I described above, so stripping bits and pieces it becomes: 

		int mip computemip(roughness);
                 float3 V = normalize(cameraPos - worldPos);

		float3 outRefl = cubemap.SampleLevel(sampler, reflectionVec, mip ).rgb;
                outRefl *= EnvBRDFApprox(roughness, dot(N, V));

Where EnvBRDFApprox is taken from unreal code (so I am assuming is correct, not sure I can copy paste it here) 

 

I am also assuming all other parameters are correct since are used correctly in other shading passes, although I am not certain.. could you see anything obviously wrong? 
 

Although if I output the result of EnvBRDFApprox  it looks like it is almost white in most of the places... I am confused...

 

 

 

 

 

 

 

I see thank you! So do you think that the example I posted above gives that result because I am assuming 100% metalness? Also how does the metalness scale the reflection? Is just a multiplicative scale? 

 

 

 

I know I am being annoying here, but I really struggle to see the problem here :( Does anyone have an idea?

Share this post


Link to post
Share on other sites
How bright is the data in your cube relative to the green analytic light?
There's no way to tell if your scene is ok because we don't know what the environment is, or what the green light is.
If the environment is inside a flood-lit photo studio and the green light is a a 0.1W Christmas decoration across the room, then your end lighting appears too dark :wink:

So do you think that the example I posted above gives that result because I am assuming 100% metalness? Also how does the metalness scale the reflection? Is just a multiplicative scale?

It doesn't look like your EnvBRDF makes use of SpecularMask/F0/Metalness. Why not? I don't know what that function does... Maybe it's hard-coded for a specular mask of 3% (common non-metal) so everything is fine.

Do your analytic lights make use of SpecularMask/F0/Metalness?
Have you read the Brian Karl's course notes?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!