Custom BRDF for Unity 5.x Surface Shaders: Possible?

Hello -

I’ve got a terrain rendering problem on a fairly large-scale Unity 5 project, that requires a custom BRDF, using the new Unity 5 deferred renderer.

Unlike what the current documentation suggests, custom lighting models no longer work like they did in Unity 4 – deferred or forward. They can be used, but they simply modify terms as they are written to the deferred buffers – they can’t meaningfully use lighting terms as suggested by even the simplest example in the docs (SimpleLambert, as discussed here)

Which brings me to a custom BRDF – In my case, I’d like to essentially override the UNITY_BRDF_PBS macro as defined in UnityPBSLighting.cging, or more specifically (for the PC platform) provide a custom variant of the BRDF1_Unity_PBS shading model as seen in UnityStandardBRDF.cginc to my surface shader.

The reason: the default PBR BRDF model used by Unity simple isn’t doing the job – it takes a few (questionable) shortcuts, and the way refractive terms (fresnel) are handled result in unacceptable results at glancing angles. Which for terrain is a total deal breaker, since your typical panorama invariably includes expanses of such areas.

Is this possible? I’m hoping there’s some undocumented Unity 5 shader magic, that would allow me to override the BRDF used by the surface shader – some comments in the include files hint at this, but I’ve yet to find some means to do it.

Any help is appreciated, and thanks,

(PS: I’m not looking for some kind of global override, but a BRDF override for a specific surface shader)

1 Like

I’ve read somewhere Unity is using blinn-phong BRDF. I wonder if I can try Torrance-Sparrow ones. Sorry for non-informative post, I’m going to watch this thread. Thanks!

1 Like

Is this what you are looking for?

Use one byte in the g-buffer to mark your object, you can then check this byte to call your custom brdf.

1 Like

Can you please confirm that Unity is still using blinn phong BRDF in 5.6.3 ? I would really appreciate it !

AFAIK, ever since 5.3, Unity uses GGX.

1 Like

Can I know the details, like I know 4 GGX variations, which one does Unity use ? Where can I read this up . Thanks!

There is a comment in UnityStandardBRDF.cginc (download the shader sources if you want to take a look), that says:

That’s for High quality shader (in the tier settings).

Medium should be:

And Low:

Unity uses their own variation. So now you know of 5.