https://gist.github.com/CoderJackLiu/dfe206bfec0bb6c694daa5299d50cd79
https://www.bilibili.com/video/BV1Cq4y1A7P1?p=1&vd_source=8fa6b6117b9aadb7a238a8d563f80d0c
//圆角 | |
float2 UV = uvs; | |
float PixelRange = min(min(SizeX/2,SizeY/2),Range); | |
//当前绘制的像素 | |
float2 CurrentP = float2(UV.x*SizeX,UV.y*SizeY); | |
//像素坐标参照点 | |
//float2 MiddleP=float2(0.5*SizeX,0.5*SizeY); | |
//左上角圆心像素坐标 | |
float2 MP1=float2(PixelRange , PixelRange); | |
//右上角圆心像素坐标 | |
float2 MP2=float2(SizeX - PixelRange , PixelRange); | |
//左下角圆心像素坐标 | |
float2 MP3=float2(PixelRange , SizeY - PixelRange); | |
//右下角圆心像素坐标 | |
float2 MP4=float2(SizeX - PixelRange , SizeY - PixelRange); | |
if (CurrentP.x<MP1.x&&CurrentP.y<MP1.y) | |
{ | |
/* 左上角 */ | |
if (length((CurrentP-MP1))<PixelRange) | |
{ | |
/* code */ | |
return 1; | |
} | |
return 0; | |
}else if (CurrentP.x>MP2.x&&CurrentP.y<MP2.y) | |
{ | |
/* 右上角 */ | |
if (length((CurrentP-MP2))<PixelRange) | |
{ | |
/* code */ | |
return 1; | |
} | |
return 0; | |
}else if (CurrentP.x<MP3.x&&CurrentP.y>MP3.y) | |
{ | |
/* 左下角 */ | |
if (length((CurrentP-MP3))<PixelRange) | |
{ | |
/* code */ | |
return 1; | |
} | |
return 0; | |
}else if (CurrentP.x>MP4.x&&CurrentP.y>MP4.y) | |
{ | |
/* 右下角 */ | |
if (length((CurrentP-MP4))<PixelRange) | |
{ | |
/* code */ | |
return 1; | |
} | |
return 0; | |
} | |
return 1; |