Incorrect Image Textures interpolation!

Project:YafaRay
Version:development
Component:Code
Category:bug report
Priority:critical
Assigned:David Bluecame
Status:ready to commit
Description

Hello,

While trying to implement MipMaps (as of http://yafaray.org/node/695), I've been having difficulties with strange seams that appear sometimes at the edge of textures when they are repeated over a surface.

Obviously my first thought was to suspect my own additions to the code for MipMapping. However, after a long struggle, I've found that the original YafaRay texture interpolation was incorrect. Therefore, if I'm not mistaken, this is a problem that has been happening for a very long time in all YafaRay versions.

The problem is subtle, just a fine seam in the edge of the textures, but it's there. To replicate it and compare it with Blender Internal, I've created a small 4x4 texture and these are the results:

Blender Internal render (correct)

texels1 - blender internal (good).pngtexels1 - blender internal (good).png

 

YafaRay render (wrong, see strange colored stripes at top and left of each repeated texture).

texels1 - yafaray (incorrect, weird bands top left each texture).pngtexels1 - yafaray (incorrect, weird bands top left each texture).png

 

This problem is not trivial. To solve this, I have not only to correct the bug but also to implement an extension to the current interpolation code. For example if we have textures repeated, to determine the color to be calculated to the pixels near the texture edges, the interpolation should also take into account the colors of the texels in the next repetition of the texture. This also involves taking into account any "mirrorX, mirrorY" effect in the interpolation, so it takes into account the correct texel from the next texture "repetition".

As this is a major problem in my opinion, I'll try to fix it and integrate the texture interpolation with the Texture Clip Mode and MirrorX/Y parameters to make YafaRay texture interpolation behavior more similar to Blender.

Comments

#1

Hello,

I've attached here a zip file with the .blend and texture I used for the example above.

AttachmentSize
texels1.zip 129.92 KB

#2

Status:active» ready to commit

Hello,

After a long struggle I believe I've fixed this in the commit: https://github.com/YafaRay/Core/commit/db6261db5fc0e70b3fbb17d38b099ba11...

Also, the changes implement extra code to take into account texture edge interpolation differently when:
* Texture is alone (clip), extended or checkered. In this case, the edges are interpolated against themselves
* Texture is repeated. In this case the way the edges are interpolated depends on the MirrorX/MirrorY parameters. Depending on these params, the edges are interpolated against the opposite edge (normal) or the same edge (mirrored).

I hope this change works fine and does not cause problems. We will have to test it thoroughly. In any case, I've tested it with similar small textures combining different colors in the edges, etc, with different modes (clip, extend, checker, repeat), including MirrorX/MirrorY and now I'm getting similar results to Blender Internal, which I believe is a good sign.

For example, the scene described above now gives me the correct result:

texels1 - yafaray (fixed texture interpolation).pngtexels1 - yafaray (fixed texture interpolation).png

 

This change will be available in the next YafaRay version.

#3

Hello David,

thanks for the report and for having brilliantly solved the problem.

regards

John

ACCA Software