Monday, February 13, 2012

[How-To] use Oren-Nayar diffuse reflectance for UE3 materials

The oren-nayar lighting model is predestined for rough surfaces like sand, broken concrete or clothing for example. It takes into account inter-reflections and therefore has a major advantage over UDKs default lambertian diffuse lighting.

The following material is based on a simplified (yet quite correct) version of the original model and a mathematical simpification suggested here.



Material Setup:















The roughness parameter should be within the 0-1 range. For values > 0 you will notice the point light shader instruction count increasing by more than 20. If the roughness is equal zero the whole shader gets simplified and is the same as UDKs default lambertian lighting.
Also notice that that you won't need to use a custom lighting material to implement the oren-nayar diffuse lighting model. In case of a custom lighting solution keep in mind that you'll need to add the lambertian lighting part to this material network (multiply diffuse by a clamped dot product if light and normal vector)
I will will add a downloadable .upk later, in case you dont have the time to build this material on your own. (I don't expect you'll do this out of laziness ;) )




Comparison

I made comparison screens of 2 different surfaces at 3 different roughness parameter values to give you a rough impression. The FPS counter illustrates the impact on performance. Don't worry about the absolute low values, I tested this with my office rig and a low-end gfx card (Geforce GT520)

1 comment:

  1. Thanks again this was really helpful, Is there a download link for this material?

    ReplyDelete