当前位置:网站首页>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"
}
边栏推荐
- Three. JS introductory learning notes 13: animation learning
- Getting started with webgl (2)
- 深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
- 无线传感器网络--ZigBee和6LoWPAN
- Vite path alias @ configuration
- Getting started with webgl (3)
- XMIND frame drawing tool
- [quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
- [quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
猜你喜欢

postman生成时间戳,未来时间戳
![[quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)](/img/a3/7f08f189c608d6086b368dfa3831f7.png)
[quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)

深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)

Annexb and avcc are two methods of data segmentation in decoding

LeetCode1_ Sum of two numbers

numpy--数据清洗

AE learning 01: AE complete project summary

webgl_ Enter the three-dimensional world (2)

After UE4 is packaged, mesh has no material problem

webgl_ Graphic transformation (rotation, translation, zoom)
随机推荐
Three. JS introductory learning notes 11:three JS group composite object
[markdown grammar advanced] make your blog more exciting (IV: set font style and color comparison table)
Function: JS Click to copy content function
[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
招标公告:盘锦市人民医院盘锦医院数据库维保项目
神经网络c语言中的指针是怎么回事
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
Cocos uses custom material to display problems
Three. JS introductory learning notes 15: threejs frame animation module
The download button and debug button in keil are grayed out
Syntax of generator function (state machine)
LeetCode1_ Sum of two numbers
The significance of XOR in embedded C language
AE learning 01: AE complete project summary
Limit of total fields [1000] in index has been exceeded
2022山东智慧养老展,适老穿戴设备展,养老展,山东老博会
2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
Whether runnable can be interrupted
C Alibaba cloud OSS file upload, download and other operations (unity is available)
一大波开源小抄来袭