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

Support Octane Renderer (or create fitting materiels) #237

Closed
TheGreyDiamond opened this issue Aug 6, 2021 · 7 comments
Closed

Support Octane Renderer (or create fitting materiels) #237

TheGreyDiamond opened this issue Aug 6, 2021 · 7 comments
Labels
enhancement Feature requests or new functionality suggestions

Comments

@TheGreyDiamond
Copy link

Maybe add support for the octane renderer for Blender. This would improve my and others live a lot, because I have to manually change all materials.

@StandingPadAnimations
Copy link
Collaborator

While Octane support would be interesting, it's a pretty niche thing and not many people use it. However, MCprep is open-sourced so you can always make a Octane version of MCprep

@TheDuckCow
Copy link
Member

Indeed, there are a few different alt render engine requests that I have not been able to get to.

However, it may be that the "Sync materials" function inadvertently covers your needs. It would require a one-time setup of materials for the engine and a given resource pack, but then you can reuse it as many times after that in other files, so long as "sync materials" is ticked.

Let me know if you need more information than here: https://github.com/TheDuckCow/MCprep#sync-materials
I haven't made a video tutorial yet, but it's on my list to get to, as I see it's a seldom used but very powerful feature of MCprep.

@TheDuckCow TheDuckCow added user-troubleshoot enhancement Feature requests or new functionality suggestions and removed user-troubleshoot labels Sep 6, 2021
@StandingPadAnimations
Copy link
Collaborator

Alternatively, we could add an API to MCprep for prepping materials. I've mentioned something like this here: #149 (comment)

@StandingPadAnimations
Copy link
Collaborator

