|
|
Frequently Asked Questions Bilinear Mode Operation
This document is part of the SGL Programming Guide
The manufacturing releases of the 4.0 drivers support a new field eFilterType in SGL Directs SGLCONTEXT structure which sets the bilinear filtering mode: SGLCONTEXT.eFilterType = 0 - point sampling (bilinear off): DEFAULT 1 - adaptive bilinear 2 - bilinear This value will be read by sgltri_startofframe(). SGLCONTEXT.eFilterType is at the same location as SGLCONTEXT.u32Reserve9[0] in the 4.0.0b3 driver. Set the SGLTT_BILINEAR bit in SGLCONTEXT.u32Flags for all calls to sgltri_triangles(). This is important for compatibility with future hardware revisions that are able to switch bilinear on/off for different triangles in the scene. Since current PowerVR hardware needs to use a constant filtering mode for the whole frame the Direct3D driver uses the state of the first set of triangles after BeginScene to determine the mode. Games designed for per-triangle filtering systems should send a non-visible dummy triangle with the required global state at the start of the frame to ensure the required mode for PowerVR. Without this the game may switch from bilinear mode to point sampling from time to time depending on the state of the first triangle. Bilinear filtering is implemented on PowerVR according to the OpenGL standard. When a texture is expanded on the screen such that there are multiple pixels per texel, the centre of the texel will be the pure texel colour and the other pixels will be a weighted average of that texel with its neighbours. This may cause a slight wraparound effect for textures that are not designed to repeat multiple times. At U/V values of 0.0 or 1.0 the colour is an average of the first and last texels in the texture map. Also, U/V values of 0.5 will always contain an average of neighbouring texel colours, therefore sub textures sharing a single hardware texture page will have their edge texels wrapping into each other.
To solve these problems U/V values need to be brought in away from the edges by half a texel, for example 1/64 to 1-(1/64) for a 32x32 texture. Another method is to use U/V flipping (mirroring). This is not implemented for actually flipping a texture in bilinear mode but is very useful for ensuring the last row and column of the texture map is interpolated with itself rather than with the first row/column. For textures that share a texture map some of the U/V values will still have to be brought in by half a texel since U/V flipping only affects the edges of the hardware texture map. The U/V flipping method is not implemented for 256x256 textures. Future versions of the PowerVR Direct3D driver may use U/V flipping for the clamp feature in Direct3D. Cutout textures ('sprites') using on/off alpha transparency which have been generated for non-bilinear hardware will show a dark halo around the edges of the cutout image when it appears on screen. This occurs because bilinear filtering takes partial samples from pixels beyond the edges of the cutout itself. These pixels, usually black, causing the edge of the cutout to blend between the cutout colour and black.
To solve these problems, it is necessary to understand that bilinear filtering must sample beyond the edge of the cutout texture, and to colour the surrounding pixels accordingly. Click Here to download a little example program which illustrates the (u,v) correction [266K] ... and here is another example program which illustrates the (u,v)
correction: Both of these example programs use the PowerVR Shell Environment. The correct method is to take each pixel surrounding the cutout in turn and to extend the neighbouring colour to this pixel, by averaging the values of any neighbouring (adjacent) pixels which are within the cutout. The alpha value of these newly-coloured pixels will remain 1 (equals transparent), as in the original case. To cope with more complex filtering methods in the
future, such as a multi sampling elliptical filter, the method described should be applied
right out to the edges of the texture map, rather than just one pixel beyond the cutout. |
Confidential / provided under Non-Disclosure Agreement Copyright © 1999-2000, PowerVR Technologies and partners. PowerVR Technologies is a division of Imagination Technologies Limited. |