mr_pinc

Is there Support for Object Space Normal Maps?

Recommended Posts

Is there a way to use object-space normal maps instead of tangent-space normal maps?  If not  do you plan to support object-space normal maps, or world-space normal maps, in the future builds?

Share this post


Link to post
Share on other sites

From my technical artist:
 

our typical project showcases a very complex mechanical object, or set of objects.

we are constrained by draw culls and by content size in megabytes, due to the fact that our app needs to download quickly even with a mediocre connection speed.

since the amount of pieces in our objects is high, the triangle count we can afford per piece has to be minimal. what makes matters worse is often most pieces have unique shapes, so instancing does not completely solve the problem.

we are using normal maps to fake some details, but we run into the common issue of lowpoly geometry smoothing which produces visual artifacts. we can provide examples later if required; but just think of your keyboard which has no definite smoothing seams, but lots of smooth angles and bevels, many of which have to have a geometrical representation in addition to pixels.

 

utilizing the normal compensation approach we can bake the geometry smoothness data, invert it, and combine with the normal map to restore the visual smoothness where required (check handplane.com for some nice examples). we are also averaging the geometrical normals to reduce the artifacts.

but this can only take us half-way, since this approach does not always work 100%. in such cases, using object-space normal map instead would give us full control over the look of our assets - and those arealways either static, or animated on object level.

of course the same could be achieved with world-space normal maps, but this would result in wrong visuals for instanced objects (think of two instanced bolts facing different directions); thus we would have to revert to unique meshes with unique UVs and correct world space normal data in the texture.

 

the cost of one extra channel does not seem too high (meaning we could use B of tangent space normal map for storing something useful, and that of course would not be possible with OS or WS). the precision difference would be negligible as well. we are also not using any detail normals currently, so combining normals would not be an issue. 

now, we understand that adding the OS option could lead to refactoring in many unexpected places. but we keep our hopes up.

 

The attached image  is for illustration purposes only - example of smoothness artifacts resulting from geometry; adding tangent-space normal map here would not hide the issues completely.   this asset in general also illustrates how the artist had to introduce numerous hard edges across bevels to preserve the smoothness. this introduces a lot of sharp lines where things need to be smooth, and adds extra cost to geometry, multiplying the number of verts to be exported

 

smoothness.jpg

Share this post


Link to post
Share on other sites

right now you're taking normal of the triangle. the missing step (which would be optional with default == false) would rotate this normal based on object pivot or world

it would be in this section:

 

// get edge vectors of the pixel triangle
vec3 dp1 = dFdx(p);
vec3 dp2 = dFdy(p);
vec2 duv1 = dFdx(uv);
vec2 duv2 = dFdy(uv);
 
// solve the linear system
vec3 dp2perp = cross(dp2, normal);
vec3 dp1perp = cross(normal, dp1);
vec3 tangent = dp2perp * duv1.x + dp1perp * duv2.x;

vec3 bitangent = dp2perp * duv1.y + dp1perp * duv2.y;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.