• 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 Major · Feb 28, 2015 at 11:57 PM · gameobjecttransformgamespaceworld

Render Extremely Far off Objects

I'm trying to render objects that are very very very very (1.5x10^15) far away. I can adjust clipping planes on the camera to render t$$anonymous$$s far away but the objects are so far away that they don't even render on the screen regardless. Is there any way to render objects t$$anonymous$$s far away as a minimum of 1 pixel or even 5?

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 jpthek9 · Mar 01, 2015 at 12:04 AM

You could hard code t$$anonymous$$s feature in with somet$$anonymous$$ng like...

 public float FarRender = 10000; //Minimum distance to far render

 void OnGUI()
 {
     if (Vector3.sqrMagnitude(transform.position, Camera.main.transform.position) < 10000 * 10000)
     {
         Vector2 ScreenPos = Camera.main.WorldToScreenPoint(transform.position);
         if (new Rect (1,1, Screen.Width - 2, Screen.Height - 2).Contains(ScreenPos))
         {
             GUI.DrawTexture(new Rect(ScreenPos.x, ScreenPos.y, 5,5), *Your 'far texture' for the object*);
         }
     }
 }
Comment
Add comment · Show 4 · 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 Major · Mar 01, 2015 at 01:15 AM 0
Share

This is actually a pretty fantastic solution, but the textures start looping across the screen and even display when the object isn't being looked at, and when rotating the camera the texture doesn't follow the object. I am not an experienced GUI programmer, so is there any way to fix this?

avatar image jpthek9 · Mar 01, 2015 at 01:59 AM 0
Share

Oh, sorry about that. You have to check if the object is within the camera's view. You can check by doing:

if (new Rect (1,1, Screen.Width - 2, Screen.Height - 2).contains(ScreenPos)) { Gui.DrawTexture(...) }

I added it in to the answer's code. By the way, this is all theorycrafting so no guarantees but I do hope it works for you. I'm not very experienced with GUI either :D

avatar image Major · Mar 03, 2015 at 03:21 AM 0
Share

Would there be any other way to do this same strategy but not in OnGUI()? This works great for up to 3 objects but when 100 pop up it becomes more than unplayable...

avatar image jpthek9 · Mar 19, 2015 at 10:48 PM 0
Share

OnGUI would probably be your best bet though I haven't tested it with that many objects. Definitely don't let the possibility of high performance demand stop you from trying it out. I can't think of any other methods except for maybe rendering to a texture then manually drawing the objects on the texture each frame. If OnGUI turns out to be a bust performance-wise, you could try that out and it might also give you a bit more control over the drawings but editing textures with code can get pretty messy.

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

20 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

Related Questions

Procedural Skyboxes Based on Scene Data 1 Answer

Extremely Fast Travel 1 Answer

Normal Texture to Skybox 0 Answers

Problem with the algorithm when deleting an object 0 Answers

How can I make a GameObject move from one side to the other 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