isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.47k stars 2.31k forks source link

Howto render without shadows in custom gui built using python binding #4329

Open hernot opened 2 years ago

hernot commented 2 years ago

When setting lightning to NO_SHADOWS than all surfaces are black even when enabling indirect light. In visualization/Open3DVisualizer.cpp also the FillamentScene.GemoetryShadows function is called when displaying a TriangleMesh without shadows, which is not available through python binding of o3d.visualization.rendering.Scene Is there an other trick to get surfaces properly rendered when turning off shadows. With sun enabled and any other shadow settings surfaces are rendered with colors visible but the down is shadows make it hard to interpret the data encoded by surface colors.

System Mint 20., Python 3.8 Open3D 0.13.x

BTW: I also get in my installation the following warnings from python:

[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx
[Open3D WARNING] Resource request for path /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx failed:
* Code: 2
* Error: Failed to read spherical harmonics from ktx

Could these be related. And how to resolve them as the files and the related skybox files do exist. and are writeable for owner and readable for owner,group,others.

Open3d was installed from pypi wheel globally as superuse so that all users can use.

hernot commented 2 years ago

Seems as would the missing harmonics error prevent loading any ibl files and thus no indirect light is set at all. Do you see any chance to get at least a working default_ibl.ktx or brightday_ibl.ktx for manual installation as proper as shadow free rendering as possible is crucial to us and we do not have the resources (especially man power) to install filament just for ibl.ktx file generation but need the results timely from now. Therefore if you could point to a link or resource where to find and download sutiable *_ibl.ktx files would be apriciated as an intermediate workaround until solved on the next open3d release pypi-wheel.

hernot commented 2 years ago

Cracy I found it after downloading binary filament package and trying to convert my own ibl file. Which did not work either. Reading carefully the code behind of filament::KtxBundle::getSphericalHarmonics it turned out that they are using std::strtof function to parse the ascii encoded spherical harmonics. And std::strtof is causing all the problems cause it is locals sensitive. And as our computers are set to German/Austrian locals std::strtof expects , for decimal separator compared to English based locals which use . for decimal separator. By modifying the spherical harmonics list inside for example derfault_ibl.ktx file accordingly, replacing . by , all errors (warnings) related to spherical harmonics are gone and SOFT_SHADOWS as well as NO_SCHADOWS lightning works as expected even without FillamentScene.GemoetryShadows beeing available through python interface.

Not sure if as a quick-fix within open3d it would be a wise idea to temporarily switch locals (at least on linux, mac, android and alike) to default or C or en before calling `bundle.getSphericalHarmonics function and back to what user has set for his system.

The final fix anyway has to be done on filament sources (see filament issue #4883 ).

hovren commented 2 years ago

It seems like the issue was fixed in Filament, but the error is still present in Open3D 0.15.2. A work around until the issue is fixed is to change the locale before performing the visualization:

# Set the locale to 'C' to allow default_ibl.ktx to load
import locale
loc = locale.getlocale()
locale.setlocale(locale.LC_ALL, 'C')

app = gui.Application.instance
app.initialize()

# Visualization goes here
...

app.run()

# Reset the locale
locale.setlocale(locale.LC_ALL, loc)
hernot commented 2 years ago

Yes it was, after i have reported it. Without this fix in fillament all surfaces are just black.

A rather annoying fix is edit all affected *.kblfiles eg.: /usr/local/lib/python3.8/dist-packages/open3d//resources/default_ibl.ktx

Replace at top of the file the '.' in all float numbers by ',' or whatever decimal separator is used by your locals.

A proper fix is only possible through open3D project updating fillament version.

hernot commented 1 year ago

Are there any plans to update to newer fillament version to finally fix this really anyoing issue as it persists since at least 2 if not even more versions of open3d, reducing the value of open3d for all which have not set their locals to english and either are not allowed to change or have other reasons preventing them to change. Fillament download cmake file has not be changed since 2 years while compilation cmake has been change 4 month ago.