当前位置:网站首页>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
边栏推荐
- Static test tool
- JNI primary contact
- PDF文档签名指南
- Automatic classification of defective photovoltaic module cells in electronic images
- TCP/IP 协议栈
- [open source] Net ORM accessing Firebird database
- Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
- 2022 how to evaluate and select low code development platforms?
- Reinforcement learning - learning notes 9 | multi step TD target
- Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
猜你喜欢
如何实现横版游戏中角色的移动控制
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Virtual machine network configuration in VMWare
Automatic classification of defective photovoltaic module cells in electronic images
用语雀写文章了,功能真心强大!
Navicat connect 2002 - can't connect to local MySQL server through socket '/var/lib/mysql/mysql Sock 'solve
It's worth seeing. Interview sites and interview skills
Dry goods sharing | devaxpress v22.1 original help document download collection
ByteDance senior engineer interview, easy to get started, fluent
South China x99 platform chicken blood tutorial
随机推荐
How to turn on win11 game mode? How to turn on game mode in win11
Meta force force meta universe system development fossage model
SAR image quality evaluation
What if the win11u disk does not display? Solution to failure of win11 plug-in USB flash disk
Implementation method of data platform landing
Tupu digital twin coal mining system to create "hard power" of coal mining
[JDBC Part 1] overview, get connection, CRUD
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?
Nine degree 1201 - traversal of binary sort number - binary sort tree "suggestions collection"
The cyberspace office announced the measures for data exit security assessment, which will come into force on September 1
Jerry's fast pairing does not support canceling pairing [article]
Google SEO external chain backlinks research tool recommendation
Use blocconsumer to build responsive components and monitor status at the same time
100million single men and women "online dating", supporting 13billion IPOs
Tsconfig of typescript TS basics JSON configuration options
Actual combat: sqlserver 2008 Extended event XML is converted to standard table format [easy to understand]
ByteDance Android interview, summary of knowledge points + analysis of interview questions
[open source] Net ORM accessing Firebird database
客户案例|华律网,通过观测云大幅缩短故障定位时间
Embedded development: how to choose the right RTOS for the project?