还以为高深了,其实只是换了个过滤器,然后变成灰色,再取绝对值。不过最难的是换成什么样的过滤器可以达到最佳效果。我这里用的是最一般的过滤器。如下:
(-0.5 ,-1.0 , 0.0 ,
-1.0 , 0.0 , 1.0 ,
-0.0 , 1.0 , 0.5 )
加入变化灰度取绝对值的过程:总共是这样的
float2 realxy = float2(IN.texCoordDiffuse.x*256,IN.texCoordDiffuse.y*256);
float3x3 matr = float3x3(-0.5 ,-1.0 , 0.0 ,
-1.0 , 0.0 , 1.0 ,
-0.0 , 1.0 , 0.5
);
float2 si = float2(256,256);
float4 colorEnd = fit_filter(matr,TextureSampler,realxy,si);
float deltaGray = 0.3 * colorEnd.x + 0.59 * colorEnd.y + 0.11* colorEnd.z;
if(deltaGray < 0.0) deltaGray = -1.0 * deltaGray;
deltaGray = 1.0 - deltaGray;
return float4(deltaGray,deltaGray,deltaGray,1.0);
效果如下:
文章来源:http://songxiaoyu8.blog.163.com/blog/static/20818128200791723053725

浙公网安备 33010602011771号