Skip to content
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

Double Sided per Material #280

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

DoobesURU
Copy link
Contributor

This is my WIP solution to issue #255 . The goal is to give the Age builder the option to set double-sided by material instead of by entire objects.

To do:

  • Fix toolbar buttons so they can work with the new Plasma material panel option, which isn't working yet, probably due to multiple materials being on objects and multiple users of materials.
  • Fix an issue where the exporter runs into lighting_mod.unleashed .
  • Possible conversion option to bring mesh double sided over to new material double sided, whether automatically or manually via button.

Again, this is my (admittedly clumsy) attempt to fix this issue as I believe it aligns more with how Cyan's plugin did things based on observations. It would keep extra materials from being needlessly set to TWOSIDE and possibly be a slight improvement in performance.

@DoobesURU DoobesURU marked this pull request as draft August 20, 2021 15:39
@@ -174,33 +174,33 @@ def execute(self, context):


class PlasmaToggleDoubleSidedOperator(ToolboxOperator, bpy.types.Operator):
bl_idname = "mesh.plasma_toggle_double_sided"
bl_idname = "mat.plasma_toggle_double_sided"
Copy link
Member

Choose a reason for hiding this comment

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

Blender uses bpy.ops.material for material operators instead of bpy.ops.mat.

Comment on lines 200 to 203
mat_list = [i.data for i in context.selected_objects if i.type == "MATERIAL"]
enable = not all((mat.plasma_mat.plasma_double_sided for mat in mat_list))
for mat in mat_list:
mat.plasma_mat.plasma_double_sided = enable
Copy link
Member

@Hoikas Hoikas Aug 20, 2021

Choose a reason for hiding this comment

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

Unfortunately, MATERIAL isn't a valid object type. It might be easier for us to chain the material slots, so something like...

        mat_list = [slot.material for slot in itertools.chain.from_iterable((i.material_slots for i in context.selected_objects)) if slot and slot.material]

(Warning: untested)

korman/properties/prop_material.py Outdated Show resolved Hide resolved
korman/ui/ui_material.py Outdated Show resolved Hide resolved
korman/ui/ui_material.py Outdated Show resolved Hide resolved
korman/properties/prop_material.py Outdated Show resolved Hide resolved
Copy link
Member

@Hoikas Hoikas left a comment

Choose a reason for hiding this comment

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

Cope with some rename changes.

korman/operators/op_toolbox.py Outdated Show resolved Hide resolved
korman/operators/op_toolbox.py Outdated Show resolved Hide resolved
korman/operators/op_toolbox.py Outdated Show resolved Hide resolved
korman/properties/prop_material.py Outdated Show resolved Hide resolved
@Jrius
Copy link
Collaborator

Jrius commented Aug 26, 2021

Sorry for being late to the party, but maybe this could tie into material.game_settings.use_backface_culling ? (Either keep both in sync, or rely on it instead of a new property.)
Note that theoretically, material.game_settings.use_backface_culling is specific to the Blender Game renderer (and the relevant UI toggle is hidden if you select another renderer). The reason I'm mentioning it is that it DOES make the material two-sided in the textured view for the Blender Internal/Korman renderers.

@Hoikas
Copy link
Member

Hoikas commented Aug 26, 2021

That sounds like a good idea, but isn't BGE gone in Blender 2.80 and above?

@Deledrius
Copy link
Member

That sounds like a good idea, but isn't BGE gone in Blender 2.80 and above?

One way or another, that's irrelevant for Korman, I assume.

@Jrius
Copy link
Collaborator

Jrius commented Aug 27, 2021

Blender 2.80 moved the use_backface_culling property directly into the material class, but it still works the same.

@Hoikas
Copy link
Member

Hoikas commented Aug 27, 2021

Will 2.80 migrate the old BGE property into the materials for us? I'd like to future proof this as much as possible now so that there are no surprises an unknown amount of time in the future.

@Jrius
Copy link
Collaborator

Jrius commented Aug 27, 2021

Unfortunately it's not migrated. Good catch.
Furthermore, all materials created in 2.80 are now two-sided by default (probably because unlike Eevee, Cycles is unable to do backface culling), which means pretty much everyone will forget to reenable that checkbox at some point when creating stuff in 2.80, which is bad practice.
So I guess it's better to have our own dedicated property, which will correctly migrate when upgrading and have a sane default value for new materials. If we can still sync use_backface_culling to our property for better viewport display, all the better, but it's not a huge priority.

...With that said, Blender 2.80 wipes clean materials from 2.79 anyway (save for custom props). So upgrading older files will require a custom operator/utility to convert existing materials to the equivalent Korman will use in 2.80.

DoobesURU and others added 5 commits October 13, 2022 12:57
Start of Plasma Material Panel additions
Adjusts the Toolbox Double Sided Button Operators to use new material panel toggle for double sided.
More adjustments to get the dang thing working
Added suggestions from Hoikas
Puts in suggestions from Hoikas.

Co-authored-by: Adam Johnson <AdamJohnso@gmail.com>
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.

None yet

4 participants