2

I am not sure this is the best place the ask but here I go...

I am trying to render an image with the Pov ray addon for Blender 2.79b. When I do so, it just shows me an ugly checkerboard.

After some goofing around I clicked the info tab and it showed me this little message:

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\render.py", line 4147, in render
    self._export(scene, povPath, renderImagePath)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\render.py", line 3837, in _export
    write_pov(self._temp_file_in, scene, info_callback)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\render.py", line 3648, in write_pov
    shading.writeMaterial(using_uberpov, DEF_MAT_NAME, scene, tabWrite, safety, comments, uniqueName, materialNames, material)
  File "C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\shading.py", line 251, in writeMaterial
    if(t and t.use and validPath and
UnboundLocalError: local variable 'validPath' referenced before assignment

location: <unknown location>:-1

I don't really understand Python (or coding in general) unfortunately, so I don't want to touch anything until I understand it better.

Tyler
  • 23
  • 1
  • 5

1 Answers1

1

Open the file C:\Program Files\Blender Foundation\Blender\2.79\scripts\addons\render_povray\shading.py and replace lines

if material:
    special_texture_found = False
    for t in material.texture_slots:
        if t and t.use and t.texture is not None:
            if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE':
                validPath=True
        else:
            validPath=False
        if(t and t.use and validPath and
           (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha)):
            special_texture_found = True
            continue  # Some texture found

    if special_texture_found or colored_specular_found:
        # Level=1 Means No specular nor Mirror reflection
        povHasnoSpecularMaps(Level=1)

        # Level=3 Means Maximum Spec and Mirror
        povHasnoSpecularMaps(Level=3)

with the following code from the updated add-on for Blender 2.8. Make sure that the identation level is the same as in the original file.

if material:
    special_texture_found = False
    for t in material.texture_slots:
        if t and t.use and t.texture is not None:
            if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE':
                #validPath
                if(t and t.use and
                   (t.use_map_specular or t.use_map_raymir or t.use_map_normal or t.use_map_alpha)):
                    special_texture_found = True
                    continue  # Some texture found

    if special_texture_found or colored_specular_found:
        # Level=1 Means No specular nor Mirror reflection
        povHasnoSpecularMaps(Level=1)

        # Level=3 Means Maximum Spec and Mirror
        povHasnoSpecularMaps(Level=3)

The issue in the code is that the if-case if (t.texture.type == 'IMAGE' and t.texture.image) or t.texture.type != 'IMAGE': doesn't have an else case where validPath is set. If that case occurs, then validPath isn't initialized which results in the error you're experiencing.

  • Uh thanks I guess I will try it out. Is indentation how much space is in between lines? – Tyler Aug 04 '19 at 21:38
  • @Tyler How much space is in front of the line. You need as many blanks/spaces as there are dots in front of each line in the following screenshot: https://i.stack.imgur.com/1z1Dv.jpg –  Aug 04 '19 at 21:43
  • No problem. Please mark the answer as accepted using the check mark if it solved your problem. –  Aug 04 '19 at 22:20