To achieve a better result, you can use a shader, which smoothly change the gradient, from a circular (or elliptical) gradient in the middle of the the view, to a square gradient at the borders of the view:void mainImage( out vec4 fragColor, in vec2 fragCoord ){ // Normalized pixel coordinates (from 0 to 1) vec2 uv = fragCoord/iResolution.xy; vec2 uvn=abs(uv-0.5)*2.0; vec2 distV = uvn; float maxDist = max(abs(distV.x), abs(distV.y)); float circular = length(distV); float square = maxDist; vec3 color1 = vec3(0.0); vec3 color2 = vec3(1.0); vec3 mate=mix(color1, color2, mix(circular,square,maxDist)); fragColor = vec4(mate.xyz,1);}预览: 这篇关于着色矩形到距离最近边缘的距离函数会在对角线上产生奇怪的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-20 10:57