全部產品
Search
文件中心

:ST_MakeMaterial

更新時間:Feb 28, 2024

構造一個材質對象。

文法

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);

參數

參數名稱描述
ambient環境顏色光,用16進位字串表示RGBA顏色,例如:#FF88FF00
diffuse散射光,用16進位字串表示RGBA顏色,例如:#FF88FF00
specular鏡面光顏色,用16進位字串表示RGBA顏色,例如:#FF88FF00
shininess光澤度,取值:0~100。
transparency透明度,取值:0~100。
texture_index材質所對應紋理的索引資訊,取值:0~32767。
table_name已存在material的表名。
column_name已存在material的列名。
key_value已存在material的查詢唯一ID,用於where條件中。
schema_name已存在material的方案名,預設為使用者search path中表所在的Schema。
attributes基於JSON類型的材質描述資訊,形式為GLTF中的PBR材質描述。
texturesmaterial所包含的textures數組。

描述

構造一個材質對象。
  • 文法一提供了基於OpenCL類型的材質描述資訊,最終會轉換為基於JSON的表述形式。
  • 文法二提供了基於其他表中儲存的材質資訊,可以有效地降低Mesh的資料量,方便統一進行修改。
  • 文法三提供了基於JSON類型的材質描述資訊。

樣本

  • 文法一:
    -- 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"}}
  • 文法二:
    -- form 2,reference to other 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"}}
  • 文法三:
    -- form3, with 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}}}