Roughness below 0.01 treated as mirror by PATH engine

Use this forum for general user support and related questions.
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
Post Reply
Martini
Posts: 125
Joined: Fri Nov 23, 2018 11:36 am
Location: Australia

Roughness below 0.01 treated as mirror by PATH engine

Post by Martini »

I have gathered some evidence... see the following render from Blender 2.80, LuxCore 2.2rc1:
12,288spp rendered at 4K but scaled to 1080p for upload
12,288spp rendered at 4K but scaled to 1080p for upload
I checked the output .scn file as well, the exported materials look correct.

Material for roughness 0.01:

Code: Select all

scene.textures.2441963438968Fresnel.type = "fresnelconst"
scene.textures.2441963438968Fresnel.n = 0.0981203318 0.373658836 1.57057941
scene.textures.2441963438968Fresnel.k = 3.35364223 2.52603722 1.76780081
scene.textures.Implicit-ConstFloatTexture-2e7883ad-e292-43a8-a2d3-a4b9df7771f3.type = "constfloat1"
scene.textures.Implicit-ConstFloatTexture-2e7883ad-e292-43a8-a2d3-a4b9df7771f3.value = 0.00999999978
scene.textures.Implicit-ConstFloatTexture-cf3860dd-d6b1-41e7-9c39-d391e48fc320.type = "constfloat1"
scene.textures.Implicit-ConstFloatTexture-cf3860dd-d6b1-41e7-9c39-d391e48fc320.value = 0.00999999978
scene.materials.MetallicPointOhOne2440874536696.type = "metal2"
scene.materials.MetallicPointOhOne2440874536696.fresnel = "2441963438968Fresnel"
scene.materials.MetallicPointOhOne2440874536696.uroughness = "Implicit-ConstFloatTexture-2e7883ad-e292-43a8-a2d3-a4b9df7771f3"
scene.materials.MetallicPointOhOne2440874536696.vroughness = "Implicit-ConstFloatTexture-cf3860dd-d6b1-41e7-9c39-d391e48fc320"
scene.materials.MetallicPointOhOne2440874536696.id = 13398304
scene.materials.MetallicPointOhOne2440874536696.emission.gain = 1 1 1
scene.materials.MetallicPointOhOne2440874536696.emission.power = 0
scene.materials.MetallicPointOhOne2440874536696.emission.efficency = 0
scene.materials.MetallicPointOhOne2440874536696.emission.theta = 90
scene.materials.MetallicPointOhOne2440874536696.emission.id = 0
scene.materials.MetallicPointOhOne2440874536696.emission.importance = 1
scene.materials.MetallicPointOhOne2440874536696.emission.directlightsampling.type = "AUTO"
scene.materials.MetallicPointOhOne2440874536696.visibility.indirect.diffuse.enable = 1
scene.materials.MetallicPointOhOne2440874536696.visibility.indirect.glossy.enable = 1
scene.materials.MetallicPointOhOne2440874536696.visibility.indirect.specular.enable = 1
scene.materials.MetallicPointOhOne2440874536696.shadowcatcher.enable = 0
scene.materials.MetallicPointOhOne2440874536696.shadowcatcher.onlyinfinitelights = 0
Material for roughness 0.00999:

Code: Select all

