Generating Custom Per-Pixel Normals?

I’m trying (and failing) to create super-accurate per-pixel normals for a Sphere object. The problem is both the texture and the mesh don’t give enough fidelity, there’s still a lot of break-up and visible seams, particularly with reflections that seem to be very sensitive to this.

I thought just taking World Position and Normalizing it, then transforming to Tangent Space would give me the correct normals, but apparently not. Do I need to rotate them or something as well?

EDIT: It does, I’m just being stupid…

All you should need is local worldposition. No need to convert to tangent space since UE4 renders the lighting with everything in worldspace.

So normally just do normalize(worldpos-actorpos).

That’s exactly what I thought at first too, but surprisingly it didn’t give me the right result, especially with the reflections - I had to transform from World > Tangent.

You have to specify that the Normal input is in world space instead of the default tangent space. There’s a checkbox on the material - bTangentSpaceNormal - uncheck that then you can hook up world space normals.

Ah, thats because we both forgot that for that to work, you need to uncheck “Tangent Space Normal” in the material options.

if you do that, it will be a tad cheaper. Otherwise you are paying some tiny cost to transform into tangent space and then back to worldspace by the engine.

haha beat me to it.

Ninja’d :stuck_out_tongue:

That makes sense now! Thanks :slight_smile: