PDA

View Full Version : texturing a checkerboard



mikemor
09-26-2002, 05:48 AM
I need to draw a checkerboard which is NxM (with N and M any integers) in such a way that the squares look like squares!
(not rectangles) when textured onto a rectangle polygon. Somebody sugested I use mipmaping. Does anybody has come across this before?

Thanks

Overmind
09-26-2002, 10:01 AM
This problem is not really related to the drawing of the texture, more to the drawing of the geometry.

The texture will be stretched/repeated across your polygon, so when the size of the board is incorrect, your squares are not square.

If X,Y is the size of your board and N,M is the square count, X/Y must be equal to N/M, else your squares will be rectangular.

It is impossible to make a board that is for example 200x300 with 10x10 squares that are square. It should be clear that then each square has to be 20x30...

Omaha
09-27-2002, 03:41 AM
Advanced?

Anyway, to me the easiest way to do this would be with a simple 2x2 texture of a checkerboard pattern, then just apply your texture coords appropriately to a large quad.

For example, if your quad is 2.0 x 1.0, the texture coords would range on [(0, 0), (2.0, 1.0)] or a multiple if you want the texture repeated more. Use a nearest magnify filter and whatever you want for min. Make sure your texture coords match the aspect ratio of your quad.