nav2

Showing posts with label normal maps. Show all posts
Showing posts with label normal maps. Show all posts

Sunday, May 15, 2016

Some notes on baking Normal maps again

Flipping UV islands is a common way of getting more pixels to cram in detail. What you do is for each symmetrical part of your model, you take the left side and flip it over the right side.

 That doesnt mean that the entire left side should be the same as the right - if you do that your model will of course be a bit bland. So plan in advance which parts you want to have symmetric and which not. You should plan it right from when you start making your high poly model.
In my case, I sculpted the nude in Zbrush completely from scratch, but used marvelous designer to create his outfit:

Making the hoodie was a  gotcha moment.I had to first stitch it in neutral pose over his head and run the simulation to get it to wrap around it naturally, then I puled it down to fall over his jacket during another cloth simulation. He looked good with a hoodie on, but the final design was planned  with a hat on instead.
Marvelous provided some really nice realistic cloth simulation which resulted in a good starting point for wrinkles and detail. Bringing the clothing back to Zbrush - I added detail to it - more wrinkles and a zipper here and there, the shoes and shoe laces. The hat, the hands and the respirator mask are all made in blender - where modelling them made much more sense. For the mask I used modifiers heavily. Wireframe modifier was perfect  for the cage.

Naturally the generated cloth mesh had no symmetry. So then when I started doing retopology in blender - the plan started forming more. For the outfit I will keep the middle part asymmetric, but will reuse the texture space of the sleeves. Same goes for the pants. His face will be completely unwrapped, but I will reuse uv texture space of the neck, the the cap shade and the shoes.


So I did the model accordingly in two stages- first retopo the asymmetric bits, then do the ones that reuse texture space - with a mirror modifier. I had to cut the hi poly model import from zbrush and marvelous designer into body parts and make the planned ones symmetrized for the high poly mesh - where there was no symmetry for the clothing. Thankfully blender has wonderful sculpting and modelling tools that make that part a walk in the park.

 When baking a normal for a target model with flipped islands that overlap their counterparts, you are most probably going to get seams.
If you want to avoid it, but still be able to reuse texture space via flipped uv islands, it is important to do this: Select all islands that overlap other islands, and move them in X + texture.width.


As a side note you need to consider that this UV technique does not work if you need to bake a lightmap on the model - which is usually the case for static background objects.

For the mask normal baking, I arranged the uv islands in a way that it will bake the bars perfectly horizontally and vertically. It is generally a good practice to arrange your islands in a way where you will get less diagonal lines on the bake - try to avoid diagonal straight lines as a whole. Horizontal and Vertical lines have  no anti-aliasing you see - so geometric detail such as this looks much crisper on lower texture sizes. If you look at model rips from old video games - you will see that they utilized this approach quite successfully to get some good looking textures as small as 256 or even less. I was also being cheap again with reusing UV space  with a vertical mirror. Whenever you can, and especially for detailed parts with repeating elements - try to reuse texture space!

In most cases, you will still need to clean up the bake result.
The normal cleanup was done in Krita, as 3D-Coat does not allow cleaning up external normal maps. Their import layer is locked and limited to very few operations.
 It was however quite good at further detailing them during texturing with your PBR materials. Next post will be about that =)

Monday, May 5, 2014

Normal maps - Round two (3d Coat)- Dragon



I thought that my portfolio needs more detailed, game friendly 3d models. For that reason it was needed to tackle the subject of normal map baking yet again. I have done so in the past and looking at it retrospectively, that post didn't really reveal in a concise way the things that affect how a normal map bakes. So here goes my dragon experiment.

First off I used Blender to sculpt the dragon and push dyntopo to the test. I wanted to push it to it's limits on my dual core, 4gb ram laptop.
593 108 triangles seems to be the limit dyntopo can get to before becoming completely unusable. Now some of you might think - oh but  you can use lights instead of matcaps, you can disable double sided faces, switch off outline selected, turn on vbos, you can do this or that to speed up the viewport. I know about those tricks - they do help the viewport. It is not the viewport, it is dyntopo. The moment you turn on dynamic topology at that polycount , the screen freezes and lags extremely on every brush stroke.Optimize doesn't seem to do anything either. A trick would be to split the model to parts, but I didnt wanna do that. So at that point I just decided to continue working on this in 3d coat. It would be a fine opportunity to practice more in 3d coat.

I gave the model more detail there and played with the voxel room's tools. The rest of the pipeline I did in 3d coat. So what are the things that affect a normal map bake:


