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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by FTWinston · Jan 17, 2014 at 03:39 PM · graphicsoptimization

"Minimum size on screen" for primitives

Hi all,

I'm rendering some basic spheres as stars, but particularly far away stars are too small to show up very well.

I want them to never appear smaller than a few pixels across, and instead just to fade out as they get further away.

I'm wondering if anyone can think of any clever tricks to avoid looping over every star each frame, because I currently have many thousands of stars.

I've considered using a single-particle particle system for each star when they're far enough away, a billboarded sprite, and just changing the scale of the mesh. None of these seem able to avoid looping over every star each frame.

By partitioning space and pre-calculating angular sizes, I've been able to determine which stars ought to be rendered at a "fixed screen size" without doing a loop over every star. But that still leaves me almost every star to loop over, to rescale so as to achieve a fixed screen size.

Can anyone think of any clever tricks to avoid doing this?

Thanks,

Winston

Comment
Add comment · Show 4
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 robertbu · Jan 17, 2014 at 04:54 PM 0
Share

If once they are reach a distance, the star is forever small, then you could detect when they reach this threshold, replace them with a Quad (or not), and make the Quad a child of the ship. This doesn't fade them...just gives them a $$anonymous$$imum size.

avatar image FTWinston · Jan 17, 2014 at 05:52 PM 0
Share

Unfortunately as the ship moves around, the direction to a star needs to change, so simply adding as child of the ship won't work for that on its own. I was excited for a moment there! Thanks, though.

avatar image robertbu · Jan 17, 2014 at 07:14 PM 0
Share

Again, assu$$anonymous$$g once a star is too far it never needs to transition back to it's active state, make the Quad a child of an empty game object that tracks the position but not the rotation of the ship.

I have to wonder if you are borrowing trouble. Are you sure a brute force approach of just sizing all the 'too far' objects has that much impact on your game? What is the target platform?

Depending on your needs, there are a number of ways to optimize what you are doing here. Some would involve significant code. The easiest is to recognize that object at that distance change size slowly, so you don't need to do the calculation every frame for these 'too far' objects. A couple times a second might be good enough, and you don't have to do the calculation for all the 'too far' objects at the same time.

avatar image FTWinston · Jan 17, 2014 at 11:09 PM 0
Share

The ship flies around in among these stars, so the angle between any given pair of stars will change as you move. As such, I don't think I pinning the quads to a sphere surrounding the ship will work without very regular updating.

Batching the star updates, and adjusting their re-calculation depending on distance (& lu$$anonymous$$osity) sounds like it'll probably be my best tactic.

For each volume of space, I've already pre-computed what stars could be close enough & large enough to be visible as more than just a point. It'd involve more memory use, but I could possibly even pre-compute what "nearby" stars might require more regular updates.

I get the feeling I'm diving into far too much premature optimisation at this point. I'll set up some performance monitoring to see how the different options stack up.

Thanks for the help, Winston

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

18 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

Related Questions

Multi Resolution 1 Answer

Why is the CPU usage so high? 1 Answer

Best transparent shader for Android devices 1 Answer

What Resolution to draw sprites for Mobile game?? 1 Answer

Shader Based Mesh Generation 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