当前位置:网站首页>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
边栏推荐
- Basic knowledge sorting of mongodb database
- Webcodecs parameter settings -avc1.42e01e meaning
- C Alibaba cloud OSS file upload, download and other operations (unity is available)
- Do not use memset to clear floating-point numbers
- UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
- How to deploy the super signature distribution platform system?
- Tkinter after how to refresh data and cancel refreshing
- Whole process analysis of unity3d rendering pipeline
- Learn good-looking custom scroll bars in 1 minute
- leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
猜你喜欢
【数字IC验证快速入门】25、SystemVerilog项目实践之AHB-SRAMC(5)(AHB 重点回顾,要点提炼)
尤雨溪,来了!
2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
LeetCode2_ Add two numbers
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
AB package details in unity (super detail, features, packaging, loading, manager)
The bank needs to build the middle office capability of the intelligent customer service module to drive the upgrade of the whole scene intelligent customer service
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
随机推荐
15. Using the text editing tool VIM
Asynchronous application of generator function
【微信小程序】Chapter(5):微信小程序基础API接口
unnamed prototyped parameters not allowed when body is present
Async and await
Write sequence frame animation with shader
Three. Introduction to JS learning notes 17: mouse control of 3D model rotation of JSON file
10 schemes to ensure interface data security
Align individual elements to the right under flex layout
LeetCode2_ Add two numbers
Cocos makes Scrollview to realize the effect of zooming in the middle and zooming out on both sides
【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)
C4D learning notes 2- animation - timeline and time function
Numpy -- epidemic data analysis case
nodejs package. JSON version number ^ and~
Three. JS introductory learning notes 19: how to import FBX static model
JS array foreach source code parsing
强化实时数据管理,英方软件助力医保平台安全建设
航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
[quick start of Digital IC Verification] 22. Ahb-sramc of SystemVerilog project practice (2) (Introduction to AMBA bus)