0. Topology - the retopology stage can be really important as to how your bake ends up looking like.
One must strive to have good edge flow not only for animation, but also for a better normal map- an optimal number of polygons to cover the high density mesh in a way that would best preserve it's silhouette. After all the silhouette will be the thing that would give away the fact that it's just a low poly model with a normal.

It is also good to note that weird edge flow used to reduce the polycount can cause problems further down the line. N-gons should be avoided. Triangles shouldn't be used at areas that will deform. Non-planar faces can be problematic too- some turn all polygons to triangles for that reason.

There are a lot of elements that can amount to a better normal map bake if you know about them. Since it's a big subject and I am certainly not an expert yet, you could try checking out Hai Phan's excellent video course on sculpting and baking.


1. UV unwrapping - is the next step of the pipeline that is key to the resolution of your normal map.
In previous posts here I have noted that one way to efficiently use UV space is to have folded and overlapping islands (left over right half). Since overlapping them could cause problems, another approach to have them reuse pixel space is to simply shift them in X or Y by exactly the size of your texture space. That way if you set your texture to "tiling" the outside of uv space islands will still get the detail. Other obvious points to rehash:
- Every uv seam is taxing a bit more the real time renderer. So a good rule of thumb would be to have less uv islands if you can. In example above I was just pressured by time to unwrap it faster. It's always easier to just have many islands.
- Try to pack the islands in a way that they use as much pixel space as possible.
- Try not to have any weird uv island overlap/twist upon itself. Example above has one island that way on purpose to test the possible issues that could arise during bake.
- Try to hide uv seams in areas where they are not likely to be seen from the common camera angles/character poses. Crevices are also a good spot to place them.

2. Baking (cages) - That is another thing Blender users can't enjoy at the moment I am writing this. 3d coat gives you the ability to easily set a baking cage. An inner and outer shells that would determine the range of the high density model. It's a nice way to reduce potential normal map garbage for cleaning up later on. But I found that it is still not enough to give a completely perfect bake on a complex model such as the dragon. So I still had to do some cleaning up.

3. Dealing with holes and garbage in the normal map (clone tool)

At this point after getting my bake out, it is important to compare the low poly mesh with the normal to the high density mesh. Comparing the two reveals minor issues scattered all over the normal.

The easiest way I found to clean up those issues is by using the smudge, blur and clone brushes. These tools are well known to photoshop users, but can also be found in both 3d coat and blender.Finally I used a new bump layer in 3d coat to touch up the normal map- increase some crevices, smooth out some other areas. And another bump layer to add more fine detail such as scales/etc. And here is all that combined with a quick texture: 
In this post I do sort of compare 3d coat to blender. The truth is that both are excellent apps for 3d sculpting. Blender is still catching up on that front though. Some of it's current disadvantages are being worked on. If you want to support that development, consider donating to the blender foundation or joining the Blender Cloud!..


.

Tuesday, March 1, 2011

Blender vs Zbrush on normal maps

I've been juggling a number of projects lately. The animation on piggybank has been in the background and I haven't done much work on it since the last post. The models for the moCap project are ready now and this article will focus on the technical side of things as normal maps are concerned.

There is also a freelance job (a short 2d animation) that took some priority- I just want to make sure it ends up looking very good. :) I wont go into detail about it right now, as it wouldnt be professional to discuss it in early stages, while the client is very much deciding on how it progresses. I am not the type who would release anything I'm working on without the client's permission.

Anyway, onto normal maps.
It has been my main interest since the first day I started using a 3d package. How do I get a LOT of detail projected onto a low poly mesh. And whats with that obsession with low poly stuff (!?) some might ask. Am I just being a cheap bastard here , with today's technology advancing so quick. :D
Let me state the obvious advantages of keeping your mesh low on polycount- use geometry only where you need it.
- your computer can handle the files, especially if they are part of a giant scene.The files can be used in real time rendering engines. The playback speed while animating is near normal- no need to playblast it a billion times- its a waste of time.
- you can edit the files faster- its easier to edit the overall shape (especially with maya), its easier to paint weights (skinning) when you dont have to deal with a lot of geometry= that equals faster workflow
- You need geometry only to define the silhouette of a character and to define how the character deforms. The details can be achieved through bumpmaps and even better - normal maps. It makes me cry a little, every time I see a model that has been subdivided a million times, has geometry to define cloth wrinkles, face wrinkles,creases/cracks/etc, hair detail, etc etc. Why oh why dont you just make a normal map and bake all that stuff there?

