当前位置:网站首页>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"
}
边栏推荐
- Streaming end, server end, player end
- Ida Pro reverse tool finds the IP and port of the socket server
- UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
- 招标公告:盘锦市人民医院盘锦医院数据库维保项目
- Clang compile link ffmpeg FAQ
- Three. JS introductory learning notes 11:three JS group composite object
- Postman generate timestamp, future timestamp
- The difference between full-time graduate students and part-time graduate students!
- Yunxiaoduo software internal test distribution test platform description document
- Gd32 F3 pin mapping problem SW interface cannot be burned
猜你喜欢
A wave of open source notebooks is coming
Tkinter after how to refresh data and cancel refreshing
Asynchronous application of generator function
Numpy -- epidemic data analysis case
Starting from 1.5, build a microservice framework link tracking traceid
HPDC smart base Talent Development Summit essay
星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
Getting started with webgl (1)
Monthly observation of internet medical field in May 2022
10 schemes to ensure interface data security
随机推荐
Steps to create P8 certificate and warehousing account
Yunxiaoduo software internal test distribution test platform description document
AB package details in unity (super detail, features, packaging, loading, manager)
Virtual memory, physical memory /ram what
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
The download button and debug button in keil are grayed out
Jacobo code coverage
Three. JS introductory learning notes 19: how to import FBX static model
一大波开源小抄来袭
unnamed prototyped parameters not allowed when body is present
Three. JS introductory learning notes 15: threejs frame animation module
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
Whole process analysis of unity3d rendering pipeline
Learn good-looking custom scroll bars in 1 minute
AE learning 02: timeline
Syntaxhighlight highlights the right scroll bar
[wechat applet] Chapter (5): basic API interface of wechat applet
A wave of open source notebooks is coming
Zhongang Mining: Fluorite continues to lead the growth of new energy market
Detailed explanation of unity hot update knowledge points and introduction to common solution principles