-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScatter.dctl
More file actions
40 lines (26 loc) · 1.7 KB
/
Scatter.dctl
File metadata and controls
40 lines (26 loc) · 1.7 KB
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
// Scatter
// Adjustable region
// No rand function, so used modulo operation to improvise
// New x,y values consistant in the three channels
// New x,y values that exceed image boundaries are mirrored i.e. -5,y becomes 5,y and x,1087 becomes x,1071 (in 1920x1080 image)
// If pixel values are repeated over a number of frames (resulting in identical scatter) use in conjuntion with...
// ...Film Grain OFX Plugin on same Node, choosing 35mm, Multiply, 0.1 Opacity, and 0.0 Saturation
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, __TEXTURE__ p_TexR, __TEXTURE__ p_TexG, __TEXTURE__ p_TexB)
{
//
int range = 7; // declares range of region i.e. 3 = 3x3, 5 = 5x5, 7 = 7x7, 9 = 9x9, etc. Must be odd number.
//
float rg = (range + 1.0f)/2.0f;
int totA = _round((_tex2D(p_TexR, p_X, p_Y) + _tex2D(p_TexG, p_X, p_Y) + _tex2D(p_TexB, p_X, p_Y)) * 1111) + p_X;
int totB = _round((_tex2D(p_TexR, p_X, p_Y) + _tex2D(p_TexG, p_X, p_Y)) * 1111) + p_Y;
int polarityA = _fmod(totA, 2.0f) > 0.0f ? -1.0f : 1.0f;
int polarityB = _fmod(totB, 2.0f) > 0.0f ? -1.0f : 1.0f;
int scatterA = _fmod(totA, rg) * polarityA;
int scatterB = _fmod(totB, rg) * polarityB;
int X = (p_X + scatterA) < 0 ? abs(p_X + scatterA) : ((p_X + scatterA) > (p_Width - 1) ? (2 * (p_Width - 1)) - (p_X + scatterA) : (p_X + scatterA));
int Y = (p_Y + scatterB) < 0 ? abs(p_Y + scatterB) : ((p_Y + scatterB) > (p_Height - 1) ? (2 * (p_Height - 1)) - (p_Y + scatterB) : (p_Y + scatterB));
const float r = _tex2D(p_TexR, X, Y);
const float g = _tex2D(p_TexG, X, Y);
const float b = _tex2D(p_TexB, X, Y);
return make_float3(r, g, b);
}