首页 > 其他 > 详细

简单的光照贴图

时间:2018-01-13 18:03:47      阅读:216      评论:0      收藏:0      [点我收藏+]
Shader "Custom/LightMap"
{
    Properties
    {
        _Color("Base Color", Color) = (1,1,1,1)
        _MainTex("Base(RGB)", 2D) = "white" {}
        _LightMap("LightMap", 2D) = "white" {}
    }
    
    SubShader
    {
        tags{"Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True"}
        Blend SrcAlpha OneMinusSrcAlpha
        
        Pass
        {
            
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            
            float4 _Color;
            sampler2D _MainTex;
            sampler2D _LightMap;
            
            struct v2f
            {
                float4 pos:POSITION;
                float4 uv:TEXCOORD0;
                float2 uvLM:TEXCOORD1;
            };
            
            v2f vert(appdata_full v)
            {
                v2f o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                o.uv = v.texcoord;
                o.uvLM = v.texcoord1.xy;
                return o;
            }
            
            half4 frag(v2f i):COLOR
            {    
                half4 c = tex2D(_MainTex , i.uv.xy) * _Color;
                half3 l = 2.0 * tex2D(_LightMap, i.uvLM).rgb;
                //half4 lm= tex2D(_LightMap, i.uvLM);
                //half3 l = 8.0 * lm.a * lm.rgb;
                c.rgb *= l;
                
                return c;
            }
            
            ENDCG
        }
    }
}

 

简单的光照贴图

原文:https://www.cnblogs.com/wang-jin-fu/p/8279683.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!