rnd-team-dev / plotoptix

Data visualisation and ray tracing in Python based on OptiX 7.7 framework.
https://rnd.team/plotoptix
Other
499 stars 26 forks source link

Material Compile Error: Symbol defined multiple times #13

Closed riccardomarin closed 4 years ago

riccardomarin commented 4 years ago

Hi, I am trying to run the example about materials and glass colors. However it rise a compilation error.

Here is the code:

import numpy as np
from plotoptix import TkOptiX
from plotoptix.materials import m_clear_glass, m_mirror, m_plastic  # predefined materials
from plotoptix.utils import map_to_colors  # map variable to matplotlib color map

n = 6
a = 8
s = a / n
xyz = np.mgrid[0:a:s, 0:a:s, 0:a:s].reshape(3,-1).T
rnd = np.random.uniform(0, 1, xyz.shape[0])

# most cubes with the standard material:
xyz_c_diffuse = xyz[((xyz[:,0] == 0) | (xyz[:,1] == 0) | (xyz[:,2] == 0)) & (rnd < 0.7)]
# the rest made of mirror walls:
xyz_c_mirror = xyz[((xyz[:,0] == 0) | (xyz[:,1] == 0) | (xyz[:,2] == 0)) & (rnd >= 0.7)]

# most particles made of glass:
xyz_p_glass = xyz[(xyz[:,0] > 0) & (xyz[:,1] > 0) & (xyz[:,2] > 0) & (rnd < 0.4)]
# some plastic-like particles:
xyz_p_plastic = xyz[(xyz[:,0] > 0) & (xyz[:,1] > 0) & (xyz[:,2] > 0) & (rnd > 0.9)]

optix = TkOptiX(start_now=False) # no need to open the window yet
optix.set_param(min_accumulation_step=4,     # set more accumulation frames
                max_accumulation_frames=500, # to get rid of the noise
                light_shading="Hard")        # use "Hard" light shading for the best caustics and "Soft" for fast convergence

optix.set_uint("path_seg_range", 15, 30)

optix.setup_material("glass", m_clear_glass)
optix.setup_material("plastic", m_plastic)
optix.setup_material("mirror", m_mirror)

optix.set_data("particles_g", pos=xyz_p_glass + np.array([0.5*s, 0.5*s, 0.5*s]), r=0.4*s,
               geom="ParticleSet",     # set the geometry of data points to particles
               mat="glass",            # use the glass material
               c=10)                   # and set the color to transparent, neutral
# optix.set_data("particles_p", pos=xyz_p_plastic + np.array([0.5*s, 0.5*s, 0.5*s]), r=0.4*s,
#                geom="ParticleSet",     # set geometry of to particles
#                mat="plastic",          # slightly reflective, plastic look
#                c=0.95)                 # white color

# optix.set_data("cubes_d", pos=xyz_c_diffuse, u=[0.9*s, 0, 0], v=[0, 0.9*s, 0], w=[0, 0, 0.9*s],
#                geom="Parallelepipeds", # cubes, actually default geometry
#                mat="diffuse",          # opaque, mat, default
#                c=0.95)                 # white color

# optix.set_data("cubes_m", pos=xyz_c_mirror, u=[0.9*s, 0, 0], v=[0, 0.9*s, 0], w=[0, 0, 0.9*s],
#                geom="Parallelepipeds", # cubes, same default geometry
#                mat="mirror")           # 100% reflective mirror, no color

optix.setup_camera("cam1", eye=[20, 10, 10], target=[0.5*a, 0.4*a, 0.5*a], fov=35)
optix.set_background(0)
optix.set_ambient(0)

optix.set_float("tonemap_exposure", 0.5)
optix.set_float("tonemap_gamma", 2.2)

optix.add_postproc("Gamma")      # apply gamma correction postprocessing stage, or
#optix.add_postproc("Denoiser")  # use AI denoiser (exposure and gamma are applied as well)

optix.setup_light("light1", pos=[5, 20, 5], color=10*np.array([1.0, 0.97, 0.7]), radius=4)
optix.setup_light("light2", pos=[7, 7, 20], color=15*np.array([0.7, 0.85, 1.0]), radius=3)
optix.setup_light("light3", pos=[15, 2, 2], color=15, radius=1)

optix.start()

Here is the running log:

    [0]: GeForce RTX 2080 Ti
    Selected devices: [0]
    Primary device: 0
[ 2][COMPILE FEEDBACK]: COMPILE ERROR: 
Error: Symbol '__anyhit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_transparency_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__blurred_dot_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__cos_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__flat_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__glass_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_hard_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_soft_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'

OPTIX_ERROR_PIPELINE_LINK_ERROR: Optix call 'optixPipelineCreate( state.context, &state.modules.pipelineCompileOptions(), &pipeline_link_options, program_groups.data(), program_groups.size(), log, &sizeof_log, &state.pipeline )' failed: c:\users\sulej\documents\visual studio 2017\projects\optix\cppsharpoptix7\pathtracer.cpp:2588)
Log:
COMPILE ERROR: 
Error: Symbol '__anyhit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_transparency_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__blurred_dot_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__cos_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__flat_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__glass_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_hard_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_soft_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'

[ 2][COMPILE FEEDBACK]: COMPILE ERROR: 
Error: Symbol '__anyhit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_transparency_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__blurred_dot_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__cos_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__flat_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__glass_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_hard_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_soft_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'

OPTIX_ERROR_PIPELINE_LINK_ERROR: Optix call 'optixPipelineCreate( state.context, &state.modules.pipelineCompileOptions(), &pipeline_link_options, program_groups.data(), program_groups.size(), log, &sizeof_log, &state.pipeline )' failed: c:\users\sulej\documents\visual studio 2017\projects\optix\cppsharpoptix7\pathtracer.cpp:2588)
Log:
COMPILE ERROR: 
Error: Symbol '__anyhit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__occlusion_transparency_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__blurred_dot_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__cos_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__diffuse_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__flat_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__glass_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_hard_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__light_soft_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'
Error: Symbol '__closesthit__radiance__reflective_masked_0xb614949e7d10947' was defined multiple times. First seen in: '__closesthit__occlusion_and_12_more_6240569349103738604'

...

If I exclude the "mat" parameter from the set_data() method, it runs.

Do you have any suggestions on this?

Thanks!

robertsulej commented 4 years ago

Hi Riccardo,

Thanks for reporting. I need to check includes in shaders code. The error message points to that part. Good that OptiX is now verbose on this kind of problems. I'll let you know, likely tomorrow.

robertsulej commented 4 years ago

Could you, please, let me know the plotoptix and nvidia driver versions you are running? I can't reproduce the problem on linux and windows, with 2070 and 1060 boards. Also the shader compilation looks right, however this problem was present in earlier linux release (one of the first after the transition to OptiX 7, I think).

riccardomarin commented 4 years ago

Sure. I am on Windows 10. plotoptix==0.10.1 GPU: RTX 2080 Ti Driver: 460.15 I have both Cuda 10.0 and 10.1.

robertsulej commented 4 years ago

Ok, thanks!

There is a potential reason: OptiX compilation cache is not invalidated correctly after updates done with pip. Please, try deleting the folder %LOCALAPPDATA%\NVIDIA\OptixCache. If this helps I'll find a way to remove old compiled shaders when updating plotoptix.

riccardomarin commented 4 years ago

Great, it works! :D 👍🏼

test_hand obj

robertsulej commented 4 years ago

Super. Next release (this weekend I hope) will not make such problems.

robertsulej commented 4 years ago

OK, the fix is in place in the new release.