1.常用
1.Sobel描边
//sobel
float core[3][3];
float4 ori=SceneTextureLookup(UV ,14, false);
int i,j;
for (i=0;i<3;i++){
for (j=0;j<3;j++){
float4 tem=SceneTextureLookup(UV + float2(-1.0f / sW,-1.0f/sH)+float2(i*1.0f/sW,j*1.0f/sH), 14,false);
core[i][j]=tem.r*0.299 + tem.g*0.587 + tem.b*0.114;
}
}
float wx[3][3]={
-1,0,1,
-2,0,2,
-1,0,1
};
float wy[3][3]={
-1,-2,-1,
0,0,0,
1,2,1
};
float gx=0.0f;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
gx+=wx[i][j] *core[i][j];
}
}
float gy=0.0f;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
gy+=wy[i][j]*core[i][j];
}
}
return lerp(ori,float3(0,0,0),sqrt(gy*gy+gx*gx));
2.其他