XPlane2Blender icon indicating copy to clipboard operation
XPlane2Blender copied to clipboard

Always apply GLOBAL_specular 1.0 when NORMAL texture given

Open tngreene opened this issue 5 years ago • 1 comments

Since the NORMAL texture is supplying its own specularity, we want to make sure the OBJ default is to not mess with it and always return to 1.0 for the 1% of people who want to change the specular level of an object with a normal texture.

If has TEXTURE_NORMAL and GLOBAL_specular != 1.0:
    write GLOBAL_specular 1.0

TEXTURE_DRAPED_NORMAL has "non-stupid" defaults and doesn't need this protection.

XPlane2Blender 2.49 shows this behavior with

           if tex_exists(core+"_NML.png"): self.file.write("TEXTURE_NORMAL %s%s_NML.png\nGLOBAL_specular 1.0\n" % (self.prefix,core))

We get this a little correct by inserting this after NORMAL_METALNESS is active

        if xplane_version >= 1100 and self.xplaneFile.referenceMaterials[0]:
            mat = self.xplaneFile.referenceMaterials[0]
            if mat.getEffectiveNormalMetalness():
                self.attributes['GLOBAL_specular'].setValue(1.0)
                self.xplaneFile.commands.written['ATTR_shiny_rat'] = 1.0 # Here we are fooling ourselves
                write_user_specular_values = False #It will be skipped from now on

but it should be for more than NORMAL_METALNESS

tngreene avatar Aug 20 '19 16:08 tngreene

We'll need a unit test for this behavior, but this also affects #443 for what we should be testing for. Therefore I'm giving it the 249 bug label and also scheduled for v3.5.1-beta.2

tngreene avatar Aug 20 '19 16:08 tngreene