当前位置:网站首页>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 :
边栏推荐
- How to release NFT in batches in opensea (rinkeby test network)
- MySQL bit type resolution
- Ctfshow, information collection: web14
- Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
- [quick start of Digital IC Verification] 26. Ahb-sramc of SystemVerilog project practice (6) (basic points of APB protocol)
- TypeScript 发布 4.8 beta 版本
- HW primary flow monitoring, what should we do
- 2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
- 【目标检测】YOLOv5跑通VOC2007数据集
- Ctfshow, information collection: web4
猜你喜欢
MySQL bit类型解析
HPDC smart base Talent Development Summit essay
【数字IC验证快速入门】25、SystemVerilog项目实践之AHB-SRAMC(5)(AHB 重点回顾,要点提炼)
【深度学习】图像超分实验:SRCNN/FSRCNN
Ctfshow, information collection: web7
What is data leakage
Unity之ASE实现全屏风沙效果
Bye, Dachang! I'm going to the factory today
[Data Mining] Visual Pattern Mining: Hog Feature + cosinus Similarity / K - means Clustering
MySQL bit type resolution
随机推荐
Basic knowledge sorting of mongodb database
Yunxiaoduo software internal test distribution test platform description document
避坑:Sql中 in 和not in中有null值的情况说明
Ctfshow, information collection: web12
Typescript release 4.8 beta
有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
Monthly observation of internet medical field in May 2022
【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
Ctfshow, information collection: web9
#HPDC智能基座人才发展峰会随笔
【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
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
How to create Apple Developer personal account P8 certificate
Write a ten thousand word long article "CAS spin lock" to send Jay's new album to the top of the hot list
Implementation of crawling web pages and saving them to MySQL using the scrapy framework
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
【OBS】RTMPSockBuf_Fill, remote host closed connection.
大表delete删数据导致数据库异常解决
Change win10 Screensaver
HPDC smart base Talent Development Summit essay