Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2014-07-11 19:37:17 +0000
committerStijn Buys <ingar@osirion.org>2014-07-11 19:37:17 +0000
commitd95f18442ea216a886bfddf75d349362d1e537bc (patch)
treea86352393b9f51181594ea4e167e8beba57f2f3a /src/model/material.cc
parent1d518a54914531d7a4fab3a6835b75de85bd7bc7 (diff)
Support material layer blending.
Diffstat (limited to 'src/model/material.cc')
-rw-r--r--src/model/material.cc57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/model/material.cc b/src/model/material.cc
index 0f3487c..d4accc8 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -63,12 +63,16 @@ void Material::print()
con_print << "bounds ";
}
}
- con_print << " layers: " << layers().size() << std::endl;
+
+ int count = 0;
for (Layers::const_iterator lit = material_layers.begin(); lit != material_layers.end(); ++lit) {
const Layer *layer = (*lit);
- con_print << " - texture: ";
+ count++;
+ con_print << " layer " << count << std::endl;
+
+ con_print << " texture: ";
if (layer->texmap() == Layer::TexMapNone) {
con_print << "none";
} else if (layer->texmap() == Layer::TexMapImage) {
@@ -76,9 +80,9 @@ void Material::print()
}
con_print << std::endl;
- con_print << " color: " << layer->color() << std::endl;
+ con_print << " color: " << layer->color() << std::endl;
- con_print << " rgbgen: ";
+ con_print << " rgbgen: ";
switch (layer->rgbgen()) {
case Layer::RGBGenIdentity:
con_print << "identity";
@@ -100,6 +104,21 @@ void Material::print()
break;
}
con_print << std::endl;
+
+ if (layer->fullbright()) {
+ con_print << " fullbright" << std::endl;
+ }
+
+ switch(layer->blendfunc()) {
+ case Layer::BlendFuncNone:
+ break;
+ case Layer::BlendFuncAdd:
+ con_print << " blendfunc: add" << std::endl;
+ break;
+ case Layer::BlendFuncBlend:
+ con_print << " blendfunc: blend" << std::endl;
+ break;
+ }
}
}
@@ -298,11 +317,26 @@ void Material::load_shaderfile(const std::string &shadername)
layer->set_rgbgen(Layer::RGBGenSecondary);
} else if (firstword.compare("entitythird") == 0) {
layer->set_rgbgen(Layer::RGBGenTertiary);
- } else if (firstword.compare("bright") == 0) {
- layer->set_bright(true);
+ } else if ((firstword.compare("bright") == 0) || (firstword.compare("fullbright") == 0)) {
+ layer->set_fullbright(true);
} else if (firstword.compare("environment") == 0) {
layer->set_tcgen(Layer::TCGenEnvironment);
- layer->set_texmap(Layer::TexMapEnvironment);
+ layer->set_texmap(Layer::TexMapEnvironment);
+ } else if (firstword.compare("blendfunc") == 0) {
+ if (linestream >> firstword) {
+ aux::to_lowercase(firstword);
+ if (firstword.compare("none") == 0) {
+ layer->set_blendfunc(Layer::BlendFuncNone);
+ } else if (firstword.compare("add") == 0) {
+ layer->set_blendfunc(Layer::BlendFuncAdd);
+ } else if (firstword.compare("blend") == 0) {
+ layer->set_blendfunc(Layer::BlendFuncBlend);
+ } else {
+ con_warn << shaderfile.name() << " unknown blend function '" << firstword << "' at line " << linenumber << std::endl;
+ }
+ } else {
+ con_warn << shaderfile.name() << " missing blend function at line " << linenumber << std::endl;
+ }
} else if (firstword.compare("map") == 0) {
if (linestream >> firstword) {
@@ -323,6 +357,8 @@ void Material::load_shaderfile(const std::string &shadername)
}
}
}
+ } else {
+ con_warn << shaderfile.name() << " missing texture map at line " << linenumber << std::endl;
}
} else {
con_warn << shaderfile.name() << " unknown layer key '" << firstword << "' at line " << linenumber << std::endl;
@@ -357,7 +393,7 @@ Material *Material::find(const std::string &name)
return 0;
}
-Material *Material::load(const std::string &name, const bool bright)
+Material *Material::load(const std::string &name, const bool ui_texture)
{
// check if the requested material already exist
Material *material = find(name);
@@ -374,7 +410,10 @@ Material *Material::load(const std::string &name, const bool bright)
// add a texture
layer->set_texture(name);
- layer->set_bright(bright);
+ if (ui_texture) {
+ layer->set_fullbright(true);
+ layer->set_blendfunc(Layer::BlendFuncBlend);
+ }
if (material_imageloaderfunc) {
material_imageloaderfunc(layer);
if ((layer->size().width() > 0) && (layer->size().height() > 0)) {