scene.textures.2441963428056Fresnel.type = "fresnelconst"
scene.textures.2441963428056Fresnel.n = 0.0981203318 0.373658836 1.57057941
scene.textures.2441963428056Fresnel.k = 3.35364223 2.52603722 1.76780081
scene.textures.Implicit-ConstFloatTexture-cc8d6cb8-5537-4475-bdc2-5332e2e51548.type = "constfloat1"
scene.textures.Implicit-ConstFloatTexture-cc8d6cb8-5537-4475-bdc2-5332e2e51548.value = 0.00999000017
scene.textures.Implicit-ConstFloatTexture-61406085-9f72-4eaa-adc4-6d216b01460c.type = "constfloat1"
scene.textures.Implicit-ConstFloatTexture-61406085-9f72-4eaa-adc4-6d216b01460c.value = 0.00999000017
scene.materials.MetallicPointOhOhNines2440874528968.type = "metal2"
scene.materials.MetallicPointOhOhNines2440874528968.fresnel = "2441963428056Fresnel"
scene.materials.MetallicPointOhOhNines2440874528968.uroughness = "Implicit-ConstFloatTexture-cc8d6cb8-5537-4475-bdc2-5332e2e51548"
scene.materials.MetallicPointOhOhNines2440874528968.vroughness = "Implicit-ConstFloatTexture-61406085-9f72-4eaa-adc4-6d216b01460c"
scene.materials.MetallicPointOhOhNines2440874528968.id = 706207
scene.materials.MetallicPointOhOhNines2440874528968.emission.gain = 1 1 1
scene.materials.MetallicPointOhOhNines2440874528968.emission.power = 0
scene.materials.MetallicPointOhOhNines2440874528968.emission.efficency = 0
scene.materials.MetallicPointOhOhNines2440874528968.emission.theta = 90
scene.materials.MetallicPointOhOhNines2440874528968.emission.id = 0
scene.materials.MetallicPointOhOhNines2440874528968.emission.importance = 1
scene.materials.MetallicPointOhOhNines2440874528968.emission.directlightsampling.type = "AUTO"
scene.materials.MetallicPointOhOhNines2440874528968.visibility.indirect.diffuse.enable = 1
scene.materials.MetallicPointOhOhNines2440874528968.visibility.indirect.glossy.enable = 1
scene.materials.MetallicPointOhOhNines2440874528968.visibility.indirect.specular.enable = 1
scene.materials.MetallicPointOhOhNines2440874528968.shadowcatcher.enable = 0
scene.materials.MetallicPointOhOhNines2440874528968.shadowcatcher.onlyinfinitelights = 0
As you can see it's virtually identical. Exported roughness values are 0.00999999978 vs 0.00999000017, yet somehow the second one gets rendered as a perfect mirror (as though roughness were 0). Also you may note that Glossy material is also affected, and the roughness on the Disney material is not working at all.

It also renders the same way from within LuxCoreUI:
Rendered in LuxCoreUI
Rendered in LuxCoreUI
I have tested with Light Tracing on and off, makes no difference. CPU vs GPU makes no difference.

The only thing that does make a difference is BIDIRCPU. Roughness works just fine with BiDir engine!
Rendered in LuxCoreUI with BIDIRCPU
Rendered in LuxCoreUI with BIDIRCPU
It seems reasonable to me to conclude that the bug may lie within the PATH LuxCore engine.
Attachments
roughness.blend
(1.05 MiB) Downloaded 180 times
AMD Ryzen Threadripper PRO 5995WX 64-Cores | 2x Gigabyte RTX 4090 Gaming OC
ASUS Pro WS WRX80E-SAGE SE WIFI | 256GB Kingston Server Premier ECC Unbuffered DDR4
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by Dade »

I'm seeing the problem only with OpenCL, not with CPU rendering. Are you sure to have the same problem with CPU rendering (don't forget to disable hybrid CPU/GPU rendering when doing the test) ?
Support LuxCoreRender project with salts and bounties
Martini
Posts: 125
Joined: Fri Nov 23, 2018 11:36 am
Location: Australia

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by Martini »

Dade wrote: Sat Sep 21, 2019 4:28 pm I'm seeing the problem only with OpenCL, not with CPU rendering. Are you sure to have the same problem with CPU rendering (don't forget to disable hybrid CPU/GPU rendering when doing the test) ?
Well, you are right of course. Apologies, I could've sworn I tested that! :oops:

Ah yes, so it seems limited to OpenCL... well, hopefully that can help narrow down possible locations for the cause even more, right?
AMD Ryzen Threadripper PRO 5995WX 64-Cores | 2x Gigabyte RTX 4090 Gaming OC
ASUS Pro WS WRX80E-SAGE SE WIFI | 256GB Kingston Server Premier ECC Unbuffered DDR4
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by Dade »

Ok, it was intentional, there was lower cap at sqrt(.0001): https://github.com/LuxCoreRender/LuxCor ... ric.cl#L68

Code: Select all

// Values of roughness < .0001f seems to trigger some kind of exceptions with
// AMD OpenCL on GPUs. The result is a nearly freeze of the PC.
I have remove the work around and the bug in AMD drivers seems to have been fixed.

