ST_MakeMaterial

更新时间:
复制 MD 格式

Creates a material object.

Syntax

material ST_MakeMaterial(cstring ambient default NULL,
                         cstring diffuse default NULL,
                         cstring specular default NULL,
                         integer shininess default NULL,
                         integer transparency default NULL,
                         integer texture_index default NULL);
material ST_MakeMaterial(text table_name,
                         text column_name,
                         text key_value,
                         text schema_name default NULL);
material ST_MakeMaterial(cstring attributes,
                         texture[] textures default NULL);

Parameters

Parameter name

Description

ambient

The ambient light color. The value is an RGBA color represented as a hexadecimal string. For example: #FF88FF00.

diffuse

The diffuse color. The value is an RGBA color represented as a hexadecimal string. For example: #FF88FF00.

specular

The specular color. The value is an RGBA color represented as a hexadecimal string. For example: #FF88FF00.

shininess

The shininess. Valid values: 0 to 100.

transparency

The transparency. Valid values: 0 to 100.

texture_index

The index of the texture for the material. Valid values: 0 to 32767.

table_name

The name of the table that contains the existing material.

column_name

The name of the column that contains the existing material.

key_value

The unique ID used to query the existing material. This parameter is used in the WHERE clause.

schema_name

The name of the schema for the existing material. The default value is the schema that contains the table in the user's search path.

attributes

The JSON-formatted description of the material. The value is in the form of a PBR material description in GL Transmission Format (glTF).

textures

The array of textures in the material.

Description

This function creates a material object.

  • Syntax 1 uses an Open Computing Language (OpenCL)-based description for the material. This description is then converted to a JSON format.

  • Syntax 2 uses material information stored in another table. This method reduces the data volume of the mesh and simplifies modifications.

  • Syntax 3 uses a JSON-formatted description for the material.

Examples

  • Syntax 1:

    -- form 1
    SELECT ST_AsText(ST_MakeMaterial('#FFDDEEAA', '#FFDDEEAA', '#FFDDEEAA', 30, 70, 2));
    
    --------------------------------------------------------------------------------
    {"type":"raw", "attributes": {"ambient":"#FFDDEEAA","diffuse":"#FFDDEEAA","specular":"#FFDDEEAA","shininess":30,"transparency":70,"texture":2}}
    
    
    -- form 1
    SELECT ST_AsText(ST_MakeMaterial(diffuse => '#FFDDEEAA'));
    
    -------------------------
     {"type":"raw", "attributes": {"diffuse":"#FFDDEEAA"}}
  • Syntax 2:

    -- form 2, reference to another material object
     SELECT ST_AsText(ST_MakeMaterial('t_material'::text,
        'the_material'::text,
        'num=1'::text));
     -----------------------------
     {"type":"db", "attributes": {"schema":"public","table":"t_material","column":"the_material","key":"num=1"}}
  • Syntax 3:

    -- form 3, with a PBR JSON string and textures
    SELECT ST_AsText(ST_MakeMaterial('{"pbrMetallicRoughness": {"baseColorFactor": [ 1.000, 0.766, 0.336, 1.0 ], "metallicFactor": 0.5,"roughnessFactor": 0.1}}',
                                     ARRAY(SELECT the_texture from t_texture)));
    -----------------------------
    {"type":"raw", "textures":[{"compressionType" : "None", "format" : "JPEG", "wrap" : "Wrap", "type" : "Raw", "depth" : 3, "width" : 256, "height" : 256, "size" : 6, "data" : "313233343536"}], "attributes": {"pbrMetallicRoughness":{"baseColorFactor":[1.0,0.766,0.336,1.0],"metallicFactor":0.5,"roughnessFactor":0.1}}}