Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Flat smooth shaded parts on same object!?

Discussion in 'Editor & General Support' started by Ricks, Jan 31, 2011.

  1. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Got a short question: I have an object which consists of 2 parts (meshes): one needs to be flat shaded and the other one smooth shaded. E.g think of a spear with a sharp head and smooth shaded shaft). However on import unity always makes the object either completely smooth or completely flat shaded!

    Changing the "Smoothing-Angle" will act as a whole and only approximate the effect if I use a smoothing angle of ~145°, but it's not as crisp as I'd like it to be. Why can't I determine which of the 2 meshes shall be flat shaded and which not?
     
    Last edited: Jan 31, 2011
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    If you import the two meshes as separate objects, you should be able to set the smoothing angle differently for each. Then, make them both children of an empty parent object to recombine them.
     
  3. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Thanks, I'll try to do it this way.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    If you're using Blender, you can add an edge split modifier and mark desired edges as sharp. Presumably other 3D apps have something similar.

    --Eric
     
  5. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Max has smoothing groups for faces, Maya works on the edges instead.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    In the worst case you can split edges manually, though that usually makes the model harder to work with.

    --Eric
     
  7. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Ah thanks for these hints, I'll have a look if the 3d modelling application (currently using lightwave) has a way to achieve that. Would be much more comfortable than re-combining.
     
  8. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    733
    I use Lightwave.
    Right now my models are fairly simple so I'm just
    - unweld points
    - set up UVs
    - and merge the points on the UV map for things that need to be smooth.

    It worked on a tree trunk model.

    I suppose thats the hard way. LW does not have smoothing groups.
    Maybe its got something else I havent discovered, so have a look around.
    They introduced Edges with LW 9 (or maybe 8), I havent really done anything with them yet.

    Usually when making a non game model you just make a different surface with different smoothing attributes, no UV stuff.
     
  9. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    I must admit, saving each part of a model in a separate file and making a UV map for each one by its own and then putting it together again on an EmptyObject in Unity is very inconvenient. Even simple models turn out to be ridiculously inconvenient and timeconsuming to implement. I can't imagine this is the way to go.

    Basically what I want to know is: does Unity really support models which have different smoothing on edges (setup in the 3d tool of choice)? Is there anything I must do additionally that it imports correctly? e.g. a specific import format etc. which has integrated this information?

    @Tzan: I have tried to get it done in Lightwave 9.6. You can setup different materials on different sections of the object and make each of them "smooth" or "edged". However these settings seem to apply to Lightwaves internal renderer only. After exporting these models into fbx and importing it into Unity, everything is gone. Unity only recognizes the different colors/textures on the sections of the object but the edginess/smoothing is gone. Maybe LW doesn't support this option at all?
     
  10. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yes, as I said, in Blender you use the edge split modifier. You can also use smooth and flat faces directly if you export as .obj, but that's not ideal (no animation, have to export manually), so the edge split modifier is better, even if it's somewhat more cumbersome to use than smooth/flat faces.

    As I also mentioned, in the worst case you can split edges manually, but that doesn't involve any separate files or anything, it's just splitting edges. (In blender: select edges or vertices, press "Y". I haven't used Lightwave but surely it can manage that. In fact, yes, an extremely quick google brought me here, which in fact deals with this exact situation; go to step 5.)

    --Eric
     
  11. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Thanks a lot Eric5h5, I just tried it out in blender and added a Splitmodifier. It still didn't seem to work at first - until I saw that "Normals" wasn't selected by default at the export setting of .obj/.fbx. After selecting it, the edges were correctly and sharp in Unity. It also works with the "Set smooth" "Set Flat" for the .obj format in blender as long as "Normals" is selected.

    Edit: when digging through Lightwave google results it seems Newtek has "solved" the sharp edges only by applying normal maps. Does not sound reasonable - and the 3rd party solution for LW (link above) costs money. They must be kidding...
     
    Last edited: Feb 9, 2011
  12. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    733
    In Lightwave I already told you how it works.
    One Surface only. The multiple surface use only works for non game models.

    - one surface only
    - unweld points
    - set up UVs like normal
    - and merge the points on the UV map for things that need to be smooth. Select the points on the UV map, merge them


    Yes this works
    Try it with a simple model.
    Is it a pain, yes.
     
  13. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    This workflow is completely unacceptable. I'll try to find another solution.
     
    Last edited: Feb 10, 2011
  14. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    733
    Yeah I understand. LW has a major problem with smoothing for game models and the smoothing slider isnt always going to work the way you need it, in either LW or Unity.

    I was working in a different game engine years ago and I had to.

    - model in LW
    - uv map in LW
    - take it into Max to set up smoothing groups
    - the max model was then imported to game engine.
     
  15. Ricks

    Ricks

    Joined:
    Jun 17, 2010
    Posts:
    650
    Tzan, you were actually right. Only the specific vertices enclosing the edges which needed to be sharp had to be selected in LW and then "Unwelded". I didn't do anything in the UV though. The .fbx export and import into Unity worked correctly showing the sharp edges, the .obj didn't show the sharp edges. However sticking with .fbx is ok for me :)
     
  16. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    733
    Great!

    When you pick points on the model with the UV view open you will see those points highlighted in the UV view also.
    So you can pick from either area, whichever is easier.
     
  17. avedis777

    avedis777

    Joined:
    Jul 10, 2011
    Posts:
    25
    I'm actually dealing with this problem (using Lightwave also) and I thought I tried unwelding the points of the faces that I needed to be unsmoothed...using fbx export/import, unity 3.3 but it didn't seem to work...I will try unwelding everything and merging on the uv map.

    This sounds like the usual solution for Lightwave->Unity? It doesn't seem like too much trouble :)