当前位置:网站首页>threejs+shader 曲线点运动,飞线运动
threejs+shader 曲线点运动,飞线运动
2022-08-09 10:50:00 【榴莲不好吃】
飞线-从开始到结束都显示
别忘了设置
transparent: true,
depthWrite: false,
blending: THREE.AdditiveBlending,
vertexShader: ` attribute float aIndex; uniform float uTime; uniform float uLength; uniform float uScale; varying float vSize; void main() { vec4 viewPosition = viewMatrix * modelMatrix * vec4(position,1); gl_Position = projectionMatrix * viewPosition; vSize = aIndex- uTime; if(vSize<=0.0){ vSize = vSize + uLength; }else{ vSize = 0.0; } gl_PointSize = vSize * uScale; } `,
fragmentShader: ` varying float vSize; uniform vec3 uColor; void main(){ float distanceToCenter = distance(gl_PointCoord,vec2(0.5)); float alpha = 1.0 - (distanceToCenter*2.0); gl_FragColor = vec4(1,0,0,alpha); if(vSize<=0.0){ gl_FragColor = vec4(1,0,0,0); }else{ // // gl_FragColor = vec4(uColor,1.0); gl_FragColor = vec4(uColor,alpha); // 圆点点 } } `
飞线-快结束的时候淡出
fragmentShader: ` varying float vSize; uniform float uTime; uniform float uLength; uniform vec3 uColor; void main(){ float distanceToCenter = distance(gl_PointCoord,vec2(0.5)); float alpha = 1.0 - (distanceToCenter*2.0); if(vSize<=0.0){ gl_FragColor = vec4(1,0,0,0); }else{ float s = 0.9; if(uTime > uLength *s){ gl_FragColor = vec4(uColor, alpha - ((uTime - uLength * s) / (uLength * (1.0-s)))); // 圆点 }else{ gl_FragColor = vec4(uColor,alpha); // 圆点 } } } `,
飞线- 显示部分点,前面的点大,后面的点小
vertexShader: ` attribute float aIndex; uniform float uTime; uniform float uLength; uniform float uScale; varying float vSize; void main() { vec4 modelPosition = modelMatrix * vec4( position, 1.0 ); // 顶点坐标 gl_Position = projectionMatrix * viewMatrix * modelPosition; float size = aIndex - uTime; if(size < 0.0) { size = size + uLength; } vSize = (size - uLength / 2.0) * uScale; // 设置二分之一的点为不可见 gl_PointSize = vSize; } `,
fragmentShader: ` varying float vSize; uniform vec3 uColor; void main(){ float distanceToCenter = distance(gl_PointCoord,vec2(0.5,0.5)); float alpha = 1.0 - (distanceToCenter*2.0); if(vSize<=0.0){ gl_FragColor = vec4(1,0,0,0); }else{ gl_FragColor = vec4(uColor,alpha); } } `,
飞线- 点越小越透明,形成一个小尾巴
vertexShader: ` attribute float aIndex; uniform float uTime; uniform float uLength; uniform float uScale; varying float vSize; void main() { vec4 modelPosition = modelMatrix * vec4( position, 1.0 ); // 顶点坐标 gl_Position = projectionMatrix * viewMatrix * modelPosition; float size = aIndex - uTime; if(size < 0.0) { size = size + uLength; } vSize = (size - uLength / 2.0) * uScale; // 设置二分之一的点为不可见 gl_PointSize = vSize; } `,
fragmentShader: ` varying float vSize; uniform float uLength; uniform float uScale; void main(){ if(vSize <= 0.0){ gl_FragColor = vec4(1,1,0,0); }else{ // 根据点的大小设置透明度,点越小越透明 float opacity = uLength / 2.0 * uScale; gl_FragColor = vec4(1,1,0,vSize / opacity); } } `,
保留曲线路径
vertexShader: ` attribute float aIndex; uniform float uTime; uniform float uLength; uniform float uScale; varying float vSize; void main() { vec4 modelPosition = modelMatrix * vec4( position, 1.0 ); // 顶点坐标 gl_Position = projectionMatrix * viewMatrix * modelPosition; float size = aIndex - uTime; if(size < 0.0) { size = size + uLength; } vSize = (size - uLength / 2.0) * uScale; // 设置二分之一的点为不可见 gl_PointSize = vSize<=2.0?2.0:vSize; } `,
fragmentShader: ` varying float vSize; uniform vec3 uColor; void main(){ float distanceToCenter = distance(gl_PointCoord,vec2(0.5,0.5)); float alpha = 1.0 - (distanceToCenter*2.0); if(vSize<=2.0){ gl_FragColor = vec4(1,0,1,alpha); }else{ gl_FragColor = vec4(uColor,alpha); } } `,
点在线上运行
vertexShader: ` attribute float aIndex; uniform float uTime; uniform float uLength; uniform float uScale; varying float vSize; void main() { vec4 modelPosition = modelMatrix * vec4( position, 1.0 ); // 顶点坐标 gl_Position = projectionMatrix * viewMatrix * modelPosition; float size = aIndex - uTime; if(size < 0.0) { size = size + uLength; } vSize = (size - (uLength * 0.99)); // 只显示0.01的点 gl_PointSize = vSize<=2.0?2.0:vSize; } `,
fragmentShader: ` varying float vSize; uniform vec3 uColor; void main(){ float distanceToCenter = distance(gl_PointCoord,vec2(0.5,0.5)); float alpha = 1.0 - (distanceToCenter*2.0); if(vSize<=2.0){ gl_FragColor = vec4(1,0,1,alpha); }else{ gl_FragColor = vec4(uColor,alpha); } } `,
边栏推荐
- jmeter BeanShell 后置处理器
- 15.8 the semaphore Unix environment programming chapter 15
- OpenSSF's open source software risk assessment tool: Scorecards
- Netscope: Online visualization tool for neural network structures
- 相关系数计算,热力图绘制,代码实现
- CSDN的markdown编辑器语法完整大全
- 机器学习--线性回归(Linear Regression)
- 聚类了解
- 基于STM32设计的环境检测设备
- 实测办公场景下,国产远程控制软件的表现力如何?(技术解析)
猜你喜欢
【 original 】 VMware Workstation implementation Openwrt soft routing, the ESXI, content is very detailed!
Tensorflow realize parameter adjustment of linear equations
华为VRRP+MSTP联动接口检测实验案例
史上最小白之《Word2vec》详解
LM小型可编程控制器软件(基于CoDeSys)笔记二十六:plc的数据存储区(模拟量输入通道部分)
批量转换经纬度的网页实现方法
[Original] Usage of @PrePersist and @PreUpdate in JPA
arcgis制图之天地图符号样式配置
对话跨国消费品牌DPO:数据安全合规从何做起?8.11直播见!
相关系数计算,热力图绘制,代码实现
随机推荐
Preparation for gold three silver four: how to successfully get an Ali offer (experience + interview questions + how to prepare)
RPN principle in faster-rcnn
笔记本电脑使用常见问题,持续更新
乘积量化(PQ)
Product Quantization (PQ)
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization论文阅读
Unix Environment Programming Chapter 15 15.3 Functions popen and pclose
linux mysql操作的相关命令
The torch. The stack () official explanation, explanation and example
How tall is the B+ tree of the MySQL index?
unix环境编程 第十四章 14.8 存储映射I/O
UNIX Environment Programming Chapter 15 15.6 XSI IPC
【原创】VMware Workstation实现Openwrt软路由功能,非ESXI,内容非常详细!
Solve the ali cloud oss - the original 】 【 exe double-click response can't open, to provide a solution
Cpolar内网穿透的面板功能介绍
Oracle数据库常用函数总结
日期工具类
详细的np.matmul / np.dot / np.multiply / tf.matmul / tf.multiply / *
pip common commands and changing source files
cnn的输入输出