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.
Asked
Active
Viewed 602 times
5

Samvel Siradeghyan
- 3,523
- 3
- 30
- 49
2 Answers
1
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
you will get something like that
Good luck

Agnius Vasiliauskas
- 10,935
- 5
- 50
- 70
-
Exectly what I need. If anybody need HLSL here is it sampler2D input : register(s0); float4 main(float2 uv : TEXCOORD) : COLOR { float4 color = 0; float2 center = float2(0.5, uv.x / 2); center = float2(pow(center.x, 1.7),pow(center.y, 2.2)); center.y = 3.9 * sin(1.8 * uv.x - 2.3); float2 mcoord = 1.65 * float2(-0.22 + uv.x, 1.95 + uv.y); uv.x = mcoord.x + center.x; uv.y = mcoord.y + center.y; color = tex2D(input, uv); return(color); } With this link you can learn how to use custom shader effects: http://www.silverlight.net/learn/videos/all/pixel-effects/ – Samvel Siradeghyan Sep 05 '10 at 06:19
-
can we get a generalized shader with input variables? – foson Feb 08 '11 at 22:36
0
You may want to try Zam3d. I have used trial versions previously, and you can get the 3D shape and try and set the background to an image. Have a look and see if that helps.

Abhi
- 161
- 1
- 8