How do I Rotate a Skybox's Material

How can I rotate a skybox's material so it simulates slow movement of the sky? Does anyone have a script that does this? I have a script that can animate UV's but it won't let me apply it to a material or a skybox.

Below is the UV animation script...maybe someone can modify it to animate the UV's of a skybox?

//Scroll main texture based on time
var scrollSpeed = 0.5;
function Update() {
    var offset = Time.time * scrollSpeed;
    renderer.material.mainTextureOffset = Vector2 (0,offset);
    renderer.material.mainTexture.wrapMode = TextureWrapMode.Repeat;
}

Any help is greatly appreciated. Thanks!

Shawn

haha ya I inserted my text inside the quotes for the code...but it kept refusing to properly format...do I need to do anything specific to get them formatted properly? thanks for your help, I appreciate it

4 Answers

4

Sorry for digging up an old question that is also answered, but i would like to contribute my solution too.

What i did was to create a second camera, set the depth to be less than the depth of the main camera, at the main camera i set clear flags as “depth only” while the second camera would have clear flags set as “Skybox”. then a simple script for the second camera’s rotation and you get the effect that you want.

Thank you, I had no clue on how to do this until I tried your solution and it worked. I just created an account here to say thanks to you.

Wish I had rep enough to +1; Ty!

Great solution! Easy and works well. FYI i had to set the camera's culling mask to nothing as well.

My god constantine that's brilliant! Why can i only upvote once?!

Wonderful! Except that I am having some issues with it while in mouselook... Trying to figure out a way to disable it moving with the main cam :)

This may interest you: http://answers.unity3d.com/questions/14461/how-do-i-make-a-moving-skybox

I'm pretty sure the Asset Store has a nice plugin for doing what you want.

Thanks, but I'm not looking to spend any money. I appreciate the advice.

And for the help I get downvoted? Nice.

I didn't want to downvote you. =( This should have been an upvote. I do appreciate your help. I am sorry. It won't let me remove the downvote either. So I accepted it as a correct answer instead. I hope you understand.

Ah, thanks

It’s fairly simple actually.

If you are using built in “Skybox/6 Sided” shader, modify “_Rotation” property.

Skybox skybox;

void Update()
{
	skybox.material.SetFloat("_Rotation", Time.time * 10);
}   

If you want to do it with cubemap, copy and paste the code from built in shader “Skybox.shader” available in unity archives.

Of what I've read... You have skyboxes thought out wrong... It's not as easy as just moving it... Like clouds are very complex...

http://unity3d.com/support/documentation/Components/class-Skybox.html

I recommend reading up on it...

Also, this place has some good info on it:

http://www.unifycommunity.com/wiki/index.php?search=skybox&go=Go

But yeah, I'd rather you read it than I explain it wrong, but I might be wrong, but meh.

Good luck! =).

Ya I've read all of those. I've looked everywhere. I understand Skybox's and the multiple ways to create them. I just don't know how to animate the actual textures of the skybox to simulate movement. Thanks for the links though, I appreciate it. Shawn