当前位置:网站首页>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
边栏推荐
- 2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
- Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
- Numpy --- basic learning notes
- How to understand that binary complement represents negative numbers
- JS array foreach source code parsing
- The rebound problem of using Scrollview in cocos Creator
- Asynchronous application of generator function
- C4D learning notes 3- animation - animation rendering process case
- Wireless sensor networks -- ZigBee and 6LoWPAN
- 【数字IC验证快速入门】19、SystemVerilog学习之基本语法6(线程内部通信...内含实践练习)
猜你喜欢

Wireless sensor networks -- ZigBee and 6LoWPAN

10 schemes to ensure interface data security
![[quick start of Digital IC Verification] 22. Ahb-sramc of SystemVerilog project practice (2) (Introduction to AMBA bus)](/img/3f/40475f9f6e0fcd3f58c93164f65674.png)
[quick start of Digital IC Verification] 22. Ahb-sramc of SystemVerilog project practice (2) (Introduction to AMBA bus)

Cut ffmpeg as needed, and use emscripten to compile and run

20th anniversary of agile: a failed uprising

A wave of open source notebooks is coming
![[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)](/img/91/16a370ac41adc8fe31507765a82b0a.png)
[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)

AE learning 02: timeline

Super simple and fully automated generation super signature system (cloud Xiaoduo minclouds.com cloud service instance), free application in-house test app distribution and hosting platform, maintenan

Three. JS introductory learning notes 11:three JS group composite object
随机推荐
Three. JS introductory learning notes 10:three JS grid
webgl_ Enter the three-dimensional world (1)
Numpy --- basic learning notes
【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
Monthly observation of internet medical field in May 2022
Do not use memset to clear floating-point numbers
Wireless sensor networks -- ZigBee and 6LoWPAN
神经网络c语言中的指针是怎么回事
Super signature principle (fully automated super signature) [Yun Xiaoduo]
C4D learning notes 2- animation - timeline and time function
OpenGL common functions
What is Base64?
Cocos makes Scrollview to realize the effect of zooming in the middle and zooming out on both sides
Jacobo code coverage
Three. JS introductory learning notes 13: animation learning
Mesh merging under ue4/ue5 runtime
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
unnamed prototyped parameters not allowed when body is present
20th anniversary of agile: a failed uprising