WebGL 矩形
2022/6/22 23:21:32
本文主要是介绍WebGL 矩形,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
shadertoy
vec3 Rect(vec2 st, float left, float bottom, float right, float top, float blur ){ vec3 col = vec3(0.); float l = smoothstep(left,left+blur,st.x); float b = smoothstep(bottom,bottom+blur,st.y); float t = smoothstep(top,top+blur,1.-st.y); float r = smoothstep(right,right+blur,1.-st.x); col = vec3(t*b*l*r); return col; } vec3 Rect2(vec2 st, float left, float bottom, float right, float top, float blur ){ vec3 col = vec3(0.); // left-bottom vec2 lb = step(vec2(left,bottom), 1.-st); float pct = lb.x * lb.y; // top-right vec2 tr = step(vec2(right, top),st); pct *= tr.x * tr.y; col = vec3(pct); return col; } void mainImage( out vec4 fragColor, in vec2 fragCoord ) { // Normalized pixel coordinates (from 0 to 1) vec2 st = fragCoord.xy/iResolution.xy; //st.x *= iResolution.x/iResolution.y; vec3 col = vec3(1.); col = Rect2(st, .1,.1,.1,.1,.01); // Output to screen fragColor = vec4(col,1.0); }
这篇关于WebGL 矩形的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15鸿蒙生态设备数量超8亿台
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?