From d2b93f0cbbe159e5f4316be966ade9825998f4fd Mon Sep 17 00:00:00 2001 From: milek7 Date: Mon, 7 Mar 2022 21:02:14 +0100 Subject: [PATCH] revert, try to maintain compatiblity with weirdness for now... --- DynObj.cpp | 8 ++++---- material.cpp | 9 +++++++++ material.h | 1 + 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/DynObj.cpp b/DynObj.cpp index fef45eb8..5ccfcfbd 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -209,18 +209,18 @@ material_data::assign( std::string const &Replacableskin ) { // BUGS! it's not entierly designed whether opacity is property of material or submodel, // and code does confusing things with this in various places textures_alpha = ( - GfxRenderer->Material( replacable_skins[ 1 ] ).get_or_guess_opacity() == 0.0f ? + GfxRenderer->Material( replacable_skins[ 1 ] ).is_translucent() ? 0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych 0x30300030 ); // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych - if( GfxRenderer->Material( replacable_skins[ 2 ] ).get_or_guess_opacity() == 0.0f ) { + if( GfxRenderer->Material( replacable_skins[ 2 ] ).is_translucent() ) { // tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych textures_alpha |= 0x02020002; } - if( GfxRenderer->Material( replacable_skins[ 3 ] ).get_or_guess_opacity() == 0.0f ) { + if( GfxRenderer->Material( replacable_skins[ 3 ] ).is_translucent() ) { // tekstura -3 z kanałem alfa - nie renderować w cyklu nieprzezroczystych textures_alpha |= 0x04040004; } - if( GfxRenderer->Material( replacable_skins[ 4 ] ).get_or_guess_opacity() == 0.0f ) { + if( GfxRenderer->Material( replacable_skins[ 4 ] ).is_translucent() ) { // tekstura -4 z kanałem alfa - nie renderować w cyklu nieprzezroczystych textures_alpha |= 0x08080008; } diff --git a/material.cpp b/material.cpp index 81d3f208..523e6c8b 100644 --- a/material.cpp +++ b/material.cpp @@ -446,6 +446,15 @@ float opengl_material::get_or_guess_opacity() const { return 0.5f; } +bool +opengl_material::is_translucent() const { + + return ( + textures[ 0 ] != null_handle ? + GfxRenderer->Texture( textures[ 0 ] ).has_alpha : + false ); +} + // create material object from data stored in specified file. // NOTE: the deferred load parameter is passed to textures defined by material, the material itself is always loaded immediately material_handle diff --git a/material.h b/material.h index 8d848967..d6a6359f 100644 --- a/material.h +++ b/material.h @@ -41,6 +41,7 @@ struct opengl_material { void finalize(bool Loadnow); bool update(); float get_or_guess_opacity() const; + bool is_translucent() const; // members static struct path_data { std::unordered_map index_map;