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

Fix block model leaves vegetation not doing saturated color #644

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
zNightlord marked this conversation as resolved.
Show resolved Hide resolved
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
Loading