Pages

Saturday, September 8, 2012

[How-To] create Self-Shadowing Materials (UDK/UE3)

An esay approach on implementing self shadowing for UE3 to increase the quality of normal and bump offset/parallax mapped materials even further. It does require a heightmap and is useful for bumpy surfaces like bricks and cobblestones.



Material

The idea is quite simple. Offsetting the height map along the light direction and comparing it's value with the actual height determines which areas are shadowed. Scale and darkness/hardness of shadows can be controlled by adjusting the offset and contrast value.


The technique is not very expensive - adding an extra of 5-10 point light shader instructions (depending on the contrast value). It's possible to save some instructions by adding a constant clamp (0-1) before the contrast adjustment and by replacing the power node with a series of multiply nodes (e.g. 3x multiply by itself = power of eight).




Screenshots





7 comments:

  1. Hey m8 :)

    The material look awesome :D

    I've made the material but I don't understand how to setup the "constant clamp instruction -1" node ?

    Can you plz elaborate more on this & explain the value to put to achieve -1 :o

    ReplyDelete
  2. Hi mate,
    both constant clamp nodes have a min value of 0 and a max of 1. You don't necesseraily need the first one, but it does decrease the material instruction count by 1. So nothing special, just add a constant clamp and leave as it is.

    cheers

    ReplyDelete
  3. Ah, now that I understand it decrease the material instruction count, it's great! THX again m8 :)

    ReplyDelete
  4. Very good technique, but why after build lighting all the shadows disappear

    ReplyDelete
  5. It's a little bit late to answer but it's because static lights does not have coordinate information stored after building.
    The closest one to use instead standart lights is toggleable lights.

    ReplyDelete
  6. The reason is, there is no light vector with fully static lights (e.g. a regular point light).
    Lights labeled with D/S (e.g. dominant directional light, toggleable lights) should let you use static lighting but with a dynamic lighting component.
    This is not only beneficial for this technique but also to have dynamic specular highlights instead of the pre-baked/lightmapped ones.

    ReplyDelete
  7. Is this achievable in UE4? (Im a noob when it comes to shaders, i tried to mimic your set-up, but got no results).

    ReplyDelete