Question: How do you calculate what the result of trilinear filtering should be?
I am working on getting a video driver working and am running into an issue where I am not passing a test that looks at mipmap levels. A 32x32 texture is created and the mipmap levels are maunally populated as seen below.
texsize_____mip lvl_____R____G_____B
32__________0________ff____00____00
16__________1________00____ff____00
8___________2________00____00____ff
4___________3________ff_____ff____00
2___________4________ff_____00____ff
1___________5________00_____ff____ff
Now I pass my test when using GL_NEAREST_MIPMAP_NEAREST/GL_LINEAR_MIPMAP_NEAREST but when I use GL_NEAREST_MIPMAP_LINEAR/GL_LINEAR_MIPMAP_LINEAR (which from what I can gather both use trilinear filtering) I fail the test which compares my results against an expected of the data above +/- 8 plus an additional small amount of error. When I draw I am drawing using a texture size of 32/16/8/4/2/1 I am getting
texsize_____mip lvl_____R____G_____B
32__________0________ff____00____00
16__________1________01____fe____00
8___________2________00____00____ff
4___________3________f9_____f9____06
2___________4________ff_____0c____f3
1___________5________00_____ff____ff
Where I am failing is at tex size 2 since the error is +/- 12. It also seems like I may be missing somethign since I would expect all of the levels to fail or none of the levels to fail, anyone have any insight into if it is normal for different levels to be filtered differently?
My question is given the results and inputs above what would one expect the results to be? From what I understand if I choose a texture size that correlates to a given level, it should interpolate between that level (lowest) and the level above it (highest). Is there a weighting that also comes into play that I am missing?