[导入]再贴个圆形马赛克
感觉做这些很没技术含量的东西往blog上贴很丢人。可是还想贴,算是记录吧。再丢下人好了。
圆形马赛克:
代码如下:
float4 PS_Textured( vertexOutput IN): COLOR
{
float2 curTex = tex2D( TextureSampler, IN.texCoordDiffuse );
float4 diffuseTexture;
if(IN.texCoordDiffuse.x < IN.texCoordDiffuse.y)
diffuseTexture = float4(1.0,0.0,0.0,1.0);
else
diffuseTexture = tex2D( TextureSampler, IN.texCoordDiffuse );
float2 mosAicSize = float2(18,18);
float2 realXY = float2(IN.texCoordDiffuse.x * 512 ,IN.texCoordDiffuse.y * 256 );
float2 xyMos = float2( int(realXY.x/mosAicSize.x) * mosAicSize.x,
int(realXY.y/mosAicSize.y) * mosAicSize.y)
+ 0.5 * mosAicSize;
float len = length( realXY-xyMos);
if(len<0.5*mosAicSize.x)
{
float2 cxy = float2(xyMos.x/512,xyMos.y/256);
diffuseTexture = tex2D(TextureSampler,cxy);
}
return IN.diffAmbColor*diffuseTexture +IN.specCol;
}
其实换了个物体,环境光和镜面光都没有用上。但还是写上去了。马赛克直径是18,还有我假设了贴图宽度是512,高度是256。因为不知道怎么在nvdia fx composer里面穿入贴图的宽度和高度。丢下人好了。
文章来源:http://songxiaoyu8.blog.163.com/blog/static/208181282007917102848305