当前位置:网站首页>Use partial derivatives to display normals in unity
Use partial derivatives to display normals in unity
2022-07-07 22:09:00 【qq_ fifty-seven million two hundred and fifty-one thousand thre】
One 、 Using partial derivatives , stay Unity It shows the normal
// ddx ddy Calculating normals
Shader "lcl/ddxddy/CalculateNormal"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float3 worldPos : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float3 normalDir = normalize(cross(ddy(i.worldPos),ddx(i.worldPos)));
return fixed4(normalDir,1);
}
ENDCG
}
}
}
Tangent line
边栏推荐
- [colmap] sparse reconstruction is converted to mvsnet format input
- Qt编写物联网管理平台39-报警联动
- 使用 BlocConsumer 同时构建响应式组件和监听状态
- NVR hard disk video recorder is connected to easycvr through the national standard gb28181 protocol. What is the reason why the device channel information is not displayed?
- 如何实现横版游戏中角色的移动控制
- Open source OA development platform: contract management user manual
- What is the reason for the abnormal flow consumption of 4G devices accessing the easygbs platform?
- Google SEO external chain backlinks research tool recommendation
- Prometheus remote_ write InfluxDB,unable to parse authentication credentials,authorization failed
- Codemail auto collation code of visual studio plug-in
猜你喜欢
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
Solve the problem of uni in uni app Request sent a post request without response.
The maximum number of meetings you can attend [greedy + priority queue]
South China x99 platform chicken blood tutorial
Anti climbing killer
Talk about relational database and serverless
Embedded development: how to choose the right RTOS for the project?
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
Wechat official account oauth2.0 authorizes login and displays user information
随机推荐
Overseas agent recommendation
Open source OA development platform: contract management user manual
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
Which futures company is the safest to open a futures account?
三元表达式、各生成式、匿名函数
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
Record a garbled code during servlet learning
Jerry's about TWS pairing mode configuration [chapter]
嵌入式开发:如何为项目选择合适的RTOS?
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
ISO 26262 - considerations other than requirements based testing
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Crawler (17) - Interview (2) | crawler interview question bank
NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
Jerry's configuration of TWS cross pairing [article]
Time standard library
TCP/IP 协议栈
MIT6.S081-Lab9 FS [2021Fall]
Matplotlib drawing interface settings
How to make agile digital transformation strategy for manufacturing enterprises