mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +02:00
Getting the unlit to work from the pipeline, and found the isLinear for texture bug!
This commit is contained in:
parent
8bad58749c
commit
a8347cac6e
5 changed files with 43 additions and 10 deletions
|
@ -72,6 +72,10 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
// foreach (const QString& materialID, materials) {
|
// foreach (const QString& materialID, materials) {
|
||||||
for (QHash<QString, FBXMaterial>::iterator it = _fbxMaterials.begin(); it != _fbxMaterials.end(); it++) {
|
for (QHash<QString, FBXMaterial>::iterator it = _fbxMaterials.begin(); it != _fbxMaterials.end(); it++) {
|
||||||
FBXMaterial& material = (*it);
|
FBXMaterial& material = (*it);
|
||||||
|
|
||||||
|
// Maya is the exporting the shading model and we aretrying to use it
|
||||||
|
bool isMaterialLambert = (material.shadingModel.toLower() == "lambert");
|
||||||
|
|
||||||
// the pure material associated with this part
|
// the pure material associated with this part
|
||||||
bool detectDifferentUVs = false;
|
bool detectDifferentUVs = false;
|
||||||
FBXTexture diffuseTexture;
|
FBXTexture diffuseTexture;
|
||||||
|
@ -171,6 +175,13 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
emissiveTexture = getTexture(emissiveTextureID);
|
emissiveTexture = getTexture(emissiveTextureID);
|
||||||
detectDifferentUVs |= (emissiveTexture.texcoordSet != 0) || (!emissiveTexture.transform.isIdentity());
|
detectDifferentUVs |= (emissiveTexture.texcoordSet != 0) || (!emissiveTexture.transform.isIdentity());
|
||||||
material.emissiveTexture = emissiveTexture;
|
material.emissiveTexture = emissiveTexture;
|
||||||
|
|
||||||
|
if (isMaterialLambert) {
|
||||||
|
// If the emissiveTextureID comes from the Texture bound to Emissive when material is lambert, we know it s exported from maya
|
||||||
|
// And the EMissiveColor is forced to 0.5 by Maya which is bad
|
||||||
|
// So we need to force it to 1.0
|
||||||
|
material.emissiveColor = vec3(1.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FBXTexture occlusionTexture;
|
FBXTexture occlusionTexture;
|
||||||
|
@ -198,7 +209,7 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
material._material = std::make_shared<model::Material>();
|
material._material = std::make_shared<model::Material>();
|
||||||
|
|
||||||
// Emissive color is the mix of emissiveColor with emissiveFactor
|
// Emissive color is the mix of emissiveColor with emissiveFactor
|
||||||
auto emissive = material.emissiveColor * material.emissiveFactor;
|
auto emissive = material.emissiveColor * (isMaterialLambert ? 1.0f : material.emissiveFactor); // In lambert there is not emissiveFactor
|
||||||
material._material->setEmissive(emissive);
|
material._material->setEmissive(emissive);
|
||||||
|
|
||||||
// Final diffuse color is the mix of diffuseColor with diffuseFactor
|
// Final diffuse color is the mix of diffuseColor with diffuseFactor
|
||||||
|
@ -213,9 +224,17 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
float metallic = std::max(material.specularColor.x, std::max(material.specularColor.y, material.specularColor.z));
|
float metallic = std::max(material.specularColor.x, std::max(material.specularColor.y, material.specularColor.z));
|
||||||
material._material->setMetallic(metallic);
|
material._material->setMetallic(metallic);
|
||||||
|
|
||||||
if (material.shadingModel == "lambert") {
|
if (isMaterialLambert) {
|
||||||
if (!material._material->getKey().isAlbedo()) {
|
if (!material._material->getKey().isAlbedo()) {
|
||||||
|
// switch emissive to material albedo as we tag the material to unlit
|
||||||
material._material->setUnlit(true);
|
material._material->setUnlit(true);
|
||||||
|
material._material->setEmissive(diffuse);
|
||||||
|
material._material->setAlbedo(emissive);
|
||||||
|
|
||||||
|
if (!material.emissiveTexture.isNull()) {
|
||||||
|
material.albedoTexture = material.emissiveTexture;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << emissive;
|
std::cout << emissive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ const QImage& image, bool isLinear, bool doCompress) {
|
||||||
if (image.hasAlphaChannel()) {
|
if (image.hasAlphaChannel()) {
|
||||||
gpu::Semantic gpuSemantic;
|
gpu::Semantic gpuSemantic;
|
||||||
gpu::Semantic mipSemantic;
|
gpu::Semantic mipSemantic;
|
||||||
if (isLinear) {
|
if (!isLinear) {
|
||||||
mipSemantic = gpu::SBGRA;
|
mipSemantic = gpu::SBGRA;
|
||||||
if (doCompress) {
|
if (doCompress) {
|
||||||
gpuSemantic = gpu::COMPRESSED_SRGBA;
|
gpuSemantic = gpu::COMPRESSED_SRGBA;
|
||||||
|
@ -124,7 +124,7 @@ const QImage& image, bool isLinear, bool doCompress) {
|
||||||
} else {
|
} else {
|
||||||
gpu::Semantic gpuSemantic;
|
gpu::Semantic gpuSemantic;
|
||||||
gpu::Semantic mipSemantic;
|
gpu::Semantic mipSemantic;
|
||||||
if (isLinear) {
|
if (!isLinear) {
|
||||||
mipSemantic = gpu::SRGB;
|
mipSemantic = gpu::SRGB;
|
||||||
if (doCompress) {
|
if (doCompress) {
|
||||||
gpuSemantic = gpu::COMPRESSED_SRGB;
|
gpuSemantic = gpu::COMPRESSED_SRGB;
|
||||||
|
|
|
@ -144,6 +144,11 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
|
||||||
auto materialKey = _drawMaterial->getKey();
|
auto materialKey = _drawMaterial->getKey();
|
||||||
auto textureMaps = _drawMaterial->getTextureMaps();
|
auto textureMaps = _drawMaterial->getTextureMaps();
|
||||||
|
|
||||||
|
int numUnlit = 0;
|
||||||
|
if (materialKey.isUnlit()) {
|
||||||
|
numUnlit++;
|
||||||
|
}
|
||||||
|
|
||||||
// Albedo
|
// Albedo
|
||||||
if (materialKey.isAlbedoMap()) {
|
if (materialKey.isAlbedoMap()) {
|
||||||
auto albedoMap = textureMaps[model::MaterialKey::ALBEDO_MAP];
|
auto albedoMap = textureMaps[model::MaterialKey::ALBEDO_MAP];
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
<@include DeferredBufferWrite.slh@>
|
<@include DeferredBufferWrite.slh@>
|
||||||
<@include model/Material.slh@>
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
uniform sampler2D albedoMap;
|
<@include MaterialTextures.slh@>
|
||||||
|
<$declareMaterialTextures(ALBEDO, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
|
||||||
|
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
in vec3 _normal;
|
in vec3 _normal;
|
||||||
|
@ -23,14 +24,21 @@ in vec3 _color;
|
||||||
in float _alpha;
|
in float _alpha;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 texel = texture(albedoMap, _texCoord0);
|
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
//vec3 fragColor = getMaterialEmissive(mat) * texel.rgb * _color;
|
int matKey = getMaterialKey(mat);
|
||||||
vec3 fragColor = vec3(1.0, 0.5, 0.0);
|
<$fetchMaterialTextures(matKey, _texCoord0, albedoTex, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL, _SCRIBE_NULL)$>
|
||||||
|
|
||||||
|
float opacity = 1.0;
|
||||||
|
<$evalMaterialOpacity(albedoTex.a, opacity, matKey, opacity)&>;
|
||||||
|
<$discardTransparent(opacity)$>;
|
||||||
|
|
||||||
|
vec3 albedo = getMaterialAlbedo(mat);
|
||||||
|
<$evalMaterialAlbedo(albedoTex, albedo, matKey, albedo)$>;
|
||||||
|
albedo *= _color;
|
||||||
|
|
||||||
packDeferredFragmentUnlit(
|
packDeferredFragmentUnlit(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
1.0,
|
opacity,
|
||||||
fragColor);
|
albedo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ Column {
|
||||||
"Roughness",
|
"Roughness",
|
||||||
"Metallic",
|
"Metallic",
|
||||||
"Emissive",
|
"Emissive",
|
||||||
|
"Shaded/Lightmapped/Unlit",
|
||||||
"Occlusion",
|
"Occlusion",
|
||||||
"Lightmap",
|
"Lightmap",
|
||||||
"Lighting",
|
"Lighting",
|
||||||
|
|
Loading…
Reference in a new issue