Skip to content

Commit c22a150

Browse files
committed
Enable transparent surfaces
1 parent e391d67 commit c22a150

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

src/fea/doc/RELEASE_NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Version 1.2.0
33

44
- Replace the legacy display-list / immediate-mode rendering pipeline with a fully VBO-based backend and GLSL 1.20 shaders
5+
- Enable transparent surfaces
56

67
------------------------------------------------------------------
78
Version 1.1.3

src/fea/src/color_combo_box.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ QColor ColorComboBox::getColor()
3737

3838
void ColorComboBox::setColor(const QColor &color)
3939
{
40-
this->setColorName(color.name());
40+
this->setColorName(color.name(QColor::HexArgb));
4141
}
4242

4343
QString ColorComboBox::getColorName()
4444
{
45-
return this->getColor().name();
45+
return this->getColor().name(QColor::HexArgb);
4646
}
4747

4848
void ColorComboBox::setColorName(const QString &colorName)
@@ -73,7 +73,7 @@ QIcon ColorComboBox::createIcon(const QString &colorName)
7373

7474
void ColorComboBox::addColor(const QColor &color)
7575
{
76-
this->addColor(color.name());
76+
this->addColor(color.name(QColor::HexArgb));
7777
}
7878

7979
void ColorComboBox::addColor(const QString &colorName)
@@ -99,7 +99,7 @@ void ColorComboBox::onCurrentIndexChanged(int index)
9999
if (index == 0)
100100
{
101101
// Select custom color.
102-
QColor color = QColorDialog::getColor(this->color,this->parentWidget(),"Choose entity color");
102+
QColor color = QColorDialog::getColor(this->color,this->parentWidget(),"Choose entity color",QColorDialog::ShowAlphaChannel);
103103
if (color.isValid())
104104
{
105105
this->setColor(color);

src/fea/src/model.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,17 +1975,25 @@ void Model::glDraw(GLWidget *glWidget) const
19751975
return a < 255;
19761976
};
19771977

1978-
// Two-pass rendering for correct alpha blending:
1979-
// Pass 0 (opaque) — depth writes ON, draw entities with alpha == 255
1980-
// Pass 1 (transparent) — depth writes OFF, draw entities with alpha < 255
1981-
// Opaque geometry fills the depth buffer first so transparent surfaces
1982-
// correctly blend against whatever is visible behind them.
1983-
for (int pass = 0; pass < 2; pass++)
1984-
{
1985-
const bool transparentPass = (pass == 1);
1986-
if (transparentPass)
1978+
// Three-pass rendering for correct alpha blending with silver back-faces:
1979+
// Pass 0 — opaque (alpha=255): depth writes ON, normal cull state
1980+
// Pass 1 — transp. back faces: depth writes OFF, GL_FRONT culled → back faces drawn (silver)
1981+
// Pass 2 — transp. front faces: depth writes OFF, GL_BACK culled → front faces drawn (entity color)
1982+
// Drawing back faces before front faces gives correct layering for convex transparent shells
1983+
// without needing per-triangle depth sorting.
1984+
GLStateCache &stateCache = GLStateCache::instance();
1985+
for (int pass = 0; pass < 3; pass++)
1986+
{
1987+
const bool transparentPass = (pass >= 1);
1988+
if (pass == 1)
19871989
{
19881990
GL_SAFE_CALL(glDepthMask(GL_FALSE));
1991+
stateCache.enableCullFace();
1992+
stateCache.setCullFaceMode(GL_FRONT); // cull front → draw back (silver)
1993+
}
1994+
else if (pass == 2)
1995+
{
1996+
stateCache.setCullFaceMode(GL_BACK); // cull back → draw front (entity color)
19891997
}
19901998

19911999
// Draw volume entities.
@@ -2087,11 +2095,12 @@ void Model::glDraw(GLWidget *glWidget) const
20872095
glIso.paint();
20882096
}
20892097

2090-
if (transparentPass)
2098+
if (pass == 2)
20912099
{
20922100
GL_SAFE_CALL(glDepthMask(GL_TRUE));
2101+
stateCache.disableCullFace();
20932102
}
2094-
} // two-pass loop
2103+
} // three-pass loop
20952104

20962105
if (glWidget->getGLDisplayProperties().getShowModelEdges())
20972106
{

0 commit comments

Comments
 (0)