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 whebert · Mar 09, 2013 at 03:50 AM · c#movementterrainperformanceculling

Moving Terrains causes severe lag, why?

I have this project at work where we are displaying certain simulations (Solar System sized) and need double precision accuracy. Since Unity only uses single precision, we have incorporated a "Floating Origin" system where the camera stays at 0,0,0 and the objects move around the camera, instead of the other way around.

This all works great when we are just moving standard GameObjects, but when we start moving Terrains, the performance is significantly degraded. Going from about 60fps down to 5 or 10fps. If we were to run our simulations the normal way, no floating origin and the camera moves about the scene as usual, the performance stays at 60fps or so. We just get the spatial jitter when played this way, so we prefer the floating origin approach.

I know the Terrain system does some dynamic LOD switching based on heightmapMaximumLOD, heightmapPixelError, and other parameters, as you move about, but I would think those calculations are done based on the camera's relative position/orientation to the terrain and it shouldn't matter if you move the camera or the terrain.

I've been able to track down where the lag occurs using the profiler. Inside the Terrain.CullAllTerrains() call there is a call to a TerrainRenderer.RenderStep3(), which is a wrapper to an internal call that I cannot look inside to see what is going on.

I was wondering if anybody knows what may be causing this and has a possible work around? I would think the performance of moving the camera relative to a terrain vs moving the terrain relative to the camera would be the same. Apparently it isn't.

I have made a simple fix where I allow the camera to move a certain threshold from the origin and then reset the origin when needed, which allows the terrain to stay in place more often and therefor keeps performance up most of the time. But this isn't ideal and it would be nice to know why the terrain system doesn't like to be moved.

Sorry for the long-winded question... and thanks for any information.

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
1

Answer by sharpshot124 · Mar 09, 2013 at 06:19 AM

well i dont have a true workaround but a plausible idea that could solve this since you said regular objects work fine, assuming you are using unity 4.

u could use a low res plane as ur base object then use ur terrain height map to displace it with the standard tessellated displacement shader. and the tessellation will work much like the dynamic lods. and it wouldnt be hard to write a shader that read the splat maps to use textures like the terrains do. you seem to have a good understanding of the terrain system but just in case ill explain the splat maps and a basic idea to turn it into the shader.

you have four textures (which u can use tiling to control detail) that correspond with a 5th texture's RGBA channels (the splat map). Then u blend all the textures together and determine the weight of each based off the splat.

for example (assuming u know a bit of shader coding)

 fixed4 splatTex = tex2D(_Splat, IN.uv_Tex1);
 fixed4 finalColor = (tex2D(_Tex1, IN.uv_Tex1) * splatTex.r) *
                     (tex2D(_Tex2, IN.uv_Tex1) * splatTex.g) *
                     (tex2D(_Tex3, IN.uv_Tex1) * splatTex.b) *
                     (tex2D(_Tex4, IN.uv_Tex1) * splatTex.a);

im not sure if this is how color blending works but u can see what i mean here

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 whebert · Mar 09, 2013 at 02:44 PM 0
Share

That's an interesting idea, thank you. We are currently using Unity 3.5 and are about to upgrade soon, so I'll keep that in $$anonymous$$d as a possibility. That would probably give much better performance than Unity's Terrain engine LODing too. Unfortunately, we will also be deploying on $$anonymous$$acs so that may limit our deployment a bit. From what I can gather, there isn't any plan for Unity to support OpenGL 4 in the near future. Would be nice though.

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

11 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

Related Questions

Distribute terrain in zones 3 Answers

Making a bubble level (not a game but work tool) 1 Answer

Unity Terrain Performance 2 Answers

Terrain Performance on Shaded Terrain 0 Answers

How do I check where my character is moving before he moves there? 1 Answer


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