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
4
Question by Aubrey-Falconer · Feb 16, 2011 at 03:34 AM · texturerendertexturecubemap

Easiest way to rotate a cubemap?

Unity's automatic texture importer cubemap generation is quite handy, but it produces cubemaps that are 90 degrees off of the direction I need them to face.

I used an editorscript to apply to cubemaps to a skybox, create a rotated camera, and render the skybox to a new cubemap, but the new cubemap's rotation is the same as the old one.

I would love to use the rendering approach, as it will allow me to bake in a tint as well. Any ideas why it isn't working?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
10

Answer by coastwise · Apr 04, 2011 at 01:27 PM

I just figured out how to rotate a skybox for my own purposes, check this out:

Create a copy of the built in skybox cubed.shader and rename it (available from here).

Change line one to have the name "Rotated Skybox Cubed" (or whatever)

At about line 23 add: uniform float4x4 _Rotation;

Modify the vert function (around line 35) to the following:

v2f vert (appdata_t v)
{
    v2f o;
    o.vertex = mul(_Rotation, v.vertex);
    o.vertex = mul(UNITY_MATRIX_MVP, o.vertex);
    o.texcoord = v.texcoord;
    return o;
}

Create a C# script called RotateSkybox like so:

using UnityEngine;

[RequireComponent(typeof(Skybox))] public class RotateSkybox : MonoBehaviour {

 void Start () {
     // Construct a rotation matrix and set it for the shader
     Quaternion rot = Quaternion.Euler (60f, 0f, 0f);
     Matrix4x4 m = Matrix4x4.TRS (Vector3.zero, rot, new Vector3(1,1,1) );
     GetComponent<Skybox>().material.SetMatrix ("_Rotation", m);
 }

}

Slap that baby on your camera and you're laughin! (hopefully)

Note: I've simply hardcoded the rotation I needed into the RotateSkybox script as rot, from you're description you'd either want +/- 90 in the y component instead.

Comment
Add comment · Show 3 · 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 aeronmiles · Sep 28, 2011 at 11:08 AM 0
Share

thanks for posting this!

avatar image renanss · Aug 19, 2013 at 06:06 AM 0
Share

I'm gonna test this, thank you for posting!

avatar image moatdd · Jul 02, 2016 at 02:43 PM 1
Share

@coastwise: The Unity staff have moved the location of the builtin shader downloads.

Get them here! (see the dropdowns)

avatar image
0

Answer by videep · Nov 20, 2014 at 01:26 PM

Please follow the links for a tutorial on rotating the cubemap in any axis as per users convenience. http://themaxscriptguy.wordpress.com/2014/11/20/rotating-cubemap-in-unity/ https://github.com/theMaxscriptGuy/Unity_Dev/tree/master/CubeMap_Rotation

Comment
Add comment · 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

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting cubemap faces as rendertexture 0 Answers

Rendering a G-Buffer for a cubemap 0 Answers

forcing texture resolution? 1 Answer

Cubemap render faces 1 Answer

Projecting camera view on to a right angled surface 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