mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-28 22:49:54 +02:00
Merge pull request #7889 from samcake/color
add support for ambient occlusion texture and lightmap texture for fbx exported from Blender
This commit is contained in:
commit
262e0262fc
23 changed files with 78 additions and 27 deletions
|
@ -927,6 +927,9 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
// material.emissiveColor = getVec3(property.properties, index);
|
// material.emissiveColor = getVec3(property.properties, index);
|
||||||
// material.emissiveFactor = 1.0;
|
// material.emissiveFactor = 1.0;
|
||||||
|
|
||||||
|
} else if (property.properties.at(0) == "AmbientFactor") {
|
||||||
|
material.ambientFactor = property.properties.at(index).value<double>();
|
||||||
|
// Detected just for BLender AO vs lightmap
|
||||||
} else if (property.properties.at(0) == "Shininess") {
|
} else if (property.properties.at(0) == "Shininess") {
|
||||||
material.shininess = property.properties.at(index).value<double>();
|
material.shininess = property.properties.at(index).value<double>();
|
||||||
|
|
||||||
|
@ -1128,8 +1131,10 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
} else if (type.contains("tex_emissive_map")) {
|
} else if (type.contains("tex_emissive_map")) {
|
||||||
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
emissiveTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
} else if (type.contains("ambient")) {
|
} else if (type.contains("ambientcolor")) {
|
||||||
ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
ambientTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
|
} else if (type.contains("ambientfactor")) {
|
||||||
|
ambientFactorTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
} else if (type.contains("tex_ao_map")) {
|
} else if (type.contains("tex_ao_map")) {
|
||||||
occlusionTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
occlusionTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
} else if (type == "lcl rotation") {
|
} else if (type == "lcl rotation") {
|
||||||
|
|
|
@ -151,6 +151,7 @@ public:
|
||||||
float metallic{ 0.0f };
|
float metallic{ 0.0f };
|
||||||
float roughness{ 1.0f };
|
float roughness{ 1.0f };
|
||||||
float emissiveIntensity{ 1.0f };
|
float emissiveIntensity{ 1.0f };
|
||||||
|
float ambientFactor{ 1.0f };
|
||||||
|
|
||||||
QString materialID;
|
QString materialID;
|
||||||
QString name;
|
QString name;
|
||||||
|
@ -437,6 +438,7 @@ public:
|
||||||
QHash<QString, QString> shininessTextures;
|
QHash<QString, QString> shininessTextures;
|
||||||
QHash<QString, QString> emissiveTextures;
|
QHash<QString, QString> emissiveTextures;
|
||||||
QHash<QString, QString> ambientTextures;
|
QHash<QString, QString> ambientTextures;
|
||||||
|
QHash<QString, QString> ambientFactorTextures;
|
||||||
QHash<QString, QString> occlusionTextures;
|
QHash<QString, QString> occlusionTextures;
|
||||||
|
|
||||||
QHash<QString, FBXMaterial> _fbxMaterials;
|
QHash<QString, FBXMaterial> _fbxMaterials;
|
||||||
|
|
|
@ -186,6 +186,14 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
|
|
||||||
FBXTexture occlusionTexture;
|
FBXTexture occlusionTexture;
|
||||||
QString occlusionTextureID = occlusionTextures.value(material.materialID);
|
QString occlusionTextureID = occlusionTextures.value(material.materialID);
|
||||||
|
if (occlusionTextureID.isNull()) {
|
||||||
|
// 2nd chance
|
||||||
|
// For blender we use the ambient factor texture as AOMap ONLY if the ambientFactor value is > 0.0
|
||||||
|
if (material.ambientFactor > 0.0f) {
|
||||||
|
occlusionTextureID = ambientFactorTextures.value(material.materialID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!occlusionTextureID.isNull()) {
|
if (!occlusionTextureID.isNull()) {
|
||||||
occlusionTexture = getTexture(occlusionTextureID);
|
occlusionTexture = getTexture(occlusionTextureID);
|
||||||
detectDifferentUVs |= (occlusionTexture.texcoordSet != 0) || (!emissiveTexture.transform.isIdentity());
|
detectDifferentUVs |= (occlusionTexture.texcoordSet != 0) || (!emissiveTexture.transform.isIdentity());
|
||||||
|
@ -198,6 +206,14 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
|
|
||||||
FBXTexture ambientTexture;
|
FBXTexture ambientTexture;
|
||||||
QString ambientTextureID = ambientTextures.value(material.materialID);
|
QString ambientTextureID = ambientTextures.value(material.materialID);
|
||||||
|
if (ambientTextureID.isNull()) {
|
||||||
|
// 2nd chance
|
||||||
|
// For blender we use the ambient factor texture as Lightmap ONLY if the ambientFactor value is set to 0
|
||||||
|
if (material.ambientFactor == 0.0f) {
|
||||||
|
ambientTextureID = ambientFactorTextures.value(material.materialID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_loadLightmaps && !ambientTextureID.isNull()) {
|
if (_loadLightmaps && !ambientTextureID.isNull()) {
|
||||||
ambientTexture = getTexture(ambientTextureID);
|
ambientTexture = getTexture(ambientTextureID);
|
||||||
detectDifferentUVs |= (ambientTexture.texcoordSet != 0) || (!ambientTexture.transform.isIdentity());
|
detectDifferentUVs |= (ambientTexture.texcoordSet != 0) || (!ambientTexture.transform.isIdentity());
|
||||||
|
|
|
@ -418,6 +418,8 @@ model::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& baseUrl, c
|
||||||
|
|
||||||
auto map = std::make_shared<model::TextureMap>();
|
auto map = std::make_shared<model::TextureMap>();
|
||||||
map->setTextureSource(texture->_textureSource);
|
map->setTextureSource(texture->_textureSource);
|
||||||
|
map->setTextureTransform(fbxTexture.transform);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,6 +429,7 @@ model::TextureMapPointer NetworkMaterial::fetchTextureMap(const QUrl& url, Textu
|
||||||
|
|
||||||
auto map = std::make_shared<model::TextureMap>();
|
auto map = std::make_shared<model::TextureMap>();
|
||||||
map->setTextureSource(texture->_textureSource);
|
map->setTextureSource(texture->_textureSource);
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,6 +478,7 @@ NetworkMaterial::NetworkMaterial(const FBXMaterial& material, const QUrl& textur
|
||||||
|
|
||||||
if (!material.occlusionTexture.filename.isEmpty()) {
|
if (!material.occlusionTexture.filename.isEmpty()) {
|
||||||
auto map = fetchTextureMap(textureBaseUrl, material.occlusionTexture, NetworkTexture::OCCLUSION_TEXTURE, MapChannel::OCCLUSION_MAP);
|
auto map = fetchTextureMap(textureBaseUrl, material.occlusionTexture, NetworkTexture::OCCLUSION_TEXTURE, MapChannel::OCCLUSION_MAP);
|
||||||
|
map->setTextureTransform(material.occlusionTexture.transform);
|
||||||
setTextureMap(MapChannel::OCCLUSION_MAP, map);
|
setTextureMap(MapChannel::OCCLUSION_MAP, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,6 +122,10 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
|
||||||
_texMapArrayBuffer.edit<TexMapArraySchema>()._texcoordTransforms[0] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4());
|
_texMapArrayBuffer.edit<TexMapArraySchema>()._texcoordTransforms[0] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channel == MaterialKey::OCCLUSION_MAP) {
|
||||||
|
_texMapArrayBuffer.edit<TexMapArraySchema>()._texcoordTransforms[1] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4());
|
||||||
|
}
|
||||||
|
|
||||||
if (channel == MaterialKey::LIGHTMAP_MAP) {
|
if (channel == MaterialKey::LIGHTMAP_MAP) {
|
||||||
// update the texcoord1 with lightmap
|
// update the texcoord1 with lightmap
|
||||||
_texMapArrayBuffer.edit<TexMapArraySchema>()._texcoordTransforms[1] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4());
|
_texMapArrayBuffer.edit<TexMapArraySchema>()._texcoordTransforms[1] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4());
|
||||||
|
|
|
@ -83,7 +83,7 @@ static const std::string DEFAULT_NORMAL_SHADER {
|
||||||
static const std::string DEFAULT_OCCLUSION_SHADER{
|
static const std::string DEFAULT_OCCLUSION_SHADER{
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
" DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);"
|
||||||
" return vec4(vec3(frag.obscurance), 1.0);"
|
" return vec4(vec3(pow(frag.obscurance, 1.0 / 2.2)), 1.0);"
|
||||||
" }"
|
" }"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ float fetchOcclusionMap(vec2 uv) {
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
||||||
<@func fetchMaterialTextures(matKey, texcoord0, albedo, roughness, normal, metallic, emissive, occlusion)@>
|
<@func fetchMaterialTexturesCoord0(matKey, texcoord0, albedo, roughness, normal, metallic, emissive)@>
|
||||||
<@if albedo@>
|
<@if albedo@>
|
||||||
vec4 <$albedo$> = (((<$matKey$> & (ALBEDO_MAP_BIT | OPACITY_MASK_MAP_BIT | OPACITY_TRANSLUCENT_MAP_BIT)) != 0) ? fetchAlbedoMap(<$texcoord0$>) : vec4(1.0));
|
vec4 <$albedo$> = (((<$matKey$> & (ALBEDO_MAP_BIT | OPACITY_MASK_MAP_BIT | OPACITY_TRANSLUCENT_MAP_BIT)) != 0) ? fetchAlbedoMap(<$texcoord0$>) : vec4(1.0));
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
@ -106,12 +106,19 @@ float fetchOcclusionMap(vec2 uv) {
|
||||||
<@if emissive@>
|
<@if emissive@>
|
||||||
vec3 <$emissive$> = (((<$matKey$> & EMISSIVE_MAP_BIT) != 0) ? fetchEmissiveMap(<$texcoord0$>) : vec3(0.0));
|
vec3 <$emissive$> = (((<$matKey$> & EMISSIVE_MAP_BIT) != 0) ? fetchEmissiveMap(<$texcoord0$>) : vec3(0.0));
|
||||||
<@endif@>
|
<@endif@>
|
||||||
|
<@endfunc@>
|
||||||
|
|
||||||
|
<@func fetchMaterialTexturesCoord1(matKey, texcoord1, occlusion, lightmapVal)@>
|
||||||
<@if occlusion@>
|
<@if occlusion@>
|
||||||
float <$occlusion$> = (((<$matKey$> & OCCLUSION_MAP_BIT) != 0) ? fetchOcclusionMap(<$texcoord0$>) : 1.0);
|
float <$occlusion$> = (((<$matKey$> & OCCLUSION_MAP_BIT) != 0) ? fetchOcclusionMap(<$texcoord1$>) : 1.0);
|
||||||
|
<@endif@>
|
||||||
|
<@if lightmapVal@>
|
||||||
|
vec3 <$lightmapVal$> = fetchLightmapMap(<$texcoord1$>);
|
||||||
<@endif@>
|
<@endif@>
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<@func declareMaterialLightmap()@>
|
<@func declareMaterialLightmap()@>
|
||||||
|
|
||||||
<$declareMaterialTexMapArrayBuffer()$>
|
<$declareMaterialTexMapArrayBuffer()$>
|
||||||
|
@ -123,11 +130,6 @@ vec3 fetchLightmapMap(vec2 uv) {
|
||||||
}
|
}
|
||||||
<@endfunc@>
|
<@endfunc@>
|
||||||
|
|
||||||
<@func fetchMaterialLightmap(texcoord1, lightmapVal)@>
|
|
||||||
vec3 <$lightmapVal$> = fetchLightmapMap(<$texcoord1$>);
|
|
||||||
<@endfunc@>
|
|
||||||
|
|
||||||
|
|
||||||
<@func tangentToViewSpace(fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
|
<@func tangentToViewSpace(fetchedNormal, interpolatedNormal, interpolatedTangent, normal)@>
|
||||||
{
|
{
|
||||||
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);
|
vec3 normalizedNormal = normalize(<$interpolatedNormal$>.xyz);
|
||||||
|
|
|
@ -22,12 +22,14 @@ in vec4 _position;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
float opacity = 1.0;
|
float opacity = 1.0;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
out vec3 _color;
|
out vec3 _color;
|
||||||
out float _alpha;
|
out float _alpha;
|
||||||
out vec2 _texCoord0;
|
out vec2 _texCoord0;
|
||||||
|
out vec2 _texCoord1;
|
||||||
out vec4 _position;
|
out vec4 _position;
|
||||||
out vec3 _normal;
|
out vec3 _normal;
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ void main(void) {
|
||||||
|
|
||||||
TexMapArray texMapArray = getTexMapArray();
|
TexMapArray texMapArray = getTexMapArray();
|
||||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||||
|
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$>
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
|
@ -29,8 +29,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness)$>
|
||||||
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||||
|
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
|
|
|
@ -30,8 +30,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness, normalTexel)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel)$>
|
||||||
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||||
|
|
||||||
vec3 viewNormal;
|
vec3 viewNormal;
|
||||||
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$>
|
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$>
|
||||||
|
|
|
@ -30,8 +30,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, normalTexel, metallicTex)$>
|
||||||
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||||
|
|
||||||
vec3 viewNormal;
|
vec3 viewNormal;
|
||||||
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$>
|
<$tangentToViewSpace(normalTexel, _normal, _tangent, viewNormal)$>
|
||||||
|
|
|
@ -29,8 +29,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedo, roughness, _SCRIBE_NULL, metallicTex)$>
|
||||||
<$fetchMaterialLightmap(_texCoord1, lightmapVal)$>
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, _SCRIBE_NULL, lightmapVal)$>
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _tangent;
|
in vec3 _tangent;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
|
@ -28,7 +29,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, _SCRIBE_NULL, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
float opacity = 1.0;
|
float opacity = 1.0;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
out vec4 _position;
|
out vec4 _position;
|
||||||
out vec2 _texCoord0;
|
out vec2 _texCoord0;
|
||||||
|
out vec2 _texCoord1;
|
||||||
out vec3 _normal;
|
out vec3 _normal;
|
||||||
out vec3 _tangent;
|
out vec3 _tangent;
|
||||||
out vec3 _color;
|
out vec3 _color;
|
||||||
|
@ -34,6 +35,7 @@ void main(void) {
|
||||||
|
|
||||||
TexMapArray texMapArray = getTexMapArray();
|
TexMapArray texMapArray = getTexMapArray();
|
||||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||||
|
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$>
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _tangent;
|
in vec3 _tangent;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
|
@ -28,7 +29,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, normalTex, metallicTex, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
float opacity = 1.0;
|
float opacity = 1.0;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
|
|
||||||
|
@ -28,7 +29,8 @@ in vec3 _color;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, metallicTex, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
float opacity = 1.0;
|
float opacity = 1.0;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
<$declareMaterialTextures(ALBEDO, ROUGHNESS, _SCRIBE_NULL, _SCRIBE_NULL, EMISSIVE, OCCLUSION)$>
|
||||||
|
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
|
in vec2 _texCoord1;
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
|
@ -35,7 +36,8 @@ out vec4 _fragColor;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex, occlusionTex)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex, roughnessTex, _SCRIBE_NULL, _SCRIBE_NULL, emissiveTex)$>
|
||||||
|
<$fetchMaterialTexturesCoord1(matKey, _texCoord1, occlusionTex)$>
|
||||||
|
|
||||||
float opacity = getMaterialOpacity(mat) * _alpha;
|
float opacity = getMaterialOpacity(mat) * _alpha;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
@ -61,7 +63,7 @@ void main(void) {
|
||||||
_fragColor = vec4(evalGlobalLightingAlphaBlended(
|
_fragColor = vec4(evalGlobalLightingAlphaBlended(
|
||||||
cam._viewInverse,
|
cam._viewInverse,
|
||||||
1.0,
|
1.0,
|
||||||
1.0,
|
occlusionTex,
|
||||||
fragPosition,
|
fragPosition,
|
||||||
fragNormal,
|
fragNormal,
|
||||||
albedo,
|
albedo,
|
||||||
|
|
|
@ -26,7 +26,7 @@ out vec4 _fragColor;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||||
|
|
||||||
float opacity = getMaterialOpacity(mat) * _alpha;
|
float opacity = getMaterialOpacity(mat) * _alpha;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<@include model/Material.slh@>
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
<@include MaterialTextures.slh@>
|
<@include MaterialTextures.slh@>
|
||||||
<$declareMaterialTextures(ALBEDO, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
|
<$declareMaterialTextures(ALBEDO)$>
|
||||||
|
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
|
@ -27,7 +27,7 @@ void main(void) {
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
int matKey = getMaterialKey(mat);
|
int matKey = getMaterialKey(mat);
|
||||||
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
|
<$fetchMaterialTexturesCoord0(matKey, _texCoord0, albedoTex)$>
|
||||||
|
|
||||||
float opacity = 1.0;
|
float opacity = 1.0;
|
||||||
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)$>;
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
out vec4 _position;
|
out vec4 _position;
|
||||||
out vec2 _texCoord0;
|
out vec2 _texCoord0;
|
||||||
|
out vec2 _texCoord1;
|
||||||
out vec3 _normal;
|
out vec3 _normal;
|
||||||
out vec3 _color;
|
out vec3 _color;
|
||||||
out float _alpha;
|
out float _alpha;
|
||||||
|
@ -40,6 +41,7 @@ void main(void) {
|
||||||
|
|
||||||
TexMapArray texMapArray = getTexMapArray();
|
TexMapArray texMapArray = getTexMapArray();
|
||||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||||
|
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$>
|
||||||
|
|
||||||
// standard transform
|
// standard transform
|
||||||
TransformCamera cam = getTransformCamera();
|
TransformCamera cam = getTransformCamera();
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
out vec4 _position;
|
out vec4 _position;
|
||||||
out vec2 _texCoord0;
|
out vec2 _texCoord0;
|
||||||
|
out vec2 _texCoord1;
|
||||||
out vec3 _normal;
|
out vec3 _normal;
|
||||||
out vec3 _tangent;
|
out vec3 _tangent;
|
||||||
out vec3 _color;
|
out vec3 _color;
|
||||||
|
@ -42,6 +43,7 @@ void main(void) {
|
||||||
|
|
||||||
TexMapArray texMapArray = getTexMapArray();
|
TexMapArray texMapArray = getTexMapArray();
|
||||||
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
<$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$>
|
||||||
|
<$evalTexMapArrayTexcoord1(texMapArray, inTexCoord0, _texCoord1)$>
|
||||||
|
|
||||||
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0);
|
||||||
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
|
interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0);
|
||||||
|
|
|
@ -33,7 +33,7 @@ Column {
|
||||||
"Roughness",
|
"Roughness",
|
||||||
"Metallic",
|
"Metallic",
|
||||||
"Emissive",
|
"Emissive",
|
||||||
"Shaded/Lightmapped/Unlit",
|
"Unlit",
|
||||||
"Occlusion",
|
"Occlusion",
|
||||||
"Lightmap",
|
"Lightmap",
|
||||||
"Lighting",
|
"Lighting",
|
||||||
|
|
Loading…
Reference in a new issue