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 iwanowskip · Mar 24, 2011 at 08:45 PM · shaderlightmapbeast

lightmap transitions?

I am trying to create two lightmap sets for two times of day in the scene. The plan is to be able to transition from one to another. Using new lightmapping techniques does not seem to support that. I tried to write a shader to blend second lightmap previously generated but I realized that I do not have access to the uv set generated via Beast tool, I tried using secondary uv set but it is not the one generated while baking lightmap on an object. Is there a way within Unity I can achieve what I want? Only solution I currently see is to use external package to bake lightmaps and generate second UV set, then import them in Unity and write a shader that blends the two textures. I am hoping though that there is a way within Unity to do it. Any ideas? Thanks!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Andy Korth · Mar 24, 2011 at 09:38 PM

I've modified the mesh.uv2 before to access the beast generated light map set. Can you quick check to see if that's what you want?

I've used it to apply a generated lightmap to a new set of meshes- because we wanted to share a lightmap with a cloned world.

Edit: http://unity3d.com/support/documentation/ScriptReference/Mesh-uv2.html

Make sure "Generate UV coordinates" is checked in your mesh importer? Probably not the problem you had though...

Good luck- I do remember it was a bit finicky, but I think that was me just not understanding what was happening under the hood- unity doesn't give you too many hints.

MeshFilter meshFilter = r.GetComponent(typeof(MeshFilter)) as MeshFilter; Mesh mesh = meshFilter.mesh; Vector2[] uvs = mesh.uv2; int uvsLength = uvs.Length; Vector4 lightmapTilingOffset = r.lightmapTilingOffset; Vector2 scale = new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y); Vector2 offset = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);

     for (int i=0; i < uvsLength; i++) {
         uvs[i] = offset + new Vector2(scale.x * uvs[i].x, scale.y * uvs[i].y);
     }

     mesh.uv2 = uvs;

Comment
Add comment · Show 2 · 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 iwanowskip · Mar 24, 2011 at 10:10 PM 0
Share

yeah, that might be the way to do it. How did you access beast's generated lightmap uv set to modify that code? thanks!

avatar image Andy Korth · Mar 29, 2011 at 06:18 PM 0
Share

I edited my answer with some code where we change the uv2s.

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

No one has followed this question yet.

Related Questions

Transparent glsl shader is still opaque in the lightmap. 0 Answers

Mobile BEAST lightmapping shader/lighting question 0 Answers

Vertex colour transparency and Beast lightmapping? 3 Answers

How to correct shading with ao lightmaps from Beast 0 Answers

External lightmaps deleted on build 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