Error While Importing

Issue #134 closed
arrrtie created an issue

I’m not sure if this is the correct place to come for support, but this is where the video I found suggested. I’m getting the following errors when trying to upload from Daz. Any thoughts or assistance in what I’ve done wrong or what the issue may be would be very appreciated!

bpy.context.space_data.system_bookmarks_active = 1
Modules Installed (import-daz) from 'C:\Users\arrrt\OneDrive\Desktop\import-daz-v1.4.2-20200623.zip' into 'C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons'
bpy.context.scene.DazShowPaths = True
bpy.context.scene.DazShowSettings = True
bpy.context.scene.DazShowSettings = False
bpy.context.scene.DazNumPaths = 5
bpy.context.scene.DazPath4 = "D:\OneDrive\Documents\DAZ 3D\Studio\My Library"
bpy.context.scene.DazPath5 = "D:\OneDrive\Documents\DAZ 3D\Studio\My Daz Connect Library"
bpy.context.scene.DazShowRiggingSettings = True
bpy.context.scene.DazShowRiggingSettings = False
bpy.context.scene.DazShowSettings = True
bpy.context.scene.DazShowSettings = False
bpy.context.space_data.recent_folders_active = 1
bpy.context.scene.DazPath2 = "C:\Users/Public/Documents/My DAZ 3D Library"
bpy.context.scene.DazPath3 = "C:\Program Files/DAZ 3D/DAZStudio4/shaders/iray"
bpy.context.scene.DazPath1 = "D:\OneDrive\Documents\DAZ 3D\Studio\My Daz Connect Library"
Traceback (most recent call last):
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\error.py", line 246, in execute
self.run(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\daz.py", line 47, in run
getMainAsset(self.filepath, context, self)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\main.py", line 80, in getMainAsset
asset.build(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\cycles.py", line 99, in build
self.tree.build(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\cycles.py", line 272, in build
self.buildLayer(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\pbr.py", line 62, in buildLayer
self.buildPBRNode(scn)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\pbr.py", line 159, in buildPBRNode
color,reftex = self.getColorTex("getChannelGlossySpecular", "COLOR", WHITE, True, useTex)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\cycles.py", line 525, in getColorTex
value = self.material.getChannelColor(channel, default)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\material.py", line 388, in getChannelColor
return self.srgbToLinear(color)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\material.py", line 400, in srgbToLinear
l = round(s**2.2, 6)
TypeError: type complex doesn't define round method

location: <unknown location>:-1

Traceback (most recent call last):
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\error.py", line 246, in execute
self.run(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\daz.py", line 47, in run
getMainAsset(self.filepath, context, self)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\main.py", line 80, in getMainAsset
asset.build(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\cycles.py", line 99, in build
self.tree.build(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\cycles.py", line 272, in build
self.buildLayer(context)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\pbr.py", line 62, in buildLayer
self.buildPBRNode(scn)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\pbr.py", line 159, in buildPBRNode
color,reftex = self.getColorTex("getChannelGlossySpecular", "COLOR", WHITE, True, useTex)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\cycles.py", line 525, in getColorTex
value = self.material.getChannelColor(channel, default)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\material.py", line 388, in getChannelColor
return self.srgbToLinear(color)
File "C:\Users\arrrt\AppData\Roaming\Blender Foundation\Blender\2.82\scripts\addons\import-daz\material.py", line 400, in srgbToLinear
l = round(s**2.2, 6)
TypeError: type complex doesn't define round method

location: <unknown location>:-1

Comments (6)

  1. Thomas Larsson repo owner

    Weird bug. I guess that the srgb value s for some reason is negative, so the 2.2:th power becomes complex. This should not happen. Replaced s by abs(s) to make sure that complex numbers do not appear.

  2. Alessandro Padovani

    I’m a bit rusty on math but I don’t get how the power of a negative number gives a complex number. I mean for example -0.5 ** 2.2 is just about 0.218. Then I agree s shouldn’t be negative anyway. Though it does appear that negative colors can be defined in daz studio if I remove limits but this is unexplored ground for me.

  3. Alessandro Padovani

    It seems cycles doesn’t allow to input negative colors. If I try it is clamped to zero. We can input colors greater than 1 though. I don’t know if this is a limit in cycles or a limit in the color picker. May be via script we can set negative colors.

    Or may be we should clamp the negative values as the color picker does, instead of keeping the absolute value.

  4. Alessandro Padovani

    It seems if I try to input negative colors via script it doesn’t work either they’re clamped to zero. So below is what I’d propose to handle negative colors.

    # below there's the correct linear function used by cycles
    #
    #     if s < 0.04045:
    #         l = s/12.92
    #     else:
    #         l = ((s+0.055)/1.055)**2.4
    #
    # to read the duf colors we use the gamma 2.2 approximation used by iray
    def srgbToLinear(self, srgb):
        lin = []
        for s in srgb:
            # negative colors are not supported
            if s < 0:
                l = 0
            else:
                l = s**2.2
            # daz studio limits the color precision so we do the same
            lin.append(round(l, 6))
        return Vector(lin)
    

  5. Thomas Larsson repo owner

    The last commit truncates s at 0 as suggested.

    Alessandro, -1 = exp(pi*i), so (-1)**2.2 = exp(2.2*pi*i) = exp(2*pi*i)*exp(0.2*pi*i) = 1*(cos(0.2*pi) + i sin(0.2*pi))

    Actually it is a multivalued function, since -1 = exp((pi+2*n*pi)*i) for all integers n.

  6. Log in to comment