I've noticed that UE4 doesn't allow one to access the light direction vector when creating a pixel shader in the material editor.
I understand that we are now in the age of physically-based rendering, but I find this limitation to be quite problematic. I cannot, for instance, recreate the HeidrichSeidel anisotropic distribution model inside of UE4 as the formula relies upon an incoming light direction vector.
I wonder if anyone has found a way around this restriction. Is it possible to access the light direction vector if one writes and compiles in HLSL, and then integrates the shader instructions into UE4 somehow? Has anyone else hit this problem and found a way around it?
Replies
All materials that have that MPC vector will get auto updated as the blueprint updates the vector, without any noticeable performance cost.
More info on MPCs: https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/ParameterCollections/index.html
Obviously, this will only work for 1 light, but it very doable if one light is all you need.
If you don't mind diving into the code, the source for the basic shading models is all editable. This just goes beyond what you can do in the shader editor.
Also, if you look around in the shader sources you'll notice that some alternative shading models are already hidden in there, just not exposed by default. Nothing anisotropic as far as I know though.