Skip to content

Commit

Permalink
GRAPHICS: Use special blending for textures with no alpha channel
Browse files Browse the repository at this point in the history
This fixes how lightsabers and windows are rendered in KotOR.
  • Loading branch information
vkremianskii authored and DrMcCoy committed Mar 13, 2019
1 parent 6443cac commit 79f9a07
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/graphics/aurora/modelnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,25 @@ void ModelNode::renderGeometry(ModelNode::Mesh &mesh) {
}

void ModelNode::renderGeometryNormal(Mesh &mesh) {
bool specialBlending = false;

for (size_t t = 0; t < mesh.data->textures.size(); t++) {
TextureMan.activeTexture(t);
TextureMan.set(mesh.data->textures[t]);

if (!mesh.data->textures[t].empty()) {
const Graphics::Aurora::Texture &texture = mesh.data->textures[t].getTexture();
if (!texture.hasAlpha() && (texture.getTXI().getFeatures().blending == TXI::kBlendingAdditive))
specialBlending = true;
}
}

if (mesh.data->textures.empty())
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

if (specialBlending)
glBlendFunc(GL_SRC_COLOR, GL_ONE);

mesh.data->rawMesh->renderImmediate();

for (size_t t = 0; t < mesh.data->textures.size(); t++) {
Expand All @@ -682,6 +693,8 @@ void ModelNode::renderGeometryNormal(Mesh &mesh) {

if (mesh.data->textures.empty())
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}

void ModelNode::renderGeometryEnvMappedUnder(Mesh &mesh) {
Expand Down

0 comments on commit 79f9a07

Please sign in to comment.