Search Unity

Lost transparency on planes imported from Blender

Discussion in 'Asset Importing & Exporting' started by alexandermetzke, Nov 7, 2018.

  1. alexandermetzke

    alexandermetzke

    Joined:
    Nov 7, 2018
    Posts:
    4
    Dear All,

    I searched through numerous threads regarding imports from Blender into Unity but I couldn't really find a solution that worked for me.

    My idea is to take a simple picture of a space craft, put it into a plane in Blender and generate a "height" 3d Model from it. My problem is that when I import it back into Unity all transparency is gone and replaced by some greyish dark color.

    1) see original picture PNG with transparent border

    2) then see extruded plane in Blender, still with good transparency around the ship

    3) then see the Unity screenshot. Transparency is gone and replaced by a grey base color.

    I want the mesh still to be rectangular and would not like to cut any vertices away.

    Any ideas how I could solve that?

    Thank you and best regards
    Alex
     

    Attached Files:

  2. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    You need a way to actually move the tranparency, as it isn't done automatically. Many things that work in Blender don't just automatically work in Unity, though for some of them there are workarounds. In this case, you need to get that transparency information into a texture for Unity to use. Then you need to use a transparent material that would look at that texture for said information. Some shaders could possibly use the alpha channel of the diffuse texture for transparency as well.

    I should mention, in the Blender screenshot, I'm wondering how you achieved the transparency. It is the texture, which the material then uses? If so, you could likely use that same texture in Unity, but you'll have to use a certain material/shader in Unity to do so.

    That being said, what is the reason why you don't want to remove the vertices? I'm genuinely curious!
     
  3. alexandermetzke

    alexandermetzke

    Joined:
    Nov 7, 2018
    Posts:
    4
    Well to put it into Blender I simply created a plane with the same dimensions as the sprite and subdivided it several times until the grid size looked nice. Then I simply dragged and droppd the sprite onto it. The next step was manually adapt height of the nodes on one side and then apply mirror and smooth.

    I finally got it to work. The trick was not to import texture and mesh as a package. I imported the blender file into Unity and only took out the plane mesh component. I then created a new material with the sprite being assigned as albedo map. Then I set the material to be "Cut out" instead of opaque or transparent. When I assigned it did the trick and transparency was back.

    I didn't want to cut away the left over vertices to make sure the texture map is still exactly in the format as it was in the sprite to do grid color manipulations.

    Thank you for your response!

    Best regards
    Alex
     
  4. alexandermetzke

    alexandermetzke

    Joined:
    Nov 7, 2018
    Posts:
    4
    Though I have to add that it takes surprisingly much performance from the graphics card.

    400 ships of this and my GTX960 is at 100%... 400 sprites though take only 30%.

    I assume that 140x70 (9800) vertices per ship is to high. Handling 400 Ships this is almost 4mio vertices.

    I have no Idea what that means for the graphics card. But I guess that is already quite a high number?
     
  5. kburkhart84

    kburkhart84

    Joined:
    Apr 28, 2012
    Posts:
    910
    You are likely better off either doing sprites, or just making better optimized 3d models. 9800 verts isn't all that extreme for models generally these days(some "hero" models have 40,000, even real-time). But with that many ships, you need something else. It may not be the actual vertex count, rather all the different materials, texture swaps, and the like. You may need to optimize differently.

    I'd also recommend you do better profiling. I don't know too much about percentages on GPUs, but I know on pr0cessors, there is nothing wrong high percentages as long as you get the framerate you want. I'd recommend you go more along those lines instead of worrying about percentages.