当前位置:网站首页>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
边栏推荐
- [quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
- 航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
- [wechat applet] Chapter (5): basic API interface of wechat applet
- LeetCode1_ Sum of two numbers
- 航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- [Lanzhou University] information sharing of postgraduate entrance examination and re examination
- Webcodecs parameter settings -avc1.42e01e meaning
- Wireless sensor networks -- ZigBee and 6LoWPAN
- SPI master rx time out中断
猜你喜欢
[quick start of Digital IC Verification] 23. AHB sramc of SystemVerilog project practice (3) (basic points of AHB protocol)
Three. JS introductory learning notes 18: how to export JSON files with Blender
C4D learning notes 2- animation - timeline and time function
The download button and debug button in keil are grayed out
10 schemes to ensure interface data security
Iterator and for of.. loop
【数字IC验证快速入门】24、SystemVerilog项目实践之AHB-SRAMC(4)(AHB继续深入)
JS array foreach source code parsing
postman生成时间戳,未来时间戳
Introduction of mongod management database method
随机推荐
numpy--疫情数据分析案例
Three. JS introductory learning notes 03: perspective projection camera
Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import
Zhongang Mining: Fluorite continues to lead the growth of new energy market
Function: JS Click to copy content function
Android -- jetpack: the difference between livedata setValue and postvalue
Three. Introduction to JS learning notes 17: mouse control of 3D model rotation of JSON file
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
Ue4/ue5 multi thread development attachment plug-in download address
从 1.5 开始搭建一个微服务框架链路追踪 traceId
AB package details in unity (super detail, features, packaging, loading, manager)
Do not use memset to clear floating-point numbers
【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
TS as a general cache method
Whether runnable can be interrupted
The significance of XOR in embedded C language
HW primary flow monitoring, what should we do
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
Three. JS introductory learning notes 0: illustration of how webgl and threejs work
How to build your own super signature system (yunxiaoduo)?