当前位置:网站首页>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
边栏推荐
- 【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
- Yunxiaoduo software internal test distribution test platform description document
- 航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
- Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
- [quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)
- Webgl texture
- Streaming end, server end, player end
- 2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
- 招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
- 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 2- animation - timeline and time function
Whole process analysis of unity3d rendering pipeline
OpenGL's distinction and understanding of VAO, VBO and EBO
webgl_ Enter the three-dimensional world (1)
TS as a general cache method
[quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)
一大波开源小抄来袭
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
Cocos uses custom material to display problems
HW primary flow monitoring, what should we do
随机推荐
招标公告:盘锦市人民医院盘锦医院数据库维保项目
JS array foreach source code parsing
Use of SVN
尤雨溪,来了!
Getting started with webgl (3)
numpy--数据清洗
【数字IC验证快速入门】29、SystemVerilog项目实践之AHB-SRAMC(9)(AHB-SRAMC SVTB Overview)
TS typescript type declaration special declaration field number is handled when the key key
Asynchronous application of generator function
Monthly observation of internet medical field in May 2022
【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
Three. JS introductory learning notes 04: external model import - no material obj model
Three. JS introductory learning notes 19: how to import FBX static model
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
Points for attention in porting gd32 F4 series programs to gd32 F3 series
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
有钱人买房就是不一样
[Lanzhou University] information sharing of postgraduate entrance examination and re examination