What's this doing in the PBR shader? (Chapter 7)

float3 Cspec0 = float3(1.0);
float fresnel = pow(clamp(1.0 - hDotl, 0.0, 1.0), 5.0);
float3 Fs = float3(mix(float3(Cspec0), float3(1), fresnel));

Isn’t that using the fresnel value to mix between (1.0, 1.0, 1.0) and (1.0, 1.0, 1.0)? I checked the source shader from the referenced Apple firetruck sample and it’s the same there.

Huh. Yes, I think you’re right. I used the Apple one, as you can see in the shader code, because it looked so much better than all the ones that I calculated. But perhaps I should have stuck with mine.

I’ll revisit it in the near future.

Apple’s Modern Rendering with Metal sample has a different implementation of fresnel.

1 Like

Ha! I have that open in another tab already so I guess I should take a look … :slight_smile:

There are a number of links on PBR in references.markdown in the Resources folder.

This was the formula that I followed, but couldn’t get it to look as good as the Apple shader in time for publication.