zoukankan      html  css  js  c++  java
  • Unity4中的lightmap怎么在Unity5及其以上版本中使用

    Unity5的Lightmap管线与Unity4的有很大的不同了,u5不能直接使用u4的lightmap。但是u5中,可以把u4的lightmap当作光照贴图来使用,就像一张普通的贴图一样,具体可以参考 Lightmap-xxxx.shader之类的shader, 如:
    Lightmap-Bumped.shader
    Lightmap-BumpSpec.shader
    Lightmap-Diffuse.shader
    Lightmap-Glossy.shader
    Lightmap-VertexLit.shader

    具体如 :Lightmap-Diffuse.shader

    Shader "Legacy Shaders/Lightmapped/Diffuse" {
    Properties {
        _Color ("Main Color", Color) = (1,1,1,1)
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _LightMap ("Lightmap (RGB)", 2D) = "black" {}
    }
    
    SubShader {
        LOD 200
        Tags { "RenderType" = "Opaque" }
    CGPROGRAM
    #pragma surface surf Lambert nodynlightmap
    struct Input {
      float2 uv_MainTex;
      float2 uv2_LightMap;
    };
    sampler2D _MainTex;
    sampler2D _LightMap;
    fixed4 _Color;
    void surf (Input IN, inout SurfaceOutput o)
    {
      o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * _Color;
      half4 lm = tex2D (_LightMap, IN.uv2_LightMap);
      o.Emission = lm.rgb*o.Albedo.rgb;
      o.Alpha = lm.a * _Color.a;
    }
    ENDCG
    }
    FallBack "Legacy Shaders/Lightmapped/VertexLit"
    }

    本来是Unity引擎lightmap管线自动设定的lightmap贴图以及scale offset等值,现在需要在材质中明确指定了:也就是需要显式设定 _Lightmap 和 _Lightmap_ST 了。

  • 相关阅读:
    Vue状态管理
    Vue延迟点击
    Vue路由
    简单的队列应用
    Uncaught SyntaxError: Unexpected token )
    视频转码
    判断是否为视频文件
    Press ^C at any time to quit.
    Node.js学习
    YUM安装LAMP与LNMP
  • 原文地址:https://www.cnblogs.com/open-coder/p/13910956.html
Copyright © 2011-2022 走看看