当前位置:网站首页>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
边栏推荐
- The function is really powerful!
- 使用 BlocConsumer 同时构建响应式组件和监听状态
- cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
- Main functions of OS, Sys and random Standard Libraries
- 大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
- Oracle advanced (VI) Oracle expdp/impdp details
- Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
- Jerry's manual matching method [chapter]
- [开源] .Net ORM 访问 Firebird 数据库
- Crawler (17) - Interview (2) | crawler interview question bank
猜你喜欢

TCP/IP 协议栈

L2: current situation, prospects and pain points of ZK Rollup

使用 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?

Win11U盘不显示怎么办?Win11插U盘没反应的解决方法

How to make agile digital transformation strategy for manufacturing enterprises

Customer case | China law network, through observing the cloud, greatly shortens the time of fault location

Jenkins user rights management

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

ByteDance senior engineer interview, easy to get started, fluent
随机推荐
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
Use blocconsumer to build responsive components and monitor status at the same time
The maximum number of meetings you can attend [greedy + priority queue]
Jerry's manual matching method [chapter]
Qt编写物联网管理平台39-报警联动
How polardb-x does distributed database hotspot analysis
Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Reinforcement learning - learning notes 9 | multi step TD target
EasyCVR配置中心录像计划页面调整分辨率时的显示优化
三元表达式、各生成式、匿名函数
使用 BlocConsumer 同时构建响应式组件和监听状态
Tupu digital twin coal mining system to create "hard power" of coal mining
Index summary (assault version)
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Take the intersection of two sets
Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
Record a garbled code during servlet learning
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
JNI primary contact