@TheGreyDiamond just curious, how does Octane handle node editing (as in does it has the same editor as Cycles and EEVEE but with it's own nodes?). Does Octane also support the image texture node Cycles users?

The main reason I'm asking is because I'm curious if the new custom default materials #274 will help your dilemma. It's not fully ready (since I have to change some stuff) but testing with Cycles and Radeon ProRender seems to show that it somewhat works

@TheGreyDiamond
Copy link
Author

Hey, I'll look into it, I've been very busy recently but I'll check that.

@StandingPadAnimations
Copy link
Collaborator

StandingPadAnimations commented Dec 21, 2023

With this issue, I'm not sure how we continue with reports like these. There's no easy way to support external engines beyond either hoping that they all have some level of Cycles nodes support, and adding support for every engine would be a huge undertaking for us.

@TheDuckCow should we keep issues related to external engines open (and then add that to the discussion at #500), or close them on the basis that implementing external engine support is more trouble for what it's worth? Personally, I'm fine with also measuring how much of the userbase actually uses external engines and applying the 5% threshold rule to decide, but let me know what are your thoughts on external engine support for MCprep.

@TheGreyDiamond I think the best route for now would be to fork MCprep and add support for Octane on your own (while we at upstream decide on what course of action to take). I know in the past, MCprep's material generation was... horrifying to say the least, but MCprep 3.5 massively improved on this front. Here's some reference you might find handy:

def matgen_cycles_simple(mat: Material, options: PrepOptions) -> Optional[bool]:
"""Generate principled cycles material."""
matGen = util.nameGeneralize(mat.name)
canon, form = get_mc_canonical_name(matGen)
image_diff = options.passes["diffuse"]
if not image_diff:
print(f"Could not find diffuse image, halting generation: {mat.name}")
return
elif image_diff.size[0] == 0 or image_diff.size[1] == 0:
if image_diff.source != 'SEQUENCE':
# Common non animated case; this means the image is missing and would
# have already checked for replacement textures by now, so skip.
return
if not os.path.isfile(bpy.path.abspath(image_diff.filepath)):
# can't check size or pixels as it often is not immediately avaialble
# so instead, check against firs frame of sequence to verify load
return
mat.use_nodes = True
animated_data = copy_texture_animation_pass_settings(mat)
nodes = mat.node_tree.nodes
links = mat.node_tree.links
nodes.clear()
nodeTexDiff = create_node(
nodes, "ShaderNodeTexImage",
name="Diffuse Texture",
label="Diffuse Texture",
location=(0, 0),
interpolation='Closest',
image=image_diff)
nodeSaturateMix = create_node(
nodes, "ShaderNodeMixRGB",
name="Add Color",
label="Add Color",
location=(300, 0),
blend_type='MULTIPLY',
mute=True,
hide=True)
principled = create_node(nodes, "ShaderNodeBsdfPrincipled", location=(600, 0))
node_out = create_node(nodes, "ShaderNodeOutputMaterial", location=(900, 0))
# Sets default reflective values
if options.use_reflections and checklist(canon, "reflective"):
principled.inputs["Roughness"].default_value = 0
else:
principled.inputs["Roughness"].default_value = 0.7
# Sets default metallic values
if options.use_reflections and checklist(canon, "metallic"):
principled.inputs["Metallic"].default_value = 1
if principled.inputs["Roughness"].default_value < 0.2:
principled.inputs["Roughness"].default_value = 0.2
else:
principled.inputs["Metallic"].default_value = 0
# Get MixRGB sockets
saturateMixIn = get_node_socket(nodeSaturateMix)
saturateMixOut = get_node_socket(nodeSaturateMix, is_input=False)
# Set values.
# Specular causes issues with how blocks look, so let's disable it.
nodeSaturateMix.inputs[saturateMixIn[0]].default_value = 1.0
principled.inputs["Specular IOR Level" if util.min_bv((4, 0, 0)) else "Specular"].default_value = 0
# Connect nodes.
links.new(nodeTexDiff.outputs[0], nodeSaturateMix.inputs[saturateMixIn[1]])
links.new(nodeSaturateMix.outputs[saturateMixOut[0]], principled.inputs[0])
links.new(principled.outputs["BSDF"], node_out.inputs[0])
if options.only_solid is True or checklist(canon, "solid"):
# faster, and appropriate for non-transparent (and refelctive?) materials
principled.distribution = 'GGX'
if hasattr(mat, "blend_method"):
mat.blend_method = 'OPAQUE' # eevee setting
else:
# non-solid (potentially, not necessarily though)
links.new(nodeTexDiff.outputs[1], principled.inputs["Alpha"])
if hasattr(mat, "blend_method"): # 2.8 eevee settings
if hasattr(mat, "blend_method"):
mat.blend_method = 'HASHED'
if hasattr(mat, "shadow_method"):
mat.shadow_method = 'HASHED'
if options.use_emission_nodes and options.use_emission:
inputs = [inp.name for inp in principled.inputs]
if 'Emission Strength' in inputs: # Later 2.9 versions only.
principled.inputs['Emission Strength'].default_value = 1
links.new(
nodeSaturateMix.outputs[saturateMixOut[0]],
principled.inputs["Emission Color" if util.min_bv((4, 0, 0)) else "Emission"])
# reapply animation data if any to generated nodes
apply_texture_animation_pass_settings(mat, animated_data)
# Graystyle Blending
if not checklist(canon, "desaturated"):
pass
elif not is_image_grayscale(image_diff):
pass
else:
env.log(f"Texture desaturated: {canon}", vv_only=True)
desat_color = env.json_data['blocks']['desaturated'][canon]
if len(desat_color) < len(nodeSaturateMix.inputs[saturateMixIn[2]].default_value):
desat_color.append(1.0)
nodeSaturateMix.inputs[saturateMixIn[2]].default_value = desat_color
nodeSaturateMix.mute = False
nodeSaturateMix.hide = False
# annotate special nodes for finding later, and load images if available
nodeTexDiff["MCPREP_diffuse"] = True
nodeSaturateMix["SATURATE"] = True
return 0

@StandingPadAnimations
Copy link
Collaborator

Alright since no follow up was given, and there really isn't a good way to add support (nor test) for 3rd party engines, I'll just close this and all issues related to 3rd party engines

@StandingPadAnimations StandingPadAnimations closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests or new functionality suggestions
Projects
None yet
Development

No branches or pull requests

3 participants