当前位置:网站首页>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
边栏推荐
- Dry goods sharing | devaxpress v22.1 original help document download collection
- Reinforcement learning - learning notes 9 | multi step TD target
- Tupu digital twin coal mining system to create "hard power" of coal mining
- Prometheus remote_ write InfluxDB,unable to parse authentication credentials,authorization failed
- Jerry's about TWS channel configuration [chapter]
- What if the win11u disk does not display? Solution to failure of win11 plug-in USB flash disk
- Code of "digital image processing principle and Practice (matlab version)" part2[easy to understand]
- 强化学习-学习笔记9 | Multi-Step-TD-Target
- DNS series (I): why does the updated DNS record not take effect?
- Leetcode SQL first day
猜你喜欢
Ad domain group policy management
NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
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?
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
PDF文档签名指南
Solve the problem of uni in uni app Request sent a post request without response.
Automatic classification of defective photovoltaic module cells in electronic images
三元表达式、各生成式、匿名函数
随机推荐
Wechat official account oauth2.0 authorizes login and displays user information
Solve the problem of uni in uni app Request sent a post request without response.
使用 BlocConsumer 同时构建响应式组件和监听状态
How to make agile digital transformation strategy for manufacturing enterprises
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?
DBSync新增对MongoDB、ES的支持
Overseas agent recommendation
2022 how to evaluate and select low code development platforms?
Ternary expressions, generative expressions, anonymous functions
The cyberspace office announced the measures for data exit security assessment, which will come into force on September 1
How does win11 time display the day of the week? How does win11 display the day of the week today?
Latest Android advanced interview questions summary, Android interview questions and answers
SAR image quality evaluation
Ten thousand word summary data storage, three knowledge points
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
Tsconfig of typescript TS basics JSON configuration options
Jerry's about TWS pairing mode configuration [chapter]
How to turn on win11 game mode? How to turn on game mode in win11
Record a garbled code during servlet learning
Qt编写物联网管理平台39-报警联动