当前位置:网站首页>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"
}
边栏推荐
- Mesh merging under ue4/ue5 runtime
- 航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
- AE learning 01: AE complete project summary
- Introduction of mongod management database method
- leetcode 241. Different Ways to Add Parentheses 为运算表达式设计优先级(中等)
- Create lib Library in keil and use lib Library
- 星瑞格数据库入围“2021年度福建省信息技术应用创新典型解决方案”
- 招标公告:2022年云南联通gbase数据库维保公开比选项目(第二次)比选公告
- AE learning 02: timeline
- TS as a general cache method
猜你喜欢
How to create Apple Developer personal account P8 certificate
Iterator and for of.. loop
Configure mongodb database in window environment
[quick start of Digital IC Verification] 24. AHB sramc of SystemVerilog project practice (4) (AHB continues to deepen)
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
UE4 exports the picture + text combination diagram through ucanvasrendertarget2d
webgl_ Enter the three-dimensional world (2)
A wave of open source notebooks is coming
Super signature principle (fully automated super signature) [Yun Xiaoduo]
HW primary flow monitoring, what should we do
随机推荐
航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆
Align individual elements to the right under flex layout
【花雕体验】15 尝试搭建Beetle ESP32 C3之Arduino开发环境
Detailed explanation of unity hot update knowledge points and introduction to common solution principles
航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
Three. JS introductory learning notes 13: animation learning
Numpy -- data cleaning
【数字IC验证快速入门】19、SystemVerilog学习之基本语法6(线程内部通信...内含实践练习)
[markdown grammar advanced] make your blog more exciting (IV: set font style and color comparison table)
[quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
持续创作,还得靠它!
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
LeetCode1_ Sum of two numbers
Keil5 does not support online simulation of STM32 F0 series
20th anniversary of agile: a failed uprising
Nacos conformance protocol cp/ap/jraft/distro protocol
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
一大波开源小抄来袭