mkolar / maya-look-hookup

Maya shader network transfer
MIT License
3 stars 0 forks source link

Interface #3

Open mkolar opened 8 years ago

mkolar commented 8 years ago

Goal

Define what the final user experience should be.

Proposal

exporting shader

import maya.cmds as mc
from maya_look_hookup import export_shader

shaded_mesh = mc.ls(selection=True)[0]
output_file = 'some/path/to/file.ma'

export_shader(shaded_mesh, output_file)

hookup all start with

import maya.cmds as mc
from maya_look_hookup import hookup_shaders

hookup should be able to handle being passed mesh and shader in forms of file, single node or referenceNode which might contain multiple shaders or multiple meshes. And of course any combination of these and result should be the same. Animated mesh with shaders applied.

mesh_file = shader_file = 'some/path/to/file_anim.abc'
mesh_node = mc.ls(selection=True)[0]
mesh_ref = 'bob_animRN'

shader_file = 'some/path/to/file_look.ma'
shader_node = 'bob_look:body_mat'
shader_ref = 'bob_lookRN'

hookup_shaders(mesh_node, shader_node)
hookup_shaders(mesh_file, shader_node)
hookup_shaders(mesh_ref, shader_file)
# you get the jist ...

# It would also be nice to be able to pass just a mesh, or just a shader and hookup would try to 
# find it's counterpart in the scene based on the assignment data stored on the shaders.
hookup_shaders(shader_node)
hookup_shaders(mesh_node)

Additionally it would be nice to be able to provide force flag which would ignore the assignment stored on the shader and simply apply supplied shader to supplied mesh.

All of these should be fairly straightforward to implement and would provide a lot of flexibility

tokejepsen commented 8 years ago

Additionally it would be nice to be able to provide force flag which would ignore the assignment stored on the shader and simply apply supplied shader to supplied mesh.

Maybe have where the shader should be applied as a keyword argument, if nothing is supplied the shader tries to find its assignment?

hookup_shaders(shader_file, assignment=mesh) # assigns to the specified mesh.
hookup_shaders(shader_file) # tries to find meshes based on assignment stored.
mkolar commented 8 years ago

That's practically what I proposed, only I didn't give it the keyword, however I feel that force flag should be on top. If

hookup_shaders(shader_file, assignment=mesh) # throws error if mesh doesn't match the one stored in the shader
hookup_shaders(shader_file, assignment=mesh, force=True) # Applies shader to mesh, regardless whether it matches expected mesh or not.

Passing only shader should of course try to find and connect the correct mesh.

BigRoy commented 8 years ago

Using force that way would mean the hookup shader command would only work for a single mesh? I mean when forcing a set of shaders to multiple meshes (where the look contains multiple shaders) what's the expected behaviour?

I'd suspect that most of my saved looks for an asset would contain multiple shaders, e.g. for the body/skin, clothing, teeth, tongue, etc.

I think the trick here could be to allow an interface which loads the shaders as expected and can return the information of the "look" so that a TD could develop any suitable workaround, or even a force wrapper that'd behave as expected for them?

mkolar commented 8 years ago

hookup shader command would only work for a single mesh

Good point. That actually escaped me :)

interface which loads the shaders as expected and can return the information of the "look"

That sounds reasonable. It would be very difficult to try making it work on a supplied mesh/meshes considering there would be not information about how to map it.

In that case, let's first make sure we have all the functionality without the forece override and we can add that login in later on