当前位置:网站首页>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"
}
边栏推荐
- Super simple and fully automated generation super signature system (cloud Xiaoduo minclouds.com cloud service instance), free application in-house test app distribution and hosting platform, maintenan
- 【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
- The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
- OpenGL's distinction and understanding of VAO, VBO and EBO
- 如何在shell中实现 backspace
- Share the technical details of super signature system construction
- HPDC smart base Talent Development Summit essay
- OpenGL common functions
- TS as a general cache method
- C Alibaba cloud OSS file upload, download and other operations (unity is available)
猜你喜欢
webgl_ Enter the three-dimensional world (1)
[Lanzhou University] information sharing of postgraduate entrance examination and re examination
[quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
Use of SVN
Write sequence frame animation with shader
保证接口数据安全的10种方案
Iterator and for of.. loop
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
随机推荐
[quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
A wave of open source notebooks is coming
Virtual memory, physical memory /ram what
Please supervise the 2022 plan
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
Super signature principle (fully automated super signature) [Yun Xiaoduo]
Matlab experience summary
LeetCode1_ Sum of two numbers
Three. JS introductory learning notes 10:three JS grid
HPDC smart base Talent Development Summit essay
Ue4/ue5 multi thread development attachment plug-in download address
Three. JS introduction learning notes 12: the model moves along any trajectory line
深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
The rebound problem of using Scrollview in cocos Creator
A JS script can be directly put into the browser to perform operations
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
VS2005 strange breakpoint is invalid or member variable value cannot be viewed
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
Spin animation of Cocos performance optimization
It's different for rich people to buy a house