当前位置:网站首页>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
边栏推荐
- Webcodecs parameter settings -avc1.42e01e meaning
- 【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)
- Monthly observation of internet medical field in May 2022
- Getting started with webgl (3)
- Detailed explanation of unity hot update knowledge points and introduction to common solution principles
- Align individual elements to the right under flex layout
- Numpy -- data cleaning
- 【数字IC验证快速入门】19、SystemVerilog学习之基本语法6(线程内部通信...内含实践练习)
- After UE4 is packaged, mesh has no material problem
- Getting started with webgl (1)
猜你喜欢
webgl_ Graphic transformation (rotation, translation, zoom)
【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)
TS as a general cache method
The rebound problem of using Scrollview in cocos Creator
JS array foreach source code parsing
HW primary flow monitoring, what should we do
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
Syntax of generator function (state machine)
C4D learning notes 1- animation - animation key frames
Gd32 F3 pin mapping problem SW interface cannot be burned
随机推荐
LeetCode2_ Add two numbers
C4D learning notes 2- animation - timeline and time function
Numpy -- epidemic data analysis case
webgl_ Graphic transformation (rotation, translation, zoom)
Three. JS introductory learning notes 11:three JS group composite object
Three. JS introductory learning notes 15: threejs frame animation module
Shipping companies' AI products are mature, standardized and applied on a large scale. CIMC, the global leader in port and shipping AI / container AI, has built a benchmark for international shipping
从 1.5 开始搭建一个微服务框架链路追踪 traceId
Function: JS Click to copy content function
C4D learning notes 3- animation - animation rendering process case
10 schemes to ensure interface data security
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
Numpy -- data cleaning
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
有钱人买房就是不一样
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
How to build your own super signature system (yunxiaoduo)?
2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
Tkinter after how to refresh data and cancel refreshing
VS2005 strange breakpoint is invalid or member variable value cannot be viewed