zoukankan      html  css  js  c++  java
  • 简单的光照贴图

    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
            }
        }
    }
    一直想把之前工作、学习时记录的文档整理到博客上,一方面温故而知新,一方面和大家一起学习 -程序小白
  • 相关阅读:
    腾讯云 ubuntu 上tomcat加载项目很慢
    ubuntu 中iptables
    linux ssh修改 默认22端口
    jetty 客服端 与服务端
    spring mvc 拦截器
    linux配置iptables(3)
    el取bean 对象属性规则
    mybatis 反射bean规则
    fastjson tojson部分规则
    正则获取参数 分组
  • 原文地址:https://www.cnblogs.com/wang-jin-fu/p/8279683.html
Copyright © 2011-2022 走看看