private static double[] GetFactors(GrayType gray_type) { switch (gray_type) { case GrayType.AVERAGE: return(new double [] { 0.0, 1.0, 1.0, 1.0 }); case GrayType.LUMINACE: return(new double [] { 0.0, 0.2126, 0.7152, 0.0722 }); // http://en.wikipedia.org/wiki/Luma_(video) case GrayType.LUMINOSITY: return(new double [] { 0.0, 0.299, 0.587, 0.114 }); // http://en.wikipedia.org/wiki/Luminosity case GrayType.ALFACHANNEL: return(new double [] { 1.0, 0.0, 0.0, 0.0 }); case GrayType.REDCHANNEL: return(new double [] { 0.0, 1.0, 0.0, 0.0 }); case GrayType.GREENCHANNEL: return(new double [] { 0.0, 0.0, 1.0, 0.0 }); case GrayType.BLUECHANNEL: return(new double [] { 0.0, 0.0, 0.0, 1.0 }); default: throw new Exception("Unimplemented color"); } }
private static float[] GetFactors( GrayType gray_type) { switch (gray_type) { case GrayType.AVERAGE: return(new float [] { 0.0f, 1.0f, 1.0f, 1.0f }); case GrayType.LUMINACE: return(new float [] { 0.0f, 0.2126f, 0.7152f, 0.0722f }); // http://en.wikipedia.org/wiki/Luma_(video) case GrayType.LUMINOSITY: return(new float [] { 0.0f, 0.299f, 0.587f, 0.114f }); // http://en.wikipedia.org/wiki/Luminosity case GrayType.ALFACHANNEL: return(new float [] { 1.0f, 0.0f, 0.0f, 0.0f }); case GrayType.REDCHANNEL: return(new float [] { 0.0f, 1.0f, 0.0f, 0.0f }); case GrayType.GREENCHANNEL: return(new float [] { 0.0f, 0.0f, 1.0f, 0.0f }); case GrayType.BLUECHANNEL: return(new float [] { 0.0f, 0.0f, 0.0f, 1.0f }); default: throw new Exception("Unkown gray type"); } }
static void SetMaterialKeywords(Material material, WorkflowMode workflowMode) { // Note: keywords must be based on Material value not on MaterialProperty due to multi-edit & material animation // (MaterialProperty value might come from renderer material property block) SetKeyword(material, "_NORMALMAP", material.GetTexture("_BumpMap") || material.GetTexture("_DetailNormalMap")); if (workflowMode == WorkflowMode.Specular) { SetKeyword(material, "_SPECGLOSSMAP", material.GetTexture("_SpecGlossMap")); } else if (workflowMode == WorkflowMode.Metallic) { SetKeyword(material, "_METALLICGLOSSMAP", material.GetTexture("_MetallicGlossMap")); } SetKeyword(material, "_PARALLAXMAP", material.GetTexture("_ParallaxMap")); SetKeyword(material, "_DETAIL_MULX2", material.GetTexture("_DetailAlbedoMap") || material.GetTexture("_DetailNormalMap")); // A material's GI flag internally keeps track of whether emission is enabled at all, it's enabled but has no effect // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color. // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color. MaterialEditor.FixupEmissiveFlag(material); bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); if (material.HasProperty("_SmoothnessTextureChannel")) { SetKeyword(material, "_SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A", GetSmoothnessMapChannel(material) == SmoothnessMapChannel.AlbedoAlpha); } GrayType gray = (GrayType)material.GetInt("_Gray"); SetKeyword(material, "_GRAY_DOT", gray == GrayType.Dot); SetKeyword(material, "_GRAY_MAX", gray == GrayType.Max); }
public FunctionColorToUInt16Gray(GrayType gray_type) : this(GetFactors(gray_type)) { }
public FunctionColorToFloat32Gray( GrayType gray_type) : this(GetFactors(gray_type)) { }