Search Unity

How would I go about texturing inside-edges of 2D (or 3D extruded) procedural meshes?

Discussion in 'Scripting' started by J_P_, Jun 12, 2011.

  1. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    My iPhone game can already build meshes but they use a single texture. This is the sort of thing I'm after -- the edges have a different texture than the main body of the mesh -- I want to add those border textures to my meshes:



    There seems to be two main goals -- smart mesh creation and smart UV mapping so that the texture is mapped appropriately.

    As far as mesh creation of the border goes, in this thread, Johot was doing something similar:


    but he was extending the border to the outside and I need it to the inside.

    What I'm kind of lost on is how I'd check for tight spaces so that the boarder
    a. doesn't extend outside of the original mesh's space
    b. doesn't overlap with other parts of the boarder



    This demonstrates what I want and what problems I expect to face.

    Then there's the UV mapping -- I'm kind of clueless here. Anybody have any experience with these things? Any resources that have covered stuff like this I can read up on? I don't really know what to search for. Any help is greatly appreciated!
     
    Last edited: Jun 12, 2011
  2. callahan.44

    callahan.44

    Joined:
    Jan 9, 2010
    Posts:
    694
    Extruding out will save you a *lot* of headaches, and creates a nice quad strip that can be easily UV'd. Even doing it in a 3d package by hand is a chore to fix up the overlaps, let alone a procedural method.
     
  3. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    I almost think I need to make the edges of the shape and the edge/vert normals into walls and use raycasting to find out where I need to place vertices... but that seems like I'd be overdoing it

    Not an option -- I draw the meshes in a level editor I made and I need what I draw to be accurate with the colliders it generates. I can't draw something and have it expand on me.

    Would it be any easier to do something like this?

     
    Last edited: Jun 12, 2011
  4. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    How about some way to mask a shape? Check for overlap with the original mesh and trim it to fit within those bounds afterward (and probably some way to clean it up)?

    I see what I think I'm trying to do in so many games -- so how do most games do it? Do the inside edges but avoid shapes that would break their system? Doing the outside edges seems like it'd be a total pain because whatever you draw wouldn't reflect what's created. My game relies on being able to have those very thin shapes, so neither of these options would really work for my case.

    More examples in other games:




    How do these games do it? Am I completely in the wrong direction?
     
  5. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027