Dot Product Material Setup from basic nodes

Hi,

I’m learning Unreal 4 materials/shaders and have started trying to recreate some of the functions that Unreal packages up into a nice node by recreating them with the basic nodes, I’m attempting to try Dot Product as shown here on the Nvidia website;

so the formula is as follows;

float dot(float4 a, float4 b)
{
return a.xb.x + a.yb.y + a.zb.z + a.wb.w;
}

I’ve tried to recreate it in Unreal but my results are very different to the normal dot product result,

Any ideas or help is appreciated!

Thanks :slight_smile:

OK i did it!!!

I was appending the vectors rather than adding them!

http://s14.postimg.org/mmjn70ow1/Dot_Product_Final.jpg