HLSL获得圆柱效果 [英] HLSL for getting cylinder effect

查看:184
本文介绍了HLSL获得圆柱效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用Silverlight 4编写一个应用程序,并且需要显示如包裹在圆柱体上的图像.我需要一些HLSL代码,因为我不会使用Silverlight效果来做到这一点.
我不会用Silverlight的3D库来做到这一点.我只需要HLSL代码即可更改像素.
我需要让我的图片看起来像
谢谢.

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.

推荐答案

这似乎是您想要的效果,您可能希望更改0.2的值以增加或减少效果,或者在着色器中使其可调,但这是一个简单的改变就可以了.如果您不使用 Shazzam ,我建议您不要使用它来为WPF或Silverlight编写着色器.

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

这篇关于HLSL获得圆柱效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