Calculating Bidirectional Reflectance Distribution Functions using UE4

Hello all, I was wondering how the calculation of BRDFs in relation to UE4 engine work is done. I’m currently trying to learn how BRDFs work and how they relate to physically based lighting models as part of a PBR pipeline which I intend to use for my project (though I’m only just learning now how PBR is used and how it’s implemented in modern real time rendered applications). How do the stuff like BRDF shaders, specular/diffuse models and stuff come together to accurately determine the bounce refractive light in relation to objects with real-world PBR material values? Can this all be done solely in UE4 or do I require some other software, like how Autodesk Maya is used for MEL scripting?

Hi Icaraeus,

The BRDF models are all calculated under the hood in engine code, and you can see the source code for it in Unreal Shader Files (.usf). To modify them you need to build the engine from source code and take a look there. There isn’t really much if any documentation on these since if you’re playing with them you usually know what you’re doing, so it’s mostly up to you to figure out what’s going on there. You can modify them just like any other bit of engine source and recompile the engine to see the differences in your materials.

I did play around with this a while ago and switched the standard Lambert diffuse shader out for an Oren-Nayar diffuse model. PBR is made up of several components though, such as the specular part of the shader as well for example.

Thanks Jamsh!

Just to clarify, would I need to use the VS 2015 Community compiler to build the UE4 source code? I’ve never done something like work with source code before - at least, not yet :smiley: If, say, I figure out a unique way to make UE4 work with BRDFs effectively do I just upload the source code to the GitHub panel so that it gets integrated into further revisions of the engine?

You can just update shaders. No c++ code changes needed. Shader also can be hotloaded. Shader Debugging Workflows Unreal Engine | Unreal Engine 5.1 Documentation