当前位置:网站首页>Shader basic UV operations, translation, rotation, scaling
Shader basic UV operations, translation, rotation, scaling
2022-07-07 15:52:00 【Le_ Sam】
Shader "Custom/MoveUV"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Speed("Rotate Speed",Range(0,4))=1
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float _Speed;
struct a2v{
float4 vertex:POSITION;
float4 texcoord:TEXCOORD;
};
struct v2f{
float4 pos:POSITION;
float4 uv:texcoord;
};
v2f vert(a2v v){
v2f o;
o.pos=UnityObjectToClipPos(v.vertex);
o.uv=v.texcoord;
return o;
}
fixed4 frag(v2f i):SV_Target{
// Twist effect
fixed2 uv = i.uv - fixed2(0.5,0.5);
float angle = _Speed * 0.1745/(length(uv) + 0.1);// Add 0.1 It's placement length(uv) by 0
float angle2 = angle * _Time.y;
uv = float2(uv.x*cos(angle2)-uv.y*sin(angle2),uv.y*cos(angle2)+uv.x*sin(angle2));
uv+=fixed2(0.5,0.5);
fixed4 c = tex2D(_MainTex,uv);
return c;
// The zoom
//float4 uv = i.uv;
//uv.x*=_Speed;
//uv.w=0.5;
//return tex2D(_MainTex,uv);
// rotate
//float2 uv=i.uv.xy-float2(0.5,0.5);
//uv=float2(uv.x*cos(_Speed*_Time.y)-uv.y*sin(_Speed*_Time.y),uv.y*cos(_Speed*_Time.y) + uv.x*sin(_Speed*_Time.y));
//uv+=float2(0.5,0.5);
//fixed4 lateUV = tex2D(_MainTex,uv);
//return lateUV;
// translation
//return tex2D(_MainTex,i.uv - _Time.x*fixed2(2,0)* _Speed);
}
ENDCG
}
}
}
Reproduced in :https://blog.csdn.net/yiwei151/article/details/78687354 =》 Playful childhood
边栏推荐
- LeetCode2_ Add two numbers
- Steps to create P8 certificate and warehousing account
- 【数字IC验证快速入门】19、SystemVerilog学习之基本语法6(线程内部通信...内含实践练习)
- C4D learning notes 3- animation - animation rendering process case
- Three. JS introductory learning notes 11:three JS group composite object
- Cocos makes Scrollview to realize the effect of zooming in the middle and zooming out on both sides
- Three. JS introductory learning notes 13: animation learning
- 【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
- [quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
- When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
猜你喜欢

numpy--疫情数据分析案例

Vertex shader to slice shader procedure, varying variable

【数字IC验证快速入门】29、SystemVerilog项目实践之AHB-SRAMC(9)(AHB-SRAMC SVTB Overview)

After UE4 is packaged, mesh has no material problem
![[quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)](/img/7e/188e57ee026200478a6f61eb507c92.png)
[quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)

神经网络c语言中的指针是怎么回事

强化实时数据管理,英方软件助力医保平台安全建设

Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?

无线传感器网络--ZigBee和6LoWPAN
Configure mongodb database in window environment
随机推荐
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
[quick start of Digital IC Verification] 20. Basic grammar of SystemVerilog learning 7 (coverage driven... Including practical exercises)
numpy--数据清洗
[quick start of Digital IC Verification] 22. Ahb-sramc of SystemVerilog project practice (2) (Introduction to AMBA bus)
Getting started with webgl (2)
Async and await
UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
Three. JS introductory learning notes 10:three JS grid
2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
Whole process analysis of unity3d rendering pipeline
强化实时数据管理,英方软件助力医保平台安全建设
Please supervise the 2022 plan
[quick start of Digital IC Verification] 23. AHB sramc of SystemVerilog project practice (3) (basic points of AHB protocol)
Three. JS introductory learning notes 04: external model import - no material obj model
Detailed explanation of unity hot update knowledge points and introduction to common solution principles
Jacobo code coverage
保证接口数据安全的10种方案
Do not use memset to clear floating-point numbers
numpy--疫情数据分析案例