Show / Hide Table of Contents

    Material data

    Materials contain color, intensity and multi-layered textures properties for the different channels. There are a number of different standard color channels and the user is also able to create custom user channels.

    From version 4.3 onwards materials in the SimplygonSDK support multi layered textures. Each channel in a Simplygon material can be composed of multiple texture layers having their own UV set. Multi layered textures for a channel are baked into a single texture while casting based on the blend function, see the casting with texture blend example.

    IMaterialTable

    The IMaterialTable is a collection of materials. The material table is assigned to an object. The material each part of the geometry is using is found in the array of material IDs received when calling GetMaterialIds from the geometry object.

    IMaterial

    The IMaterial class contains the material information. Materials are either imported alongside the object or created using the Simplygon API. They are identified by their name or index and the names are set with SetName. Channels for all commonly used PBR and non-PBR material models are pre-defined in Simplygon, and it is possible to add additional user-defined custom channels as well. The channels are defined using shading networks. If a shading network with texture nodes is used, a texture table must also be defined in order to successfully use any of the Simplygon material casters.

    • AddUserChannel
      Creates user channels in the material.

    • ShadingNetwork
      Set/get a shading network that will be used instead of the defined texture path or texture image in the relevant channel.

    ITextureTable

    The ITextureTable is a collection of textures. This structure is used by the material casters when casting based on input materials defined by shading networks. Each texture referenced by a texture node in the shading node networks that define the input materials must be represented in this table, which is supplied to the material casters along with the material table.

    ITexture

    The ITexture class contains definition of a single texture. The image data can either be defined using a single file path pointing to the input image, or by setting its ImageData object directly, using the format discussed in the Image Data section. When these are added to the texture table for usage in material casting with node networks, the name, as set by SetName(), is the identifier used to correlate a texture in the shading networks with a texture in the texture table. The Material Casting Example contains an example implementation of how to use this in a casting context properly.

    Material casting

    For information about casting materials see the Material Casting section.

    Example - Generate material

    spMaterial GenerateMaterial(spTextureTable textureTable)
    {
        spMaterial mat = sg->CreateMaterial();
    
        spImageData imgDiffuse = GenerateGradientImage( 512, 512 );
        spTexture diffuseTexture = sg->CreateTexture();
        diffuseTexture->SetName("DiffuseTexture");
        diffuseTexture->SetImageData(imgDiffuse);
    
        textureTable->AddTexture( diffuseTexture );
    
        spShadingTextureNode diffuseTextureNode = sg->CreateShadingTextureNode();
        diffuseTextureNode->SetTextureName( "DiffuseTexture" );
        mat->SetShadingNetwork( SG_MATERIAL_CHANNEL_DIFFUSE, diffuseTextureNode );
    
        return mat;
    }
    
    Back to top Terms of Use | Privacy and cookies | Trademarks | Copyright © 2019 Microsoft