当前位置:网站首页>逐片元-兰伯特光照模型
逐片元-兰伯特光照模型
2022-08-09 00:08:00 【ThomasQxx】
Shader "QStudyShader/Per_Fragment_LambertLaw"
{
Properties{
}
SubShader{
Pass{
Tags{
"LightModel" = "ForwardBase"}
CGPROGRAM
#include "Lighting.cginc"
#pragma vertex Vertex
#pragma fragment Fragment
struct a2v {
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f {
float4 pos : SV_POSITION;
float3 worldNormal : TEXCOORD0;
};
v2f Vertex(a2v v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.worldNormal = UnityObjectToWorldNormal(v.normal);
return o;
}
fixed4 Fragment(v2f i) :SV_TARGET{
fixed3 worldNormal = normalize(i.worldNormal);
fixed3 worldLightDir = normalize(_WorldSpaceLightPos0.xyz);
fixed3 diffuse = _LightColor0.xyz * max(0, dot(worldNormal,worldLightDir));
fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
return fixed4(diffuse + ambient, 1.0);
}
ENDCG
}
}
}
边栏推荐
- Mysql Workbench uses .sql file to import data into database
- 第四章 SQL与关系数据库基本操作(上)
- Why software development methodology make you feel bad?
- 将板子芯片从ST32F101改为STM32F103要改的地方
- 有人负责,才有质量:写给在集市中迷失的一代
- 穿越派·派盘(WebDAV)解决OmniFocus同步问题
- 最新:新冠疫苗多久起效?能保护多久?
- flutter Future的正确用法
- 穿越派·派盘 + 静读天下 = 顶级电子书阅读器
- 《MySQL入门很轻松》第3章:数据库的创建与操作
猜你喜欢
随机推荐
对js基础知识的一些理解
2017年11月历史文章汇总
Canvas绘图基础知识
C-关键字之volatile
蓝牙模块HC-08——连接
最新7篇数据科学/深度学习/CNN/知识图谱/文本匹配等中英文综述论文推介(附下载)
第四章 SQL与关系数据库基本操作(下)
线性复杂度优化 / 离散化
2021ccpc网络选拔赛
flutter Future的正确用法
爬虫学习整理
Ubuntu下Docker安装Redis (快速简便)
2017年8月历史文章汇总
第三章 数据库设计
AutoX安途杯中山大学程序设计校赛(同步赛)
2017年10月历史文章汇总
Refract-折射
ReflectCubeMap
如何购买穿越派V3.14版本产品?
Idea碰到的问题总结