Home Technical Talk

Box to Sphere chamfer in shader - how to Normal Map?

polycounter
Offline / Send Message
Davision3D polycounter
I can chamfer any mesh inside the shader by using world position, this world position can then also be used for the normal simply by transforming it from world to tangent space. But the problem is how can I make use of the normal map texture without it being completely wrong and is that even possible?


Here is how it works, I'm using the material edtior of UE4:

This is basically range clamped world position with a box mesh:


I then use that for world position offset by multiplying where the edges are, so where 2 directions are located. I then do that with a different multiply for the edge points, so where 3 directions are. With some use of Power I can chamfer it pretty smoothly:

With a different range and power It can almost be spherical:


Here is it with the world position range transformed to tangent and plugged into the normal of the material:

But with trying to get any normal map texture working with it I'm getting nowhere. I tried all kinds of combinations with rotate vector and also using the vertex normal WS node but the result either has the normal map in it but is less rounder or it is fully rounded but the normal map looks only slightly applied.

I made this box for testing it, nothing is applied here:


here is it raw without the normal texture:

here the normal map texture:

Now I guess the smoothing group edges being smooth might be a unsolvable problem. Only getting any normal map applied correctly would be already great.

The goal would be to get something like this with chamfer:

Replies

  • Davision3D
    Options
    Offline / Send Message
    Davision3D polycounter
    No one? Just a guess if this is even possible would already help.

    I tried it some more but no luck. Also tried if setting the material setting to use only world position normal instead of tangent would help but it did not. If a heightmap would be required to do this that would be no problem to generate.

    Here is what I managed to do:

    The normalize input is the range clamped world position. This is using World Space normals as the normal input set in the material settings. As you can see the normal texture is only somewhat slightly doing something but it is fully rounded shaded. Those black spots are just there because I used lerps in the material before to quickly turn things on it off for testing. (Might because of some NAN errors because of lerp in the compiled shader code.)


    This looks more right but it is not spherical shaded, yet more rounded as just plugging in the normal map in the normal slot. If this setup looks kinda crazy to you then that is because I don't really know what I'm doing. I tried a lot more combinations but this are the 2 most promising.
  • bellas
    Options
    Offline / Send Message
    bellas null
    Hi my friend,
    
    Congratulations and thank you for your post.
    How do you do to get your chamfered cube ???
    I'm trying to do exactly that on any mesh.
    On what value do you act to increase the power of the chamfer ???
    "I then use that for world position offset by multiplying where the edges are, so where 2 directions are located, then I have multiple directions for the edge points, so where are 3 directions. it pretty smoothly: "
    
    Can you send me a screenshot of the blue print about the channel "world posiiont? Do you have a tutorial? Thank you Math

Sign In or Register to comment.