当前位置:网站首页>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"
}
边栏推荐
- Migration and reprint
- How to understand that binary complement represents negative numbers
- Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
- Whole process analysis of unity3d rendering pipeline
- SPI master rx time out中断
- Simple understanding and application of TS generics
- The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
- Zhongang Mining: Fluorite continues to lead the growth of new energy market
- It's different for rich people to buy a house
- The download button and debug button in keil are grayed out
猜你喜欢

Tkinter after how to refresh data and cancel refreshing

Virtual memory, physical memory /ram what

What is Base64?

Yunxiaoduo software internal test distribution test platform description document

Three. JS introductory learning notes 18: how to export JSON files with Blender

A wave of open source notebooks is coming

Vertex shader to slice shader procedure, varying variable

The difference between full-time graduate students and part-time graduate students!

15. Using the text editing tool VIM

神经网络c语言中的指针是怎么回事
随机推荐
Three. JS introductory learning notes 15: threejs frame animation module
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
A wave of open source notebooks is coming
SPI master rx time out中断
Vertex shader to slice shader procedure, varying variable
2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
Three. JS introductory learning notes 10:three JS grid
Detailed explanation of unity hot update knowledge points and introduction to common solution principles
Do not use memset to clear floating-point numbers
强化实时数据管理,英方软件助力医保平台安全建设
Monthly observation of internet medical field in May 2022
How to deploy the super signature distribution platform system?
TS as a general cache method
C4D learning notes 2- animation - timeline and time function
OpenGL's distinction and understanding of VAO, VBO and EBO
C4D learning notes 3- animation - animation rendering process case
[quick start of Digital IC Verification] 24. AHB sramc of SystemVerilog project practice (4) (AHB continues to deepen)
[quick start of Digital IC Verification] 22. Ahb-sramc of SystemVerilog project practice (2) (Introduction to AMBA bus)
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc