I try to get rid of the “shadows” generated by a NormalMap in order to only render the areas of the texture that are directly struck by the light.
As a new UE user, i dont know how to achieve this. I thought at first that using the “Blend_Screen” node in the material graph could be a solution, but i dont know how to apply this blend to the final texture, after the NormalMap affects it.
Any ideas ? Im also searching for the exact opposite (keeping only the shadow areas)
Welcome to UE! And yes, the effect you are looking for can be achieved, we just need to approach it differently. The engine doesn’t turn off the shadows created by a normal map, as the point of the normal is altering how the surface reacts to lighting. To separate lit surface from shadow with masks, you need to skip the default shading model, and apply a custom lighting inside the material.
Checking with my peers, the way to get this effect, is implementing a dot product between your normals and the light direction:
Use a Transform node (Tangent > World) to convert your normal map result into world space
Grab the Light Vector (assuming you are using directional lights, you can use a “VectorParameter” matching your light direction)
Apply a Dot Product between the world normal (with normal map applied) and the light vector:
Dot = 1 > fully facing the light
Dot = 0 > perpendicular
Dot = -1 > fully facing away
For more details, please check the documentation below for each topic:
Thank you VERY much for this very detailed documentation, i leared many usefull things !
Im now trying to use the DOT Product in my material BP but i cant figure out how to retrieve the light vector. How can I access to an actor property from a material BP ?
I found how to “connect” two actors BP, but not how to connect an actor BP and a material BP.
Obviously, its not working because i didnt specify how the dot products output should apply a mask. Im kinda stuck at this point : i dont know how i should use this to apply a mask on the normal map.
you can do this in forward rendering “easily”. just use the inverted normal to get the shadow vector. in deferred there are some more complications. there is no dot product. it samples a hemisphere of all the lights around it. you don’t get the light vectors for singular lamps. or multiple light vectors for all the lamps in a loop.