Fix oil spill rendering (#240)

* Make the gl renderer aware of BR_MATF_TWO_SIDED and BR_MATF_ALWAYS_VISIBLE

Prevent the gl renderer from culling back-faced textures if the material
is two-sided or always visible.

Due to the wrong order of vertices in the model, oil spill object is
subject to back face culling, preventing it from being rendered. Set
the oil spill material as two-sided, allowing it to be displayed.

Signed-off-by: Artur Rojek <contact@artur-rojek.eu>
This commit is contained in:
Artur Rojek 2022-11-17 05:25:32 +01:00 committed by GitHub
parent 6c55ba2827
commit a1504075cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -41,6 +41,8 @@ void InitOilSpills() {
the_material->flags |= BR_MATF_LIGHT;
the_material->flags |= BR_MATF_PERSPECTIVE;
the_material->flags |= BR_MATF_SMOOTH;
// TODO: added by dethrace, investigate why oil spills in OG do not need this flag set to render correctly
the_material->flags |= BR_MATF_TWO_SIDED;
the_material->index_range = 0;
the_material->colour_map = NULL;
BrMatrix23Identity(&the_material->map_transform);

View File

@ -501,6 +501,12 @@ void setActiveMaterial(tStored_material* material) {
glUniform1i(uniforms_3d.light_value, -1);
}
if (material->flags & (BR_MATF_TWO_SIDED | BR_MATF_ALWAYS_VISIBLE)) {
glDisable(GL_CULL_FACE);
} else {
glEnable(GL_CULL_FACE);
}
if (material->pixelmap) {
tStored_pixelmap* stored_px = material->pixelmap->stored;
if (stored_px != NULL) {