Game Development Reference

In-Depth Information

To this end, we can smartly use the built-in partial derivative instructions of

the shading language. According to the OpenGL specification, the partial deriva-

tives
dFdx
and
dFdy
are computed using local differencing, but the exact accuracy

of computations is not specified. Using some carefully chosen test patterns, we

have found that for each 2

2 block of pixels that is getting rasterized, the
dFdx

and
dFdy
instructions return the same value for pixel blocks of size 2

×

×

1and

1

2, respectively. The same appears to be true for the
ddx_fine
and
ddy_fine

functions in HLSL. Assuming C is the chrominance (C
o
or C
g
)thatisstored

on each pixel, it is easy to see that we can effectively compute [C
o

×

C
g
]withthe

following code snippet:

bool isBlack = ((crd.x&1)==(crd.y&1));

vec2 tmp = (isBlack)? vec2(C,0): vec2(0,C);

vec2 CoCg = abs(dFdx(tmp));

where
crd
are the integer coordinates of each pixel. In this case the missing

chrominance has beed copied from the horizontal neighbor, but the same principle

can be applied in the vertical direction, using the
dFdy
instruction. Using this

approach, we can read the missing chrominance from the two neighbors that

fall in the same 2

2 rasterization block, without even touching the memory

subsystem of the GPU, thus reducing the total fetches required to implement

Equation (4.2) from five to three.

This reduction of fetches did not yield any measurable performance increase

in our test cases. The results of course depend on the nature of each particular

application and the underlying GPU architecture, therefore we still discuss this

low-level optimization because it could be valuable in applications with differ-

ent workloads or different GPU architectures. Another option is to feed Equa-

tion (4.2) with only the two neighbors that fall in the same 2

×

2 rasterization

block, thus completely avoiding any redundant fetches. We have found, how-

ever, that the quality of this implementation is not always satisfactory, since in

the worst case the required chrominance information will be located in the two

missing neighbors.

×

4.5

Antialiasing

When rendering to a multisample framebuffer with our technique, each pixel will

contain either multiple chroma orange (C
o
) samples or multiple chroma green

(C
g
) samples, but never a mixture of both. Therefore, the framebuffer can be

resolved as usual, before applying the demosaic filter of
Section 4.4.
The only

restriction is that the reconstruction filter for the resolve should not be wider than

one pixel, in order to avoid incorrectly mixing C
o
and C
g
samples. This means

that a custom resolve pass should be used in case the automatic resolve operation

Search Nedrilad ::

Custom Search