Bump mapping artifacts when using image textures

Component:YafaRay Core
Category:bug report
Assigned:David Bluecame


I think I have found an issue in YafaRay 0.1.99 beta 3 when rendering big meshes which use global mapping coordinates for textures. It happens also with other mapping coordinates types except from UV coordinates. It happens in Windows and Linus systems. Issue does not show up when the same mesh is not using texture mapping.


Example file below:




Assigned to:Anonymous» David Bluecame

Hello, Álvaro.

I have checked with an older version of YafaRay before the changes I introduced since April and it also happens. This does not look like a self-shadowing issue but something else.. I have to investigate what's going on, something related to the rendering of textures and normals.


It looks like it happens only when using it for the Bump map. I have to look deeper at this.


Title:self shadowing with big textured meshes» Bump mapping artifacts when using image textures
Status:active» ready to commit

As I suspected this does not seem to be a self-shadowing issue. It looks more like an artifact in the Image Texture bump mapping code.

I cannot see the root cause why this happens, but for now I've disabled an entire section of the bump mapping code that is specific for image textures and it looks much better now.

The pull request is in https://github.com/YafaRay/Core/pull/87

I will include this patch in the upcoming v0.1.99-beta5 version.

This is not intended to be a definitive solution, only a temporary one to fix this particular problem. However we should investigate further why this happens in that section of the code and try to fix it there properly.

I've attached an image of the example Álvaro uploaded that looks much better in my opionion, as well as another example I created showing a cube with bump mapping before and after this fix.

mappingbug - after fix.png 378.79 KB
bump tests 2 - before fix.png 499.93 KB
bump tests 2 - after fix.png 499.8 KB
bump tests 2.blend 499.63 KB
masonry-wall-bump-map.jpg 200.13 KB


do we fully understand the consequences of disabling that part of the bump mapping code? I hope so, since users can work around this issue using UV mapping till a solution is found.


Status:ready to commit» active

Agree, I have closed the pull request for now. I'll try to look for the root causes of this.


Priority:normal» critical
Status:active» needs review


I'm trying to find out what exactly is the problem with the bump mapping processing image textures and the results of my first tests are quite discouraging.

It looks that the bump mapping system in YafaRay is working really badly. I checked reverting to old Git source trees before all the changes I started to add during April, etc, and it's still bad.

The different problems I have found so far are:

* If the object does not have UV map associated, when using an image texture with mapping Global-Cube for example, more or less subtle triangular artifacts appear as Alvaro initially reported.

* If the object has UV map associated, when using an image texture with mapping Global-Cube for example, the image looks normal but if you look more carefully and you compare with an equivalent Blender Internal render, the normals are not correct, something is clearly off even if it's not obvious at the first glance.

* If the object does not have UV map associated, when using an image texture with mapping UV-Flat for example, the image is wrong (big triangles appear) and even worse, sometimes (and totally randomly) black dots (+NaN) appear. If you render a few times they might not appear, but if you render more times (aprox.10 times in a row) then you start seeing the black dots, and sometimes huge blocks of black NaN dots appear!! :-(((

* If the object has UV map associated, when using an image texture with mapping UV-Flat for example, the image looks correct and similar to the equivalent Blender Internal rendering. This is the only of the 4 cases where the result looks correct! :-(


I'm trying to come up with some fix, but this problem is very complex and I'm surprised nobody has reported such significant issues until now?  So, please Álvaro I would like to know your opinion. I had a brief conversation with Rodrigo about this last week over Hangouts (I didn't know all these problems when we chatted), and he said bump mapping is unstable. I can confirm that is true!

I've found several interesting things, for example in some cases the bump mapping may end up using non-initialized variables (causing the NaN black dots) and I have already some fixes prepared, but I think I should try to fix all the bump mapping issues at the same time, but I don't want to break anything else in the process.


For your information I've attached the blend example file I've been using in my tests and some images so you can see the defects.

For obvious reasons, I'm changing this bug to "critical"

bump4-tests.zip 243.79 KB
bump blender internal global cube without uv map.png 436.01 KB
bump blender internal UV flat with uv map.png 390.56 KB
bump before fix - global cube without uv map.png 457.33 KB
bump before fix - global cube with uv map.png 455.73 KB
bump before fix - UV flat without uv map - black dots nan.png 106.23 KB
bump before fix - UV flat with uv map.png 430.77 KB


Status:needs review» active

More tests and information:

I've attached an example I've made with texture bump mapping and the render made with YafaRay and Blender Internal. I'm using the current master official YafaRay 0.1.5 from Git, not my experimental variation 0.1.99 (although in the experimental the same happens)

In the image we have, from left to right:

* A cube with UV map and Global Cube texture map. Here we can see the artifacts are incorrect shadowing: the angles of the incident light and shadow are wrong. Same problems happen if we choose Generated Cube.

- Top side, it's like we use the opposite criteria respect to Blender Internal (and many other renderers) where white is supposed to protude and black to carve into the object.

- Front side, it's totally incorrect, like if the light comes from one side which is not ture in this example.

- Lateral side, also incorrect. The light comes in an angle to this side, but it's showing it in the incorrect angle like in the front side.


* A cube without UV map and Global Cube texture map

- Similar problems as above

- Additionally, triangular artifacts, where the shadows/incident light change depending on the triangle where you are in each face!  This is the artifact originally reported by Alvaro in this case.


* A cube with UV map and UV Flat texture map

- It looks ok?  But I'm not sure, the "shadowed" portion does not seem to be dark enough, compared with Blender internal where the shadows of the circles are black (??)


So, I will start working on this to try to solve these issues and get YafaRay to process bump maps the same way Blender Internal does. Please let me know what you think.

bump_issue_5.zip 104.64 KB
bump test 5 - blender internal correct.png 223.87 KB
bump test 5 - yafa wrong for several reasons.png 201.86 KB


Status:active» ready to commit


This is a quite difficult one. I've been experimenting trying to achieve similar results to Blender Internal and I've sent a pull request with the proposed changes: https://github.com/YafaRay/Core/pull/89

This is not intended to be a 100% perfect fix, not at all. There is still possibility of artifacts in bump mapping, but I hope it improves and reduces the artifacts respect to the previous bump map system.

I'm too tired today, but I will upload soon examples and images showing the difference between the previous behavior and the new behavior of bump mapping.

Also, I hope to release a new beta soon with all these changes applied for testing.


Status:ready to commit» fixed

Fixed in YafaRay-E (Experimental) v1.0.0


For more information, see:  http://www.yafaray.org/community/forum/viewtopic.php?f=12&t=5117


If you still have this issue with the new version please let us know.


Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.