I want to create a special material which renders based on the color of light that falls on it. in UDk this was easy since it used a forward renderer. But UE4 is using a deferred renderer and hence I do not have access to lighting info within the material.
What I wanted to do was to change the specular color and diffuse color based on an equation that needs the color components of the light and the light vector. I know how I can achieve it for a single light source. But what I need is to make t work for arbitrary light source.
Is there a way to force a material to use forward rendering? Or is there any other trick you know?
Yes this looks like it will work for me. However I have one question, I need both the color and location of each light (so that I can calculate angle between light and surface). So I need two arrays for storing these. Now my question is does Materials allow array params. I know I can use Vectors and Scalars, but what about an array of scalar or vector properties? If that is supported, then I am good to go.
If that is not possible, then I think I will have to go with a float4x4 matrix and take only the nearest 4 lights (which might work). I can make a float4x4 as param in HLSL, so I assume this work for Unreal. right?
No, Arrays are not available in the Material Editor, but you can use the custom node to generate a float4x4 matrix. I do want to point out that the Custom node in the Material editor right now cannot handle loops of any kind.
Thanks.
I went with the matrix approach. I can manage without loops since there are only 4 items max. Still support for loops in material editor will be a nice addition (both HLSL and GLSL supports loops)