Skip to content

Commit

Permalink
Merge pull request #644 from zNightlord/fix-mcmodel-mat-desat
Browse files Browse the repository at this point in the history
Fix block model leaves vegetation not doing saturated color
  • Loading branch information
StandingPadAnimations authored Dec 24, 2024
2 parents 0d0bf91 + 4e55407 commit 6c30be5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions MCprep_addon/materials/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def get_mc_canonical_name(name: str) -> Tuple[str, Optional[Form]]:
# mixed up with the new "water": "painting/water" texture.
general_name = "water_still"

if "_stem" in general_name:
# For melon/pumpkin stem stage map to only melon_stem/pumpkin_stem
general_name = general_name.rsplit("_", 1)[0]

if general_name in env.json_data["blocks"]["block_mapping_mc"]:
canon = env.json_data["blocks"]["block_mapping_mc"][general_name]
form = "mc" if not jmc_prefix else "jmc2obj"
Expand Down
11 changes: 8 additions & 3 deletions MCprep_addon/spawner/mcmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ def add_element(
return verts, edges, faces


def add_material(
def add_get_material(
name: str = "material", path: str = "", use_name: bool = False
) -> Optional[Material]:
"""Creates a simple material with an image texture from path."""
"""Creates or get an existing created simple material with an image texture from path."""
engine = bpy.context.scene.render.engine
mat = bpy.data.materials.get(name)
if mat:
return mat

# Create the base material node tree setup
mat, err = generate.generate_base_material(bpy.context, name, path, False)
Expand Down Expand Up @@ -302,7 +305,9 @@ def add_model(
for img in textures:
if img != "particle":
tex_pth = locate_image(bpy.context, textures, img, model_filepath)
mat = add_material(f"{obj_name}_{img}", tex_pth, use_name=False)
# For json file only use 1 material for all faces
name = f"{obj_name}" if (len(textures) < 3) else f"{obj_name}_{img}"
mat = add_get_material(name, tex_pth, use_name=False)
obj_mats = obj.data.materials
if f"#{img}" not in materials:
obj_mats.append(mat)
Expand Down

0 comments on commit 6c30be5

Please sign in to comment.