2017년 7월 24일 월요일

Reconstructing world normal from depth to resolve decal artifact.

UE4 has deferred decal. and it is widely used in our levels.
Onday our artists complained that vertical projected decal pixel shows stretching artifact like below photo.


At first, I thought that multiplying dot(worldnormal, float(0, 0, 1)) to opacity could resolve this issue so that vertical face does not receive decal. But it turned out I was too naive.

Deferred decal material cannot read world normal gbuffer data while it writes normal to gbuffer. So I could use world normal to determine if it is vertical face.

I almost frustrated but soon found the solution. We actually can reconstruct world normal from depth buffer using ddx/ddy instruction.

world normal = cross(ddx(worldposition), ddy(world position)
Multiplying this to opacity give this!

Vertical face does not receive decal.








댓글 2개: