glTF格式介绍总目录:https://blog.csdn.net/qq_31709249/article/details/86477520
原文地址:https://github.com/javagl/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_010_Materials.md
https://github.com/javagl/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_011_SimpleMaterial.md
https://github.com/javagl/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_013_SimpleTexture.md
一、纹理、图片和采样器
1.纹理设置
针对纹理,在glTF中,有三个属性用来描述纹理信息:
- 1.texture:使用source和ssampler指向图片和采样器
- 2.images:通过 uri定位到图片资源
- 3.samplers:定义图片的采样和滤波方式
2.纹理坐标设置
针对纹理的坐标,可在mesh.primitives中指定,针对不同的纹理单元,对应有不同的属性,如TEXCOORD_0,TEXCOORD_1等,默认为TEXCOORD_0
3.纹理材质
glTF采用PBR材质来定义。在scene中通过material来定义,如下例所示:
"materials" : [ {
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 0
},
"metallicFactor" : 0.0,
"roughnessFactor" : 1.0
}
} ],
其中material中对应的完整的纹理的定义如下所示:
"textures" : [ {
"sampler" : 0,
"source" : 0
} ],
"images" : [ {
"uri" : "testTexture.png"
} ],
"samplers" : [ {
"magFilter" : 9729,
"minFilter" : 9987,
"wrapS" : 33648,
"wrapT" : 33648
} ],