david.cambre Posted August 16, 2020 Share Posted August 16, 2020 Hi how do i create an new material where i'm able to set the albedo color true code? I am able to clone a material (NOT base_mesh) and set its metalness. V2.12.0.1 Material mat = Materials.FindMaterial("Cone_material").Clone("mesh_base_0"); mat.SetParameterFloat("metalness", 1.0f); // mesh.SetMaterialParameterFloat4("Albedo_color_multiplier",vec4.BLACK,0); // mesh.SetMaterialParameterFloat4("diffuse_color",vec4.BLACK,0); // mesh.SetMaterialParameterFloat4("albedo",vec4.RED,0); Link to comment
devrom Posted August 17, 2020 Share Posted August 17, 2020 Hello David, you need to use "albedo_color". If you need to know more parameter names, maybe look into the corresponding .basemat-files. You can find the mesh_base material in: /"your_current_sdk"/data/core/materials/default/mesh/mesh_base.basemat. In line 160 the "albedo_color" parameter is defined. Best regards Link to comment
david.cambre Posted August 17, 2020 Author Share Posted August 17, 2020 A, ... aaaa Ok, that works. Nice to know where to find the literal strings and not have to guess. Thanks Link to comment
silent Posted August 18, 2020 Share Posted August 18, 2020 Starting with 2.13 update textures slot names will be displayed in the tooltips inside the Editor. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
david.cambre Posted August 18, 2020 Author Share Posted August 18, 2020 Sorry to follow up on a SOLVED issue. When i clone the mesh_base i get a "System.NullReferenceException: Object reference not set to an instance of an object." When i set it to new Material(); i get "Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." Is it not possible to create a new new material? Or do all materials inherit from mesh_base? Example of a transparent green mesh for how wants a full example. public Material placeable_mat; placeable_mat = Materials.FindMaterial("mesh_base").Inherit("mesh_base_0");// Clone("mesh_base_0"); placeable_mat.Transparent = 2; placeable_mat.SetBlendFunc(5,4); placeable_mat.SetParameterFloat("roughness", 0.1f); int param_ID = placeable_mat.FindParameter("albedo_color"); float transparent = 0.1f; vec4 albedo_color = vec4.GREEN - - new vec4(0f,0f,0f,transparent); placeable_mat.SetParameterFloat4(param_ID, albedo_color); Link to comment
silent Posted August 19, 2020 Share Posted August 19, 2020 It's not allowed to clone base material, only inherit: https://developer.unigine.com/en/docs/2.12/api/library/rendering/class.material?rlang=csi#clone_cstr_Material However, there should be no crash I suppose. Will try to reproduce this crash. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
alexander Posted August 19, 2020 Share Posted August 19, 2020 Hi David, When i clone the mesh_base i get a "System.NullReferenceException: Object reference not set to an instance of an object." Is it not possible to create a new new material? Or do all materials inherit from mesh_base? There is a mistake in the documentation (thanks for finding it). You can't clone a base material. When you try to do it the Clone() method returns "null" and prints an error message to the console: "Material::clone(): base material is not supported" (use "~" key to see console during runtime). You got NullRefereneceException in the next line when you tried to use null object: placeable_mat.Transparent = 2; If you don't want to create new parameters / shaders / states / etc. in your material and just want to change parameter's values then use "Inherit" method. Otherwise create a new copy of the "mesh_base.basemat" (in explorer) and modify it in any text editor. Best regards, Alexander Link to comment
Recommended Posts