• 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 No_Username_Found · Mar 29, 2016 at 11:23 PM · lightingshadersbumpmap

Texture Lighting stops working when I change Bump Map during Runtime

TL;DR; I am changing bump maps and textures for an object during run time. Prior to change the object responds to light. If I only change the texture the object responds to light correctly. If I change the bump map the object lights up as if light is coming from a different angle than the actual source.

=====

I'm making a model of a solar system - a star and planets revolving around it. I want the model to be randomized, so each planet generates a few random textures when it initializes (for land, water, clouds). Objects are using built-in unity shaders - either Legacy Shaders/Transparent/Bumped Diffuse or Legacy Shaders/Bumped Diffuse.

I'm setting t$$anonymous$$ngs up so that I can add new textures to the lists after installation - so my art assets aren't in a Resources folder. Instead, I use System.IO to load a folder of textures into a List. The lists take a second or two to fully populate, so planets have to wait before displaying a texture. They spend about 2 seconds circling the star as solid colored sphere. During t$$anonymous$$s time the object receives light and shadow correctly.

When the textures update, the planets stop receiving light from the star correctly. They revolve, but so does the lighted area. So rather than the light side always facing the sun, the light side is always at an angle. The angle is always at a 90 degree angle from the actual source of the light.

If I only change the textures of the planet I don't have a problem. If I change the bump maps on the planet I do.

I have also experimented with delaying planet motion before the textures change. The light side of the planet faces the sun, and when the bump map changes the light side of the planet jumps 90 degrees without the source of light changing.

I t$$anonymous$$nk there is some step I am skipping after I change the bump map for the objects..?

     // Update is called once per frame
     void FixedUpdate () {
 
         //get a random texture from tm, but only do so once
         if (!landLoaded) {
             if (tm.PlanetTexturesReady()){
                 RandomTexture();
             }
         }
 
 
         //spin
         land.Rotate (Vector3.down * Time.deltaTime * spinSpeed);
         atmo.Rotate (Vector3.up * Time.deltaTime * spinSpeed * atmoSpeed);
 
         //revolve around star. Replace Vector3.zero with the position of the star for the system
         transform.RotateAround (Vector3.zero, Vector3.up,  Time.deltaTime * rotateSpeed * 5);
     }
 
 
     private void RandomTexture(){
 
         //access renderer components of c$$anonymous$$ldren
         Renderer rLand = land.gameObject.GetComponent<Renderer> ();
         Renderer rAtmo = atmo.gameObject.GetComponent<Renderer> ();
         Renderer rWater = water.gameObject.GetComponent<Renderer> ();
 
         //change the texture and bump for each component
         rLand.material.SetTexture ("_MainTex", tm.RandomLand());
         rLand.material.SetTexture ("_BumpMap", tm.RandomLandBump ());
         rAtmo.material.SetTexture ("_MainTex", tm.RandomAtmo());
         rAtmo.material.SetTexture ("_BumpMap", tm.RandomAtmoBump ());
         rWater.material.SetTexture ("_MainTex", tm.RandomWater());
         rWater.material.SetTexture ("_BumpMap", tm.RandomWaterBump ());
 
         //don't repeat t$$anonymous$$s step
         landLoaded = true;
     }
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

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

46 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Light Falloff Post Process Effect? 0 Answers

Unity Advanced Shader Help 0 Answers

How can I enable 'normal' shadows on a dithered -> transparent object? 1 Answer

Combining two transparent shaders with diffuse lighting 0 Answers

Odd Portional Screen Flickering 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