My favorites | Sign in
Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<languageVersion : 1.0;>

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

parameter float2 imgSize
<
defaultValue : float2(512.0, 512.0);
minValue : float2(0.0,0.0);
maxValue : float2(512.0,512.0);
>;

parameter float2 center
<
defaultValue : float2(256.0, 256.0);
minValue : float2(0.0,0.0);
maxValue : float2(512.0,512.0);
>;

parameter float2 offset;

void evaluatePixel()
{
float2 pos = (outCoord() - center) / imgSize;

float pi = 3.141592653589793;
float a = atan(pos.y,pos.x);
float r = sqrt(pow(pos.x,2.0)+pow(pos.y,2.0));

float u = 0.0;
float v = 0.0;
float w = 0.0;

u += offset.x;
v += offset.y;

// This is where the magic happens

u += 7.0*a/pi;
v += sin(7.0*r) + .7*cos(11.0*a);
w += .7+.7*(sin(7.0*r)+ .7*cos(11.0*a));

// End of the magic

u *= imgSize.x;
v *= imgSize.y;

if (u < 0.0) u += imgSize.x * ceil(-u / imgSize.x);
if (v < 0.0) v += imgSize.y * ceil(-v / imgSize.y);
if (u > imgSize.x) u -= imgSize.x * floor(u / imgSize.x);
if (v > imgSize.y) v -= imgSize.y * floor(v / imgSize.y);

dst = sampleNearest(src,float2(u, v));
dst.rgb *= w;
}
}
Show details Hide details

Change log

r170 by i...@mrdoob.com on Apr 18, 2009   Diff
@lab
added shader effects
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1607 bytes, 63 lines
Hosted by Google Code