About Disney roughness and Glossy/Metal roughness: as far as I remember Disney roughness is equal to the square root of Glossy/Metal roughness because "(Disney) roughness = (Glossy/Metal) uroughness * vroughness".

P.S. sqrt(.0001) = 0.001
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by Dade »

Side note: Disney material glossiness is now computed as the square root of the previous value to match Glossy2/Metal roughness (for PhtonGI and Hybrid rendering).
Support LuxCoreRender project with salts and bounties
User avatar
lacilaci
Donor
Donor
Posts: 1969
Joined: Fri May 04, 2018 5:16 am

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by lacilaci »

Dade wrote: Sun Sep 22, 2019 8:28 am Side note: Disney material glossiness is now computed as the square root of the previous value to match Glossy2/Metal roughness (for PhtonGI and Hybrid rendering).
oh no... Disney values are more intuitive to use. Why should I type stupid values like 0.0whatever and see some big changes in roughness?
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by B.Y.O.B. »

lacilaci wrote: Sun Sep 22, 2019 9:15 am oh no... Disney values are more intuitive to use. Why should I type stupid values like 0.0whatever and see some big changes in roughness?
It's only about the glossiness threshold for PhotonGI and light tracing.
User avatar
lacilaci
Donor
Donor
Posts: 1969
Joined: Fri May 04, 2018 5:16 am

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by lacilaci »

B.Y.O.B. wrote: Sun Sep 22, 2019 9:47 am
lacilaci wrote: Sun Sep 22, 2019 9:15 am oh no... Disney values are more intuitive to use. Why should I type stupid values like 0.0whatever and see some big changes in roughness?
It's only about the glossiness threshold for PhotonGI and light tracing.
ohh. So no reason to panic then :lol: thanks for explanation
Martini
Posts: 125
Joined: Fri Nov 23, 2018 11:36 am
Location: Australia

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by Martini »

Dade wrote: Sun Sep 22, 2019 8:19 am I have remove the work around and the bug in AMD drivers seems to have been fixed.
Thanks Dade! :D

BTW, had a look at your commit and although I don't understand what the u0 value is, it does seem there is no longer anything stopping roughness == 0, which may cause a divide-by-zero error in the case where u0 == 0 also. Was that the original cause of the crash? I know BlendLuxCore would prevent you from entering roughness less than 0.001 but you could do it by hand...

Is there a less restrictive sensible minimum? .0001f was not enough due to coming from input 0.01 squared, maybe something like .000001f (which is input 0.001 squared). Or just set cos2Theta to 1.f when roughness == 0.f?

Sorry these are just ideas and it is probably clear by now that although I'm a programmer, I don't know how the maths behind ray tracing actually works :lol: so take these suggestions with due caution. ;)
AMD Ryzen Threadripper PRO 5995WX 64-Cores | 2x Gigabyte RTX 4090 Gaming OC
ASUS Pro WS WRX80E-SAGE SE WIFI | 256GB Kingston Server Premier ECC Unbuffered DDR4
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Roughness below 0.01 treated as mirror by PATH engine

Post by Dade »

Martini wrote: Sun Sep 22, 2019 10:14 am BTW, had a look at your commit and although I don't understand what the u0 value is, it does seem there is no longer anything stopping roughness == 0, which may cause a divide-by-zero error in the case where u0 == 0 also. Was that the original cause of the crash? I know BlendLuxCore would prevent you from entering roughness less than 0.001 but you could do it by hand...

Is there a less restrictive sensible minimum? .0001f was not enough due to coming from input 0.01 squared, maybe something like .000001f (which is input 0.001 squared). Or just set cos2Theta to 1.f when roughness == 0.f?

Sorry these are just ideas and it is probably clear by now that although I'm a programmer, I don't know how the maths behind ray tracing actually works :lol: so take these suggestions with due caution. ;)
"u0" is a sampling variable, it is a "random" value between 0.0 and 1.0. U/V roughness is clamped between 1e-9 and 1.0 so roughness can not be 0.0: https://github.com/LuxCoreRender/LuxCor ... 2.cpp#L162
Support LuxCoreRender project with salts and bounties
Post Reply