Rendering UV unfolded objects to texture in runtime

Hi

I am trying to convert dynamic lightning to some form of simple light maps at run time.

I have made a material that renders the object flat, (in this case it’s a UV flattend cylinder) as it’s UV mapped in channel 1 (light map channel).

I have also made a blueprint to rendering UV unfolded meshes in the scene objects to captured texture on disk in runtime using console command.

But the shadow rendering has been messed up, because that one uses the same material…

I guess I wonder how I set up two materials per object?

One for shadow rendering and one for drawing the object per say.

Or will the shadows still be applied in screen space and there for wrong.

Whats the correct way of doing this?

Regards

Lee