Jump to content
mohrag

Rendering Normal Maps?

Recommended Posts

Hey Guys!

In a recent demo vid on how Houdini can be used in games, they showed how ocean fx can be used to create normal maps for fluid. 

at 7:46

I'm just wondering, how do I render the normal map? 

So far, I unwrapped my grid, and used polyframe to get my normal, tangent and bitangent. But I'm unsure on how to get the colour to reflect the correct values.

From a lot of reading, it looks like I have to  orient my current normal to turn it into tangent space? I've given it a guess, but it doesn't look right. 

My next step is then how do I bring this into COPS (what it looks like he's using) to save the normal map out? 

Thanks a lot!

 

fluid_texture_02_HALP.hipnc

Share this post


Link to post
Share on other sites

You don't have to do any tangent space transformations here, with ocean surface. Idea of tangent space is, roughly, "looking along depth", like in camera space. Lifehack-solution for cases like rendering of sprites or planes. Just use object space normals from geometry oriented along depth axis. See fix scene. Don't forget to fit vectors from -1..1 to 0..1 range. By the way, isn't it just object space normals? With double gamma correction, probably. Normal maps should be in gamma 1.0 to have correct numerical values of vectors.

JzuZ7ec.png

To render a real normal map, sample object space normal, then multiply it with an inversion of tangent space basis (matrix3 of tangent, bitangent and normal) to get tangent space normal. It is good idea to compute this matrix beforehand, instead of constructing it inside vops. Less nodes, less ways to shoot yourself in the foot. Vectors must be normalized, properly transformed into same space, basis must not be broken by sop-level transformations, etc. Here an example of baking tangent space normals and color textures using Mantra and pig head. Snapshots are from Unreal Engine 4. Green channel set inverted. It can be synced with target engine by transforming tangent space.

UqpJp64.pngH01HsNY.png9AsVk9a.png

 

 

*

 

UP: this stuff was for H14 where baking tangent normals was an interesting task. Now with H15 some workflows in pighead example may be outdated a bit. But not much.

 

*

fluid_texture_02_HALPED.hipnc

pighead.hipnc

Edited by f1480187
  • Like 2

Share this post


Link to post
Share on other sites

The gradient COP in H15 can produce a tangent space normal map from a height map, as well (Gradient type: Displacement, Output: Normal Map, adjust Scale parameter to fit the displacement scale). It's very important to make sure both the loaded displacement map and the saved image are loaded/saved as Linear, especially if they're in an sRGB format like JPG, tiff or PNG.

Share this post


Link to post
Share on other sites

Rather late, but thank you for the replies!

Got so wrapped up in solving it, I forgot to come back and say thank you! :)

  • Like 1

Share this post


Link to post
Share on other sites

Hi guys !

i would be curious to know , what is now the proper workflow to compute a tangent space normal map for UE4.

I have try the new H16 ROP bake texture, but the normal map i get looks broken compare to what i get in substance ?

Cheers 

E

EDIT:

To solve the pb you must install the last Game Dev Tools Shelf 

https://github.com/sideeffects/GameDevelopmentToolset

Beware to switch the GitHub Branch to Development before download.

 

And use the ROP Game Baker

foo.jpg

Edited by sebkaine

Share this post


Link to post
Share on other sites

You probably need to flip the green channel (1.0 - G). There's 2 styles of normal maps, GL and DirectX, due to the fact that window Y=0 is at the bottom in GL, and the top in DirectX (matching X11 and Win conventions).

Share this post


Link to post
Share on other sites

Mantra's TS should be very close to MikkTSpace, with small artifacts on UV seams (if they weren't fixed in the last year). Normal maps baked in Mantra should look correct, with possible channel reversing. Houdini is +X right, +Y up, -Z forward; UE4: +X forward, +Y right, +Z up, also it is depends on baking material.

Make sure texture node inside UE4 material has Sampler set to Normal Map. If it wasn't automatically set, there are chances that texture wasn't imported and compressed as a normal map too: check asset settings and compare with normal maps from Starter Content.

When everything is correct, NM will look very nice, smooth and seamless. If it looks "moderately good" and shading reveals very distinct seams, probably, the NM still not set correctly or it was baked with very different tangent space.

Edited by f1480187

Share this post


Link to post
Share on other sites

Thanks a lot for the extra info guys ! i will push that further.

From my test for occ / height / N / thickness beetween high / low substance is just the best tool in term of speed.

But houdini shine to export all the exotic stuff you want.

 

As a side note i was using an old H16 release, i have update it and you now have a MikkTSpace option in the rop bake.

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

×