当前位置:网站首页>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
边栏推荐
- Jerry's configuration of TWS cross pairing [article]
- 如何选择合适的自动化测试工具?
- Reinforcement learning - learning notes 8 | Q-learning
- Google SEO external chain backlinks research tool recommendation
- [200 opencv routines] 223 Polygon fitting for feature extraction (cv.approxpolydp)
- 为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
- DNS series (I): why does the updated DNS record not take effect?
- Code of "digital image processing principle and Practice (matlab version)" part2[easy to understand]
- Use json Stringify() to realize deep copy, be careful, there may be a huge hole
- Overseas agent recommendation
猜你喜欢

Debugging and handling the problem of jamming for about 30s during SSH login

【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式

Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission

Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?

It's worth seeing. Interview sites and interview skills

Reptile combat (VII): pictures of the king of reptiles' heroes
![Restapi version control strategy [eolink translation]](/img/65/decbc158f467ab8c8923c5947af535.png)
Restapi version control strategy [eolink translation]

South China x99 platform chicken blood tutorial
![Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]](/img/14/1c8a70102c106f4631853ed73c4d82.png)
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]

Validutil, "Rethinking the setting of semi supervised learning on graphs"
随机推荐
Backup tidb cluster to persistent volume
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
Crawler (17) - Interview (2) | crawler interview question bank
EasyCVR配置中心录像计划页面调整分辨率时的显示优化
Reinforcement learning - learning notes 8 | Q-learning
[200 opencv routines] 223 Polygon fitting for feature extraction (cv.approxpolydp)
Validutil, "Rethinking the setting of semi supervised learning on graphs"
Can I open a stock account directly online now? Is it safe?
How to write an augmented matrix into TXT file
Meta force force meta universe system development fossage model
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Implementation method of data platform landing
Paint basic graphics with custompaint
South China x99 platform chicken blood tutorial
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Jerry's test box configuration channel [chapter]
Leetcode SQL first day
Matplotlib drawing interface settings
Ad domain group policy management
ISO 26262 - considerations other than requirements based testing