New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

Export texture map/your painting with the obj export feature?

aurialLoopaurialLoop Posts: 7
NerveGear
Hi there,

Love your software. Just started playing and already made a tesseract and other unnameable objects. However, when I export the sculpts, I get an obj file but not its corresponding painted texture file. Am I missing something here or is this a planned but not yet released feature? 

I guess also while I'm here - obj/fbx import? I see there is a stamp import feature, but haven't investigated more than that. 

Thank you!

Comments

  • KevinLongtimeKevinLongtime Posts: 283
    Nexus 6
    edited December 2016
    I was always wondering about this too. I don't have Touch yet so I can't mess with medium but I believe the painting is done with vertex color. So maybe try loading the mesh into something that can display vertex color.

    I'm most likely going to be baking color from vertex color over to UVs to use in game.

    If you don't mind, could you upload an OBJ file from medium that has color painted on...could be anything even just a blob of dented clay with some painting done on it just so I can test what is capable. I'd be much appreciative!
  • aurialLoopaurialLoop Posts: 7
    NerveGear
    edited December 2016
    Hi Kevlin,

    I believe obj wavefront files only contain geometry information (vertex positions) and references to external files. For the texture information, I need a material file (.mtl), and a texture map in the form of a .png or .jpg to be exported as well. Uhh, but I just looked more into it and there is an unoffical version where vertex color is used. Sure enough the .obj file exported from medium contains that extra rgb info, e.g.:

    vn 0.269039 -0.900869 -0.340665
    v -0.806099 -0.282606 -0.264014 0.635294 0.537255 0.000000

    I had a go trying to get this to load in unity with a vertexLit shader, but no luck as yet. The model loads fine of course.

    I can't seem to upload the obj here (due to forum permissions), but you can get it from my site: http://spiraltechnica.com/aurialLoop_2016-12-06_19-27-55.obj


    Above is the texturing on the obj file from a picture taken in medium. I'm keen to hear your results :)

    To answer the second question I posed - stamps. I can just put an obj file I want in %userprofile%\Documents\Medium\_Import\Stamps then import it from the main menu, and find it in my stamp collection.
  • KevinLongtimeKevinLongtime Posts: 283
    Nexus 6
    edited December 2016
    Hmm, that OBJ didn't appear to work for me in the software I used. Was that the only file it gave you? I read Medium spits out a low res "modelname_preview" and a high res "modelname".

    What other formats does it export as? FBX? FBX might include the texture

    And yeah, an OBJ can be imported as a stamp as long as its a closed off model without any holes.

    This has some good info: https://forums.oculus.com/community/discussion/45812/medium-frequently-asked-questions#latest
  • aurialLoopaurialLoop Posts: 7
    NerveGear
    It appears to only export OBJ, not FBX or any others at this stage. 

    In my data folder for this sculpt I have:
    aurialLoop_2016-12-06_19-27-55.asset
    aurialLoop_2016-12-06_19-27-55.obj
    aurialLoop_2016-12-06_19-27-55.png (the png I uploaded)
    aurialLoop_2016-12-06_19-27-55.sculpt
    aurialLoop_2016-12-06_19-27-55_preview.binmesh
    aurialLoop_2016-12-06_19-27-55_preview.obj

    Rather hilariously, opening the obj file in 3D Builder from Microsoft does show its painted colours.



    I'm going to look at whether from 3D Builder I can get it into another format that will allow for easier reading of the rgb info.
  • KevinLongtimeKevinLongtime Posts: 283
    Nexus 6
    Ohh wow, nice! So the color data is in there somewhere. Good to know! Can 3D builder bake onto UVs? Never heard of it.
  • aurialLoopaurialLoop Posts: 7
    NerveGear
    edited December 2016
    I've found a way of using the vertex color information inside the non-standard medium obj file to create the mtl and png texture map. 

    I'm using MeshLab 64bit (free and open source) for this.

    The basic structure is, copy your obj file somewhere (so as to not accidentally replace your medium obj):

    1. Open MeshLab
    2. File -> Import Mesh (your copied obj)
    3. Filters -> Texture -> Parametrization: Trivial Per-Triangle
    4. Increase texture dimension in Parametrization: Trivial Per-Triangle from 1024 to 2048 (will vary) and hit apply.
    5. Filters -> Texture -> Transfer Vertex Attributes to Texture (between 2 meshes)
    6. Change texture width and texture height in Transfer Vertex Attributes to Texture from 1024 to 2048, and tick Assign Texture and hit apply.
    7. File -> Export Mesh As and resave as an obj file

    Now you should have an obj, an mtl and a png file that together will form your texture.

    And here it is in unity.


  • rms8080rms8080 Posts: 17
    NerveGear
    You can load this OBJ into Autodesk Meshmixer (www.meshmixer.com), it will import the vertex colors. You might need to switch the color mode from face groups to see the colors: http://www.mmmanual.com/hotbox-1/

    Then export as Collada format (.dae). Unity will import vertex colors from Collada files.
  • aurialLoopaurialLoop Posts: 7
    NerveGear
    edited December 2016
    rms8080 thanks for that. I Went through that process in meshmixer. However, I still had to find a basic vertex color shader for unity. Once imported, and with the appropriate shader, I get these interesting subdivisions which aren't quite right.



    I still haven't figured out why this is the case - perhaps the shader's fault or to do with unity subdividing to import it or something else. Still to be figured out :)

    Here is the shader below if anyone is interested:

    Shader "Custom/VertexColor" {
    Properties{
    }
    SubShader{
    Pass{
    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag

    struct vertexInput {
    float4 vertex : POSITION;
    float4 color : COLOR;
    };
    struct vertexOutput {
    float4 pos : SV_POSITION;
    float4 vertCol : COLOR;
    };

    vertexOutput vert(vertexInput v) {
    vertexOutput o;
    o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    o.vertCol = v.color;
    return o;
    }

    float4 frag(vertexOutput i) : COLOR
    {
    return i.vertCol;
    }
    ENDCG
    }
    }
    }
  • KevinLongtimeKevinLongtime Posts: 283
    Nexus 6
    I've found a way of using the vertex color information inside the non-standard medium obj file to create the mtl and png texture map. 

    I'm using MeshLab 64bit (free and open source) for this.

    The basic structure is, copy your obj file somewhere (so as to not accidentally replace your medium obj):

    1. Open MeshLab
    2. File -> Import Mesh (your copied obj)
    3. Filters -> Texture -> Parametrization: Trivial Per-Triangle
    4. Increase texture dimension in Parametrization: Trivial Per-Triangle from 1024 to 2048 (will vary) and hit apply.
    5. Filters -> Texture -> Transfer Vertex Attributes to Texture (between 2 meshes)
    6. Change texture width and texture height in Transfer Vertex Attributes to Texture from 1024 to 2048, and tick Assign Texture.
    7. File -> Export Mesh As and resave as an obj file

    Now you should have an obj, an mtl and a png file that together will form your texture.

    And here it is in unity.


    Great tutorial, thanks! I was able to get your model into my favorite rendering app Marmoset Toolbag 3

  • aurialLoopaurialLoop Posts: 7
    NerveGear
    That's awesome Kevin! I'm a big user of hexels, which was acquired by marmoset a year or so ago. Always heard good things about toolbag, just never used it myself. Glad that process worked for you. I'm so excited about how all of these wonderful vr tools, but we gotta figure out how they best fit into existing workflows and pipelines.
Sign In or Register to comment.