当前位置:网站首页>Write sequence frame animation with shader
Write sequence frame animation with shader
2022-07-07 15:39:00 【Vegetable chicken on the road】
forehead , If you're free, then write a simple sequence frame animation ... This is really a strange idea , But very practical hahaha .
Art give you a picture , That's about it
Then let's talk about the general idea :
Divide the picture into 12 Equal division ,, One sample at a time , Pictured above , according to 1,2,3,4… Sequential sampling display ; Just pass in a start coordinate ;
//effect Code
void main () {
vec4 o = vec4(1, 1, 1, 1);
float unit = 0.25;
float unitY = 1.0/3.0;
#if USE_TEXTURE
vec2 uv = vec2(v_uv0.x * unit + uRangeData.x ,v_uv0.y * unitY + ( unitY * 2.0 - uRangeData.y));
CCTexture(texture, uv, o);
#endif
ts Code :
export default class NewClass extends cc.Component {
private uRangeData:cc.Vec2 = new cc.Vec2();
private _material:cc.Material = null;
private _rotAllTime:number= 0.05;
private _rotTime:number = 0;
private _unitWidth:number = 0.25;
private _unitLastPos:cc.Vec2 = new cc.Vec2(0.5,0.5);
start () {
this.uRangeData.x = 0;
this.uRangeData.y = 0;
let sp = this.node.getComponent(cc.Sprite);
this._material = sp.getMaterial(0);
this._material.setProperty("uRangeData", this.uRangeData);
sp.setMaterial(0, this._material);
}
update (dt) {
this._rotTime += dt;
if(this._rotTime>=this._rotAllTime){
this._rotTime = 0;
this.uRangeData.x += this._unitWidth;
if(this.uRangeData.x >= 1){ // Cross to the last
this.uRangeData.y += this._unitWidth;
this.uRangeData.x = 0;
}
if (this.uRangeData.x == this._unitLastPos.x && this.uRangeData.y == this._unitLastPos.y) { // It's the last one , Start from scratch
this.uRangeData.x = 0;
this.uRangeData.y = 0;
}
this._material.setProperty("uRangeData", this.uRangeData);
}
}
}
The effect is as follows :
边栏推荐
- [quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)
- Niuke real problem programming - day20
- Ctfshow, information collection: web9
- 有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
- Win10 or win11 taskbar, automatically hidden and transparent
- Wechat applet 01
- 【搞船日记】【Shapr3D的STL格式转Gcode】
- Nacos一致性协议 CP/AP/JRaft/Distro协议
- [target detection] yolov5 Runtong voc2007 data set
- [quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)
猜你喜欢
[quick start of Digital IC Verification] 19. Basic grammar of SystemVerilog learning 6 (thread internal communication... Including practical exercises)
15. Using the text editing tool VIM
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
【數字IC驗證快速入門】26、SystemVerilog項目實踐之AHB-SRAMC(6)(APB協議基本要點)
Keil5 does not support online simulation of STM32 F0 series
【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
Monthly observation of internet medical field in May 2022
【数据挖掘】视觉模式挖掘:Hog特征+余弦相似度/k-means聚类
Ctfshow, information collection: web7
随机推荐
HW primary flow monitoring, what should we do
[quick start for Digital IC Validation] 26. Ahb - sramc (6) for system verilog project practice (Basic Points of APB Protocol)
居然从408改考自命题!211华北电力大学(北京)
Create lib Library in keil and use lib Library
[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset
Guangzhou Development Zone enables geographical indication products to help rural revitalization
Jacobo code coverage
Connecting FTP server tutorial
Typescript release 4.8 beta
什麼是數據泄露
Ctfshow, information collection: web10
Do you know the relationship between the most important indicators of two strong wind control and the quality of the customer base
[Lanzhou University] information sharing of postgraduate entrance examination and re examination
Ctfshow, information collection: Web3
There is a cow, which gives birth to a heifer at the beginning of each year. Each heifer has a heifer at the beginning of each year since the fourth year. Please program how many cows are there in the
[follow Jiangke University STM32] stm32f103c8t6_ PWM controlled DC motor_ code
Integer learning
#HPDC智能基座人才发展峰会随笔
Zhongang Mining: Fluorite continues to lead the growth of new energy market
Win10 or win11 taskbar, automatically hidden and transparent