如何在Silverlight中将图像包裹在圆柱体周围 [英] How wrap image around cylinder in Silverlight
本文介绍了如何在Silverlight中将图像包裹在圆柱体周围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Silverlight中将图像包裹在圆柱周围.我在Google上看了很多东西,但是什么也没找到.据我所知,可以使用像素着色器完成此操作,但不知道如何操作.
有可能吗?
谢谢.
I am trying wrap image around cylinder in silverlight. I looked a lot in Google but don't found anything. As I know it can be done with pixel shader, but don't know how.
Is it possible?
Thanks.
推荐答案
这不是完整的圆柱体,但是您会得到一个入门的想法/示例:
It's not a complete wrap onto cylinder, but you will get a starting idea/example:
(代码在GLSL中,而不在HLSL中,但是我认为转换起来并不难)
(code is in GLSL, not in HLSL, but i think it will be not hard to convert it)
uniform sampler2D tex;
void main()
{
vec2 cen = vec2(0.5,gl_TexCoord[0].y)-gl_TexCoord[0].xy;
cen = vec2(pow(cen.x,1.7),pow(cen.y,2.2));
cen.y = 3.9*sin(1.8*gl_TexCoord[0].x-2.3);
vec2 mcoord = 1.65*vec2(-0.22+gl_TexCoord[0].x,1.95+gl_TexCoord[0].y);
gl_FragColor = texture2D(tex, mcoord+cen);
}
从这里
您将获得类似的信息
祝你好运
这篇关于如何在Silverlight中将图像包裹在圆柱体周围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文