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-11-23Springboot应用的多环境打包入门
- 2024-11-23Springboot应用的生产发布入门教程
- 2024-11-23Python编程入门指南
- 2024-11-23Java创业入门:从零开始的编程之旅
- 2024-11-23Java创业入门:新手必读的Java编程与创业指南
- 2024-11-23Java对接阿里云智能语音服务入门详解
- 2024-11-23Java对接阿里云智能语音服务入门教程
- 2024-11-23JAVA对接阿里云智能语音服务入门教程
- 2024-11-23Java副业入门:初学者的简单教程
- 2024-11-23JAVA副业入门:初学者的实战指南