当前位置:网站首页>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 0: illustration of how webgl and threejs work
- Syntax of generator function (state machine)
- Gd32 F3 pin mapping problem SW interface cannot be burned
- 招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
- Configure mongodb database in window environment
- Three. JS introductory learning notes 19: how to import FBX static model
- Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
- 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
- Asynchronous application of generator function
- webgl_ Enter the three-dimensional world (2)
猜你喜欢
After UE4 is packaged, mesh has no material problem
【微信小程序】Chapter(5):微信小程序基础API接口
Three. JS introductory learning notes 05: external model import -c4d into JSON file for web pages
How to create Apple Developer personal account P8 certificate
Zhongang Mining: Fluorite continues to lead the growth of new energy market
SPI master rx time out中断
How does geojson data merge the boundaries of regions?
Async and await
Cocos uses custom material to display problems
It's different for rich people to buy a house
随机推荐
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
AE learning 01: AE complete project summary
Steps to create P8 certificate and warehousing account
numpy--疫情数据分析案例
Spin animation of Cocos performance optimization
Starting from 1.5, build a microservice framework link tracking traceid
Points for attention in porting gd32 F4 series programs to gd32 F3 series
Detailed explanation of unity hot update knowledge points and introduction to common solution principles
A link opens the applet code. After compilation, it is easy to understand
Numpy -- epidemic data analysis case
20th anniversary of agile: a failed uprising
Three. JS introductory learning notes 19: how to import FBX static model
Numpy -- data cleaning
Vite path alias @ configuration
leetcode 241. Different ways to add parentheses design priority for operational expressions (medium)
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
The rebound problem of using Scrollview in cocos Creator
一大波开源小抄来袭
航天宏图信息中标乌鲁木齐某单位数据库系统研发项目
Keil5 does not support online simulation of STM32 F0 series