Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How wrap image around cylinder in Silverlight

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.

like image 477
Samvel Siradeghyan Avatar asked Nov 15 '22 08:11

Samvel Siradeghyan


1 Answers

It's not a complete wrap onto cylinder, but you will get a starting idea/example:

(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);
}

From this

alt text

you will get something like thatalt text

Good luck

like image 58
Agnius Vasiliauskas Avatar answered Dec 07 '22 22:12

Agnius Vasiliauskas