source: GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/X3DCompositor.hlsl @ 916

Revision 916, 1.9 KB checked in by szirmay, 18 years ago (diff)
Line 
1uniform int column[15] = {0,2,3,5,7,0,2,4,5,7,0,2,4,5,7};
2
3
4       
5
6const int phaseR = 0, phaseG = 1, phaseB = 2;
7
8struct VS_QUAD
9{
10        float4 Position : POSITION;
11        float2 UV               : TEXCOORD0;
12};
13
14
15int eye_pixelpattern(float2 scrcoord, int renderPhase)
16{
17        float i = floor(frac(scrcoord.x / 5) * 5);     
18        int cureye;
19        if(renderPhase == phaseR){
20                float r = floor(frac((0 + i*5) / 8) * 8); // (0 + i*5) modulo 8
21                r = floor(frac((r + scrcoord.y)/8)*8);
22                cureye = (int)r;
23        }
24        if(renderPhase == phaseG){
25                float g = floor(frac((2 + i*5) / 8) * 8); // (2 + i*5) modulo 8
26                g = g-1;
27                g = floor(frac((g + scrcoord.y)/8)*8);
28                cureye = (int)g;
29        }
30        if(renderPhase == phaseB){
31                float b = floor(frac((3 + i*5) / 8) * 8); // (3 + i*5) modulo 8
32                b = floor(frac((b + scrcoord.y)/8)*8);
33                cureye = (int)b;
34        }
35        return cureye;
36}
37
38float4 X3DPS(float2 UV : TEXCOORD0,
39                        uniform sampler2D tex3Sampler : register(s0),
40                        uniform float width, //window width
41                        uniform float height)//window height
42                        : COLOR0
43{       
44        const int SAMPLE_ROWS = 4;
45        const int SAMPLE_COLS = 2;
46       
47        float2 WPOS = float2(UV.x * width, UV.y * height);
48       
49        int cureyeRed = eye_pixelpattern(WPOS, phaseR);
50        int cureyeGreen = eye_pixelpattern(WPOS, phaseG);
51        int cureyeBlue = eye_pixelpattern(WPOS, phaseB);
52       
53        float4 col = 0;
54        float2 M = float2(0.5, 0.25);
55       
56        float colR = floor(fmod(cureyeRed , SAMPLE_COLS));
57    float rowR = floor(fmod(floor(cureyeRed / SAMPLE_COLS) , SAMPLE_ROWS));
58
59    float colG = floor(fmod(cureyeGreen , SAMPLE_COLS));
60    float rowG = floor(fmod(floor(cureyeGreen / SAMPLE_COLS) , SAMPLE_ROWS));
61
62    float colB = floor(fmod(cureyeBlue , SAMPLE_COLS));
63    float rowB = floor(fmod(floor(cureyeBlue / SAMPLE_COLS) , SAMPLE_ROWS));
64       
65        col.r = tex2D(tex3Sampler, M * (UV + float2(colR, rowR))).r;
66    col.g = tex2D(tex3Sampler, M * (UV + float2(colG, rowG))).g;
67    col.b = tex2D(tex3Sampler, M * (UV + float2(colB, rowB))).b;
68       
69    return col;     
70}
71
72
73
Note: See TracBrowser for help on using the repository browser.