HLSL for getting cylinder effect

帅比萌擦擦* 提交于 2019-12-18 07:14:53

问题


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.

回答1:


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



回答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.



来源:https://stackoverflow.com/questions/3883038/hlsl-for-getting-cylinder-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!