| Changes to /trunk/lab/effects/shaders/plane_deformations/deploy/shaders/rays2.pbk |
r0 vs. r170
Edit
|
r170
|
| /trunk/lab/effects/shaders/plane_deformations/deploy/shaders/rays2.pbk | /trunk/lab/effects/shaders/plane_deformations/deploy/shaders/rays2.pbk r170 | ||
| 1 | <languageVersion : 1.0;> | ||
|---|---|---|---|
| 2 | |||
| 3 | kernel NewFilter | ||
| 4 | < namespace : "Rays 2"; | ||
| 5 | vendor : "Mr.doob"; | ||
| 6 | version : 1; | ||
| 7 | description : "Rays effect 2"; | ||
| 8 | > | ||
| 9 | { | ||
| 10 | input image4 src; | ||
| 11 | output pixel4 dst; | ||
| 12 | |||
| 13 | parameter float2 imgSize | ||
| 14 | < | ||
| 15 | defaultValue : float2(512.0, 512.0); | ||
| 16 | minValue : float2(0.0,0.0); | ||
| 17 | maxValue : float2(512.0,512.0); | ||
| 18 | >; | ||
| 19 | |||
| 20 | parameter float2 center | ||
| 21 | < | ||
| 22 | defaultValue : float2(256.0, 256.0); | ||
| 23 | minValue : float2(0.0,0.0); | ||
| 24 | maxValue : float2(512.0,512.0); | ||
| 25 | >; | ||
| 26 | |||
| 27 | parameter float2 offset; | ||
| 28 | |||
| 29 | void evaluatePixel() | ||
| 30 | { | ||
| 31 | float2 pos = (outCoord() - center) / imgSize; | ||
| 32 | |||
| 33 | float pi = 3.141592653589793; | ||
| 34 | float a = atan(pos.y,pos.x); | ||
| 35 | float r = sqrt(pow(pos.x,2.0)+pow(pos.y,2.0)); | ||
| 36 | |||
| 37 | float u = 0.0; | ||
| 38 | float v = 0.0; | ||
| 39 | float w = 0.0; | ||
| 40 | |||
| 41 | u += offset.x; | ||
| 42 | v += offset.y; | ||
| 43 | |||
| 44 | // This is where the magic happens | ||
| 45 | |||
| 46 | u += a; | ||
| 47 | v += a; | ||
| 48 | w += 1.0/pow(r,.5); | ||
| 49 | |||
| 50 | // End of the magic | ||
| 51 | |||
| 52 | u *= imgSize.x; | ||
| 53 | v *= imgSize.y; | ||
| 54 | |||
| 55 | if (u < 0.0) u += imgSize.x * ceil(-u / imgSize.x); | ||
| 56 | if (v < 0.0) v += imgSize.y * ceil(-v / imgSize.y); | ||
| 57 | if (u > imgSize.x) u -= imgSize.x * floor(u / imgSize.x); | ||
| 58 | if (v > imgSize.y) v -= imgSize.y * floor(v / imgSize.y); | ||
| 59 | |||
| 60 | dst = sampleNearest(src,float2(u, v)); | ||
| 61 | dst.rgb *= w; | ||
| 62 | } | ||
| 63 | } | ||