当前位置:网站首页>Shader_ Animation sequence frame
Shader_ Animation sequence frame
2022-07-07 15:52:00 【Le_ Sam】
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Zombie/ZombieAnimation"
{
Properties
{
_MainTex("Base(RGB)" ,2D) = ""{}
_Row("Row",Int) = 1
_Column("Column",Int) = 1
_Speed("Speed",Range(0,60)) = 30
}
SubShader
{
tags{"Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True" "PreviewType" = "Plane" }
Blend SrcAlpha OneMinusSrcAlpha
ColorMask RGB
ZWrite Off
Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float4 pos:POSITION;
float2 uv:TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
int _Row;
int _Column;
float _Speed;
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord,_MainTex);
return o;
}
half4 frag(v2f IN) :COLOR
{
float2 uv = IN.uv;
float cellX = uv.x / _Column;
float cellY = uv.y / _Row;
//Sprite total
int count = _Row * _Column;
// stay 0 To count-1 Cycle in range
int SpriteIndex = fmod(_Time.w*_Speed,count);
// At present Sprite Subscript of the line
int SpriteRowIndx = (SpriteIndex / _Column);
// At present Sprite Subscript of the column
int SpriteColumnIndex = fmod(SpriteIndex,_Column);
// because uv The lower left corner of the coordinate is (0,0), The first line is the bottom line , In order to conform to our common sense , We switch to the first line of the top line ,eg:0,1,2-->2,1,0
SpriteRowIndx = (_Row - 1) - fmod(SpriteRowIndx,_Row);
// multiply 1.0 Convert to floating point number
uv.x = cellX + SpriteColumnIndex * 1.0 / _Column;
uv.y = cellY + SpriteRowIndx * 1.0 / _Row;
half4 c = tex2D(_MainTex,uv);
return c;
}
ENDCG
}
}
FallBack "Diffuse"
}
边栏推荐
- 【数字IC验证快速入门】18、SystemVerilog学习之基本语法5(并发线程...内含实践练习)
- 如何在shell中实现 backspace
- SPI master rx time out中断
- 深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
- Whole process analysis of unity3d rendering pipeline
- XMIND frame drawing tool
- A JS script can be directly put into the browser to perform operations
- Asynchronous application of generator function
- TS typescript type declaration special declaration field number is handled when the key key
- Use of SVN
猜你喜欢

Streaming end, server end, player end

Three. JS introductory learning notes 05: external model import -c4d into JSON file for web pages

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
![[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice](/img/f7/03975d08912afd8daee936799e8951.png)
[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice

Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
![[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)](/img/7e/188e57ee026200478a6f61eb507c92.png)
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)

Getting started with webgl (4)

Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import

After UE4 is packaged, mesh has no material problem

Tkinter after how to refresh data and cancel refreshing
随机推荐
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
Zhongang Mining: Fluorite continues to lead the growth of new energy market
Monthly observation of internet medical field in May 2022
Mysql database backup script
Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
Three. JS introductory learning notes 07: external model import -c4d to JSON file for web pages -fbx import
【数字IC验证快速入门】19、SystemVerilog学习之基本语法6(线程内部通信...内含实践练习)
AE learning 02: timeline
Cocos uses custom material to display problems
Whether runnable can be interrupted
保证接口数据安全的10种方案
深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
Gd32 F3 pin mapping problem SW interface cannot be burned
Configure mongodb database in window environment
Async and await
招标公告:盘锦市人民医院盘锦医院数据库维保项目
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
OpenGL's distinction and understanding of VAO, VBO and EBO
Numpy -- epidemic data analysis case