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 /
avatar image
0
Question by masterofcodepc · Aug 23, 2018 at 09:17 PM · scripting problemlightingefficiency

Sun rotation glitchy

Hello,

I am making a 3d game with day/night cycles. I am rotating the directional light that is default to a unity 3d scene using the line below in a script's update method to cause the rotation of the sun.

gameSunLight.transform.Rotate(degrees, 0, 0);

The problem is that i notice a bit of glitchiness that goes away when i comment out this line. I've looked at the profiler and the script section of the profiles reports 0 ms delay for this so I'm assuming the rotation is causing a rendering delay.

I've tried other variations of the Rotate method, but they all seem to have the same effect.

I'm fairly new to Unity so it may be something obvious or it just may be the cost of rotating a light. Either way i appreciate any help.

I'm using default lighting settings, and the default light object that is setup when you start a new scene, but my terrain is fairly big and complex.

Thanks,

Paul

Comment
Add comment · Show 8
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 JVene · Aug 23, 2018 at 10:32 PM 0
Share

Glitchy doesn't really say much about what you're seeing. We probably need to see how degrees is incremented.

avatar image masterofcodepc · Aug 24, 2018 at 12:30 AM 0
Share

Sorry i should have been more detailed. By glitchy i mean as you move the mouse to look around in the game (using the standard assets Unity FPS character) it is not as smooth as it is with that line commented out. Not that the frame rate is a lot lower, but more like it periodic frame skipping or something. glitchy is probably the best word to describe it. While running with the the rotation it is most noticeable when moving around. if i comment it out the looking around movements are smoother, less glitchy.

The degrees variable is a constant float so i can control the rotation. When i comment out the rotation line it goes away so i know thats the problem.

I'm newer to unity so I'm not sure if im missing something with the lighting settings or something that would improve performance. I have it on the default settings.

avatar image JVene masterofcodepc · Aug 24, 2018 at 12:36 AM 0
Share

Ok, glitchy is now clearer. I still suspect the means by which 'degrees' is incremented. That fits with your description. If the rotation isn't being applied, and movement looks ok, but then it gets glitchy when rotated, my assumption is that 'degrees' is being incremented by values large enough to make the position jump rather than smoothly move from frame to frame. So, how is 'degrees' incremented?

avatar image masterofcodepc · Aug 24, 2018 at 03:07 AM 0
Share

degrees is a constant. it is set to .02f, i just used the constant so i could change the value at the top of the code rather than find it in the code when i want to use a different sun speed. I replaced it with gameSunLight.transform.Rotate(0.02f, 0, 0); and get the same result.

the rotate method moves the sun .02f on the x axis for each frame update. I'm starting to think i am just seeing the cost of rotating a light that casts shadows, but I dont see anything in the forums that cover that as an a less efficient thing to do.

avatar image JVene masterofcodepc · Aug 24, 2018 at 03:55 AM 0
Share

@masterofcodepc On a hunch, try 0.005f and see what happens.

avatar image masterofcodepc JVene · Aug 24, 2018 at 09:00 AM 0
Share

.05f has the same result

Show more comments

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.

Follow this Question

Answers Answers and Comments

184 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 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 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 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

Is it possible to rotate the environment's reflection source at runtime? (C#) 1 Answer

Light intensity Problem in unity 2D 0 Answers

How do I make a spotlight make a model play an animation? 2 Answers

Add Light Source to Sun in Environmental Lighting with Unity 5 by Script? 3 Answers

Instantiated light not working properly 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