From a1504075cc24f07afb9b1c2e199d54edbe15a765 Mon Sep 17 00:00:00 2001 From: Artur Rojek Date: Thu, 17 Nov 2022 05:25:32 +0100 Subject: [PATCH] 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 --- src/DETHRACE/common/oil.c | 2 ++ src/harness/renderers/gl/gl_renderer.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/DETHRACE/common/oil.c b/src/DETHRACE/common/oil.c index b3857227..7c8a4c59 100644 --- a/src/DETHRACE/common/oil.c +++ b/src/DETHRACE/common/oil.c @@ -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); diff --git a/src/harness/renderers/gl/gl_renderer.c b/src/harness/renderers/gl/gl_renderer.c index eda17217..9fc3737a 100644 --- a/src/harness/renderers/gl/gl_renderer.c +++ b/src/harness/renderers/gl/gl_renderer.c @@ -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) {