Normal maps are just fancy bumpmaps. Some people convert bumpmaps to normal maps ( not much of a difference there lol). Some people convert textures to normal maps. Want to put some cracks on a rock? There is a photoshop plugin that should do it for you, you can also use xnormal. There is nothing wrong with that- it's just not good enough for something like a next-gen character. While bumpmaps contain information about depth, Normal maps go a step further. They contain information about direction of that depth. So one can have a really low poly character look very very detailed. The only thing that will give it away will be the silhouette of that character.
I know about displacement maps, but I wont go there now :D

So for next gen characters, one basically tells the software to compare the low poly mesh to the high poly mesh and create a normal map for the low poly mesh. Mudbox, zbrush, maya, blender- they all have tools to do that.

Since blender has a special multiresolution modifier for its sculpting mode, it is actually pretty damn good at detailing characters and baking a normal map. It might not be as good at handling giant meshes as zbrush, but its good enough to do the job.

I spent about a week in learning from trial and error about normal maps. For my little experiment, I used the two characters that I made for the moCap module. These guys are pretty much a work in progress and I am not even near pleased at where they are at the moment. Both of them have tangent space normal maps (tangent space is good for meshes that deform, but its a bit more expensive to render than world space, which is good for static objects)


Scarlet Thorn:

Scarlet was made almost entirely in zbrush. I made the hi res mesh (detailing) and exported a normal map from it in zbrush. The texture was also made in zbrush.Whats good about Z and I think is one of it's killer features (correct me if I'm wrong but mudbox doesnt have it) are the selection mask modes. Just with a click of a button, Z is capable of masking all the crease areas- that makes it extremely easy for the artist to flesh out detail..


On the screenshot, you can compare how it looks like with detail in zbrush (actual looks) and then how maya portrays the normal map on the low poly object. I didnt show render, because rendering has million of options to tweak and that alone can make it look like anything.

Zbrush flips the map vertically by default. It also left me with some slight edge marks, which I had to clean with the smudge tool in Gimp. That was a bit annoying, but it still got me a decent normal map.


Sepia Baron:
I dont have to tell you how much more advance zbrush is at sculpting than blender. But the new blender has some key features that make it worth my time. First of all, its a modelling package that has sculpting capabilities. The brush engine in blender is actually kind of nice.I can do the whole pipeline in it- from modelling the low poly (check metaballs as a nice alternative to zspheres), retopology, uv mapping, detailing (sculpting). Blender can do it all :D. Maya is useless at sculpting- utterly useless... So I sculpted detail of my character in Blender- the newest build , then I baked it and got out a nice normal map.



What was surprising about Blender's normal map was- it actually was cleaner than the one I got from zbrush. I know he's a simpler character, but I didnt get anything that needed my attention in gimp.
The only annoyance in blender is that when you subdivide the model, you can really feel the weight. It's probably a good idea to turn off skype while sculpting on subdiv 6. But that is likely to change, when the unlimited clay modifier gets released in some of the future builds. :D


I used the normal map as a basis for the texture, since I wanted to bake some slight shading on the finer detail. The texturing was done completely in Blender+gimp. Its incredibly easy to use them at the same time- blender has a really nice integration with gimp, when it comes to image editing.


Normal maps and rendering engines~ This is pretty much where all the hedaches start for the artist. Different software handles normal maps differently. Maya has three ways of rendering it-
~hardware (viewport) render- seems to display the normal maps without any problems. Note that you should avoid having flipped uv islands- that always offsets the map slightly and creates really ugly seams. I got away with fipped island on the hands and feet, since I wanted to preserve some UV space... but that backfired on me. I needed to go back change the UV of Scarlet thorn in order to get rid of seams. Thankfully zbrush is capable of projecting detail from one mesh onto another (both texture and shape), so I didnt have to redo all that I had.
~Software (maya) render- is absolute rubbish at rendering normal maps. :D I might have missed something. I've tried my best, but not only do I get ugly seams everywhere possible, but its also not very good at representing the hi res detail.
~ Mental Ray render- Seems to be pretty good at normal maps. I got no seams, the hi res detail is pretty good. One thing to note is that it desaturates the textures. I dont know a lot about mental ray. Everything I've posted this far has been rendered with maya's native software render. I dont have the time to learn mental ray, so what I posted now at flickr is as default as it gets.

While still being on the subject of rendering and normal maps, it would be worth looking into how it works and why there are seams/hard edges in some cases. Blender developers have been hard at work on documenting that and improving the normal map baking magic that happens . It certainly has been a growing interest for me to follow its development and there have been some pretty exciting things happening there-keeping my attention.