Cycles differences between CPU and GPU in this World nodes
Closed, ResolvedPublic


System Information
Kubuntu 14.04 - GTX 960

Blender Version
Broken: 2.79 official, master

Short description of error
First of all, I'm not good with nodes. This may be due to a bug, or a bad configuration of nodes on my part. If it is the latter, sorry for inconveniences.
There are differences between GPU or CPU. In 2.79 release CPU render some circular stripes, still result different from GPU. From Master CPU does not render any texture.

Exact steps for others to reproduce the error

Open scene. Render with CPU or GPU (or combined from master)

Related Objects

Sergey Sharybin (sergey) triaged this task as Confirmed priority.Nov 22 2017, 5:57 PM
Sergey Sharybin (sergey) claimed this task.

Root of the issue is coming from precision issue on GPU. The thing here is that gradient texture always gives black color is such configuration, which effectively causes division by zero. Now, even though we use safe division (as in, we check whether denominator is zero or not), this does not help on GPU. Root of this issue goes to --fast-math we use for CUDA. Disabling fast math solves this issue, but gives about 15% of slowdown.

Can try using some more granular flags, but this requires some time.

@Brecht Van Lommel (brecht). didn't manage to find combination of flags which will solve the artifacts without introducing speed regression. More and more tempting to declare "just avoid numerical issues in shaders". But maybe you want to have a try here? (maybe disable fast divisions and use approx intrinsic when it's needed?)

I was just trying to get a quick background for the BA weekend challenge. I'm not even sure if those nodes are being used well here, and neither is it common to use it in World nodes. If you ask me, I prefer speed :) . But I have no idea, perhaps the problem that jumped here could affect other cases, and since we have GPU + CPU combined render, differences are more sensitive.
The nodes in Material render similar on GPU and CPU:

In the gradient texture we end up computing 1 - length(unit_length_vector) which is supposed to be exactly zero, but of course in practice float precision means it's not. I'll bias it a little bit now to make it exactly zero. We have tweaks like that in other places too, like the checker texture. It helps to make things a bit more robust also when rendering with only the CPU or GPU.

In general I think we want to keep the fast math enabled, even if it risks issues like this.

This exhibits the same problem. The experimental GPUCPU render really highlights it.