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

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

问题描述

我需要用 Silverlight 4 编写一个应用程序,并且需要显示像包裹在圆柱体上的图像.我需要一些 HLSL 代码,因为我不会使用 Silverlight 的效果来做到这一点.
我不会对 Silverlight 的 3D 库这样做.我只需要更改像素的 HLSL 代码.
我需要我的图像看起来像 为 WPF 或 Silverlight 编写着色器,我会推荐它.

sampler2D 输入:寄存器(s0);float4 main(float2 uv : TEXCOORD) : 颜色{浮动 y = uv.y+(sin(uv.x*3.14) * lerp(-1,1,uv.y) * 0.2);如果(y <0 || y > 1)返回 float4(0,0,0,0);别的返回 tex2D(input,float2(uv.x,y));}

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.

解决方案

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天全站免登陆