Last active
April 14, 2019 17:20
-
-
Save attilaz/bc75cd64ca186caac3fa886ada02a32f to your computer and use it in GitHub Desktop.
material specification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Storage for materials: | |
Version A. compact/hardcoded for certain shading types | |
type: 1 byte (phong=0, pbrMetallicRoughnes=1, pbrSpecularGlossiness=2, ...) | |
if ( type == 0 ) | |
4 floats diffuseColor | |
string diffuseTexture | |
1 byte diffuseTexture texcoord channel | |
4 bytes diffuseTexture sampler parameters | |
..... | |
if ( type == 1) | |
4 floats baseColorFactor | |
.... | |
version B: | |
predefined values for parameter names and parameters are stored as array. | |
#define DIFFUSE_COLOR 1 | |
#define DIFFUSE_TEXTURE 2 | |
Parameter have types like float, float2, float3, float4, texture, int, bool, string, etc. | |
These types define what information is stored in data section. | |
type: 1 byte (phong=0, pbrMetallicRoughnes=1, pbrSpecularGlossiness=2, ...) | |
number_of_parameters: 2 bytes | |
name_of_parameter 1: 4 bytes | |
data_of_parameter 1: x bytes | |
... | |
name_of_parameter n: 4 bytes | |
data_of_parameter n: x bytes | |
diffuseTexture parameter example | |
4 bytes: (1) DIFFUSE_TEXTURE | |
string: filename | |
1 byte: texcoord channel | |
4 bytes: sampler parameters | |
version C: | |
similar to B, but there are no predefined values for shading type and params, they are strings. | |
types are predefined: | |
#define PARAMETER_TYPE_COLOR 1 | |
#define PARAMETER_TYPE_TEXTURE 2 | |
string 'pbrMetallicRoughness' | |
4byte number_of_parameters | |
1 byte: parameter type of param0 | |
string parameter_name | |
x bytes: data based on type | |
.... | |
diffuseTexture parameter example | |
1byte PARAMETER_TYPE_TEXTURE | |
string 'diffuseTexture' | |
string: filename | |
1 byte: texcoord channel | |
4 bytes: sampler parameters | |
version D: | |
similar to C, but store materials (in a separate file) in text format. | |
----------------------------------------------- | |
material parameters in different obj, gltf2, opengex and fbx | |
------------------------------------------------------------ | |
wavefront obj | |
---------------------- | |
ka, map_ka: diffuse color/texture | |
ks, map_ks: specular color/texture | |
ke, map_ke: emissive color/texture | |
ns, map_ns: specular exponent value/texture | |
d/tr, map_d: opacity/transparency value/texture | |
map_bump/bump: bumpmap | |
gltf2 - pbrMetallicRoughness | |
---------------------------- | |
baseColorFactor - rgba color in linear space | |
baseColorTexture - rgb(a) texture in srgb space | |
metallicFactor | |
roughnessFactor | |
metallicRoughnessTexture. channel b - metallic, g - roughness | |
Factor and texture are multiplied in linear space. | |
vertex color attrib COLOR_0 (assumed to be in linear space) also multiplies basecolor. | |
normalTexture - tangent space normal map. rgb in [0,1]. extra scale property | |
occlusionTexture - in .r channel linear space. extra strength property (0.0 - means no occlusion ) | |
emissiveFactor - rgb color | |
emissiveTexture - rgb in srgb space | |
each texture has a texcoord channel and a sampler. | |
sampler properties: minFilter, magFilter, wrapS, wrapT | |
alphaMode - OPAQUE, MASK (discard with alphaCutoff), BLEND | |
alphaCutoff - [0,1] | |
doubleSided | |
gltf2 - pbrSpecularGlossiness | |
----------------------------- | |
same as: pbrMetallicRoughness but it has no baseColor, metallic and roughness. | |
diffuseFactor - color in linear space | |
diffuseTexture - rgb(a) texture in srgb space | |
specularFactor - color in linear space | |
glossinessFactor - scalar value | |
specularGlossinessTexture - .rgb specular in srgb space, .a - glossiness | |
gltf2 - unlit | |
------------- | |
baseColorFactor, baseColorTexture and COLOR_0 is used to compute color with no lighting calculation. | |
opengex | |
------- | |
phong shading model | |
two_sided | |
diffuse color/texture | |
specular color/texture | |
specular_power value/texture | |
emission color/texture | |
opacity color/texture - rgb | |
transparency value/texture | |
normal - tangent space normal map | |
color and texture values are multiplied together. | |
texture have texture coordinate index and and transform. | |
fbx (with openfbx) | |
--- | |
diffuse color/texture | |
normal texture | |
it currently only exposes these parameters but there are much more here: | |
http://docs.autodesk.com/FBX/2014/ENU/FBX-SDK-Documentation/index.html?url=files/GUID-3E0DCCD0-5F9A-44D0-8D5E-423237D49DB6.htm,topicNumber=d30e10256 | |
My assumption is that the realtime friendly parameters are similar to what opengex defines. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment