mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 04:43:37 +02:00
Pass 4 on cleaning up that pr, put the SortFIlterModel.qml in the new skit/qml lib, setting the opacityMappMode correctly from script
This commit is contained in:
parent
25bcc31b72
commit
57f8095506
8 changed files with 62 additions and 27 deletions
|
@ -30,10 +30,20 @@ const float Material::DEFAULT_OPACITY_CUTOFF { 0.5f };
|
|||
|
||||
|
||||
std::string MaterialKey::getOpacityMapModeName(OpacityMapMode mode) {
|
||||
const std::string names[3] = { "OPACITY_MAP_OPAQUE", "OAPCITY_MAP_MASK", "OPACITY_MAP_BLEND" };
|
||||
const std::string names[3] = { "OPACITY_MAP_OPAQUE", "OPACITY_MAP_MASK", "OPACITY_MAP_BLEND" };
|
||||
return names[mode];
|
||||
}
|
||||
|
||||
|
||||
bool MaterialKey::getOpacityMapModeFromName(const std::string& modeName, MaterialKey::OpacityMapMode& mode) {
|
||||
for (mode = OPACITY_MAP_OPAQUE; mode <= OPACITY_MAP_BLEND; mode + 1) {
|
||||
if (modeName == getOpacityMapModeName(mode)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Material::Material() {
|
||||
for (int i = 0; i < NUM_TOTAL_FLAGS; i++) {
|
||||
_propertyFallthroughs[i] = false;
|
||||
|
@ -166,6 +176,12 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
|
|||
}
|
||||
|
||||
bool Material::resetOpacityMap() const {
|
||||
// If OpacityMapMode explicit then nothing need to change here.
|
||||
if (_key.isOpacityMapMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Else, the legacy behavior is to interpret the albedo texture assigned to tune the opacity map mode value
|
||||
auto previous = _key.getOpacityMapMode();
|
||||
// Clear the previous flags
|
||||
_key.setOpacityMaskMap(false);
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
OPACITY_VAL_BIT,
|
||||
OPACITY_MASK_MAP_BIT, // Opacity Map and Opacity MASK map are mutually exclusive
|
||||
OPACITY_TRANSLUCENT_MAP_BIT,
|
||||
OPACITY_MAP_MODE_BIT, // Opacity map mode bit is set if the value has set explicitely and not deduced from the textures assigned
|
||||
OPACITY_CUTOFF_VAL_BIT,
|
||||
SCATTERING_VAL_BIT,
|
||||
|
||||
|
@ -79,6 +80,8 @@ public:
|
|||
OPACITY_MAP_BLEND,
|
||||
};
|
||||
static std::string getOpacityMapModeName(OpacityMapMode mode);
|
||||
// find the enum value from a string, return true if match found
|
||||
static bool getOpacityMapModeFromName(const std::string& modeName, OpacityMapMode& mode);
|
||||
|
||||
// The signature is the Flags
|
||||
Flags _flags;
|
||||
|
@ -118,6 +121,7 @@ public:
|
|||
_flags.reset(OPACITY_MASK_MAP_BIT);
|
||||
break;
|
||||
};
|
||||
_flags.set(OPACITY_MAP_MODE_BIT); // Intentionally set the mode!
|
||||
return (*this);
|
||||
}
|
||||
Builder& withOpacityCutoff() { _flags.set(OPACITY_CUTOFF_VAL_BIT); return (*this); }
|
||||
|
@ -213,7 +217,9 @@ public:
|
|||
_flags.reset(OPACITY_MASK_MAP_BIT);
|
||||
break;
|
||||
};
|
||||
_flags.set(OPACITY_MAP_MODE_BIT); // Intentionally set the mode!
|
||||
}
|
||||
bool isOpacityMapMode() const { return _flags[OPACITY_MAP_MODE_BIT]; }
|
||||
OpacityMapMode getOpacityMapMode() const { return (isOpacityMaskMap() ? OPACITY_MAP_MASK : (isTranslucentMap() ? OPACITY_MAP_BLEND : OPACITY_MAP_OPAQUE)); }
|
||||
|
||||
bool isTranslucent() const { return isTranslucentFactor() || isTranslucentMap(); }
|
||||
|
@ -274,6 +280,9 @@ public:
|
|||
Builder& withoutMaskMap() { _value.reset(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
|
||||
Builder& withMaskMap() { _value.set(MaterialKey::OPACITY_MASK_MAP_BIT); _mask.set(MaterialKey::OPACITY_MASK_MAP_BIT); return (*this); }
|
||||
|
||||
Builder& withoutOpacityMapMode() { _value.reset(MaterialKey::OPACITY_MAP_MODE_BIT); _mask.set(MaterialKey::OPACITY_MAP_MODE_BIT); return (*this); }
|
||||
Builder& withOpacityMapMode() { _value.set(MaterialKey::OPACITY_MAP_MODE_BIT); _mask.set(MaterialKey::OPACITY_MAP_MODE_BIT); return (*this); }
|
||||
|
||||
Builder& withoutOpacityCutoff() { _value.reset(MaterialKey::OPACITY_CUTOFF_VAL_BIT); _mask.set(MaterialKey::OPACITY_CUTOFF_VAL_BIT); return (*this); }
|
||||
Builder& withOpacityCutoff() { _value.set(MaterialKey::OPACITY_CUTOFF_VAL_BIT); _mask.set(MaterialKey::OPACITY_CUTOFF_VAL_BIT); return (*this); }
|
||||
|
||||
|
@ -332,7 +341,7 @@ public:
|
|||
float getOpacity() const { return _opacity; }
|
||||
|
||||
static const MaterialKey::OpacityMapMode DEFAULT_OPACITY_MAP_MODE;
|
||||
void setOpacityMapMode(MaterialKey::OpacityMapMode alphaMode);
|
||||
void setOpacityMapMode(MaterialKey::OpacityMapMode opacityMapMode);
|
||||
MaterialKey::OpacityMapMode getOpacityMapMode() const;
|
||||
|
||||
static const float DEFAULT_OPACITY_CUTOFF;
|
||||
|
|
|
@ -85,17 +85,18 @@ const BITFIELD GLOSSY_VAL_BIT = 0x00000010;
|
|||
const BITFIELD OPACITY_VAL_BIT = 0x00000020;
|
||||
const BITFIELD OPACITY_MASK_MAP_BIT = 0x00000040;
|
||||
const BITFIELD OPACITY_TRANSLUCENT_MAP_BIT = 0x00000080;
|
||||
const BITFIELD OPACITY_CUTOFF_VAL_BIT = 0x00000100;
|
||||
const BITFIELD SCATTERING_VAL_BIT = 0x00000200;
|
||||
const BITFIELD OPACITY_MAP_MODE_BIT = 0x00000100;
|
||||
const BITFIELD OPACITY_CUTOFF_VAL_BIT = 0x00000200;
|
||||
const BITFIELD SCATTERING_VAL_BIT = 0x00000400;
|
||||
|
||||
|
||||
const BITFIELD EMISSIVE_MAP_BIT = 0x00000400;
|
||||
const BITFIELD ALBEDO_MAP_BIT = 0x00000800;
|
||||
const BITFIELD METALLIC_MAP_BIT = 0x00001000;
|
||||
const BITFIELD ROUGHNESS_MAP_BIT = 0x00002000;
|
||||
const BITFIELD NORMAL_MAP_BIT = 0x00004000;
|
||||
const BITFIELD OCCLUSION_MAP_BIT = 0x00008000;
|
||||
const BITFIELD LIGHTMAP_MAP_BIT = 0x00010000;
|
||||
const BITFIELD SCATTERING_MAP_BIT = 0x00020000;
|
||||
const BITFIELD EMISSIVE_MAP_BIT = 0x00000800;
|
||||
const BITFIELD ALBEDO_MAP_BIT = 0x00001000;
|
||||
const BITFIELD METALLIC_MAP_BIT = 0x00002000;
|
||||
const BITFIELD ROUGHNESS_MAP_BIT = 0x00004000;
|
||||
const BITFIELD NORMAL_MAP_BIT = 0x00008000;
|
||||
const BITFIELD OCCLUSION_MAP_BIT = 0x00010000;
|
||||
const BITFIELD LIGHTMAP_MAP_BIT = 0x00020000;
|
||||
const BITFIELD SCATTERING_MAP_BIT = 0x00040000;
|
||||
|
||||
<@endif@>
|
||||
|
|
|
@ -139,6 +139,14 @@ NetworkMaterialResource::ParsedMaterials NetworkMaterialResource::parseJSONMater
|
|||
* @property {string} opacityMap - The URL of the opacity texture image. Set the value the same as the <code>albedoMap</code>
|
||||
* value for transparency.
|
||||
* <code>"hifi_pbr"</code> model only.
|
||||
* @property {number|string} opacityMapMode - The mode defining the interpretation of the opacity map. Values can be:
|
||||
* <code>"OPACITY_MAP_OPAQUE"</code> for ignoring the opacity map information.
|
||||
* <code>"OPACITY_MAP_MASK"</code> for using the opacity map as a mask, where only the texel greater than opacityCutoff are visible and rendered opaque.
|
||||
* <code>"OPACITY_MAP_BLEND"</code> for using the opacity map for alpha blending the material surface with the background.
|
||||
* Set to <code>"fallthrough"</code> to fall through to the material below. <code>"hifi_pbr"</code> model only.
|
||||
* @property {number|string} opacityCutoff - The opacity cutoff threshold used to determine the opaque texels of the Opacity map
|
||||
* when opacityMapMode is "OPACITY_MAP_MASK", range <code>0.0</code> – <code>1.0</code>.
|
||||
* Set to <code>"fallthrough"</code> to fall through to the material below. <code>"hifi_pbr"</code> model only.
|
||||
* @property {string} roughnessMap - The URL of the roughness texture image. You can use this or <code>glossMap</code>, but not
|
||||
* both.
|
||||
* Set to <code>"fallthrough"</code> to fall through to the material below. <code>"hifi_pbr"</code> model only.
|
||||
|
@ -258,22 +266,24 @@ std::pair<std::string, std::shared_ptr<NetworkMaterial>> NetworkMaterialResource
|
|||
} else if (value.isDouble()) {
|
||||
material->setMetallic(value.toDouble());
|
||||
}
|
||||
} else if (key == "opacityCuttoff") {
|
||||
} else if (key == "opacityMapMode") {
|
||||
auto value = materialJSON.value(key);
|
||||
auto valueString = (value.isString() ? value.toString() : "");
|
||||
if (valueString == FALLTHROUGH) {
|
||||
material->setPropertyDoesFallthrough(graphics::MaterialKey::FlagBit::OPACITY_MAP_MODE_BIT);
|
||||
} else {
|
||||
graphics::MaterialKey::OpacityMapMode mode;
|
||||
if (graphics::MaterialKey::getOpacityMapModeFromName(valueString.toStdString(), mode)) {
|
||||
material->setOpacityMapMode(mode);
|
||||
}
|
||||
}
|
||||
} else if (key == "opacityCutoff") {
|
||||
auto value = materialJSON.value(key);
|
||||
if (value.isString() && value.toString() == FALLTHROUGH) {
|
||||
material->setPropertyDoesFallthrough(graphics::MaterialKey::FlagBit::OPACITY_CUTOFF_VAL_BIT);
|
||||
}
|
||||
else if (value.isDouble()) {
|
||||
} else if (value.isDouble()) {
|
||||
material->setOpacityCutoff(value.toDouble());
|
||||
}
|
||||
/* SG TODO: Implement the set opacityMapMOde intentionaly } else if (key == "opacityMapMode") {
|
||||
auto value = materialJSON.value(key);
|
||||
if (value.isString() && value.toString() == FALLTHROUGH) {
|
||||
material->setPropertyDoesFallthrough(graphics::MaterialKey::FlagBit::OPACITY_MAP_MODE_BIT);
|
||||
}
|
||||
else if (value.isDouble()) {
|
||||
material->setOpacityCutoff(value.toDouble());
|
||||
}**/
|
||||
} else if (key == "scattering") {
|
||||
auto value = materialJSON.value(key);
|
||||
if (value.isString() && value.toString() == FALLTHROUGH) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import QtQuick.Controls 2.5
|
|||
import QtQuick.Layouts 1.3
|
||||
import QtQml.Models 2.12
|
||||
|
||||
import "../../lib/skit/qml" as Skit
|
||||
import "../../lib/prop" as Prop
|
||||
|
||||
Item {
|
||||
|
@ -313,7 +314,7 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
SortFilterModel {
|
||||
Skit.SortFilterModel {
|
||||
id: visualModel
|
||||
model: ListModel {}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ Item {
|
|||
// By default, these just go get or set the value from the object[property]
|
||||
//
|
||||
function defaultGet() { var v = root.object[root.property]; return v; }
|
||||
// function defaultGet() { return root.object[root.property]; }
|
||||
function defaultSet(value) { root.object[root.property] = value; }
|
||||
function defaultSetReadOnly(value) {}
|
||||
|
||||
|
@ -36,8 +35,6 @@ Item {
|
|||
height: global.lineHeight
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
// anchors.leftMargin: global.horizontalMargin
|
||||
// anchors.rightMargin: global.horizontalMargin
|
||||
|
||||
// LabelControl And SplitterControl are on the left side of the PropItem
|
||||
property bool showLabel: true
|
||||
|
|
1
scripts/developer/utilities/lib/skit/qml/qmldir
Normal file
1
scripts/developer/utilities/lib/skit/qml/qmldir
Normal file
|
@ -0,0 +1 @@
|
|||
SortFilterModel 1.0 SortFilterModel.qml
|
Loading…
Reference in a new issue