Created
January 5, 2019 10:23
-
-
Save cecilemuller/a864731ad7909f727b166e501bb86cf3 to your computer and use it in GitHub Desktop.
Marmoset Toolbag: Get Shader ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There is no easy way to identify a shader from a MaterialSubroutine, | |
# so this tries to guess from the list of fields. | |
# | |
# However it cannot distinguish between: | |
# - "Lambertian" or "Unlit" | |
# - "Horizon Occlusion" or "Mirror" or "Blinn-Phong" | |
def getShaderId(material, subroutineId): | |
subroutine = material.getSubroutine(subroutineId) | |
if subroutine == None: | |
return "" | |
shaderFields = ",".join(subroutine.getFieldNames()) | |
if subroutineId == "albedo": | |
if shaderFields == "Albedo Map,Color": | |
return "Albedo" | |
elif shaderFields == "Albedo Map,Color,Vertex Color,sRGB Color,Vertex Alpha": | |
return "Vertex Color" | |
elif shaderFields == "Color Map,Detail Mask,Channel;detailMask,Diffuse/Fresnel Mask,Channel;diffFresnelMask,Metalness Mask,Channel;metalnessMask,Self-Illumination Mask,Channel;selfIllumMask,Self Illumination,Detail Map,Detail Strength,Detail Tile,Fresnel Warp,Fresnel Color Warp": | |
return "Dota Color" | |
elif subroutineId == "diffusion": | |
if shaderFields == "": | |
# Can't guess, but Lambertian is more likely | |
# return "Unlit" | |
return "Lambertian" | |
elif shaderFields == "Fuzz Map,Fuzz,Fuzz Color,Fuzz Scatter,Fuzz Occlusion,Mask Fuzz with Gloss": | |
return "Microfiber" | |
elif shaderFields == "Scatter Map,Scatter Depth (mm),Scatter Color,Translucency Map,Translucency,Translucency Color,Translucency Depth (mm),Translucency Scatter,Fuzz Map,Fuzz,Fuzz Color,Mask Fuzz with Gloss": | |
return "Subsurface Scatter" | |
elif shaderFields == "Diffuse Warp": | |
return "Dota Diffuse" | |
elif subroutineId == "displacement": | |
if shaderFields == "Displacement Map,Scale,Scale Center,Relative Scale": | |
return "Height" | |
elif shaderFields == "Displacement Map,Tangent Space,Flip X,Flip Y,Flip Z,Scale,Scale Center,Relative Scale": | |
return "Vector" | |
elif subroutineId == "emissive": | |
if shaderFields == "Emissive Map,Color,Intensity,UV Set,Glow": | |
return "Emissive" | |
elif shaderFields == "Heat Map,Intensity,Temperature (K),Minimum Temperature (K)": | |
return "Heat" | |
elif shaderFields == "Fluorescence Map,Color,Strength": | |
return "Fluorescent" | |
elif subroutineId == "microsurface": | |
if shaderFields == "Gloss Map,Channel,Gloss,Invert": | |
return "Gloss" | |
elif shaderFields == "Roughness Map,Channel,Roughness,Invert;roughness": | |
return "Roughness" | |
elif shaderFields == "Microsurface Map,Channel,Mode,Maximum,Minimum,Exponent,Horizon Smoothing": | |
return "Advanced Micro" | |
elif subroutineId == "occlusion": | |
if shaderFields == "Occlusion Map,Channel;occlusion,Occlusion,UV Set,Vertex Channel,Cavity Map,Channel;cavity,Diffuse Cavity,Specular Cavity": | |
return "Occlusion" | |
elif subroutineId == "reflection": | |
if shaderFields == "Horizon Occlusion": | |
# Can't guess, but GGX is most likely | |
# return "Mirror" | |
# return "Blinn-Phong" | |
return "GGX" | |
elif shaderFields == "Horizon Occlusion,Direction Map,Scale & Bias,Swap X/Y Direction,Anisotropy,Anisotropy Direction": | |
return "Anisotropic" | |
elif subroutineId == "reflectivity": | |
if shaderFields == "Specular Map,Channel;specular,Intensity,Color,Fresnel,Fresnel Color,Conserve Energy": | |
return "Specular" | |
elif shaderFields == "Metalness Map,Channel,Metalness,Invert": | |
return "Metalness" | |
elif shaderFields == "Metalness Map,Channel,Metalness,Invert,Specular Level Map,Channel;advMtlMask,Specular,Invert,Specular Curve": | |
return "Adv. Metalness" | |
elif shaderFields == "Index Map,Index,Index Hue,Extinction,Extinction Hue": | |
return "Refractive Index" | |
elif shaderFields == "Specular Mask,Channel;specMask,Rimlight Mask,Channel;rimMask,Tint Mask,Channel;tintMask,Specular Exponent;map,Channel;expMask,Specular Exponent,Specular Scale,Specular Tint,Rim Light Scale,Rim Light Tint": | |
return "Dota Specular" | |
elif subroutineId == "secondaryReflection": | |
if shaderFields == "Horizon Occlusion,Secondary Intensity,Secondary Intensity Color,Secondary Fresnel,Secondary Fresnel Color": | |
return "Mirror" | |
elif shaderFields == "Horizon Occlusion,Secondary Gloss,Secondary Intensity,Secondary Intensity Color,Secondary Fresnel,Secondary Fresnel Color": | |
return "Blinn-Phong" | |
elif shaderFields == "Horizon Occlusion,Secondary Gloss,Secondary Intensity,Secondary Intensity Color,Secondary Fresnel,Secondary Fresnel Color": | |
return "GGX" | |
elif shaderFields == "Horizon Occlusion,Secondary Gloss,Secondary Intensity,Secondary Intensity Color,Secondary Fresnel,Secondary Fresnel Color,Direction Map,Scale & Bias,Swap X/Y Direction,Anisotropy,Anisotropy Direction,Refraction Shift": | |
return "Anisotropic" | |
elif shaderFields == "Thickness Map,Strength,Film Thickness (nm),Minimum Thickness (nm)": | |
return "Newton's Rings" | |
elif subroutineId == "subdivision": | |
if shaderFields == "Tessellation": | |
return "Flat" | |
elif shaderFields == "Tessellation,Smoothing": | |
return "PN Triangles" | |
elif subroutineId == "surface": | |
if shaderFields == "Normal Map,Scale & Bias,Flip X,Flip Y,Flip Z,Object Space": | |
return "Normals" | |
elif shaderFields == "Normal Map,Scale & Bias,Flip X,Flip Y,Flip Z,Object Space,Detail Normal Map,UV Set,Scale & Bias;detail,Flip X;detail,Flip Y;detail,Flip Z;detail,Detail Tiling,Detail Offset,Detail Weight Map,Channel;detail,Detail Weight": | |
return "Detail Normals" | |
elif shaderFields == "Normal Map,Scale & Bias,Flip X,Flip Y,Flip Z,Object Space,Height Map,Channel,Depth,Depth Center": | |
return "Parallax" | |
elif subroutineId == "transparency": | |
if shaderFields == "Use Albedo Alpha,Alpha Map,Channel,Alpha,Threshold": | |
return "Cutout" | |
elif shaderFields == "Use Albedo Alpha,Alpha Map,Channel,Alpha": | |
return "Dither" | |
elif shaderFields == "Use Albedo Alpha,Alpha Map,Channel,Alpha,Tint,Include Diffuse": | |
return "Add" | |
elif shaderFields == "Index of Refraction,Distant Background,Use Microsurface,Tint,Albedo Tint,Caustics,Mask,Channel;mask,Cutout,Channel;cutout,Use Albedo Alpha,Use Dither": | |
return "Refraction" | |
return "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment