Home Unreal Engine

Can someone explain to me why this shader effect doesnt work?

I am trying to get the rain texture to pan slower when the vertex normal direction is facing upwards. Below you can see the shader network and a screenshot of the result.

It seems like the engine only chooses one normal direction and in those cases the result comes as expected. However when the normal direction is something else it fails and the panning gets really weird. The arrows in the picture describes in what UV direction the texture is panning. It should be worth mentioning that after a long time those "red"/failed areas gets really distorted/squeezed and after a certain amount of time you cannot even see the texture anymore.
If I clamp the values to min 0.0< ( example 0.8 ) max 1.0 more and more triangles get correct panning but ofcourse then I don't get the result I am after.

so yes.. It's kind of hard to explain but I hope I did ok.
If anyone has any idea of what's going on - please post : )

polycount_weird_directions.jpg

Replies

  • JedTheKrampus
    Options
    Offline / Send Message
    JedTheKrampus polycounter lvl 8
    Have you tried using world-space for texture coordinates? That could work better than UV-space.
  • JoakimMellergard
    Have you tried using world-space for texture coordinates? That could work better than UV-space.

    How do I set world-space?
  • almighty_gir
    Options
    Offline / Send Message
    almighty_gir ngon master
    one other issue i can think of, is that worldspace vertex normals aren't simply a case of "blue channel = up". up is a combination of all three channels.

    so the first thing you'd need to do is find out what direction is "up" in UE4 (for example, is it Y up? i'll use that as the example i'm about to make).

    then you'd need to find a way of describing what constitutes "up" in relation to the vertex normals. so i would do a dot product of the vertex normals, and a vec3(0,1,0). you would need to invert that though, as it would basically read as "1" or "full" whenever a face is directly up, and if i'm understanding you correctly you want it to be 0 or "none" when it's facing up.
  • JoakimMellergard
    one other issue i can think of, is that worldspace vertex normals aren't simply a case of "blue channel = up". up is a combination of all three channels.

    Thank you! I was thinking of this earlier but I had no clue on how to solve it. This might work. I am going to try it out now.
    And btw, Z is up in Unreal Engine.
  • JoakimMellergard
    @Almighty_gir
    You were thinking like this, right?
    This is giving me the same result as earlier.
    polycount_weird_directions2.jpg

    EDIT
    I changed the vector3 to (0,0,-1) and inverted the VertexNormalWS node. Now I get a complete "flow" (no more weird directions) but the time seems to be the same all over the surface. The time is always muliplied by 1.

    Also, it might be worth mentioning that in my first post where you see green arrows the effect actually worked. The panning was actually slower when the surface faced upwards.
Sign In or Register to comment.