当前位置:网站首页>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
边栏推荐
- Cocos makes Scrollview to realize the effect of zooming in the middle and zooming out on both sides
- Using eating in cocos Creator
- postman生成时间戳,未来时间戳
- OpenGL common functions
- LeetCode1_ Sum of two numbers
- 10 schemes to ensure interface data security
- webgl_ Enter the three-dimensional world (2)
- Ida Pro reverse tool finds the IP and port of the socket server
- Iterator and for of.. loop
- 无线传感器网络--ZigBee和6LoWPAN
猜你喜欢

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

C4D learning notes 1- animation - animation key frames

无线传感器网络--ZigBee和6LoWPAN

Write sequence frame animation with shader

Ida Pro reverse tool finds the IP and port of the socket server

Getting started with webgl (4)

Streaming end, server end, player end

过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?

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

深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
随机推荐
What is Base64?
Steps to create P8 certificate and warehousing account
C4D learning notes 2- animation - timeline and time function
UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
有钱人买房就是不一样
Cocos makes Scrollview to realize the effect of zooming in the middle and zooming out on both sides
webgl_ Graphic transformation (rotation, translation, zoom)
Three. JS introductory learning notes 03: perspective projection camera
【数字IC验证快速入门】25、SystemVerilog项目实践之AHB-SRAMC(5)(AHB 重点回顾,要点提炼)
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
The download button and debug button in keil are grayed out
XMIND frame drawing tool
nodejs package. JSON version number ^ and~
OpenGL common functions
After UE4 is packaged, mesh has no material problem
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
Zhongang Mining: Fluorite continues to lead the growth of new energy market
【数字IC验证快速入门】24、SystemVerilog项目实践之AHB-SRAMC(4)(AHB继续深入)
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
Webgl texture