Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef ps_main17
- PS_OUTPUT ps_main17(PS_INPUT input)
- {
- PS_OUTPUT output;
- // Potential speed optimization. There is a high probability that
- // game only want to extract a single channel (blue). It will allow
- // to remove most of the conditional operation and yield a +2/3 fps
- // boost on MGS3
- //
- // Hypothesis wrong in Prince of Persia ... Seriously WTF !
- //#define ONLY_BLUE;
- // Convert a RGBA texture into a 8 bits packed texture
- // Input column: 8x2 RGBA pixels
- // 0: 8 RGBA
- // 1: 8 RGBA
- // Output column: 16x4 Index pixels
- // 0: 8 R | 8 B
- // 1: 8 R | 8 B
- // 2: 8 G | 8 A
- // 3: 8 G | 8 A
- float c;
- uint2 sel = uint2(input.p.xy) % uint2(16u, 16u);
- int2 tb = ((int2(input.p.xy) & ~int2(15, 3)) >> 1);
- int ty = tb.y | (int(input.p.y) & 1);
- int txN = tb.x | (int(input.p.x) & 7);
- int txH = tb.x | ((int(input.p.x) + 4) & 7);
- txN *= ScalingFactor.x;
- txH *= ScalingFactor.x;
- ty *= ScalingFactor.y;
- // TODO investigate texture gather
- float4 cN = Texture.Sample(TextureSampler, int2(txN, ty), 0);
- float4 cH = Texture.Sample(TextureSampler, int2(txH, ty), 0);
- if ((sel.y & 4u) == 0u) {
- // Column 0 and 2
- #ifdef ONLY_BLUE
- c = cN.b;
- #else
- if ((sel.y & 3u) < 2u) {
- // first 2 lines of the col
- if (sel.x < 8u)
- c = cN.r;
- else
- c = cN.b;
- } else {
- if (sel.x < 8u)
- c = cH.g;
- else
- c = cH.a;
- }
- #endif
- } else {
- #ifdef ONLY_BLUE
- c = cH.b;
- #else
- // Column 1 and 3
- if ((sel.y & 3u) < 2u) {
- // first 2 lines of the col
- if (sel.x < 8u)
- c = cH.r;
- else
- c = cH.b;
- } else {
- if (sel.x < 8u)
- c = cN.g;
- else
- c = cN.a;
- }
- #endif
- }
- output.c = (float4)(c); // divide by something here?
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement