Shader "Diffuse Lightmap" {

  Properties {
_MainTex ("Texture 1", 2D) = "white" {}
} SubShader {
Tags { "RenderType" = "Opaque" } Pass {
// Disable lighting, we're only using the lightmap
Lighting Off CGPROGRAM
// Must be a vert/frag shader, not a surface shader: the necessary variables
// won't be defined yet for surface shaders.
#pragma vertex vert
#pragma fragment frag #include "UnityCG.cginc" struct v2f {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
float2 uv1 : TEXCOORD1;
}; struct appdata_lightmap {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
}; // These are prepopulated by Unity
sampler2D unity_Lightmap;
float4 unity_LightmapST; sampler2D _MainTex;
float4 _MainTex_ST; // Define this since its expected by TRANSFORM_TEX; it is also pre-populated by Unity. v2f vert(appdata_lightmap i) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, i.vertex); // UnityCG.cginc - Transforms 2D UV by scale/bias property
// #define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
o.uv0 = TRANSFORM_TEX(i.texcoord, _MainTex); // Use `unity_LightmapST` NOT `unity_Lightmap_ST`
o.uv1 = i.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw;
return o;
} half4 frag(v2f i) : COLOR {
half4 main_color = tex2D(_MainTex, i.uv0); // Decodes lightmaps:
// - doubleLDR encoded on GLES
// - RGBM encoded with range [0;8] on other platforms using surface shaders
// inline fixed3 DecodeLightmap(fixed4 color) {
// #if defined(SHADER_API_GLES) && defined(SHADER_API_MOBILE)
// return 2.0 * color.rgb;
// #else
// return (8.0 * color.a) * color.rgb;
// #endif
// } main_color.rgb *= DecodeLightmap(tex2D(unity_Lightmap, i.uv1));
return main_color;
}
ENDCG
}
}
}

转自:https://gist.github.com/jimfleming/5937437

最新文章

  1. Bootstrap+angularjs+MVC3+分页技术+角色权限验证系统
  2. JAVA面向对象之一
  3. Activity之多启动图标
  4. Oracle 死锁的检测查询及处理
  5. java基础2.0:Object、Class、克隆、异常编程
  6. IE6中使用通用选择器模拟子选择器效果
  7. DDoS攻防战(二):CC攻击工具实现与防御理论
  8. linux下安装jira详细步骤
  9. BZOJ 1018 堵塞的交通
  10. Visual Studio® 2010 Web Deployment Projects站点编译生成bin同时发表插件
  11. tmd123.com
  12. 计蒜客模拟赛D1T1 蒜头君打地鼠:矩阵旋转+二维前缀和
  13. Spring Boot实战笔记(六)-- Spring高级话题(多线程)
  14. [Alpha阶段]测试报告
  15. ReentrantLock原理学习
  16. Greenplum 日常维护手册 (汇总、点评、备查)
  17. python设计模式第二十三天【状态模式】
  18. Python中函数的嵌套及闭包
  19. Spark笔记-DataSet,DataFrame
  20. Unity3d跨平台原理

热门文章

  1. iptables 防火墙详解
  2. Drupal的入门学习
  3. 软件杯python-flask遇到的坑有感!
  4. js call 函数
  5. 认识mysql(3)
  6. ls显示前几行或后几行数据
  7. linux中搭建公网ftp服务器
  8. ELK详细安装部署
  9. SSH密钥验证
  10. mybatis的优缺点及应用场合