读书人

旋转浪头shader

发布时间: 2012-11-01 11:11:33 作者: rapoo

旋转波浪shader
<languageVersion : 1.0;>

kernel NewFilter
< namespace : "gamecube";
vendor : "gamecube";
version : 1;
description : "your description";
>
{
input image4 src;
output pixel4 dst;

parameter float2 center
<
minValue : float2(1.0);
maxValue : float2(200.0);
defaultValue : float2(0.0);
>;

parameter float radius
<
minValue : 0.1;
maxValue : 50.0;
defaultValue : 4.0;
>;

    void    evaluatePixel()    {        float radians = 3.0;        float2 relativePos = outCoord() - center;        float distFromCenter = length(relativePos);        distFromCenter /= radius;        float sincWeight = sin(distFromCenter)*radians/distFromCenter;                float cosAngle = cos(sincWeight);        float sinAngle = sin(sincWeight);        float2x2 rotMat = float2x2(            cosAngle,sinAngle,            -sinAngle,cosAngle        );                relativePos *= rotMat;        dst = sampleNearest(src,relativePos);    }

}

读书人网 >Web前端

热点推荐