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 Rosscoe3 · Dec 01, 2016 at 08:50 PM · materialssphereskyboxskyboxesplanets

How to create a spherical skybox???

https://www.youtube.com/watch?v=H7-3dZTERf0 I was watching this video by sebastian lague and at 3:51 he shows to planets with different spheres that work as skyboxes.. how is this achieved???

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
2

Answer by Bunny83 · Dec 01, 2016 at 09:38 PM

That's just a sphere with inward looking faces. A normal sphere mesh (like the one that comes with Unity) has it's faces point outwards so when you view the sphere from the inside you wouldn't see anything. When the faces are reverted it's the opposite So from outside you see through the faces but from the inside you can see them. That's why you see the back of the sphere when you're outside the sphere.

edit

I quickly made a simple script that inverts all faces of a mesh at runtime. Just attach the script to a sphere GameObject. It can invert the faces as well as the normal vectors (so any lighting calculation would be correct). It also works on a cube or any other mesh.

 //MeshInverter.cs
 using UnityEngine;
 
 public class MeshInverter : MonoBehaviour
 {
     public bool InvertFaces = true;
     public bool InvertNormals = true;
     void Start ()
     {
         var mf = GetComponent<MeshFilter>();
         if (mf != null)
         {
             var m = Instantiate(mf.sharedMesh);
             Process(m);
             mf.sharedMesh = m;
         }
         var smr = GetComponent<SkinnedMeshRenderer>();
         if (smr != null)
         {
             var m = Instantiate(smr.sharedMesh);
             Process(m);
             smr.sharedMesh = m;
         }
     }
 
     private void Process(Mesh m)
     {
         int subMeshes = m.subMeshCount;
         for (int i = 0; i < subMeshes; i++)
         {
             if (InvertFaces)
             {
                 var type = m.GetTopology(i);
                 var indices = m.GetIndices(i);
                 if (type == MeshTopology.Quads)
                 {
                     for (int n = 0; n < indices.Length; n += 4)
                     {
                         int tmp = indices[n];
                         indices[n] = indices[n + 3];
                         indices[n + 3] = tmp;
                         tmp = indices[n + 1];
                         indices[n + 1] = indices[n + 2];
                         indices[n + 2] = tmp;
                     }
                 }
                 else if (type == MeshTopology.Triangles)
                 {
                     for (int n = 0; n < indices.Length; n += 3)
                     {
                         int tmp = indices[n];
                         indices[n] = indices[n + 1];
                         indices[n + 1] = tmp;
                     }
                 }
                 m.SetIndices(indices, type, i);
             }
         }
         if (InvertNormals)
         {
             var normals = m.normals;
             for (int n = 0; n < normals.Length; n++)
                 normals[n] = -normals[n];
             m.normals = normals;
         }
     }
 }

Comment
Add comment · Show 2 · 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 tomekkie2 · Dec 02, 2016 at 12:35 AM 0
Share

What would you think of achieving the same effect with shader? Just by adding the Cull front directive to the shader diplicate.

avatar image Bunny83 tomekkie2 · Dec 02, 2016 at 01:38 AM 0
Share

Well it depends on the kind of shader. If the shader uses any kind of lighting you have to flip the normals as well (I mean in the shader). However it makes much more sense to just use a proper model in the first place as this allows you to use any shader you want.

If the shader is an unlit shader then yes, using just cull front would be enough when using a normal sphere.

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

60 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

Related Questions

Object looks different in different skyboxes 1 Answer

Dynamic Skybox 2 Answers

Skybox keeps crashing my app? 1 Answer

Custom Skybox not loading or saving.,Skybox won't save when I drag and drop custom material. 2 Answers

creating skybox material problem 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