# Path: mayaLib/shaderLib/base/shader_base.py
# class Shader_base():
#     """
#     Create general Shader
#     """
# 
#     def __init__(self, shader_name, shader_type='aiStandard'):
#         # create a shader
#         self.shader_name = shader_name
#         self.shader = pm.shadingNode(shader_type, asShader=True, name=shader_name)
# 
#         # create a shading group
#         self.shading_group = pm.sets(renderable=True, noSurfaceShader=True, empty=True, name=self.shader_name)
#         # connect shader to sg surface shader
#         pm.connectAttr(self.shader.outColor, self.shading_group.surfaceShader)
# 
#     def get_shader(self):
#         return self.shader
# 
#     def assign_shader(self, geo):
#         """
#         Assign Shader to selected objects
#         :param geo: geometry list (list)
#         :return:
#         """
#         pm.select(geo)
#         pm.hyperShade(assign=self.shader)
# 
#     def connect_color_texture(self, file_node, slot_name):
#         pm.connectAttr(file_node.outColor, '%s.%s' % (self.shader, slot_name))
# 
#     def connect_luminance_texture(self, file_node, slot_name):
#         file_node.alphaIsLuminance.set(True)
#         pm.connectAttr(file_node.outAlpha, '%s.%s' % (self.shader, slot_name))
# 
#     def connect_fresnel(self, file_node, slot_name):
#         file_node.alphaIsLuminance.set(True)
#         pm.connectAttr(file_node.outAlpha, '%s.%s' % (self.shader, slot_name))
# 
#     def connect_normal(self, file_node, slot_name):
#         # create bump_node
#         self.bump_node = pm.shadingNode("bump2d", asUtility=True)
#         self.bump_node.bumpInterp.set(1)
#         self.bump_node.aiFlipR.set(0)
#         self.bump_node.aiFlipG.set(0)
# 
#         # connect file_node to bump_node
#         file_node.alphaIsLuminance.set(True)
#         pm.connectAttr(file_node.outAlpha, self.bump_node.bumpValue)
# 
#         # connect bump_node to shader
#         pm.connectAttr(self.bump_node.outNormal, '%s.%s' % (self.shader, slot_name))
# 
# Path: mayaLib/shaderLib/utils/config.py



from mayaLib.shaderLib.base.shader_base import Shader_base
from mayaLib.shaderLib.utils import config
class aiStandard_shaderBase(Shader_base):
    """
    Create aiStandard shader
    """

    def __init__(self, shader_name, file_node_dict, shader_type='aiStandard'):
        """
        Create aiStandard shader
        :param shader_name: Geo or Texture set (String)
        :param file_node_dict: file node (instance)
        :param shader_type:
        """
        # init base class
        Shader_base.__init__(self, shader_name, shader_type=shader_type)
        self.shader = Shader_base.get_shader(self)
        self.shader.specularFresnel.set(True)

        # connect texture
        self.makeAiStandard(file_node_dict)

    def makeAiStandard(self, file_node):
        connect_diffuse = Shader_base.connect_color_texture
        connect_backlighting = Shader_base.connect_luminance_texture
        connect_specularColor = Shader_base.connect_color_texture
        connect_specularWeight = Shader_base.connect_luminance_texture
        connect_specularRoughness = Shader_base.connect_luminance_texture
        connect_fresnel = Shader_base.connect_fresnel
        connect_normal = Shader_base.connect_normal

        try:

# Path: mayaLib/shaderLib/base/shader_base.py
# class Shader_base():
#     """
#     Create general Shader
#     """
# 
#     def __init__(self, shader_name, shader_type='aiStandard'):
#         # create a shader
#         self.shader_name = shader_name
#         self.shader = pm.shadingNode(shader_type, asShader=True, name=shader_name)
# 
#         # create a shading group
#         self.shading_group = pm.sets(renderable=True, noSurfaceShader=True, empty=True, name=self.shader_name)
#         # connect shader to sg surface shader
#         pm.connectAttr(self.shader.outColor, self.shading_group.surfaceShader)
# 
#     def get_shader(self):
#         return self.shader
# 
#     def assign_shader(self, geo):
#         """
#         Assign Shader to selected objects
#         :param geo: geometry list (list)
#         :return:
#         """
#         pm.select(geo)
#         pm.hyperShade(assign=self.shader)
# 
#     def connect_color_texture(self, file_node, slot_name):
#         pm.connectAttr(file_node.outColor, '%s.%s' % (self.shader, slot_name))
# 
#     def connect_luminance_texture(self, file_node, slot_name):
#         file_node.alphaIsLuminance.set(True)
#         pm.connectAttr(file_node.outAlpha, '%s.%s' % (self.shader, slot_name))
# 
#     def connect_fresnel(self, file_node, slot_name):
#         file_node.alphaIsLuminance.set(True)
#         pm.connectAttr(file_node.outAlpha, '%s.%s' % (self.shader, slot_name))
# 
#     def connect_normal(self, file_node, slot_name):
#         # create bump_node
#         self.bump_node = pm.shadingNode("bump2d", asUtility=True)
#         self.bump_node.bumpInterp.set(1)
#         self.bump_node.aiFlipR.set(0)
#         self.bump_node.aiFlipG.set(0)
# 
#         # connect file_node to bump_node
#         file_node.alphaIsLuminance.set(True)
#         pm.connectAttr(file_node.outAlpha, self.bump_node.bumpValue)
# 
#         # connect bump_node to shader
#         pm.connectAttr(self.bump_node.outNormal, '%s.%s' % (self.shader, slot_name))
# 
# Path: mayaLib/shaderLib/utils/config.py



# Path: mayaLib/shaderLib/base/arnold.py
from mayaLib.shaderLib.base.shader_base import Shader_base
from mayaLib.shaderLib.utils import config

class aiStandard_shaderBase(Shader_base):
    """
    Create aiStandard shader
    """

    def __init__(self, shader_name, file_node_dict, shader_type='aiStandard'):
        """
        Create aiStandard shader
        :param shader_name: Geo or Texture set (String)
        :param file_node_dict: file node (instance)
        :param shader_type:
        """
        # init base class
        Shader_base.__init__(self, shader_name, shader_type=shader_type)
        self.shader = Shader_base.get_shader(self)
        self.shader.specularFresnel.set(True)

        # connect texture
        self.makeAiStandard(file_node_dict)

    def makeAiStandard(self, file_node):
        connect_diffuse = Shader_base.connect_color_texture
        connect_backlighting = Shader_base.connect_luminance_texture
        connect_specularColor = Shader_base.connect_color_texture
        connect_specularWeight = Shader_base.connect_luminance_texture
        connect_specularRoughness = Shader_base.connect_luminance_texture
        connect_fresnel = Shader_base.connect_fresnel
        connect_normal = Shader_base.connect_normal

        try:

            connect_diffuse(self, file_node[config.diffuse], slot_name='color')