Skip to content

Fixed compatibility with Blender version 4.3#8

Open
hentila wants to merge 1 commit intoEatTheFuture:masterfrom
hentila:master
Open

Fixed compatibility with Blender version 4.3#8
hentila wants to merge 1 commit intoEatTheFuture:masterfrom
hentila:master

Conversation

@hentila
Copy link
Copy Markdown

@hentila hentila commented Jan 2, 2025

mat.shadow_method is removed from Blender 4.3

mat.shadow_method is removed from Blender 4.3
@hentila
Copy link
Copy Markdown
Author

hentila commented Jan 2, 2025

Fixes #7

mat = bpy.data.materials.new(name)
mat.use_nodes = True
mat.blend_method = 'HASHED'
mat.shadow_method = 'HASHED'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of removing this, you could create a function that will work in both environments:

def _set_hashed_shadow(mat):
    """
    Make a material cast alpha‑hashed (dithered) shadows on
    every Blender version that still supports the add‑on.
    """
    if hasattr(mat, "shadow_method"):                       # Blender 2.8 – 3.6
        mat.shadow_method = 'HASHED'
    elif hasattr(mat, "surface_render_method"):             # Blender 4.0 +
        # ‘DITHERED’ == hashed transparency in Eevee‑Next
        mat.surface_render_method = 'DITHERED'

Than call that in place of the removed line. This seems to work as far as 5.0.

@marklio
Copy link
Copy Markdown

marklio commented Jul 21, 2025

@hentila I have a comment with a backwards-compatible replacement that seems to work (although I'm unfamiliar with common approaches for this kind of breaking change in blender add-ons. There may be a better pattern I'm unaware of.

@cessen For the record, this change gets things working (seemingly) as far as the current 5.0 alphas. I'd love to see this concrete issue fixed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants