# 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.

## 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 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.

Edited by Frenetic Pony

##### 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 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 :)

##### 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 :)

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 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:

Image that without reflections looks like

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 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 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 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:

Image that without reflections looks like

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 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.

Have you read the Brian Karl's course notes?

1. 1
2. 2
3. 3
Rutin
18
4. 4
JoeJ
14
5. 5

• 14
• 10
• 23
• 9
• 32
• ### Forum Statistics

• Total Topics
632630
• Total Posts
3007521
• ### Who's Online (See full list)

There are no registered users currently online

×