mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 18:10:37 +02:00
Changing diffuse to albedo and breaking everything...
This commit is contained in:
parent
6eda7aac6a
commit
0ad7bacf02
31 changed files with 106 additions and 138 deletions
|
@ -342,9 +342,9 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename
|
||||||
void ModelPackager::listTextures() {
|
void ModelPackager::listTextures() {
|
||||||
_textures.clear();
|
_textures.clear();
|
||||||
foreach (const FBXMaterial mat, _geometry->materials) {
|
foreach (const FBXMaterial mat, _geometry->materials) {
|
||||||
if (!mat.diffuseTexture.filename.isEmpty() && mat.diffuseTexture.content.isEmpty() &&
|
if (!mat.albedoTexture.filename.isEmpty() && mat.albedoTexture.content.isEmpty() &&
|
||||||
!_textures.contains(mat.diffuseTexture.filename)) {
|
!_textures.contains(mat.albedoTexture.filename)) {
|
||||||
_textures << mat.diffuseTexture.filename;
|
_textures << mat.albedoTexture.filename;
|
||||||
}
|
}
|
||||||
if (!mat.normalTexture.filename.isEmpty() && mat.normalTexture.content.isEmpty() &&
|
if (!mat.normalTexture.filename.isEmpty() && mat.normalTexture.content.isEmpty() &&
|
||||||
!_textures.contains(mat.normalTexture.filename)) {
|
!_textures.contains(mat.normalTexture.filename)) {
|
||||||
|
|
|
@ -151,7 +151,7 @@ public:
|
||||||
QString materialID;
|
QString materialID;
|
||||||
model::MaterialPointer _material;
|
model::MaterialPointer _material;
|
||||||
|
|
||||||
FBXTexture diffuseTexture;
|
FBXTexture albedoTexture;
|
||||||
FBXTexture opacityTexture;
|
FBXTexture opacityTexture;
|
||||||
FBXTexture normalTexture;
|
FBXTexture normalTexture;
|
||||||
FBXTexture specularTexture;
|
FBXTexture specularTexture;
|
||||||
|
|
|
@ -79,7 +79,7 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
material.diffuseTexture = diffuseTexture;
|
material.albedoTexture = diffuseTexture;
|
||||||
|
|
||||||
detectDifferentUVs = (diffuseTexture.texcoordSet != 0) || (!diffuseTexture.transform.isIdentity());
|
detectDifferentUVs = (diffuseTexture.texcoordSet != 0) || (!diffuseTexture.transform.isIdentity());
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
auto diffuse = material.diffuseColor;
|
auto diffuse = material.diffuseColor;
|
||||||
// FIXME: Do not use the Diffuse Factor yet as some FBX models have it set to 0
|
// FIXME: Do not use the Diffuse Factor yet as some FBX models have it set to 0
|
||||||
// diffuse *= material.diffuseFactor;
|
// diffuse *= material.diffuseFactor;
|
||||||
material._material->setDiffuse(diffuse);
|
material._material->setAlbedo(diffuse);
|
||||||
|
|
||||||
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));
|
||||||
// FIXME: Do not use the Specular Factor yet as some FBX models have it set to 0
|
// FIXME: Do not use the Specular Factor yet as some FBX models have it set to 0
|
||||||
|
|
|
@ -555,11 +555,11 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
|
||||||
model::MaterialPointer modelMaterial = fbxMaterial._material;
|
model::MaterialPointer modelMaterial = fbxMaterial._material;
|
||||||
|
|
||||||
if (!objMaterial.diffuseTextureFilename.isEmpty()) {
|
if (!objMaterial.diffuseTextureFilename.isEmpty()) {
|
||||||
fbxMaterial.diffuseTexture.filename = objMaterial.diffuseTextureFilename;
|
fbxMaterial.albedoTexture.filename = objMaterial.diffuseTextureFilename;
|
||||||
}
|
}
|
||||||
|
|
||||||
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
|
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
|
||||||
modelMaterial->setDiffuse(fbxMaterial.diffuseColor);
|
modelMaterial->setAlbedo(fbxMaterial.diffuseColor);
|
||||||
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
|
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
|
||||||
modelMaterial->setGloss(fbxMaterial.shininess);
|
modelMaterial->setGloss(fbxMaterial.shininess);
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool NetworkGeometry::isLoadedWithTextures() const {
|
||||||
|
|
||||||
if (!_isLoadedWithTextures) {
|
if (!_isLoadedWithTextures) {
|
||||||
for (auto&& material : _materials) {
|
for (auto&& material : _materials) {
|
||||||
if ((material->diffuseTexture && !material->diffuseTexture->isLoaded()) ||
|
if ((material->albedoTexture && !material->albedoTexture->isLoaded()) ||
|
||||||
(material->normalTexture && !material->normalTexture->isLoaded()) ||
|
(material->normalTexture && !material->normalTexture->isLoaded()) ||
|
||||||
(material->specularTexture && !material->specularTexture->isLoaded()) ||
|
(material->specularTexture && !material->specularTexture->isLoaded()) ||
|
||||||
(material->emissiveTexture && !material->emissiveTexture->isLoaded())) {
|
(material->emissiveTexture && !material->emissiveTexture->isLoaded())) {
|
||||||
|
@ -154,15 +154,15 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
|
||||||
for (auto&& material : _materials) {
|
for (auto&& material : _materials) {
|
||||||
auto networkMaterial = material->_material;
|
auto networkMaterial = material->_material;
|
||||||
auto oldTextureMaps = networkMaterial->getTextureMaps();
|
auto oldTextureMaps = networkMaterial->getTextureMaps();
|
||||||
if (material->diffuseTextureName == name) {
|
if (material->albedoTextureName == name) {
|
||||||
material->diffuseTexture = textureCache->getTexture(url, DEFAULT_TEXTURE);
|
material->albedoTexture = textureCache->getTexture(url, DEFAULT_TEXTURE);
|
||||||
|
|
||||||
auto diffuseMap = model::TextureMapPointer(new model::TextureMap());
|
auto albedoMap = model::TextureMapPointer(new model::TextureMap());
|
||||||
diffuseMap->setTextureSource(material->diffuseTexture->_textureSource);
|
albedoMap->setTextureSource(material->albedoTexture->_textureSource);
|
||||||
diffuseMap->setTextureTransform(
|
albedoMap->setTextureTransform(
|
||||||
oldTextureMaps[model::MaterialKey::DIFFUSE_MAP]->getTextureTransform());
|
oldTextureMaps[model::MaterialKey::ALBEDO_MAP]->getTextureTransform());
|
||||||
|
|
||||||
networkMaterial->setTextureMap(model::MaterialKey::DIFFUSE_MAP, diffuseMap);
|
networkMaterial->setTextureMap(model::MaterialKey::ALBEDO_MAP, albedoMap);
|
||||||
} else if (material->normalTextureName == name) {
|
} else if (material->normalTextureName == name) {
|
||||||
material->normalTexture = textureCache->getTexture(url);
|
material->normalTexture = textureCache->getTexture(url);
|
||||||
|
|
||||||
|
@ -200,9 +200,9 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
|
||||||
QStringList NetworkGeometry::getTextureNames() const {
|
QStringList NetworkGeometry::getTextureNames() const {
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (auto&& material : _materials) {
|
for (auto&& material : _materials) {
|
||||||
if (!material->diffuseTextureName.isEmpty() && material->diffuseTexture) {
|
if (!material->albedoTextureName.isEmpty() && material->albedoTexture) {
|
||||||
QString textureURL = material->diffuseTexture->getURL().toString();
|
QString textureURL = material->albedoTexture->getURL().toString();
|
||||||
result << material->diffuseTextureName + ":\"" + textureURL + "\"";
|
result << material->albedoTextureName + ":\"" + textureURL + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!material->normalTextureName.isEmpty() && material->normalTexture) {
|
if (!material->normalTextureName.isEmpty() && material->normalTexture) {
|
||||||
|
@ -310,15 +310,15 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
|
||||||
|
|
||||||
networkMaterial->_material = material._material;
|
networkMaterial->_material = material._material;
|
||||||
|
|
||||||
if (!material.diffuseTexture.filename.isEmpty()) {
|
if (!material.albedoTexture.filename.isEmpty()) {
|
||||||
networkMaterial->diffuseTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.diffuseTexture.filename)), DEFAULT_TEXTURE, material.diffuseTexture.content);
|
networkMaterial->albedoTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.albedoTexture.filename)), DEFAULT_TEXTURE, material.albedoTexture.content);
|
||||||
networkMaterial->diffuseTextureName = material.diffuseTexture.name;
|
networkMaterial->albedoTextureName = material.albedoTexture.name;
|
||||||
|
|
||||||
auto diffuseMap = model::TextureMapPointer(new model::TextureMap());
|
auto albedoMap = model::TextureMapPointer(new model::TextureMap());
|
||||||
diffuseMap->setTextureSource(networkMaterial->diffuseTexture->_textureSource);
|
albedoMap->setTextureSource(networkMaterial->albedoTexture->_textureSource);
|
||||||
diffuseMap->setTextureTransform(material.diffuseTexture.transform);
|
albedoMap->setTextureTransform(material.albedoTexture.transform);
|
||||||
|
|
||||||
material._material->setTextureMap(model::MaterialKey::DIFFUSE_MAP, diffuseMap);
|
material._material->setTextureMap(model::MaterialKey::ALBEDO_MAP, albedoMap);
|
||||||
}
|
}
|
||||||
if (!material.normalTexture.filename.isEmpty()) {
|
if (!material.normalTexture.filename.isEmpty()) {
|
||||||
networkMaterial->normalTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.normalTexture.filename)), (material.normalTexture.isBumpmap ? BUMP_TEXTURE : NORMAL_TEXTURE), material.normalTexture.content);
|
networkMaterial->normalTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.normalTexture.filename)), (material.normalTexture.isBumpmap ? BUMP_TEXTURE : NORMAL_TEXTURE), material.normalTexture.content);
|
||||||
|
|
|
@ -174,8 +174,8 @@ public:
|
||||||
class NetworkMaterial {
|
class NetworkMaterial {
|
||||||
public:
|
public:
|
||||||
model::MaterialPointer _material;
|
model::MaterialPointer _material;
|
||||||
QString diffuseTextureName;
|
QString albedoTextureName;
|
||||||
QSharedPointer<NetworkTexture> diffuseTexture;
|
QSharedPointer<NetworkTexture> albedoTexture;
|
||||||
QString normalTextureName;
|
QString normalTextureName;
|
||||||
QSharedPointer<NetworkTexture> normalTexture;
|
QSharedPointer<NetworkTexture> normalTexture;
|
||||||
QString specularTextureName;
|
QString specularTextureName;
|
||||||
|
|
|
@ -44,9 +44,9 @@ Material& Material::operator= (const Material& material) {
|
||||||
Material::~Material() {
|
Material::~Material() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Material::setDiffuse(const Color& diffuse, bool isSRGB) {
|
void Material::setAlbedo(const Color& albedo, bool isSRGB) {
|
||||||
_key.setDiffuse(glm::any(glm::greaterThan(diffuse, Color(0.0f))));
|
_key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f))));
|
||||||
_schemaBuffer.edit<Schema>()._diffuse = (isSRGB ? ColorUtils::toLinearVec3(diffuse) : diffuse);
|
_schemaBuffer.edit<Schema>()._albedo = (isSRGB ? ColorUtils::toLinearVec3(albedo) : albedo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Material::setMetallic(float metallic) {
|
void Material::setMetallic(float metallic) {
|
||||||
|
|
|
@ -28,13 +28,13 @@ class MaterialKey {
|
||||||
public:
|
public:
|
||||||
enum FlagBit {
|
enum FlagBit {
|
||||||
EMISSIVE_VAL_BIT = 0,
|
EMISSIVE_VAL_BIT = 0,
|
||||||
DIFFUSE_VAL_BIT,
|
ALBEDO_VAL_BIT,
|
||||||
METALLIC_VAL_BIT,
|
METALLIC_VAL_BIT,
|
||||||
GLOSS_VAL_BIT,
|
GLOSS_VAL_BIT,
|
||||||
TRANSPARENT_VAL_BIT,
|
TRANSPARENT_VAL_BIT,
|
||||||
|
|
||||||
EMISSIVE_MAP_BIT,
|
EMISSIVE_MAP_BIT,
|
||||||
DIFFUSE_MAP_BIT,
|
ALBEDO_MAP_BIT,
|
||||||
METALLIC_MAP_BIT,
|
METALLIC_MAP_BIT,
|
||||||
GLOSS_MAP_BIT,
|
GLOSS_MAP_BIT,
|
||||||
TRANSPARENT_MAP_BIT,
|
TRANSPARENT_MAP_BIT,
|
||||||
|
@ -47,7 +47,7 @@ public:
|
||||||
|
|
||||||
enum MapChannel {
|
enum MapChannel {
|
||||||
EMISSIVE_MAP = 0,
|
EMISSIVE_MAP = 0,
|
||||||
DIFFUSE_MAP,
|
ALBEDO_MAP,
|
||||||
METALLIC_MAP,
|
METALLIC_MAP,
|
||||||
GLOSS_MAP,
|
GLOSS_MAP,
|
||||||
TRANSPARENT_MAP,
|
TRANSPARENT_MAP,
|
||||||
|
@ -71,13 +71,13 @@ public:
|
||||||
MaterialKey build() const { return MaterialKey(_flags); }
|
MaterialKey build() const { return MaterialKey(_flags); }
|
||||||
|
|
||||||
Builder& withEmissive() { _flags.set(EMISSIVE_VAL_BIT); return (*this); }
|
Builder& withEmissive() { _flags.set(EMISSIVE_VAL_BIT); return (*this); }
|
||||||
Builder& withDiffuse() { _flags.set(DIFFUSE_VAL_BIT); return (*this); }
|
Builder& withAlbedo() { _flags.set(ALBEDO_VAL_BIT); return (*this); }
|
||||||
Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); }
|
Builder& withMetallic() { _flags.set(METALLIC_VAL_BIT); return (*this); }
|
||||||
Builder& withGloss() { _flags.set(GLOSS_VAL_BIT); return (*this); }
|
Builder& withGloss() { _flags.set(GLOSS_VAL_BIT); return (*this); }
|
||||||
Builder& withTransparent() { _flags.set(TRANSPARENT_VAL_BIT); return (*this); }
|
Builder& withTransparent() { _flags.set(TRANSPARENT_VAL_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); }
|
Builder& withEmissiveMap() { _flags.set(EMISSIVE_MAP_BIT); return (*this); }
|
||||||
Builder& withDiffuseMap() { _flags.set(DIFFUSE_MAP_BIT); return (*this); }
|
Builder& withAlbedoMap() { _flags.set(ALBEDO_MAP_BIT); return (*this); }
|
||||||
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
|
Builder& withMetallicMap() { _flags.set(METALLIC_MAP_BIT); return (*this); }
|
||||||
Builder& withGlossMap() { _flags.set(GLOSS_MAP_BIT); return (*this); }
|
Builder& withGlossMap() { _flags.set(GLOSS_MAP_BIT); return (*this); }
|
||||||
Builder& withTransparentMap() { _flags.set(TRANSPARENT_MAP_BIT); return (*this); }
|
Builder& withTransparentMap() { _flags.set(TRANSPARENT_MAP_BIT); return (*this); }
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
Builder& withLightmapMap() { _flags.set(LIGHTMAP_MAP_BIT); return (*this); }
|
Builder& withLightmapMap() { _flags.set(LIGHTMAP_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
// Convenient standard keys that we will keep on using all over the place
|
// Convenient standard keys that we will keep on using all over the place
|
||||||
static MaterialKey opaqueDiffuse() { return Builder().withDiffuse().build(); }
|
static MaterialKey opaqueAlbedo() { return Builder().withAlbedo().build(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
void setEmissive(bool value) { _flags.set(EMISSIVE_VAL_BIT, value); }
|
void setEmissive(bool value) { _flags.set(EMISSIVE_VAL_BIT, value); }
|
||||||
|
@ -95,11 +95,11 @@ public:
|
||||||
void setEmissiveMap(bool value) { _flags.set(EMISSIVE_MAP_BIT, value); }
|
void setEmissiveMap(bool value) { _flags.set(EMISSIVE_MAP_BIT, value); }
|
||||||
bool isEmissiveMap() const { return _flags[EMISSIVE_MAP_BIT]; }
|
bool isEmissiveMap() const { return _flags[EMISSIVE_MAP_BIT]; }
|
||||||
|
|
||||||
void setDiffuse(bool value) { _flags.set(DIFFUSE_VAL_BIT, value); }
|
void setAlbedo(bool value) { _flags.set(ALBEDO_VAL_BIT, value); }
|
||||||
bool isDiffuse() const { return _flags[DIFFUSE_VAL_BIT]; }
|
bool isAlbedo() const { return _flags[ALBEDO_VAL_BIT]; }
|
||||||
|
|
||||||
void setDiffuseMap(bool value) { _flags.set(DIFFUSE_MAP_BIT, value); }
|
void setAlbedoMap(bool value) { _flags.set(ALBEDO_MAP_BIT, value); }
|
||||||
bool isDiffuseMap() const { return _flags[DIFFUSE_MAP_BIT]; }
|
bool isAlbedoMap() const { return _flags[ALBEDO_MAP_BIT]; }
|
||||||
|
|
||||||
void setMetallic(bool value) { _flags.set(METALLIC_VAL_BIT, value); }
|
void setMetallic(bool value) { _flags.set(METALLIC_VAL_BIT, value); }
|
||||||
bool isMetallic() const { return _flags[METALLIC_VAL_BIT]; }
|
bool isMetallic() const { return _flags[METALLIC_VAL_BIT]; }
|
||||||
|
@ -154,11 +154,11 @@ public:
|
||||||
Builder& withoutEmissiveMap() { _value.reset(MaterialKey::EMISSIVE_MAP_BIT); _mask.set(MaterialKey::EMISSIVE_MAP_BIT); return (*this); }
|
Builder& withoutEmissiveMap() { _value.reset(MaterialKey::EMISSIVE_MAP_BIT); _mask.set(MaterialKey::EMISSIVE_MAP_BIT); return (*this); }
|
||||||
Builder& withEmissiveMap() { _value.set(MaterialKey::EMISSIVE_MAP_BIT); _mask.set(MaterialKey::EMISSIVE_MAP_BIT); return (*this); }
|
Builder& withEmissiveMap() { _value.set(MaterialKey::EMISSIVE_MAP_BIT); _mask.set(MaterialKey::EMISSIVE_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutDiffuse() { _value.reset(MaterialKey::DIFFUSE_VAL_BIT); _mask.set(MaterialKey::DIFFUSE_VAL_BIT); return (*this); }
|
Builder& withoutAlbedo() { _value.reset(MaterialKey::ALBEDO_VAL_BIT); _mask.set(MaterialKey::ALBEDO_VAL_BIT); return (*this); }
|
||||||
Builder& withDiffuse() { _value.set(MaterialKey::DIFFUSE_VAL_BIT); _mask.set(MaterialKey::DIFFUSE_VAL_BIT); return (*this); }
|
Builder& withAlbedo() { _value.set(MaterialKey::ALBEDO_VAL_BIT); _mask.set(MaterialKey::ALBEDO_VAL_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutDiffuseMap() { _value.reset(MaterialKey::DIFFUSE_MAP_BIT); _mask.set(MaterialKey::DIFFUSE_MAP_BIT); return (*this); }
|
Builder& withoutAlbedoMap() { _value.reset(MaterialKey::ALBEDO_MAP_BIT); _mask.set(MaterialKey::ALBEDO_MAP_BIT); return (*this); }
|
||||||
Builder& withDiffuseMap() { _value.set(MaterialKey::DIFFUSE_MAP_BIT); _mask.set(MaterialKey::DIFFUSE_MAP_BIT); return (*this); }
|
Builder& withAlbedoMap() { _value.set(MaterialKey::ALBEDO_MAP_BIT); _mask.set(MaterialKey::ALBEDO_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
Builder& withoutMetallic() { _value.reset(MaterialKey::METALLIC_VAL_BIT); _mask.set(MaterialKey::METALLIC_VAL_BIT); return (*this); }
|
Builder& withoutMetallic() { _value.reset(MaterialKey::METALLIC_VAL_BIT); _mask.set(MaterialKey::METALLIC_VAL_BIT); return (*this); }
|
||||||
Builder& withMetallic() { _value.set(MaterialKey::METALLIC_VAL_BIT); _mask.set(MaterialKey::METALLIC_VAL_BIT); return (*this); }
|
Builder& withMetallic() { _value.set(MaterialKey::METALLIC_VAL_BIT); _mask.set(MaterialKey::METALLIC_VAL_BIT); return (*this); }
|
||||||
|
@ -185,7 +185,7 @@ public:
|
||||||
Builder& withLightmapMap() { _value.set(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); }
|
Builder& withLightmapMap() { _value.set(MaterialKey::LIGHTMAP_MAP_BIT); _mask.set(MaterialKey::LIGHTMAP_MAP_BIT); return (*this); }
|
||||||
|
|
||||||
// Convenient standard keys that we will keep on using all over the place
|
// Convenient standard keys that we will keep on using all over the place
|
||||||
static MaterialFilter opaqueDiffuse() { return Builder().withDiffuse().withoutTransparent().build(); }
|
static MaterialFilter opaqueAlbedo() { return Builder().withAlbedo().withoutTransparent().build(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Item Filter operator testing if a key pass the filter
|
// Item Filter operator testing if a key pass the filter
|
||||||
|
@ -223,8 +223,8 @@ public:
|
||||||
void setEmissive(const Color& emissive, bool isSRGB = true);
|
void setEmissive(const Color& emissive, bool isSRGB = true);
|
||||||
Color getEmissive(bool SRGB = true) const { return (SRGB ? ColorUtils::toGamma22Vec3(_schemaBuffer.get<Schema>()._emissive) : _schemaBuffer.get<Schema>()._emissive); }
|
Color getEmissive(bool SRGB = true) const { return (SRGB ? ColorUtils::toGamma22Vec3(_schemaBuffer.get<Schema>()._emissive) : _schemaBuffer.get<Schema>()._emissive); }
|
||||||
|
|
||||||
void setDiffuse(const Color& diffuse, bool isSRGB = true);
|
void setAlbedo(const Color& albedo, bool isSRGB = true);
|
||||||
Color getDiffuse(bool SRGB = true) const { return (SRGB ? ColorUtils::toGamma22Vec3(_schemaBuffer.get<Schema>()._diffuse) : _schemaBuffer.get<Schema>()._diffuse); }
|
Color getAlbedo(bool SRGB = true) const { return (SRGB ? ColorUtils::toGamma22Vec3(_schemaBuffer.get<Schema>()._albedo) : _schemaBuffer.get<Schema>()._albedo); }
|
||||||
|
|
||||||
void setMetallic(float metallic);
|
void setMetallic(float metallic);
|
||||||
float getMetallic() const { return _schemaBuffer.get<Schema>()._metallic.x; }
|
float getMetallic() const { return _schemaBuffer.get<Schema>()._metallic.x; }
|
||||||
|
@ -239,7 +239,7 @@ public:
|
||||||
class Schema {
|
class Schema {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
glm::vec3 _diffuse{ 0.5f };
|
glm::vec3 _albedo{ 0.5f };
|
||||||
float _opacity{1.f};
|
float _opacity{1.f};
|
||||||
glm::vec3 _metallic{ 0.03f };
|
glm::vec3 _metallic{ 0.03f };
|
||||||
float _gloss{0.1f};
|
float _gloss{0.1f};
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<@def MODEL_MATERIAL_SLH@>
|
<@def MODEL_MATERIAL_SLH@>
|
||||||
|
|
||||||
struct Material {
|
struct Material {
|
||||||
vec4 _diffuse;
|
vec4 _albedoOpacity;
|
||||||
vec4 _specular;
|
vec4 _specular;
|
||||||
vec4 _emissive;
|
vec4 _emissive;
|
||||||
vec4 _spare;
|
vec4 _spare;
|
||||||
|
@ -26,40 +26,8 @@ Material getMaterial() {
|
||||||
return _mat;
|
return _mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
<! // TODO: use this code for correct gamma correction
|
float getMaterialOpacity(Material m) { return m._albedoOpacity.a; }
|
||||||
/*
|
vec3 getMaterialAlbedo(Material m) { return m._albedoOpacity.rgb; }
|
||||||
float componentSRGBToLinear(float cs) {
|
|
||||||
// sRGB to linear conversion
|
|
||||||
// { cs / 12.92, cs <= 0.04045
|
|
||||||
// cl = {
|
|
||||||
// { ((cs + 0.055)/1.055)^2.4, cs > 0.04045
|
|
||||||
// constants:
|
|
||||||
// T = 0.04045
|
|
||||||
// A = 1 / 1.055 = 0.94786729857
|
|
||||||
// B = 0.055 * A = 0.05213270142
|
|
||||||
// C = 1 / 12.92 = 0.0773993808
|
|
||||||
// G = 2.4
|
|
||||||
const float T = 0.04045;
|
|
||||||
const float A = 0.947867;
|
|
||||||
const float B = 0.052132;
|
|
||||||
const float C = 0.077399;
|
|
||||||
const float G = 2.4;
|
|
||||||
|
|
||||||
if (cs > T) {
|
|
||||||
return pow((cs * A + B), G);
|
|
||||||
} else {
|
|
||||||
return cs * C;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 SRGBToLinear(vec3 srgb) {
|
|
||||||
return vec3(componentSRGBToLinear(srgb.x),componentSRGBToLinear(srgb.y),componentSRGBToLinear(srgb.z));
|
|
||||||
}
|
|
||||||
vec3 getMaterialDiffuse(Material m) { return (gl_FragCoord.x < 800 ? SRGBToLinear(m._diffuse.rgb) : m._diffuse.rgb); }
|
|
||||||
*/!>
|
|
||||||
|
|
||||||
float getMaterialOpacity(Material m) { return m._diffuse.a; }
|
|
||||||
vec3 getMaterialDiffuse(Material m) { return m._diffuse.rgb; }
|
|
||||||
vec3 getMaterialSpecular(Material m) { return m._specular.rgb; }
|
vec3 getMaterialSpecular(Material m) { return m._specular.rgb; }
|
||||||
float getMaterialShininess(Material m) { return m._specular.a; }
|
float getMaterialShininess(Material m) { return m._specular.a; }
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ typedef glm::vec3 Color;
|
||||||
class TextureUsage {
|
class TextureUsage {
|
||||||
public:
|
public:
|
||||||
gpu::Texture::Type _type{ gpu::Texture::TEX_2D };
|
gpu::Texture::Type _type{ gpu::Texture::TEX_2D };
|
||||||
Material::MapFlags _materialUsage{ MaterialKey::DIFFUSE_MAP };
|
Material::MapFlags _materialUsage{ MaterialKey::ALBEDO_MAP };
|
||||||
|
|
||||||
int _environmentUsage = 0;
|
int _environmentUsage = 0;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ void DebugDeferredBufferConfig::setMode(int newMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Slot {
|
enum Slot {
|
||||||
Diffuse = 0,
|
Albedo = 0,
|
||||||
Normal,
|
Normal,
|
||||||
Specular,
|
Specular,
|
||||||
Depth,
|
Depth,
|
||||||
|
@ -52,9 +52,9 @@ enum Slot {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const std::string DEFAULT_DIFFUSE_SHADER {
|
static const std::string DEFAULT_ALBEDO_SHADER {
|
||||||
"vec4 getFragmentColor() {"
|
"vec4 getFragmentColor() {"
|
||||||
" return vec4(pow(texture(diffuseMap, uv).xyz, vec3(1.0 / 2.2)), 1.0);"
|
" return vec4(pow(texture(albedoMap, uv).xyz, vec3(1.0 / 2.2)), 1.0);"
|
||||||
" }"
|
" }"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -144,8 +144,8 @@ DebugDeferredBuffer::DebugDeferredBuffer() {
|
||||||
|
|
||||||
std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string customFile) {
|
std::string DebugDeferredBuffer::getShaderSourceCode(Mode mode, std::string customFile) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DiffuseMode:
|
case AlbedoMode:
|
||||||
return DEFAULT_DIFFUSE_SHADER;
|
return DEFAULT_ALBEDO_SHADER;
|
||||||
case SpecularMode:
|
case SpecularMode:
|
||||||
return DEFAULT_SPECULAR_SHADER;
|
return DEFAULT_SPECULAR_SHADER;
|
||||||
case RoughnessMode:
|
case RoughnessMode:
|
||||||
|
@ -206,7 +206,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
|
||||||
const auto program = gpu::Shader::createProgram(vs, ps);
|
const auto program = gpu::Shader::createProgram(vs, ps);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding("diffuseMap", Diffuse));
|
slotBindings.insert(gpu::Shader::Binding("albedoMap", Albedo));
|
||||||
slotBindings.insert(gpu::Shader::Binding("normalMap", Normal));
|
slotBindings.insert(gpu::Shader::Binding("normalMap", Normal));
|
||||||
slotBindings.insert(gpu::Shader::Binding("specularMap", Specular));
|
slotBindings.insert(gpu::Shader::Binding("specularMap", Specular));
|
||||||
slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));
|
slotBindings.insert(gpu::Shader::Binding("depthMap", Depth));
|
||||||
|
@ -262,7 +262,7 @@ void DebugDeferredBuffer::run(const SceneContextPointer& sceneContext, const Ren
|
||||||
|
|
||||||
batch.setPipeline(getPipeline(_mode, first));
|
batch.setPipeline(getPipeline(_mode, first));
|
||||||
|
|
||||||
batch.setResourceTexture(Diffuse, framebufferCache->getDeferredColorTexture());
|
batch.setResourceTexture(Albedo, framebufferCache->getDeferredColorTexture());
|
||||||
batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());
|
batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());
|
||||||
batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
|
batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
|
||||||
batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
|
batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());
|
||||||
|
|
|
@ -47,7 +47,7 @@ protected:
|
||||||
|
|
||||||
enum Mode : uint8_t {
|
enum Mode : uint8_t {
|
||||||
// Use Mode suffix to avoid collisions
|
// Use Mode suffix to avoid collisions
|
||||||
DiffuseMode = 0,
|
AlbedoMode = 0,
|
||||||
SpecularMode,
|
SpecularMode,
|
||||||
RoughnessMode,
|
RoughnessMode,
|
||||||
NormalMode,
|
NormalMode,
|
||||||
|
|
|
@ -525,7 +525,7 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
|
||||||
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
|
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
|
||||||
|
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), DEFERRED_BUFFER_COLOR_UNIT));
|
slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), DEFERRED_BUFFER_COLOR_UNIT));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT));
|
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), DEFERRED_BUFFER_EMISSIVE_UNIT));
|
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), DEFERRED_BUFFER_EMISSIVE_UNIT));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), DEFERRED_BUFFER_DEPTH_UNIT));
|
slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), DEFERRED_BUFFER_DEPTH_UNIT));
|
||||||
|
@ -584,10 +584,10 @@ void DeferredLightingEffect::setAmbientLightMode(int preset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeferredLightingEffect::setGlobalLight(const glm::vec3& direction, const glm::vec3& diffuse, float intensity, float ambientIntensity) {
|
void DeferredLightingEffect::setGlobalLight(const glm::vec3& direction, const glm::vec3& color, float intensity, float ambientIntensity) {
|
||||||
auto light = _allocatedLights.front();
|
auto light = _allocatedLights.front();
|
||||||
light->setDirection(direction);
|
light->setDirection(direction);
|
||||||
light->setColor(diffuse);
|
light->setColor(color);
|
||||||
light->setIntensity(intensity);
|
light->setIntensity(intensity);
|
||||||
light->setAmbientIntensity(ambientIntensity);
|
light->setAmbientIntensity(ambientIntensity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -504,7 +504,7 @@ GeometryCache::GeometryCache() :
|
||||||
std::make_shared<render::ShapePipeline>(getSimplePipeline(), nullptr,
|
std::make_shared<render::ShapePipeline>(getSimplePipeline(), nullptr,
|
||||||
[](const render::ShapePipeline&, gpu::Batch& batch) {
|
[](const render::ShapePipeline&, gpu::Batch& batch) {
|
||||||
// Set the defaults needed for a simple program
|
// Set the defaults needed for a simple program
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::DIFFUSE_MAP,
|
batch.setResourceTexture(render::ShapePipeline::Slot::ALBEDO_MAP,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP,
|
batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP,
|
||||||
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
DependencyManager::get<TextureCache>()->getNormalFittingTexture());
|
||||||
|
@ -1848,7 +1848,7 @@ void GeometryCache::bindSimpleProgram(gpu::Batch& batch, bool textured, bool cul
|
||||||
|
|
||||||
// If not textured, set a default diffuse map
|
// If not textured, set a default diffuse map
|
||||||
if (!textured) {
|
if (!textured) {
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::DIFFUSE_MAP,
|
batch.setResourceTexture(render::ShapePipeline::Slot::ALBEDO_MAP,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
}
|
}
|
||||||
// Set a default normal map
|
// Set a default normal map
|
||||||
|
|
|
@ -145,20 +145,20 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
|
||||||
auto textureMaps = _drawMaterial->getTextureMaps();
|
auto textureMaps = _drawMaterial->getTextureMaps();
|
||||||
glm::mat4 texcoordTransform[2];
|
glm::mat4 texcoordTransform[2];
|
||||||
|
|
||||||
// Diffuse
|
// Albedo
|
||||||
if (materialKey.isDiffuseMap()) {
|
if (materialKey.isAlbedoMap()) {
|
||||||
auto diffuseMap = textureMaps[model::MaterialKey::DIFFUSE_MAP];
|
auto albedoMap = textureMaps[model::MaterialKey::ALBEDO_MAP];
|
||||||
if (diffuseMap && diffuseMap->isDefined()) {
|
if (albedoMap && albedoMap->isDefined()) {
|
||||||
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, diffuseMap->getTextureView());
|
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, albedoMap->getTextureView());
|
||||||
|
|
||||||
if (!diffuseMap->getTextureTransform().isIdentity()) {
|
if (!albedoMap->getTextureTransform().isIdentity()) {
|
||||||
diffuseMap->getTextureTransform().getMatrix(texcoordTransform[0]);
|
albedoMap->getTextureTransform().getMatrix(texcoordTransform[0]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getGrayTexture());
|
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, textureCache->getGrayTexture());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getWhiteTexture());
|
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, textureCache->getWhiteTexture());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal map
|
// Normal map
|
||||||
|
|
|
@ -1197,7 +1197,7 @@ void Model::segregateMeshGroups() {
|
||||||
if (showingCollisionHull) {
|
if (showingCollisionHull) {
|
||||||
if (!_collisionHullMaterial) {
|
if (!_collisionHullMaterial) {
|
||||||
_collisionHullMaterial = std::make_shared<model::Material>();
|
_collisionHullMaterial = std::make_shared<model::Material>();
|
||||||
_collisionHullMaterial->setDiffuse(glm::vec3(1.0f, 0.5f, 0.0f));
|
_collisionHullMaterial->setAlbedo(glm::vec3(1.0f, 0.5f, 0.0f));
|
||||||
_collisionHullMaterial->setMetallic(0.02f);
|
_collisionHullMaterial->setMetallic(0.02f);
|
||||||
_collisionHullMaterial->setGloss(1.0f);
|
_collisionHullMaterial->setGloss(1.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ void initStencilPipeline(gpu::PipelinePointer& pipeline) {
|
||||||
|
|
||||||
gpu::BufferView getDefaultMaterialBuffer() {
|
gpu::BufferView getDefaultMaterialBuffer() {
|
||||||
model::Material::Schema schema;
|
model::Material::Schema schema;
|
||||||
schema._diffuse = vec3(1.0f);
|
schema._albedo = vec3(1.0f);
|
||||||
schema._opacity = 1.0f;
|
schema._opacity = 1.0f;
|
||||||
schema._metallic = vec3(0.1f);
|
schema._metallic = vec3(0.1f);
|
||||||
schema._gloss = 10.0f;
|
schema._gloss = 10.0f;
|
||||||
|
@ -74,8 +74,8 @@ gpu::BufferView getDefaultMaterialBuffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {
|
void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {
|
||||||
// Set a default diffuse map
|
// Set a default albedo map
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::DIFFUSE_MAP,
|
batch.setResourceTexture(render::ShapePipeline::Slot::ALBEDO_MAP,
|
||||||
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
DependencyManager::get<TextureCache>()->getWhiteTexture());
|
||||||
// Set a default normal map
|
// Set a default normal map
|
||||||
batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP,
|
batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP,
|
||||||
|
|
|
@ -33,7 +33,7 @@ void main(void) {
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(_normal.xyz),
|
normalize(_normal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialShininess(mat));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ void main(void) {
|
||||||
vec4 texel = texture(diffuseMap, _texCoord0);
|
vec4 texel = texture(diffuseMap, _texCoord0);
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
vec3 fragColor = getMaterialDiffuse(mat) * texel.rgb * _color;
|
vec3 fragColor = getMaterialAlbedo(mat) * texel.rgb * _color;
|
||||||
|
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
|
|
|
@ -38,7 +38,7 @@ void main(void) {
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
getMaterialShininess(mat),
|
getMaterialShininess(mat),
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
|
|
|
@ -51,7 +51,7 @@ void main(void) {
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
getMaterialShininess(mat),
|
getMaterialShininess(mat),
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
|
|
|
@ -55,7 +55,7 @@ void main(void) {
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
specular, // no use of getMaterialSpecular(mat)
|
specular, // no use of getMaterialSpecular(mat)
|
||||||
getMaterialShininess(mat),
|
getMaterialShininess(mat),
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
|
|
|
@ -43,7 +43,7 @@ void main(void) {
|
||||||
packDeferredFragmentLightmap(
|
packDeferredFragmentLightmap(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
specular, // no use of getMaterialSpecular(mat)
|
specular, // no use of getMaterialSpecular(mat)
|
||||||
getMaterialShininess(mat),
|
getMaterialShininess(mat),
|
||||||
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));
|
||||||
|
|
|
@ -44,7 +44,7 @@ void main(void) {
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
getMaterialSpecular(mat),
|
getMaterialSpecular(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialShininess(mat));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void main(void) {
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(viewNormal.xyz),
|
normalize(viewNormal.xyz),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * diffuse.rgb * _color,
|
||||||
specular, //getMaterialSpecular(mat),
|
specular, //getMaterialSpecular(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialShininess(mat));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
<@include model/Material.slh@>
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
// the diffuse texture
|
// the albedo texture
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D albedoMap;
|
||||||
|
|
||||||
// the specular texture
|
// the specular texture
|
||||||
uniform sampler2D specularMap;
|
uniform sampler2D specularMap;
|
||||||
|
@ -29,16 +29,16 @@ in vec3 _color;
|
||||||
|
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set the diffuse, normal, specular data
|
// set the albedo, normal, specular data
|
||||||
vec4 diffuse = texture(diffuseMap, _texCoord0);
|
vec4 albedo = texture(albedoMap, _texCoord0);
|
||||||
vec3 specular = texture(specularMap, _texCoord0).rgb;
|
vec3 specular = texture(specularMap, _texCoord0).rgb;
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
|
|
||||||
packDeferredFragment(
|
packDeferredFragment(
|
||||||
normalize(_normal),
|
normalize(_normal),
|
||||||
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
|
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
|
||||||
getMaterialDiffuse(mat) * diffuse.rgb * _color,
|
getMaterialAlbedo(mat) * albedo.rgb * _color,
|
||||||
specular, //getMaterialSpecular(mat),
|
specular, //getMaterialSpecular(mat),
|
||||||
getMaterialShininess(mat));
|
getMaterialShininess(mat));
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 d
|
||||||
return vec4(color, opacity);
|
return vec4(color, opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D albedoMap;
|
||||||
|
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
in vec4 _position;
|
in vec4 _position;
|
||||||
|
@ -51,15 +51,15 @@ in float _alpha;
|
||||||
out vec4 _fragColor;
|
out vec4 _fragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 diffuse = texture(diffuseMap, _texCoord0);
|
vec4 albedo = texture(albedoMap, _texCoord0);
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
vec3 fragPosition = _position.xyz;
|
vec3 fragPosition = _position.xyz;
|
||||||
vec3 fragNormal = normalize(_normal);
|
vec3 fragNormal = normalize(_normal);
|
||||||
vec3 fragDiffuse = getMaterialDiffuse(mat) * diffuse.rgb * _color;
|
vec3 fragDiffuse = getMaterialAlbedo(mat) * albedo.rgb * _color;
|
||||||
vec3 fragSpecular = getMaterialSpecular(mat);
|
vec3 fragSpecular = getMaterialSpecular(mat);
|
||||||
float fragGloss = getMaterialShininess(mat) / 128;
|
float fragGloss = getMaterialShininess(mat) / 128;
|
||||||
float fragOpacity = getMaterialOpacity(mat) * diffuse.a * _alpha;
|
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
|
||||||
|
|
||||||
_fragColor = evalGlobalColor(1.0,
|
_fragColor = evalGlobalColor(1.0,
|
||||||
fragPosition,
|
fragPosition,
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<@include model/Material.slh@>
|
<@include model/Material.slh@>
|
||||||
|
|
||||||
uniform sampler2D diffuseMap;
|
uniform sampler2D albedoMap;
|
||||||
|
|
||||||
in vec2 _texCoord0;
|
in vec2 _texCoord0;
|
||||||
in vec3 _color;
|
in vec3 _color;
|
||||||
|
@ -23,11 +23,11 @@ in float _alpha;
|
||||||
out vec4 _fragColor;
|
out vec4 _fragColor;
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
vec4 diffuse = texture(diffuseMap, _texCoord0);
|
vec4 albedo = texture(albedoMap, _texCoord0);
|
||||||
|
|
||||||
Material mat = getMaterial();
|
Material mat = getMaterial();
|
||||||
vec3 fragColor = getMaterialDiffuse(mat) * diffuse.rgb * _color;
|
vec3 fragColor = getMaterialAlbedo(mat) * albedo.rgb * _color;
|
||||||
float fragOpacity = getMaterialOpacity(mat) * diffuse.a * _alpha;
|
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
|
||||||
|
|
||||||
_fragColor = vec4(fragColor, fragOpacity);
|
_fragColor = vec4(fragColor, fragOpacity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ void main(void) {
|
||||||
|
|
||||||
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
|
skinPositionNormalTangent(inSkinClusterIndex, inSkinClusterWeight, inPosition, inNormal.xyz, inTangent.xyz, position, interpolatedNormal.xyz, interpolatedTangent.xyz);
|
||||||
|
|
||||||
// pass along the diffuse color
|
// pass along the color
|
||||||
_color = colorToLinearRGB(inColor.rgb);
|
_color = colorToLinearRGB(inColor.rgb);
|
||||||
|
|
||||||
// and the texture coordinates
|
// and the texture coordinates
|
||||||
|
|
|
@ -53,7 +53,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
|
||||||
gpu::Shader::BindingSet slotBindings;
|
gpu::Shader::BindingSet slotBindings;
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::SKINNING_GPU));
|
slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::SKINNING_GPU));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slot::MATERIAL_GPU));
|
slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slot::MATERIAL_GPU));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("diffuseMap"), Slot::DIFFUSE_MAP));
|
slotBindings.insert(gpu::Shader::Binding(std::string("albedoMap"), Slot::ALBEDO_MAP));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP));
|
slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slot::SPECULAR_MAP));
|
slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), Slot::SPECULAR_MAP));
|
||||||
slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::LIGHTMAP_MAP));
|
slotBindings.insert(gpu::Shader::Binding(std::string("emissiveMap"), Slot::LIGHTMAP_MAP));
|
||||||
|
@ -66,7 +66,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
|
||||||
locations->texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices");
|
locations->texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices");
|
||||||
locations->emissiveParams = program->getUniforms().findLocation("emissiveParams");
|
locations->emissiveParams = program->getUniforms().findLocation("emissiveParams");
|
||||||
locations->normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap");
|
locations->normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap");
|
||||||
locations->diffuseTextureUnit = program->getTextures().findLocation("diffuseMap");
|
locations->albedoTextureUnit = program->getTextures().findLocation("albedoMap");
|
||||||
locations->normalTextureUnit = program->getTextures().findLocation("normalMap");
|
locations->normalTextureUnit = program->getTextures().findLocation("normalMap");
|
||||||
locations->specularTextureUnit = program->getTextures().findLocation("specularMap");
|
locations->specularTextureUnit = program->getTextures().findLocation("specularMap");
|
||||||
locations->emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");
|
locations->emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");
|
||||||
|
|
|
@ -195,7 +195,7 @@ public:
|
||||||
public:
|
public:
|
||||||
static const int SKINNING_GPU = 2;
|
static const int SKINNING_GPU = 2;
|
||||||
static const int MATERIAL_GPU = 3;
|
static const int MATERIAL_GPU = 3;
|
||||||
static const int DIFFUSE_MAP = 0;
|
static const int ALBEDO_MAP = 0;
|
||||||
static const int NORMAL_MAP = 1;
|
static const int NORMAL_MAP = 1;
|
||||||
static const int SPECULAR_MAP = 2;
|
static const int SPECULAR_MAP = 2;
|
||||||
static const int LIGHTMAP_MAP = 3;
|
static const int LIGHTMAP_MAP = 3;
|
||||||
|
@ -206,7 +206,7 @@ public:
|
||||||
class Locations {
|
class Locations {
|
||||||
public:
|
public:
|
||||||
int texcoordMatrices;
|
int texcoordMatrices;
|
||||||
int diffuseTextureUnit;
|
int albedoTextureUnit;
|
||||||
int normalTextureUnit;
|
int normalTextureUnit;
|
||||||
int specularTextureUnit;
|
int specularTextureUnit;
|
||||||
int emissiveTextureUnit;
|
int emissiveTextureUnit;
|
||||||
|
|
Loading…
Reference in a new issue