Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by olilamont159 · Oct 13, 2015 at 05:49 PM · unity 5lightmappingunity 4lightmaps

Unity 4 lightmaps in Unity 5

Hey all,

I'm looking for help regarding Unity UV2 Generation for lightmapping. I have a Unity 4 project that has lightmaps generated and we have to migrate to Unity 5 but reuse the Unity 4 lightmaps.

As of right now, I have been able to inject the old maps in the lightmapping system, by forcing a lightmap array and reusing each object's tiling and offset values, but UV2s are all wrong. Everything looks ok, rendering is OK, but only the positioning of the maps are off.

I tried to manually export the values of UV2 for a mesh in Unity 4 to then inject them in the Unity 5 model (first disabled the generation of UVs in Unity 5 for models), but I found out that the same model in both versions of Unity does not have the same vertex count (with the same import settings). But this is another question.

So my question is: is there any way to export the UV2 values generated in Unity 4 to Unity 5.

Thank you,

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by olilamont159 · Feb 11, 2016 at 10:46 PM

Hello all,

Yes I successfully made it work! I have Unity 4 lightmaps in Unity 5. But be aware that this is not an easy and clean solution. I'll try to explain my process as best as I can:

Start in Unity 4 by exporting all lightmapped GameObjects Meshes (those with lightmapIndex != -1 on their Renderers) on the file system in a homemade format. I personnally made a text file with separator characters. You need to export everything you will need in Unity 5 to recreate a Mesh object, so triangles, normals, tangents, sub meshes, etc, etc. This can be done with some Editor scripts looping on all of your exported scenes, then all lightmapped objects. You have to make sure all exported models have unique name, or at least they are exported uniquely.

Still in Unity 4, you must store in a component added to all lightmapped object the data needed for the lightmapping system: that is offset, tiling and lightmap Index. You can also do that with Editor scripts that loops on the scenes, then add a component to the objects, then Save.

Then, in Unity 5, you can upgrade your project. Once this is done, there is two things to do: import the exportes meshes, create new Mesh class instances, then serialize these in the object's MeshFilters components. This way, your models are not links to the Model asset in the AssetDatabase, but a serialized version of the exact data from Unity 4, including lightmaps UVs. :)

Then, you must inject lightmapping data in the multiple objects Renderers, data we stored in the components.

And last but not least, there must be code that injects the actual lightmap textures into LightmapSettings, so you must match the lightmapArray from Unity 4, also mode, etc.

You may need to turn off Static Batching options in rendering, this option seems to do weird things to the models data.

Also, your dynamic lighting may not be aware that certain objects are lit, as we are injecting stuff into the lightmapping system. You may need to work on the layers bitfield of your lights.

And lastly, your lightmap textures may need to get tweaked in their import options, to have the actual pixel perfect colors from Unity 4.

So here you go, I hope I didn't miss a step. Let me know if it helps!

Comment
Add comment · Show 1 · 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 Boris S. · Mar 18, 2016 at 03:15 PM 0
Share

Yeah! I have got it work too!

avatar image
0

Answer by SilverStorm · Oct 19, 2015 at 01:15 PM

I am also looking for a way to do this, I wonder if you have made progress in doing this since your post?

Have you tried using the export package to export entire scenes and see if the original settings stay? I am looking to see if lightmaps can be used specifically in a shader.

Comment
Add comment · 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
0

Answer by stu_chineseroom · Jan 06, 2016 at 10:35 AM

@olilamont159 @SilverStorm

Hello! Did you get any further with this? I've been trying to manually reference the lightmaps as a regular texture, but the lightmap importer in Unity5 is perhaps more involved and seems to mean I can't use the simple constant decoding as in 4. You mentioned injecting the old lightmaps into the lightmap array - that sounds interesting, do you have any more info on that? e.g. are you editing the LightmapSettings.lightmaps array directly?

Thanks, stu

Comment
Add comment · Show 1 · 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 SilverStorm · Mar 19, 2016 at 08:23 AM 0
Share

I have stayed with Unity 4 and have not found a way to export them properly. However the latest Unity stream revealed they are working on a new baked Lightmap system which is much easier to use. It will be in 5.4 I believe.

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

39 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Retaining Generated Lightmap UVs From Older Version of Unity 0 Answers

WHY !! CountDown not Working inside the IF Conndition !!! 2 Answers

URP all Objects suddenly invisible on Scene Change - The object of type 'Material' has been destroyed but you are still trying to access it 0 Answers

hi fnds.....I have a Unity solution which is developed in old version of Unity framework and im using latest one. can i able to run the solution in my frame work? or not? 0 Answers

Switch Lightmaps at runtime Unity 5 0 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