Merge pull request #9556 from samcake/blue

Adding support for disabling texturing from the material
This commit is contained in:
Brad Hefta-Gaub 2017-01-31 10:39:44 -08:00 committed by GitHub
commit cff49ea5f3
6 changed files with 43 additions and 6 deletions

View file

@ -92,6 +92,15 @@ bool LightingModel::isAlbedoEnabled() const {
return (bool)_parametersBuffer.get<Parameters>().enableAlbedo;
}
void LightingModel::setMaterialTexturing(bool enable) {
if (enable != isMaterialTexturingEnabled()) {
_parametersBuffer.edit<Parameters>().enableMaterialTexturing = (float)enable;
}
}
bool LightingModel::isMaterialTexturingEnabled() const {
return (bool)_parametersBuffer.get<Parameters>().enableMaterialTexturing;
}
void LightingModel::setAmbientLight(bool enable) {
if (enable != isAmbientLightEnabled()) {
_parametersBuffer.edit<Parameters>().enableAmbientLight = (float)enable;
@ -150,6 +159,8 @@ void MakeLightingModel::configure(const Config& config) {
_lightingModel->setSpecular(config.enableSpecular);
_lightingModel->setAlbedo(config.enableAlbedo);
_lightingModel->setMaterialTexturing(config.enableMaterialTexturing);
_lightingModel->setAmbientLight(config.enableAmbientLight);
_lightingModel->setDirectionalLight(config.enableDirectionalLight);
_lightingModel->setPointLight(config.enablePointLight);
@ -160,5 +171,8 @@ void MakeLightingModel::configure(const Config& config) {
void MakeLightingModel::run(const render::SceneContextPointer& sceneContext, const render::RenderContextPointer& renderContext, LightingModelPointer& lightingModel) {
lightingModel = _lightingModel;
lightingModel = _lightingModel;
// make sure the enableTexturing flag of the render ARgs is in sync
renderContext->args->_enableTexturing = _lightingModel->isMaterialTexturingEnabled();
}

View file

@ -49,6 +49,8 @@ public:
void setAlbedo(bool enable);
bool isAlbedoEnabled() const;
void setMaterialTexturing(bool enable);
bool isMaterialTexturingEnabled() const;
void setAmbientLight(bool enable);
bool isAmbientLightEnabled() const;
@ -88,9 +90,12 @@ protected:
float enableSpotLight{ 1.0f };
float showLightContour{ 0.0f }; // false by default
float enableObscurance{ 1.0f };
glm::vec2 spares{ 0.0f };
float enableMaterialTexturing { 1.0f };
float spares{ 0.0f };
Parameters() {}
};
@ -117,6 +122,8 @@ class MakeLightingModelConfig : public render::Job::Config {
Q_PROPERTY(bool enableSpecular MEMBER enableSpecular NOTIFY dirty)
Q_PROPERTY(bool enableAlbedo MEMBER enableAlbedo NOTIFY dirty)
Q_PROPERTY(bool enableMaterialTexturing MEMBER enableMaterialTexturing NOTIFY dirty)
Q_PROPERTY(bool enableAmbientLight MEMBER enableAmbientLight NOTIFY dirty)
Q_PROPERTY(bool enableDirectionalLight MEMBER enableDirectionalLight NOTIFY dirty)
Q_PROPERTY(bool enablePointLight MEMBER enablePointLight NOTIFY dirty)
@ -136,13 +143,16 @@ public:
bool enableScattering{ true };
bool enableDiffuse{ true };
bool enableSpecular{ true };
bool enableAlbedo{ true };
bool enableMaterialTexturing { true };
bool enableAmbientLight{ true };
bool enableDirectionalLight{ true };
bool enablePointLight{ true };
bool enableSpotLight{ true };
bool showLightContour { false }; // false by default
signals:

View file

@ -129,7 +129,7 @@ void MeshPartPayload::bindMesh(gpu::Batch& batch) const {
}
}
void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations) const {
void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, bool enableTextures) const {
if (!_drawMaterial) {
return;
}
@ -147,6 +147,17 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
numUnlit++;
}
if (!enableTextures) {
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO, textureCache->getWhiteTexture());
batch.setResourceTexture(ShapePipeline::Slot::MAP::ROUGHNESS, textureCache->getWhiteTexture());
batch.setResourceTexture(ShapePipeline::Slot::MAP::NORMAL, nullptr);
batch.setResourceTexture(ShapePipeline::Slot::MAP::METALLIC, nullptr);
batch.setResourceTexture(ShapePipeline::Slot::MAP::OCCLUSION, nullptr);
batch.setResourceTexture(ShapePipeline::Slot::MAP::SCATTERING, nullptr);
batch.setResourceTexture(ShapePipeline::Slot::MAP::EMISSIVE_LIGHTMAP, nullptr);
return;
}
// Albedo
if (materialKey.isAlbedoMap()) {
auto itr = textureMaps.find(model::MaterialKey::ALBEDO_MAP);
@ -271,7 +282,7 @@ void MeshPartPayload::render(RenderArgs* args) const {
bindMesh(batch);
// apply material properties
bindMaterial(batch, locations);
bindMaterial(batch, locations, args->_enableTexturing);
if (args) {
args->_details._materialSwitches++;
@ -588,7 +599,7 @@ void ModelMeshPartPayload::render(RenderArgs* args) const {
bindMesh(batch);
// apply material properties
bindMaterial(batch, locations);
bindMaterial(batch, locations, args->_enableTexturing);
args->_details._materialSwitches++;

View file

@ -51,7 +51,7 @@ public:
// ModelMeshPartPayload functions to perform render
void drawCall(gpu::Batch& batch) const;
virtual void bindMesh(gpu::Batch& batch) const;
virtual void bindMaterial(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations) const;
virtual void bindMaterial(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, bool enableTextures) const;
virtual void bindTransform(gpu::Batch& batch, const render::ShapePipeline::LocationsPointer locations, RenderArgs::RenderMode renderMode) const;
// Payload resource cached values

View file

@ -122,6 +122,7 @@ public:
gpu::Batch* _batch = nullptr;
std::shared_ptr<gpu::Texture> _whiteTexture;
bool _enableTexturing { true };
RenderDetails _details;
};

View file

@ -25,6 +25,7 @@ Column {
"Lightmap:LightingModel:enableLightmap",
"Background:LightingModel:enableBackground",
"ssao:AmbientOcclusion:enabled",
"Textures:LightingModel:enableMaterialTexturing",
]
CheckBox {
text: modelData.split(":")[0]