Page 1 of 1

Texture mapping 2D triangles

PostPosted: Dec 28, 2005 @ 2:05am
by _Alex_

PostPosted: Dec 28, 2005 @ 2:50am
by _Alex_

PostPosted: Dec 28, 2005 @ 6:27am
by fast_rx

PostPosted: Dec 28, 2005 @ 7:18am
by _Alex_

PostPosted: Jan 3, 2006 @ 9:10pm
by xPeterx
The division per triangle is not the bottleneck of your polygon rasterizer. It's more important to get the scanline drawn as fast as possible.
Cache coherency plays a great role in texture mapping also.

Check out this document also (I'm not sure if you've seen it before)
http://www.multi.fi/~mbc/sources/fatmap2.txt

Cheers

PostPosted: Jan 4, 2006 @ 2:23am
by _Alex_

PostPosted: Jan 4, 2006 @ 11:52am
by xPeterx
To avoid jittering of your texture you'll probably have to make all coordinates fixed point (even the ones on screen) and use the subpixel portion of the screen coordinates to correct the ones of the texture while you're stepping through through it.

Read the link I've provided, it explains how to write a subpixel/subtexel accurate texture mapper.

PostPosted: Jan 4, 2006 @ 7:12pm
by _Alex_

PostPosted: Jan 4, 2006 @ 9:46pm
by xPeterx

PostPosted: Jan 5, 2006 @ 4:43am
by rcp

PostPosted: Jan 5, 2006 @ 7:56pm
by _Alex_

PostPosted: Jan 5, 2006 @ 9:20pm
by xPeterx

PostPosted: Jan 6, 2006 @ 7:23am
by _Alex_
Thanks,
'twas not easy, but I dug up the thread. I'm assuming you're referring to this one:
http://www.pocketmatrix.com/forums/view ... s&start=30

Let me put the technique into words to make sure that I understand how it works. By intertwining the uv coordinates as follows:
A = [u7|v7|u6|v6|u5|v5|u4|v4|u3|v3|u2|v2|u1|v1|u0|v0]

A = 0 means uv = (0,0)
A = 1 means uv = (0,1)
A = 2 means uv = (1,0) etc.

So this improves cache coherency because sequential data is preloaded into the cache. So depending on the texture screen orientation we get more cache hits even if we traverse in the v direction. This also means that the texture has to be rearanged such that the intertwined addressing accesses the corresponding pixels of the original texture.

Did I get the gist of it?