4

I have four different skyboxes, one for each season in my game.

How can I create a fade transition between the skyboxes in c#?

So for example, at a certain point, the summer skybox fades into the autumn skybox.

Thank you!

1 Answer 1

0

You'll want to do the blending in a shader, there's one on the Unify wiki that can blend between two skyboxes.

You need to swap the textures in your material using a script (using material.SetTexture) when it's finished blending between 2 of them to get the effect of blending between 4.

4
  • I've set up the shader and material and the skybox blends using the slider. How can i write it in my code (c#) so that it gradually animates from blend = 0.0 to blend = 1? I understand you can use skyboxmaterial.SetFloat("_Blend", blendNumber ); But I need the blend Number to be gradually incremented over a set time.
    – Night.owl
    Apr 3, 2016 at 17:08
  • 1
    You can use Mathf.Lerp(start, end, time) to get a value between two others, where time is between 0 and 1. The easy (but technically wrong) way to use it is something like this: material.SetFloat("_Blend" , Mathf.Lerp(material.GetFloat("_Blend"),1,Time.deltaTime)); but that gives you fast blending at the start, and slows down to a stop just before reaching 1. The best way to do it is laid out well in this article:chicounity3d.wordpress.com/2014/05/23/how-to-lerp-like-a-pro
    – Rtyper
    Apr 3, 2016 at 19:00
  • 1
    Then again, if the _Blend parameter's range is 0 to 1, you probably don't need Lerp anyway, you can just increment a timer variable yourself using Time.deltaTime and use that.
    – Rtyper
    Apr 3, 2016 at 19:03
  • How do I add the Sky boxes to the blending shader, they are materials and i'm not quite sure how to go about this.
    – Jajan
    Jun 1, 2017 at 6:59

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.