Changing diffuse to albedo and breaking everything...

This commit is contained in:
samcake 2016-02-15 21:50:10 -08:00
parent 6eda7aac6a
commit 0ad7bacf02
31 changed files with 106 additions and 138 deletions

View file

@ -342,9 +342,9 @@ void ModelPackager::populateBasicMapping(QVariantHash& mapping, QString filename
void ModelPackager::listTextures() {
_textures.clear();
foreach (const FBXMaterial mat, _geometry->materials) {
if (!mat.diffuseTexture.filename.isEmpty() && mat.diffuseTexture.content.isEmpty() &&
!_textures.contains(mat.diffuseTexture.filename)) {
_textures << mat.diffuseTexture.filename;
if (!mat.albedoTexture.filename.isEmpty() && mat.albedoTexture.content.isEmpty() &&
!_textures.contains(mat.albedoTexture.filename)) {
_textures << mat.albedoTexture.filename;
}
if (!mat.normalTexture.filename.isEmpty() && mat.normalTexture.content.isEmpty() &&
!_textures.contains(mat.normalTexture.filename)) {

View file

@ -151,7 +151,7 @@ public:
QString materialID;
model::MaterialPointer _material;
FBXTexture diffuseTexture;
FBXTexture albedoTexture;
FBXTexture opacityTexture;
FBXTexture normalTexture;
FBXTexture specularTexture;

View file

@ -79,7 +79,7 @@ void FBXReader::consolidateFBXMaterials() {
}
}
material.diffuseTexture = diffuseTexture;
material.albedoTexture = diffuseTexture;
detectDifferentUVs = (diffuseTexture.texcoordSet != 0) || (!diffuseTexture.transform.isIdentity());
}
@ -140,7 +140,7 @@ void FBXReader::consolidateFBXMaterials() {
auto diffuse = material.diffuseColor;
// FIXME: Do not use the Diffuse Factor yet as some FBX models have it set to 0
// 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));
// FIXME: Do not use the Specular Factor yet as some FBX models have it set to 0

View file

@ -555,11 +555,11 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
model::MaterialPointer modelMaterial = fbxMaterial._material;
if (!objMaterial.diffuseTextureFilename.isEmpty()) {
fbxMaterial.diffuseTexture.filename = objMaterial.diffuseTextureFilename;
fbxMaterial.albedoTexture.filename = objMaterial.diffuseTextureFilename;
}
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
modelMaterial->setDiffuse(fbxMaterial.diffuseColor);
modelMaterial->setAlbedo(fbxMaterial.diffuseColor);
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
modelMaterial->setGloss(fbxMaterial.shininess);

View file

@ -136,7 +136,7 @@ bool NetworkGeometry::isLoadedWithTextures() const {
if (!_isLoadedWithTextures) {
for (auto&& material : _materials) {
if ((material->diffuseTexture && !material->diffuseTexture->isLoaded()) ||
if ((material->albedoTexture && !material->albedoTexture->isLoaded()) ||
(material->normalTexture && !material->normalTexture->isLoaded()) ||
(material->specularTexture && !material->specularTexture->isLoaded()) ||
(material->emissiveTexture && !material->emissiveTexture->isLoaded())) {
@ -154,15 +154,15 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
for (auto&& material : _materials) {
auto networkMaterial = material->_material;
auto oldTextureMaps = networkMaterial->getTextureMaps();
if (material->diffuseTextureName == name) {
material->diffuseTexture = textureCache->getTexture(url, DEFAULT_TEXTURE);
if (material->albedoTextureName == name) {
material->albedoTexture = textureCache->getTexture(url, DEFAULT_TEXTURE);
auto diffuseMap = model::TextureMapPointer(new model::TextureMap());
diffuseMap->setTextureSource(material->diffuseTexture->_textureSource);
diffuseMap->setTextureTransform(
oldTextureMaps[model::MaterialKey::DIFFUSE_MAP]->getTextureTransform());
auto albedoMap = model::TextureMapPointer(new model::TextureMap());
albedoMap->setTextureSource(material->albedoTexture->_textureSource);
albedoMap->setTextureTransform(
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) {
material->normalTexture = textureCache->getTexture(url);
@ -200,9 +200,9 @@ void NetworkGeometry::setTextureWithNameToURL(const QString& name, const QUrl& u
QStringList NetworkGeometry::getTextureNames() const {
QStringList result;
for (auto&& material : _materials) {
if (!material->diffuseTextureName.isEmpty() && material->diffuseTexture) {
QString textureURL = material->diffuseTexture->getURL().toString();
result << material->diffuseTextureName + ":\"" + textureURL + "\"";
if (!material->albedoTextureName.isEmpty() && material->albedoTexture) {
QString textureURL = material->albedoTexture->getURL().toString();
result << material->albedoTextureName + ":\"" + textureURL + "\"";
}
if (!material->normalTextureName.isEmpty() && material->normalTexture) {
@ -310,15 +310,15 @@ static NetworkMaterial* buildNetworkMaterial(const FBXMaterial& material, const
networkMaterial->_material = material._material;
if (!material.diffuseTexture.filename.isEmpty()) {
networkMaterial->diffuseTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.diffuseTexture.filename)), DEFAULT_TEXTURE, material.diffuseTexture.content);
networkMaterial->diffuseTextureName = material.diffuseTexture.name;
if (!material.albedoTexture.filename.isEmpty()) {
networkMaterial->albedoTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.albedoTexture.filename)), DEFAULT_TEXTURE, material.albedoTexture.content);
networkMaterial->albedoTextureName = material.albedoTexture.name;
auto diffuseMap = model::TextureMapPointer(new model::TextureMap());
diffuseMap->setTextureSource(networkMaterial->diffuseTexture->_textureSource);
diffuseMap->setTextureTransform(material.diffuseTexture.transform);
auto albedoMap = model::TextureMapPointer(new model::TextureMap());
albedoMap->setTextureSource(networkMaterial->albedoTexture->_textureSource);
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()) {
networkMaterial->normalTexture = textureCache->getTexture(textureBaseUrl.resolved(QUrl(material.normalTexture.filename)), (material.normalTexture.isBumpmap ? BUMP_TEXTURE : NORMAL_TEXTURE), material.normalTexture.content);

View file

@ -174,8 +174,8 @@ public:
class NetworkMaterial {
public:
model::MaterialPointer _material;
QString diffuseTextureName;
QSharedPointer<NetworkTexture> diffuseTexture;
QString albedoTextureName;
QSharedPointer<NetworkTexture> albedoTexture;
QString normalTextureName;
QSharedPointer<NetworkTexture> normalTexture;
QString specularTextureName;

View file

@ -44,9 +44,9 @@ Material& Material::operator= (const Material& material) {
Material::~Material() {
}
void Material::setDiffuse(const Color& diffuse, bool isSRGB) {
_key.setDiffuse(glm::any(glm::greaterThan(diffuse, Color(0.0f))));
_schemaBuffer.edit<Schema>()._diffuse = (isSRGB ? ColorUtils::toLinearVec3(diffuse) : diffuse);
void Material::setAlbedo(const Color& albedo, bool isSRGB) {
_key.setAlbedo(glm::any(glm::greaterThan(albedo, Color(0.0f))));
_schemaBuffer.edit<Schema>()._albedo = (isSRGB ? ColorUtils::toLinearVec3(albedo) : albedo);
}
void Material::setMetallic(float metallic) {

View file

@ -28,13 +28,13 @@ class MaterialKey {
public:
enum FlagBit {
EMISSIVE_VAL_BIT = 0,
DIFFUSE_VAL_BIT,
ALBEDO_VAL_BIT,
METALLIC_VAL_BIT,
GLOSS_VAL_BIT,
TRANSPARENT_VAL_BIT,
EMISSIVE_MAP_BIT,
DIFFUSE_MAP_BIT,
ALBEDO_MAP_BIT,
METALLIC_MAP_BIT,
GLOSS_MAP_BIT,
TRANSPARENT_MAP_BIT,
@ -47,7 +47,7 @@ public:
enum MapChannel {
EMISSIVE_MAP = 0,
DIFFUSE_MAP,
ALBEDO_MAP,
METALLIC_MAP,
GLOSS_MAP,
TRANSPARENT_MAP,
@ -71,13 +71,13 @@ public:
MaterialKey build() const { return MaterialKey(_flags); }
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& withGloss() { _flags.set(GLOSS_VAL_BIT); return (*this); }
Builder& withTransparent() { _flags.set(TRANSPARENT_VAL_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& withGlossMap() { _flags.set(GLOSS_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); }
// 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); }
@ -95,11 +95,11 @@ public:
void setEmissiveMap(bool value) { _flags.set(EMISSIVE_MAP_BIT, value); }
bool isEmissiveMap() const { return _flags[EMISSIVE_MAP_BIT]; }
void setDiffuse(bool value) { _flags.set(DIFFUSE_VAL_BIT, value); }
bool isDiffuse() const { return _flags[DIFFUSE_VAL_BIT]; }
void setAlbedo(bool value) { _flags.set(ALBEDO_VAL_BIT, value); }
bool isAlbedo() const { return _flags[ALBEDO_VAL_BIT]; }
void setDiffuseMap(bool value) { _flags.set(DIFFUSE_MAP_BIT, value); }
bool isDiffuseMap() const { return _flags[DIFFUSE_MAP_BIT]; }
void setAlbedoMap(bool value) { _flags.set(ALBEDO_MAP_BIT, value); }
bool isAlbedoMap() const { return _flags[ALBEDO_MAP_BIT]; }
void setMetallic(bool value) { _flags.set(METALLIC_VAL_BIT, value); }
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& 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& withDiffuse() { _value.set(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& 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& withDiffuseMap() { _value.set(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& 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& 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); }
// 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
@ -223,8 +223,8 @@ public:
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); }
void setDiffuse(const Color& diffuse, bool isSRGB = true);
Color getDiffuse(bool SRGB = true) const { return (SRGB ? ColorUtils::toGamma22Vec3(_schemaBuffer.get<Schema>()._diffuse) : _schemaBuffer.get<Schema>()._diffuse); }
void setAlbedo(const Color& albedo, bool isSRGB = true);
Color getAlbedo(bool SRGB = true) const { return (SRGB ? ColorUtils::toGamma22Vec3(_schemaBuffer.get<Schema>()._albedo) : _schemaBuffer.get<Schema>()._albedo); }
void setMetallic(float metallic);
float getMetallic() const { return _schemaBuffer.get<Schema>()._metallic.x; }
@ -239,7 +239,7 @@ public:
class Schema {
public:
glm::vec3 _diffuse{ 0.5f };
glm::vec3 _albedo{ 0.5f };
float _opacity{1.f};
glm::vec3 _metallic{ 0.03f };
float _gloss{0.1f};

View file

@ -12,7 +12,7 @@
<@def MODEL_MATERIAL_SLH@>
struct Material {
vec4 _diffuse;
vec4 _albedoOpacity;
vec4 _specular;
vec4 _emissive;
vec4 _spare;
@ -26,40 +26,8 @@ Material getMaterial() {
return _mat;
}
<! // TODO: use this code for correct gamma correction
/*
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; }
float getMaterialOpacity(Material m) { return m._albedoOpacity.a; }
vec3 getMaterialAlbedo(Material m) { return m._albedoOpacity.rgb; }
vec3 getMaterialSpecular(Material m) { return m._specular.rgb; }
float getMaterialShininess(Material m) { return m._specular.a; }

View file

@ -27,7 +27,7 @@ typedef glm::vec3 Color;
class TextureUsage {
public:
gpu::Texture::Type _type{ gpu::Texture::TEX_2D };
Material::MapFlags _materialUsage{ MaterialKey::DIFFUSE_MAP };
Material::MapFlags _materialUsage{ MaterialKey::ALBEDO_MAP };
int _environmentUsage = 0;

View file

@ -39,7 +39,7 @@ void DebugDeferredBufferConfig::setMode(int newMode) {
}
enum Slot {
Diffuse = 0,
Albedo = 0,
Normal,
Specular,
Depth,
@ -52,9 +52,9 @@ enum Slot {
static const std::string DEFAULT_DIFFUSE_SHADER {
static const std::string DEFAULT_ALBEDO_SHADER {
"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) {
switch (mode) {
case DiffuseMode:
return DEFAULT_DIFFUSE_SHADER;
case AlbedoMode:
return DEFAULT_ALBEDO_SHADER;
case SpecularMode:
return DEFAULT_SPECULAR_SHADER;
case RoughnessMode:
@ -206,7 +206,7 @@ const gpu::PipelinePointer& DebugDeferredBuffer::getPipeline(Mode mode, std::str
const auto program = gpu::Shader::createProgram(vs, ps);
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("specularMap", Specular));
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.setResourceTexture(Diffuse, framebufferCache->getDeferredColorTexture());
batch.setResourceTexture(Albedo, framebufferCache->getDeferredColorTexture());
batch.setResourceTexture(Normal, framebufferCache->getDeferredNormalTexture());
batch.setResourceTexture(Specular, framebufferCache->getDeferredSpecularTexture());
batch.setResourceTexture(Depth, framebufferCache->getPrimaryDepthTexture());

View file

@ -47,7 +47,7 @@ protected:
enum Mode : uint8_t {
// Use Mode suffix to avoid collisions
DiffuseMode = 0,
AlbedoMode = 0,
SpecularMode,
RoughnessMode,
NormalMode,

View file

@ -525,7 +525,7 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo
gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS);
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("specularMap"), DEFERRED_BUFFER_EMISSIVE_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();
light->setDirection(direction);
light->setColor(diffuse);
light->setColor(color);
light->setIntensity(intensity);
light->setAmbientIntensity(ambientIntensity);
}

View file

@ -504,7 +504,7 @@ GeometryCache::GeometryCache() :
std::make_shared<render::ShapePipeline>(getSimplePipeline(), nullptr,
[](const render::ShapePipeline&, gpu::Batch& batch) {
// 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());
batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP,
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 (!textured) {
batch.setResourceTexture(render::ShapePipeline::Slot::DIFFUSE_MAP,
batch.setResourceTexture(render::ShapePipeline::Slot::ALBEDO_MAP,
DependencyManager::get<TextureCache>()->getWhiteTexture());
}
// Set a default normal map

View file

@ -145,20 +145,20 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
auto textureMaps = _drawMaterial->getTextureMaps();
glm::mat4 texcoordTransform[2];
// Diffuse
if (materialKey.isDiffuseMap()) {
auto diffuseMap = textureMaps[model::MaterialKey::DIFFUSE_MAP];
if (diffuseMap && diffuseMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, diffuseMap->getTextureView());
// Albedo
if (materialKey.isAlbedoMap()) {
auto albedoMap = textureMaps[model::MaterialKey::ALBEDO_MAP];
if (albedoMap && albedoMap->isDefined()) {
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, albedoMap->getTextureView());
if (!diffuseMap->getTextureTransform().isIdentity()) {
diffuseMap->getTextureTransform().getMatrix(texcoordTransform[0]);
if (!albedoMap->getTextureTransform().isIdentity()) {
albedoMap->getTextureTransform().getMatrix(texcoordTransform[0]);
}
} else {
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getGrayTexture());
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, textureCache->getGrayTexture());
}
} else {
batch.setResourceTexture(ShapePipeline::Slot::DIFFUSE_MAP, textureCache->getWhiteTexture());
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, textureCache->getWhiteTexture());
}
// Normal map

View file

@ -1197,7 +1197,7 @@ void Model::segregateMeshGroups() {
if (showingCollisionHull) {
if (!_collisionHullMaterial) {
_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->setGloss(1.0f);
}

View file

@ -66,7 +66,7 @@ void initStencilPipeline(gpu::PipelinePointer& pipeline) {
gpu::BufferView getDefaultMaterialBuffer() {
model::Material::Schema schema;
schema._diffuse = vec3(1.0f);
schema._albedo = vec3(1.0f);
schema._opacity = 1.0f;
schema._metallic = vec3(0.1f);
schema._gloss = 10.0f;
@ -74,8 +74,8 @@ gpu::BufferView getDefaultMaterialBuffer() {
}
void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) {
// Set a default diffuse map
batch.setResourceTexture(render::ShapePipeline::Slot::DIFFUSE_MAP,
// Set a default albedo map
batch.setResourceTexture(render::ShapePipeline::Slot::ALBEDO_MAP,
DependencyManager::get<TextureCache>()->getWhiteTexture());
// Set a default normal map
batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP,

View file

@ -33,7 +33,7 @@ void main(void) {
packDeferredFragment(
normalize(_normal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -26,7 +26,7 @@ void main(void) {
vec4 texel = texture(diffuseMap, _texCoord0);
Material mat = getMaterial();
vec3 fragColor = getMaterialDiffuse(mat) * texel.rgb * _color;
vec3 fragColor = getMaterialAlbedo(mat) * texel.rgb * _color;
packDeferredFragmentLightmap(
normalize(_normal),

View file

@ -38,7 +38,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -51,7 +51,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -55,7 +55,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
specular, // no use of getMaterialSpecular(mat)
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -43,7 +43,7 @@ void main(void) {
packDeferredFragmentLightmap(
normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
specular, // no use of getMaterialSpecular(mat)
getMaterialShininess(mat),
(vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb));

View file

@ -44,7 +44,7 @@ void main(void) {
packDeferredFragment(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -49,7 +49,7 @@ void main(void) {
packDeferredFragment(
normalize(viewNormal.xyz),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
getMaterialAlbedo(mat) * diffuse.rgb * _color,
specular, //getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -16,8 +16,8 @@
<@include model/Material.slh@>
// the diffuse texture
uniform sampler2D diffuseMap;
// the albedo texture
uniform sampler2D albedoMap;
// the specular texture
uniform sampler2D specularMap;
@ -29,16 +29,16 @@ in vec3 _color;
void main(void) {
// set the diffuse, normal, specular data
vec4 diffuse = texture(diffuseMap, _texCoord0);
// set the albedo, normal, specular data
vec4 albedo = texture(albedoMap, _texCoord0);
vec3 specular = texture(specularMap, _texCoord0).rgb;
Material mat = getMaterial();
packDeferredFragment(
normalize(_normal),
evalOpaqueFinalAlpha(getMaterialOpacity(mat), diffuse.a),
getMaterialDiffuse(mat) * diffuse.rgb * _color,
evalOpaqueFinalAlpha(getMaterialOpacity(mat), albedo.a),
getMaterialAlbedo(mat) * albedo.rgb * _color,
specular, //getMaterialSpecular(mat),
getMaterialShininess(mat));
}

View file

@ -40,7 +40,7 @@ vec4 evalGlobalColor(float shadowAttenuation, vec3 position, vec3 normal, vec3 d
return vec4(color, opacity);
}
uniform sampler2D diffuseMap;
uniform sampler2D albedoMap;
in vec2 _texCoord0;
in vec4 _position;
@ -51,15 +51,15 @@ in float _alpha;
out vec4 _fragColor;
void main(void) {
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec4 albedo = texture(albedoMap, _texCoord0);
Material mat = getMaterial();
vec3 fragPosition = _position.xyz;
vec3 fragNormal = normalize(_normal);
vec3 fragDiffuse = getMaterialDiffuse(mat) * diffuse.rgb * _color;
vec3 fragDiffuse = getMaterialAlbedo(mat) * albedo.rgb * _color;
vec3 fragSpecular = getMaterialSpecular(mat);
float fragGloss = getMaterialShininess(mat) / 128;
float fragOpacity = getMaterialOpacity(mat) * diffuse.a * _alpha;
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
_fragColor = evalGlobalColor(1.0,
fragPosition,

View file

@ -14,7 +14,7 @@
<@include model/Material.slh@>
uniform sampler2D diffuseMap;
uniform sampler2D albedoMap;
in vec2 _texCoord0;
in vec3 _color;
@ -23,11 +23,11 @@ in float _alpha;
out vec4 _fragColor;
void main(void) {
vec4 diffuse = texture(diffuseMap, _texCoord0);
vec4 albedo = texture(albedoMap, _texCoord0);
Material mat = getMaterial();
vec3 fragColor = getMaterialDiffuse(mat) * diffuse.rgb * _color;
float fragOpacity = getMaterialOpacity(mat) * diffuse.a * _alpha;
vec3 fragColor = getMaterialAlbedo(mat) * albedo.rgb * _color;
float fragOpacity = getMaterialOpacity(mat) * albedo.a * _alpha;
_fragColor = vec4(fragColor, fragOpacity);
}

View file

@ -34,7 +34,7 @@ void main(void) {
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);
// and the texture coordinates

View file

@ -53,7 +53,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p
gpu::Shader::BindingSet slotBindings;
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("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("specularMap"), Slot::SPECULAR_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->emissiveParams = program->getUniforms().findLocation("emissiveParams");
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->specularTextureUnit = program->getTextures().findLocation("specularMap");
locations->emissiveTextureUnit = program->getTextures().findLocation("emissiveMap");

View file

@ -195,7 +195,7 @@ public:
public:
static const int SKINNING_GPU = 2;
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 SPECULAR_MAP = 2;
static const int LIGHTMAP_MAP = 3;
@ -206,7 +206,7 @@ public:
class Locations {
public:
int texcoordMatrices;
int diffuseTextureUnit;
int albedoTextureUnit;
int normalTextureUnit;
int specularTextureUnit;
int emissiveTextureUnit;