Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by geoffrey.jon.douglas · Mar 12, 2015 at 06:42 AM · .obj

Importing .obj files with RGB data

I want to import and render a .obj file in Unity. The vertices in the .obj file also have RGB data associated with them. I know how to import and render the .obj, but I don't know how to texture it with the correct RGB data. Can anyone help?

Thanks!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlwaysSunny · Mar 12, 2015 at 04:53 AM 0
Share

To "see" vertex colors, you'll need to use a shader which respects vertex color. I don't believe any of the stock legacy shaders do this, though I could be mistaken. This is not called "texture"-ing the model with vertex colors. You should avoid referring to making use of vertex colors in this way using the word "texture", since the two are unrelated.

To make use of this data in some other way, the $$anonymous$$esh class API exposes vertex colors.

If you are not referring to vertex colors, please refine your question.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tanoshimi · Mar 12, 2015 at 06:49 AM

@AlwaysSunny is correct; to render vertex colours assigned to a mesh, you need to assign a shader to the material that makes use of them. The built-in "VertexLit" shader will do just fine (in Unity 5 you'll find it under Legacy Shaders/VertexLit)

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image geoffrey.jon.douglas · Mar 12, 2015 at 04:58 PM 0
Share

Thanks for the suggestion! I have created a new GameObject, added a $$anonymous$$eshFilter with my mesh, and added a $$anonymous$$eshRenderer with a new $$anonymous$$aterial that has a VertexLit shader. Can you help me figure out the next step? Do I need to add a script to my GameObject that sets the colors of every vertex in my mesh to the values in my .obj file? Do I need to do this in the actual shader?

Thanks!

avatar image AlwaysSunny · Mar 12, 2015 at 05:07 PM 0
Share

I don't remember VertexLit respecting vertex colors, but @Tanoshimi's word is law 'round these parts, so I may be misremembering.

If you are entirely confident that your vertex colors were properly edited in your 3D program, perhaps there's some other factor at work I am not considering. No additional steps need to be taken - if your imported model has vertex colors, and your shader respects vertex colors, you'll see the result immediately.

avatar image tanoshimi · Mar 12, 2015 at 07:09 PM 0
Share

Oh dear, I'm beginning to doubt myself now, but am not near a computer to be able to test...! Try creating a new shader and assigning it to the material as follows:

 Shader "VertexLit Coloured" {
   Properties { _Color ("$$anonymous$$ain Colour", Color) = (1,1,1,1) } 
   SubShader { 
   CGPROGRA$$anonymous$$
     #pragma surface surf Lambert

     struct Input { float4 color : COLOR; }; 
     uniform fixed4 _Color;

     void surf(Input IN, inout SurfaceOutput o) { 
       o.Albedo = IN.color.rgb;
       o.Alpha = 1;
     } 
   ENDCG
   }
 }
avatar image HansWursT619 · Mar 03, 2016 at 03:01 AM 0
Share

Was someone able to get this to work? Is there a way do make Unity use .obj files with Vertex Colors, like $$anonymous$$eshLab exports them?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

export sketchup to unity help 1 Answer

how to enable transparency in imported .obj surface model? 1 Answer

Importing files from disk once a game has been built 1 Answer

In which format does Unity read vertex colors from .obj files? 1 Answer

how do I make imported .obj's solid? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges