zoukankan      html  css  js  c++  java
  • unity3D打造skybox淡入淡出

    原地址:http://www.it2down.com/it-mobile/426479.htm

    当前位置: IT异常查询网 »

    unity3D打造skybox淡入淡出 - 移动开发

    www.it2down.com   发布于:2013-6-18 21:54:54   
    unity3D制作skybox淡入淡出
    首先建立个shader
    Shader "Custom/Skybox" {
    
    Properties {
        _Tint ("Tint Color", Color) = (.5, .5, .5, .5)
        _FrontTex ("Front (+Z)", 2D) = "white" {}
        _BackTex ("Back (-Z)", 2D) = "white" {}
        _LeftTex ("Left (+X)", 2D) = "white" {}
        _RightTex ("Right (-X)", 2D) = "white" {}
        _UpTex ("Up (+Y)", 2D) = "white" {}
        _DownTex ("Down (-Y)", 2D) = "white" {}
        _FrontTex2("2 Front (+Z)", 2D) = "white" {}
        _BackTex2("2 Back (-Z)", 2D) = "white" {}
        _LeftTex2("2 Left (+X)", 2D) = "white" {}
        _RightTex2("2 Right (-X)", 2D) = "white" {}
        _UpTex2("2 Up (+Y)", 2D) = "white" {}
        _DownTex2("2 Down (-Y)", 2D) = "white" {}
        _Color ("Fade (use alpha)", Color) = (1,1,1,1)
    }
    
    SubShader {
        Tags { "Queue" = "Background" }
        Cull Off
        ZWrite On
        ZTest Always
        Fog { Mode Off }
        Lighting Off       
        Color [_Tint]
        Pass {
            SetTexture [_FrontTex] { combine texture }
            SetTexture[_FrontTex2] { 
                constantColor [_Color]
                combine texture lerp (constant) previous
            }
        }
        Pass {
            SetTexture [_BackTex] { combine texture }
            SetTexture[_BackTex2] { 
                constantColor [_Color]
                combine texture lerp (constant) previous
            }
        }
        Pass {
            SetTexture [_LeftTex] { combine texture }
            SetTexture[_LeftTex2] { 
                constantColor [_Color]
                combine texture lerp (constant) previous
            }
        }
        Pass {
            SetTexture [_RightTex] { combine texture }
            SetTexture[_RightTex2] { 
                constantColor [_Color]
                combine texture lerp (constant) previous
            }
        }
        Pass {
            SetTexture [_UpTex] { combine texture }
            SetTexture[_UpTex2] { 
                constantColor [_Color]
                combine texture lerp (constant) previous
            }
        }
        Pass {
            SetTexture [_DownTex] { combine texture }
            SetTexture[_DownTex2] { 
                constantColor [_Color]
                combine texture lerp (constant) previous
            }
        }
    }
    
    Fallback "RenderFX/Skybox", 1
    }
    

    材质间的动画转换
    private var thisMaterial : Material;
    private var fadeSpeed : float = 0.4;
    
    function Start (){
        thisMaterial = RenderSettings.skybox;
        thisMaterial.color.a = 0.0;
    }
    
    function Update () {
        thisMaterial.color.a += (fadeSpeed * Time.deltaTime); 
        thisMaterial.color.a = Mathf.Clamp(thisMaterial.color.a, 0.0, 1.0);
    }
    

    skybox的纹理褪色,渐渐的转变。
    public var blackTexture : Texture2D;
    
    function Start (){
        thisMaterial = RenderSettings.skybox;
        thisMaterial.color.a = 0.0;
    
        thisMaterial.SetTexture("_FrontTex", blackTexture);
        thisMaterial.SetTexture("_BackTex", blackTexture);
        thisMaterial.SetTexture("_LeftTex", blackTexture);
        thisMaterial.SetTexture("_RightTex", blackTexture);
        thisMaterial.SetTexture("_UpTex", blackTexture);
        thisMaterial.SetTexture("_DownTex", blackTexture);
    }
    function Update () {
        thisMaterial.color.a += (fadeSpeed * Time.deltaTime); 
        thisMaterial.color.a = Mathf.Clamp(thisMaterial.color.a, 0.0, 1.0);
    }
    

    设置纹理等
    thisMaterial.SetTexture("_FrontTex2", textureVariable);
  • 相关阅读:
    【.NET】VS2013创建Windows服务与调试服务
    【JS】处理数据四舍五入(tofixed与round的区别详解)
    【微信小程序】 基础语义笔记2:基本组件、获取节点信息
    面向对象和面向过程的优点和缺点
    【微信小程序】 基础语义笔记1:配置、页面文件、组件。
    【微信小程序】 wxParse组件
    zookeeper 碎片知识点
    zookeeper 基本概念
    RocketMQ 知识点
    单例模式---双层检验锁+volatile
  • 原文地址:https://www.cnblogs.com/123ing/p/3789089.html
Copyright © 2011-2022 走看看