Search Unity

New to bump mapping. What am I doing wrong?

Discussion in 'Formats & External Tools' started by MrDude, Aug 19, 2010.

  1. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hia.So I just created a simple model and then went and did something really simple to it in Mudbox (my first time using Mudbox, you see)

    So I created the bump map and imported the model into unity but it looks aweful... Please have a look at what it looks lke in Mudbox and what it looks like in unity and please tell me what I am doing wrong....

    Much appreciated...





     
  2. QFS

    QFS

    Joined:
    Jan 22, 2009
    Posts:
    302
    Whats the low poly mesh and uv map look like?

    (I ask because I see some weird n-gon's in the mudbox screenshots)

    And also the normal is inverted (the "bumps" are caving in instead of bumping out) and will need to flip a channel.
     
  3. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I am uploading a scaled down version of the UV map. The original is 1024x1024.

    I was also curious about the inverted bumping because you can clearly see that the normals are pointing in the right direction on the model in Maya...

    My workflow is as such:
    1. Build the model in Maya till I am happy with it.
    2. Quadrangulate the model and do a cleanup for that unifold geometry (whatever that means)
    3. Export as OBJ
    4. Load OBJ into Mudbox and subdivide 4 times
    5. Sculpt and extract normal map
    6. Give normal map to triangulated Mesh in Unity


     
  4. QFS

    QFS

    Joined:
    Jan 22, 2009
    Posts:
    302
    I've got a feeling it might be a smooth uv issue.

    Try xNormal

    http://www.xnormal.net/Downloads.aspx

    Export the highest subdivision level mesh from mudbox as obj.

    Export the low poly mesh from maya as obj.

    Bring those two obj meshes into xNormal and bake out the normal map.
     
  5. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Thanks for the link, bru.... but unfortunately that is Windows only :(

    Have you got any idea why the arms are so wrinkly when I didn't do anything to the arms at all? Or the face for that matter...?
     
  6. Vimalakirti

    Vimalakirti

    Joined:
    Oct 12, 2009
    Posts:
    755
    Quick fix might be to lower the resolution of your bumpmap from 2048 x 2048 or whatever down to 256 x 256... then you'd lose that annoying little details and only get the big creases you want.

    It's a cheat, but it might work... maybe...

    Or... go into photoshop or similar program and blur your bumpmap.
     
  7. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    That's an interresting idea... I was aware that people modify the bump maps in editors but I was only aware of duplicating a layer to increase an affect and not about anything else. I was under the impression that each pixel, as determined by the color thereon, dictates the direction the light would reflect and to go and manually modify the file would just result in chaos...

    So... making the bump map res 256 from 1024 might actually INCREASE the quality??? That is not something I would have thought off...

    I tried playing around with the various settings in MudBox last night exporting in all possible combinations on world space, local space and tangent space closest to the model, closest to the outside of the model and closest to the inside of the model... The results all just got weird with seams becoming really pronounced. So far it seems that tangent space closest to the model works the best (which is what I showed in the picture). Modifying the bump level in the import settings in Unity also makes quite a difference but I still get a shadow instead of a bump... Perhaps if i invert the bump map image....

    Question, when I import a bump map into unity, should it be a grayscale or whould it be the actual map? I was thinking that since I import a coloured bump map and then tell unity to "Generate bump map" from the already generated bump map might be causing the issue. If this is the case, will converting an RGB bumpmap into a grayscale image work or will that just break everything?

    Basically what I would like to know is this:
    1. Inside Mudbox, what should I set the bump map generation settings to ?
    2. Inside Unity, what should the settings be to use that bump map?

    Also, I am looking at Mudbox at the moment but with it crashing at every 3rd button I press I am considering switching over and evaluating zBrush 4 instead. Could anyone give me a quick, all round pros and cons comparison between Mudbox and zBrush, please?

    Would the move be justifiable or is the error on my side and not with the software?
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    unity requires normalmaps (tangent space if I remember right but I'm sure the reference manual includes that on the docs of the normal map shaders) and they should be rainbow colored (grayscale are either bumpmaps which are something very old school or alternatively displacement maps, which are not supported in unity unless you have an own shader for it).

    if you have grayscale, there is a little field in the texture import settings that allow you to generate normal maps from that you don't compress them unless you are on unity 3 in which case you can use DXT5 aside of uncompressed.
    reason is that normal maps normally don't work well after compression as they are trashed. DXT5 in U3 is an exception cause if it detects it to be a normalmap it will resort to a special version of DXT5 (dxt5_nm) which compresses the normalmap but in a usable format.
     
  9. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    From reading this post I have gathered that since my nm is rainbow colored I should NOT check the "build normal map" check box and I should change my image format to RGB 16 bit... I will give that a try. I think I did change my texture format before but I had the checkbox on...

    Cheers for that

    P.s. When I was first trying to incorporate normal maps into Torque I was looking all over the place and each time I found source that I could incorporate into the engine they kept taking about bump-shading so I have always been under the impression that bump-maps and normal-maps are both interchangeable terms meaning the exact same thing...

    The way I saw it, it basically acts as if each pixel has it's own "normal" and based on that light reflects differently off of the respective pixels thereby giving the illusion of depth through fancy shadows on the polygons... Displacement maps actually modify the displayed pixels's position, this much I have gathered (although I haven't read about wether this is supported in Unity 3 or not) but then, if normal maps and bump maps are not the same, what is the difference?

    I thought that bump maps used 256 shades of grey to represent the 256 values stored in the RGB values of a normal map. Since only the "R" for example would be enough to contain same info as the greyscale I was never sure what values are stored in the "G" and "B" but never bothered to find out since, at the end of the day, normal maps and bump maps are the same thing... but if I am wrong then perhaps I will have to investigate this a little more...
     
  10. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    thats not the best idea, leave it at least at 24bit RGB, optimally on 32bit as the alpha channel is used too for other shaders if I recall right
     
  11. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Gotcha, so keep the size small and the bit depth high...
     
  12. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hey, Dreamora, am I missing something here?

    This to me suggests that bump maps / normal maps need to be greyscale images and I need to let Unity convert them to rainbow or am I understanding this wrong?

    ... but then again...
     
  13. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you understand it wrong

    unity can generate the normal map for you in case you have a heightmap (-> grayscale). but that might not lead to exactly the kind of data you wanted, its normally easier, better and more straight forward to just export the normal map from your modelling application where you created it.

    chances though are that you didn't create any normal map there but displaced vertices in which case you would get a displacement / bump map which requires the normal map generation in unity
     
  14. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    When I found that last quote I basically realized what you just said, yes. Thing is, when I imported the normal map directly without turning on the "Generate bump map" check box I saw nothing on the model.

    Turning on the check box gave me very visible difference but with all those artifacts. It also gave me the bumpiness value slider whereas otherwise I have nothing...

    Would you say that what I should do is:
    1. Don't turn on the check box and just keep the rainbow file I got from Mudbox
    2. Go into Photoshop and duplicate the layer 5 times ???

    I really am at a loss here at why the normal map that looks so good in Mudbox simply doesn't work in Unity. I know I am missing something but I am just clueless as to what...

    Regarding the generated map, at least that is the one thing I AM certain about. I have the option of extracting a normal map and the option of extracting a displacement map, each under their own menu option so having selected the normal map extraction option I am definitely sure about TAHT part :)
     
  15. Vimalakirti

    Vimalakirti

    Joined:
    Oct 12, 2009
    Posts:
    755
  16. Tudor_n

    Tudor_n

    Joined:
    Dec 10, 2009
    Posts:
    359
    This is usually due to UV Mapping problems. I'm guessing you're modifying your model after you've created the uv map. Try this just to rule this out:

    Mudbox should generate more than decent Normal Maps. They rarely need tweaking in Photoshop (unlike the built-in Maya/ Max render element).

    You should also try to learn Normal Mapping in smaller increments. Try to do the all too common "space-cube" first then move on to a spherical object, then a slightly more complex object and so on. I used to practice Normal mapping on vegetables :D
     
  17. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Cheers, bru. Will have a look at that.

    Made some progress on that model of mine. Turns out changing the import format from Default to rgb 24bit solved virtually all errors. 32bit had other issues but from 16bit you can clearly start seeing artifacts...

    So by turning off the Generate bump map check box and changing the image format ... magical... :) Getting some really weird things happening at the seams though, but it is looking TONS better already :)
     
  18. Rman

    Rman

    Joined:
    Jun 6, 2010
    Posts:
    147
    Seams cannot be fixed because they are seams.

    You might need to not model those areas that overlap joins in the UV.
     
  19. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    Looks like one of the channels (green?) needs to be flipped to work properly.

    What I find gives the best results, is to avoid creating the actual normal maps themselves outside of Unity completely. Instead create a displacement map or regular bump map rather than a completed normal map, then convert it to normal map inside Unity after importing it.

    It'll create all the channels the right way around and ultimately gives nicer cleaner results, plus you can then fine tune the amount of bumpiness later through Unity without having to mess around baking and reimporting files. Something you'd not be able to do if it was already in normal map form to begin with.

    I've also noticed this method also tends to fix a lot of problems with discontinuous seam errors that'll often appear.
     
  20. Rman

    Rman

    Joined:
    Jun 6, 2010
    Posts:
    147
  21. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    what an interesting read... That also answers the question of what is stored in the respective R,G and B channels. Kudos. I was under the impression that a normal map work independently of the polys it was created from. I.e. generate the normal map, decde your model doesn't quite deform correctly at places, leave your uv borders pinned so the normal map still maps to the same part on the texture, now go and modify your vertices and uVs as you see fit as long as the borders are left untouched...

    I thought this was the case... but I never did that though :p
    My experiences with skinning a model and then collapsing edges has taught me to do one part completely before moving on to another part. Thus, normal mapping is the last stage before animation in my book... But having said that, this thing about rotating a triangle breaking the normal map... that was really interesting...
     
  22. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    It seems this must be a problem with Unity or something. I just tried applying bump maps that came with purchased models and they look crap. So I tried using it with models from commercial games and it looks crap... Hell, even Lara doesn't look good using bump maps...

    Has anyone here actually used a bump map in a Unity game? Could you upload a screenshot of what it looks like before/after?

    I can't believe that every model I make, the models I buy and even models from well known commercial games all look bad on my end and yet it looks fine for everyone else.... could it be my screen card? ATI RadeonHD2600 with 256 RAM. I tried changing the quality settings in Unity from good to fantastic but none of those settings affected the bump map at all so it is not that...

    With the purchased model I get a lifeless doll without the bump map and with it I get a pixelated doll with lots of shadows where there really shouldn't be any. But very pixelated at any import quality and any resolution...

    What am I missing here? Is there a setting I need to set on the lights or something? What am I missing?
     
  23. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    yes you need pixel lights

    normal maps only exist in relationship to pixellights, otherwise they are useless to inexistant
     
  24. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Normal maps work fine in Unity. One of the big problems is there's no real standard between engines on the direction of vectors. One of the things you should try first if it looks wrong is to invert the green channel of the normal map. If you're generating it yourself then the software usually has a setting on if you are using +Y or -Y. If you already have a normal map and not the source high/low objects then you can invert the green channel in photoshop to get the same result. Another thing that might help is to set unity to calculate normals, set the smoothing angle all the way to 180 and try w/ split tangents on and off to see which works better.

    Also you'll want to make sure that it is actually a tangent space normal map not an object space normal map. Tangent space normal maps will be mostly blue, like this:


    Whereas object space normal maps will look more like:


    One last thing you could try is making sure that the normal map has been normalized. Or you can modify the shader to use normalize the value. There's a thread in here somewhere describing that, it's pretty simple.
     
  25. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569

    Tried Texture sizes 256 to 1024 and bit depth of 16 to 32
     
  26. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    Hmm, and if you turn off mipmaps for the normal texture?
     
  27. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    This is without mipmaps :p

     
  28. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    Bring in the texture to be turned into a normal map, in grayscale form (before you've even turned it into a normal map in whatever app you used), and convert it in unity like I said already. If that doesn't get rid of that seam, then change your UV mapping to not have a seam down the center of your model.

    Someone else on the forum did exactly this and it fixed their problem, even with a seam right in the middle. Rule of thumb is if you're using normal maps in Unity, let Unity generate them. Results tend to be better than elsewhere and you can always edit the original file quickly and easily later, and fine tune the bump amount to your liking without any messing around or having to redo things.
     
  29. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Yo...

    Problem is, the first model is a commercial product that I can't use and I just put it in the game to see if that normal map works. No way I am going to get my hands on custom textures for it from the developer...

    The other one is a purchased model. Doesn't have greyscale bump map... If I had it I would have done what you said but I don't... by following your advice it means that any purchased model that has a normal map included and no bump map to accompany it cannot be used in Unity... Surely that can't be right?

    Thing is, I got Mudbox literally years ago, back when I was still in college, and completely forgot about. I just had a hard drive crash recently and as I went through my backup drives I noticed this copy of Mudbox 2009 laying in the folder next to my Quidam trial... I still haven't installed the Quidam demo as the product is just too expensive for my tastes but I decided to try Mudbox, finally. Now, this version doesn't have the option of creating bump maps so I am (as we speak) downloading the trial of the 2011 version to see if that will solve my issue...

    But this doesn't answer the question of how to make purchased models work, short of contacting the owners and asking them to create new content for their products...

    Regarding the seam in the middle... yeah... what can I say? This guy has a LOT of models I am interested in but I learnt to put your seams where they would be less likely to be noticed like under the arms, not right in plain sight of everyone... This seam right down the centre of the body has put me off buying any of the remaining models from this guy...
     
  30. oblivionfeet

    oblivionfeet

    Joined:
    Jul 24, 2010
    Posts:
    481
    No, you're putting words in my mouth there. I'm just offering you a fix to a problem.


    As for purchasing other people's work, well, that's the price you pay for getting models quick I suppose. They're not always going to be exactly right for your situation and will often always need to be fixed or repaired.
     
  31. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Yo. Didn't mean to put words in your mouth but it sounded this way ...
    I always thought you buy stuff to save yourself the time in creating it yourself but I have had some really unpleasant experiences of late... hence why I decided to try Mudbox finally.

    I have only ever modelled low poly stuff and I am used to fixing my models on a per-pixel basis so the idea of extruding a cube all around another item and then saying "done" without removing the hidden faces.... I can't stand it! A model has to be optimised to perfection... so I find myself removing polys where I don't need to but where I can manage to get away with it... So for me, high polygon modelling is going to be quite an adjustment in mindset as to me the entire model feels like a waste of polygons... Normal maps would provide a convenient solution to my problem... but I have 0 experience with them... so I buy models and regret having wasted the money... :(

    I recently bought a model to save me some time. Waited a month for it to be built and the guy was counting polygns in quads so my 5-6k limit was offered to me as 11.6k polygons that were 100% not optimised. I went in and started fixing one of the body parts and 2 hours later I had cut just shy of 1000 polygons on a prop hanging on the model's body... Took me 2 hours. By my calculations, fixing all the vertices, retexturing the model and redoing the normal map... it would literally be faster to build then entire thing from scratch myself....

    Then I got this building kit... An archway has over 200k polys! 10 house to form a town and nowhere you look you can get under 2million polygons on screen... without props or people...

    Then I got a collection of animated characters... where the kick lasts 4 times as long as the punch, some of the animations are broken Completely! and then all the animations are shared between the various characters... One animated character is permanently 1m off the ground!

    Nah, seriously, making stuff yourself is the only option in my mind... This is why I need to figure this normal map thing out. Just got Mudbox 2011 last night so whenI get off work I will see if I can generate greyscale maps with it.

    Thanks for the assist, bru.
     
  32. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    You could always use the same model, just unwrap it differently so the seam isn't right down the middle. Then use xNormal to bake the normals and diffuse textures from the orginal UV layout to the new one.