Download

Self-Shadowing in POM and Lerp for heightmap - help needed.

Hi! POM needs a light vector for self-shadowing. My question is - how do I get it? I’m not very good at Blueprints and would really appreciate a step-by-step of how I can get the light vector that I need. I tried it a couple of times some time ago and failed.

Also, MF_POM requires a TextureObject for it’s input. I want to Lerp between two heightmaps before I plug the result into MF_POM, but texture objects do not work with a Lerp. How do I solve this? I really do not want to use 2 POM_MFs for two mat layers in the same shader and blend them afterwards.

To get the light vector you make a new blueprint class and create a variable of “Directional Light” reference. Then make that variable editable. Now place the BP in your level and find your variable and use the dropper tool to select your directional light. now the BP has a reference to the actual light.

Then create a “material parameter collection” and add a single vector to it. Call it LightVector or something. Now inside of your BP, drag your directionallight variable into the construction script and then drag off it and do “get forward vector”. Now place a “set vector parameter” node, point it to your MaterialParameterCollection and set the value to be the light’s forward direction.

Then you can drag the MPC into your POM material and get the light vector there. You may opt to actually put the directional light itself into the light vector BP so that whenever you rotate the light, the MPC value updates automatically in sync.

Regarding your second request, to do what you want properly will require a new version of the POM function that actually takes 2 texture objects input, since the tracer will actually have to step through the alpha map at the same time as the heightmap. Unfortunately I cannot yet figure out a way to handle landscape alphas since they cannot be read as texture samples. And any sort of POM function will always require a texture object in order to work, since it has to sample the texture at a different location each step, and that is only possible with a texture object.

I did some experimentation with blending multiple layers with the current POM and while it kind of works, you do not get the correct intersection between multiple layers. You can see that experiment here:

https://forums.unrealengine.com/showthread.php?49169-POM-material&p=342068&viewfull=1#post342068

Thanks a lot, RyanB! Everything worked and updates nicely. Also, I’ll keep an eye on on your POM thread.