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 ChristianLinnell · Jan 10, 2013 at 08:46 PM · scalematrixlarge

Modifying the model matrix??

I've been playing with some large-scale planet rendering concepts, and I've encountered this:

http://www.gamasutra.com/view/feature/2984/a_realtime_procedural_universe_.php

Specifically this:

"I solved both of these problems by scaling down the size and the distance of planetary bodies by modifying the model matrix. Using a defined constant for the desired far clipping plane, which I'll call FCP for now, I exponentially scale down the distance so that everything past FCP/2 (out to infinity) is scaled down to fall between FCP/2 and FCP."

I understand that conceptually, but is it possible to scale the model matrix's distance in Unity? Would I just scale my planet mesh down along the camera's look axis?

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
0

Answer by Bunny83 · Jan 10, 2013 at 09:47 PM

In Unity the Transform component covers the functionality of the ModelMatrix (also called world matrix). The model matrix is just a "TSR" matrix (Translation, Scaling, Rotation). It corresponds with the Transforms localPosition, localScale and localRotation. Unity can build a matrix from those 3 seperate vectors.

You can access the matrix with the localToWorldMatrix property of a transform component. However you usually just use the localScale to change the scale.

Comment
Add comment · Show 5 · 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 ChristianLinnell · Jan 10, 2013 at 10:20 PM 0
Share

Thought as much... but to me the "exponential scaling" implies some kind of skewing is going on... any thoughts?

avatar image Bunny83 · Jan 10, 2013 at 11:02 PM 0
Share

No, i don't think so. He just scales down the worls position and the scale (uniformly). The point is the scaling factor. It has to be calculated in a way that values in the range FCP/2 ro infinity are mapped to values in the range of FCP/2 to FCP.

The distance of an object from the far clipping plane has to be calculated by yourself. $$anonymous$$aybe it's possible to do it in the shader, but that wouls complicate things if you want to use built-in shaders.

However the question is more about what exact formula he used to map [FCP/2, ininity] to [FCP/2, FCP]

avatar image DaveA · Jan 10, 2013 at 11:07 PM 1
Share

I think you can assume that at infinity, the scale factor is zero. You could do a linear interpolation of 1 to 0 from FCP/2 to FCP, but more likely that will be exponential, so you could try squaring that, or cubing it, and see how it looks. I'm not sure there's a real good formula for it (using exp or log or whatnot), just whatever looks best.

avatar image ChristianLinnell · Jan 10, 2013 at 11:07 PM 0
Share

I can calculate the distance from FCP, but let's say I have a single mesh (like an icosphere). I guess I'm asking how I scale only the parts of it that are more distant than FCP/2. That seems to be what he's suggesting, right?

avatar image Bunny83 · Jan 11, 2013 at 08:33 AM 0
Share

That's irrelevant. We talk about really great distances. Single objects keep their shape. It's just to get them back into the viewing area where otherwise the FCP would clip them. Just moving them closer would make them appear larger (sure since it'S closer) to compensate that you have to scale the object down:

 transform.localScale = originScale * factor;

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

10 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

Related Questions

Scaling the GUI using a matrix issues 2 Answers

texture detail on large scale objects 0 Answers

How can I scale the insides of a ScrollView 0 Answers

How to make a localToWorld matrix for shader parameters? 1 Answer

How to Decompose a TRS Matrix? 3 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