New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blend Mode property only uses blend_v1000 property #363

Closed
tngreene opened this Issue Jul 20, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@tngreene
Copy link
Collaborator

tngreene commented Jul 20, 2018

Steps to reproduce:

  1. Create a new Blend file
  2. Set the version to v11 or higher (or just let the default which by now is greater than v11 be fine)
  3. Create a cube and material
  4. Set the material's Blend Mode to "Alpha Cutoff" or "Alpha Shadow".

Expected:
'ATTR_no_blend' or 'ATTR_shadow_blend' (respectively) will be used, along with other related ATTRs.

Got:
'ATTR_blend' or whatever blend_v1000 has in it.

Explanation:
This comes from the tricky thing we tried to do with blend_v1000 and blend_v1100 (a superset of BLEND_GLASS and blend_v1000). We'd selectively show the user the relevant property based on the version.

blend_v1100 appears in 6110c94, 1 year ago (6/27/2017 9:41:55 PM)
The ill-fated insufficient check appears in xplane_material.py, line 124-138 c3091a5, 1 year ago (6/20/2017 11:33:41 AM)

    if xplane_version >= 1000:
         xplane_blend_enum = mat.xplane.blend_v1000
 
    if xplane_version >= 1000:
         if xplane_blend_enum == BLEND_OFF:
             self.attributes['ATTR_no_blend'].setValue(mat.xplane.blendRatio)
         elif xplane_blend_enum == BLEND_ON:
             self.attributes['ATTR_blend'].setValue(True)
         elif xplane_blend_enum == BLEND_SHADOW:
             self.attributes['ATTR_shadow_blend'].setValue(True)
     elif xplane_version < 1000:
         if mat.xplane.blend:
             self.attributes['ATTR_no_blend'].setValue(mat.xplane.blendRatio)
         else:
             self.attributes['ATTR_blend'].setValue(True)

As you can see xplane_blend_enum will only ever be the value from mat.xplane.blend_v1000. Either an old value, or the default for blend_v1000, Alpha Blend, which is the same default for v11, further contributing to why no body saw this.
And, without actually opening every Blend File and looking at every texture, looking at the documentatoin about our material tests, it appears non of our tests test if the Blend Property is written out correctly
except BLEND_GLASS, which is affected by a different code path.

@tngreene tngreene self-assigned this Jul 20, 2018

@tngreene

This comment has been minimized.

Copy link
Collaborator

tngreene commented Jul 20, 2018

Solution:
We could either fix the above code snippet and carefully inspect the code base for any additional problems related to blend_v1000 vs blend_v1100 or do what we did with manipulator types, take out type_v1100 and make type a dynamic enum.

We can use the updater to copy over user's values to the dynamic enum and not have to deal with any such issue in the future. Given that we're about to increment from 3.4 to 3.5 this could be a good time to do so.

@tngreene

This comment has been minimized.

Copy link
Collaborator

tngreene commented Jul 20, 2018

In the mean time for anyone dealing with this, you can still be productive with this work around:

  1. Temporarily set the version to "10.x"
  2. Change the blend mode on your materials
  3. Change back to "11.x" or whatever you were using.

Alternatively, you can use the console to avoid having to switch between export versions.

Alpha Cutoff
bpy.data.materials['My Material Name'].xplane.blend_v1000 = 'off'

Alpha Shadow
bpy.data.materials['My Material Name'].xplane.blend_v1000 = 'shadow'

@bsupnik

This comment has been minimized.

Copy link
Collaborator

bsupnik commented Jul 20, 2018

@tngreene To confirm, the v11 blend property has never been correctly written to an export? Like, it's been broken in export from the day of its inception?

@tngreene

This comment has been minimized.

Copy link
Collaborator

tngreene commented Jul 24, 2018

Update path:

  • Copy BLEND_GLASS to new checkbox. 6721c97
  • Delete blend_v1100 6721c97
  • Add to updater log

- [x] Also to implement and test, BLEND_GLASS is only for Aircraft objects. Turns out we already had this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment