I need to write an application with Silverlight 4 and need to show images like wrapped on cylinder. I need some HLSL code, as I wont to do that with Effects of Silverlight.
I don't wont to do that with 3D libarries for silverlight. I only need HLSL code for changing pixels.
I need for my image to look like this
Thanks.
Asked
Active
Viewed 1,051 times
2

Samvel Siradeghyan
- 3,523
- 3
- 30
- 49
2 Answers
2
While you could do this with HLSL if you really wanted to, you'd normally do it by creating a mesh in the shape you want, then applying the picture to the mesh as a texture.

Jerry Coffin
- 476,176
- 80
- 629
- 1,111
-
Thanks for answer. Of course it will work, but I don't wont to use mesh, I know, that it is possible by using effects in Silverlight. – Samvel Siradeghyan Oct 07 '10 at 16:20
-
http://stackoverflow.com/questions/3607748/how-wrap-image-around-cylinder-in-silverlight This link is nearly like what I need. – Samvel Siradeghyan Oct 07 '10 at 16:21
2
This seems to be the effect you want, you may wish to change the 0.2 value to increase or decrease the effect or make this adjustable in your shader but that's a simple change to do. I'd recommend Shazzam if your not using it for writing shaders for WPF or Silverlight.
sampler2D input : register(s0);
float4 main(float2 uv : TEXCOORD) : COLOR
{
float y = uv.y+(sin(uv.x*3.14) * lerp(-1,1,uv.y) * 0.2);
if(y < 0 || y > 1)
return float4(0,0,0,0);
else
return tex2D(input,float2(uv.x,y));
}

Kris
- 7,110
- 2
- 24
- 26
-
Hi @Kris. Unfortunatly I can't try this right now, because I haven't compiler on this computer, but I will try this tomorrow. Thanks for answer. – Samvel Siradeghyan Oct 07 '10 at 16:31
-
Exelent solution. Exactly what I need. Thank you very much. – Samvel Siradeghyan Oct 08 '10 at 17:55