public MaterialPropertyDescriptor[] GetProperties(MaterialEditor editor, object converterObject) { PropertyEditorCallback valueChangedCallback = () => editor.BuildEditor(); StandardMaterialValueConverter converter = (StandardMaterialValueConverter)converterObject; PropertyInfo modeInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.Mode, "Mode"); PropertyInfo cutoffInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.Cutoff, "Cutoff"); PropertyInfo metallicMapInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.MetallicGlossMap, "MetallicGlossMap"); PropertyInfo bumpMapInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.BumpMap, "BumpMap"); PropertyInfo parallaxMapInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.ParallaxMap, "ParallaxMap"); PropertyInfo occlusionMapInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.OcclusionMap, "OcclusionMap"); PropertyInfo emissionMapInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.EmissionMap, "EmissionMap"); PropertyInfo emissionColorInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.EmissionColor, "EmissionColor"); PropertyInfo detailMaskInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.DetailMask, "DetailMask"); PropertyInfo detailAlbedoMap = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.DetailAlbedoMap, "DetailAlbedoMap"); PropertyInfo detailNormalMap = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.DetailNormalMap, "DetailNormalMap"); // PropertyInfo uvSecondaryInfo = Strong.PropertyInfo((StandardMaterialValueConverter x) => x.UVSecondary); PropertyInfo texInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture, "Texture"); PropertyInfo colorInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Color, "Color"); PropertyInfo floatInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Float, "Float"); BlendMode mode = GetBlendMode(editor.Material); List <MaterialPropertyDescriptor> properties = new List <MaterialPropertyDescriptor>(); properties.Add(new MaterialPropertyDescriptor(converter, "Rendering Mode", RTShaderPropertyType.Float, modeInfo, new RuntimeShaderInfo.RangeLimits(), TextureDimension.None, valueChangedCallback)); properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _MainTex), "Albedo", RTShaderPropertyType.TexEnv, texInfo, new RuntimeShaderInfo.RangeLimits(), TextureDimension.Tex2D, null)); properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _Color), "Albedo Color", RTShaderPropertyType.Color, colorInfo, new RuntimeShaderInfo.RangeLimits(), TextureDimension.None, null)); if (mode == BlendMode.Cutout) { properties.Add(new MaterialPropertyDescriptor(converter, "Alpha Cutoff", RTShaderPropertyType.Range, cutoffInfo, new RuntimeShaderInfo.RangeLimits(0.5f, 0.0f, 1.0f), TextureDimension.None, null)); } properties.Add(new MaterialPropertyDescriptor(converter, "Metallic", RTShaderPropertyType.TexEnv, metallicMapInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, valueChangedCallback)); bool hasGlossMap = IsMetallicGlossMapSet(editor.Material); if (!hasGlossMap) { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _Metallic), "Metallic", RTShaderPropertyType.Range, floatInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 1.0f), TextureDimension.None, null)); if (StandardMaterialValueConverter.GetSmoothnessMapChannel(editor.Material) == StandardMaterialValueConverter.SmoothnessMapChannel.SpecularMetallicAlpha) { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _Glossiness), "Smoothness", RTShaderPropertyType.Range, floatInfo, new RuntimeShaderInfo.RangeLimits(0.5f, 0.0f, 1.0f), TextureDimension.None, null)); } else { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _GlossMapScale), "Smoothness", RTShaderPropertyType.Range, floatInfo, new RuntimeShaderInfo.RangeLimits(1.0f, 0.0f, 1.0f), TextureDimension.None, null)); } } else { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _GlossMapScale), "Smoothness", RTShaderPropertyType.Range, floatInfo, new RuntimeShaderInfo.RangeLimits(1.0f, 0.0f, 1.0f), TextureDimension.None, null)); } properties.Add(new MaterialPropertyDescriptor(converter, "Normal Map", RTShaderPropertyType.TexEnv, bumpMapInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, valueChangedCallback)); if (converter.BumpMap != null) { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _BumpScale), "Normal Map Scale", RTShaderPropertyType.Float, floatInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.None, null)); } properties.Add(new MaterialPropertyDescriptor(converter, "Height Map", RTShaderPropertyType.TexEnv, parallaxMapInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, valueChangedCallback)); if (converter.ParallaxMap != null) { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _Parallax), "Height Map Scale", RTShaderPropertyType.Range, floatInfo, new RuntimeShaderInfo.RangeLimits(0.02f, 0.005f, 0.08f), TextureDimension.None, null)); } properties.Add(new MaterialPropertyDescriptor(converter, "Occlusion Map", RTShaderPropertyType.TexEnv, occlusionMapInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, valueChangedCallback)); if (converter.OcclusionMap != null) { properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _OcclusionStrength), "Occlusion Strength", RTShaderPropertyType.Range, floatInfo, new RuntimeShaderInfo.RangeLimits(1.0f, 0, 1.0f), TextureDimension.None, null)); } properties.Add(new MaterialPropertyDescriptor(converter, "Emission Map", RTShaderPropertyType.TexEnv, emissionMapInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, null)); properties.Add(new MaterialPropertyDescriptor(converter, "Emission Color", RTShaderPropertyType.Color, emissionColorInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.None, null)); properties.Add(new MaterialPropertyDescriptor(converter, "Detail Mask", RTShaderPropertyType.TexEnv, detailMaskInfo, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, null)); properties.Add(new MaterialPropertyDescriptor(converter, "Detail Albedo Map", RTShaderPropertyType.TexEnv, detailAlbedoMap, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, null)); properties.Add(new MaterialPropertyDescriptor(converter, "Detail Normal Map", RTShaderPropertyType.TexEnv, detailNormalMap, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, null)); properties.Add(new MaterialPropertyDescriptor(new MaterialPropertyAccessor(editor.Material, _DetailNormalMapScale), "Detail Scale", RTShaderPropertyType.Float, floatInfo, new RuntimeShaderInfo.RangeLimits(0, 0, 0), TextureDimension.None, null)); //properties.Add(new MaterialPropertyDescriptor(converter, "UV Set", RTShaderPropertyType.Float, detailNormalMap, new RuntimeShaderInfo.RangeLimits(0.0f, 0.0f, 0.0f), TextureDimension.Tex2D, null)); #if !UNITY_WEBGL && PROC_MATERIAL ProceduralMaterial procMaterial = editor.Material as ProceduralMaterial; if (procMaterial != null) { MaterialDescriptor.GetProceduralMaterialDescriptors(procMaterial, properties); } #endif return(properties.ToArray()); }
public object CreateConverter(MaterialEditor editor) { return(null); }
public MaterialPropertyDescriptor[] GetProperties(MaterialEditor editor, object converter) { RuntimeShaderInfo shaderInfo = null; IRuntimeShaderUtil shaderUtil = IOC.Resolve <IRuntimeShaderUtil>(); if (shaderUtil != null) { shaderInfo = shaderUtil.GetShaderInfo(editor.Material.shader); } if (shaderInfo == null) { return(null); } List <MaterialPropertyDescriptor> descriptors = new List <MaterialPropertyDescriptor>(); if (shaderInfo != null) { for (int i = 0; i < shaderInfo.PropertyCount; ++i) { bool isHidden = shaderInfo.IsHidden[i]; if (isHidden) { continue; } string propertyDescr = shaderInfo.PropertyDescriptions[i]; string propertyName = shaderInfo.PropertyNames[i]; RTShaderPropertyType propertyType = shaderInfo.PropertyTypes[i]; RuntimeShaderInfo.RangeLimits limits = shaderInfo.PropertyRangeLimits[i]; TextureDimension dim = shaderInfo.PropertyTexDims[i]; PropertyInfo propertyInfo = null; switch (propertyType) { case RTShaderPropertyType.Color: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Color, "Color"); break; case RTShaderPropertyType.Float: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Float, "Float"); break; case RTShaderPropertyType.Range: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Float, "Float"); break; case RTShaderPropertyType.TexEnv: switch (dim) { case TextureDimension.Any: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture, "Texture"); break; case TextureDimension.Cube: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Cubemap, "Cubemap"); break; case TextureDimension.None: propertyInfo = null; break; case TextureDimension.Tex2D: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture2D, "Texture2D"); break; case TextureDimension.Tex2DArray: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture2DArray, "Texture2DArray"); break; case TextureDimension.Tex3D: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture3D, "Texture3D"); break; case TextureDimension.Unknown: propertyInfo = null; break; } break; case RTShaderPropertyType.Vector: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Vector, "Vector"); break; } if (propertyInfo == null) { continue; } MaterialPropertyDescriptor propertyDescriptor = new MaterialPropertyDescriptor( editor.Material, new MaterialPropertyAccessor(editor.Material, propertyName), propertyDescr, propertyType, propertyInfo, limits, dim, null, (accessorRef, newTarget) => { MaterialPropertyAccessor accessor = (MaterialPropertyAccessor)accessorRef; accessor.Material = newTarget as Material; }); descriptors.Add(propertyDescriptor); } } return(descriptors.ToArray()); }
public MaterialPropertyDescriptor[] GetProperties(MaterialEditor editor) { RuntimeShaderInfo shaderInfo = RuntimeShaderUtil.GetShaderInfo(editor.Material.shader); if (shaderInfo == null) { return(null); } List <MaterialPropertyDescriptor> descriptors = new List <MaterialPropertyDescriptor>(); for (int i = 0; i < shaderInfo.PropertyCount; ++i) { bool isHidden = shaderInfo.IsHidden[i]; if (isHidden) { continue; } string propertyDescr = shaderInfo.PropertyDescriptions[i]; string propertyName = shaderInfo.PropertyNames[i]; if (propertyName != "_Color" && propertyName != "_MainTex") { continue; } RTShaderPropertyType propertyType = shaderInfo.PropertyTypes[i]; RuntimeShaderInfo.RangeLimits limits = shaderInfo.PropertyRangeLimits[i]; TextureDimension dim = shaderInfo.PropertyTexDims[i]; PropertyInfo propertyInfo = null; switch (propertyType) { case RTShaderPropertyType.Color: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Color); break; case RTShaderPropertyType.Float: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Float); break; case RTShaderPropertyType.Range: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Float); break; case RTShaderPropertyType.TexEnv: switch (dim) { case TextureDimension.Any: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture); break; case TextureDimension.Cube: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Cubemap); break; case TextureDimension.None: propertyInfo = null; break; case TextureDimension.Tex2D: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture2D); break; case TextureDimension.Tex2DArray: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture2DArray); break; case TextureDimension.Tex3D: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Texture3D); break; case TextureDimension.Unknown: propertyInfo = null; break; } break; case RTShaderPropertyType.Vector: propertyInfo = Strong.PropertyInfo((MaterialPropertyAccessor x) => x.Float); break; } if (propertyInfo == null) { continue; } MaterialPropertyAccessor accessor = new MaterialPropertyAccessor(editor.Material, propertyName); MaterialPropertyDescriptor propertyDescriptor = new MaterialPropertyDescriptor(accessor, propertyDescr, propertyType, propertyInfo, limits, dim, null); descriptors.Add(propertyDescriptor); } return(descriptors.ToArray()); }
public void CreateConverters(MaterialEditor editor) { }
public virtual MaterialPropertyDescriptor[] GetProperties(MaterialEditor editor, object converter) { return(GetProperties(editor.Materials)); }