当前位置:网站首页>逐片元-兰伯特光照模型
逐片元-兰伯特光照模型
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
}
}
}
边栏推荐
- 移动web开发-布局篇
- 对纹理进行uv坐标偏移
- Flutter -自定义日历组件
- Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [33,755] milliseco
- Why software development methodology make you feel bad?
- 判断输入的信息是否为空,如果为空,提示信息
- Dart高级(一)——泛型与Json To Bean
- APUE---chap4文件和目录---4.2~4.18(stat/access/umask/chmod/remove/rename)
- 为什么软件开发方法论让你觉得糟糕?
- Win10安装 pycocotools
猜你喜欢
随机推荐
mysql建表常用sql语句
GRPC学习(An RPC library and framework)
C-关键字之volatile
第六章 数据库安全与保护
Anaconda 使用 Navigator 安装 Tensorflow(包括 Anaconda 安装)
JS数据类型
sessionStorage值改变后,页面利用window.sessionStorage.getItem()获取到的值不会更新
牛客小白月赛 37 补题
移动web开发-布局篇
Win10安装 pycocotools
《MySQL入门很轻松》第3章:数据库的创建与操作
LeetCode 0179. 最大数
2017年8月历史文章汇总
第四章 SQL与关系数据库基本操作(上)
The difference between MVC and MVP
最新7篇数据科学/深度学习/CNN/知识图谱/文本匹配等中英文综述论文推介(附下载)
指南针股票软件股票开户安全嘛
js实现继承的几种方式
2017年9月历史文章汇总
二 分析C#中的结构









