mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 11:39:19 +02:00
opacity handling hacks
This commit is contained in:
10
DynObj.cpp
10
DynObj.cpp
@@ -206,19 +206,21 @@ material_data::assign( std::string const &Replacableskin ) {
|
|||||||
replacable_skins[ 1 ] = GfxRenderer->Fetch_Material( Replacableskin );
|
replacable_skins[ 1 ] = GfxRenderer->Fetch_Material( 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 = (
|
textures_alpha = (
|
||||||
GfxRenderer->Material( replacable_skins[ 1 ] ).is_translucent() ?
|
GfxRenderer->Material( replacable_skins[ 1 ] ).get_or_guess_opacity() == 0.0f ?
|
||||||
0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
0x31310031 : // tekstura -1 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
0x30300030 ); // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych
|
0x30300030 ); // wszystkie tekstury nieprzezroczyste - nie renderować w cyklu przezroczystych
|
||||||
if( GfxRenderer->Material( replacable_skins[ 2 ] ).is_translucent() ) {
|
if( GfxRenderer->Material( replacable_skins[ 2 ] ).get_or_guess_opacity() == 0.0f ) {
|
||||||
// tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura -2 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
textures_alpha |= 0x02020002;
|
textures_alpha |= 0x02020002;
|
||||||
}
|
}
|
||||||
if( GfxRenderer->Material( replacable_skins[ 3 ] ).is_translucent() ) {
|
if( GfxRenderer->Material( replacable_skins[ 3 ] ).get_or_guess_opacity() == 0.0f ) {
|
||||||
// tekstura -3 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura -3 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
textures_alpha |= 0x04040004;
|
textures_alpha |= 0x04040004;
|
||||||
}
|
}
|
||||||
if( GfxRenderer->Material( replacable_skins[ 4 ] ).is_translucent() ) {
|
if( GfxRenderer->Material( replacable_skins[ 4 ] ).get_or_guess_opacity() == 0.0f ) {
|
||||||
// tekstura -4 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
// tekstura -4 z kanałem alfa - nie renderować w cyklu nieprzezroczystych
|
||||||
textures_alpha |= 0x08080008;
|
textures_alpha |= 0x08080008;
|
||||||
}
|
}
|
||||||
|
|||||||
45
Model3d.cpp
45
Model3d.cpp
@@ -418,39 +418,6 @@ std::pair<int, int> TSubModel::Load( cParser &parser, bool dynamic )
|
|||||||
iFlags |= 0x10;
|
iFlags |= 0x10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_material > 0)
|
|
||||||
{
|
|
||||||
opengl_material const &mat = GfxRenderer->Material(m_material);
|
|
||||||
/*
|
|
||||||
if( eType == TP_FREESPOTLIGHT ) {
|
|
||||||
iFlags &= ~0x30;
|
|
||||||
iFlags |= 0x20;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
// if material has opacity set, replace submodel opacity with it
|
|
||||||
// NOTE: reverted to use base opacity, this allows to define opacity threshold in material
|
|
||||||
// without it causing the translucent models to become opaque
|
|
||||||
auto const opacity { (
|
|
||||||
/*
|
|
||||||
false == std::isnan( mat.opacity ) ?
|
|
||||||
mat.opacity :
|
|
||||||
*/
|
|
||||||
Opacity ) };
|
|
||||||
iFlags &= ~0x30;
|
|
||||||
iFlags |= (
|
|
||||||
( ( opacity < 0.01f )
|
|
||||||
&& ( GfxRenderer->Material( m_material ).is_translucent() ) ) ?
|
|
||||||
0x20 :
|
|
||||||
0x10 ); // 0x10-nieprzezroczysta, 0x20-przezroczysta
|
|
||||||
}
|
|
||||||
// and same thing with selfillum
|
|
||||||
if( mat.selfillum ) {
|
|
||||||
fLight = mat.selfillum.value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_material > 0)
|
if (m_material > 0)
|
||||||
{
|
{
|
||||||
const opengl_material &mat = GfxRenderer->Material(m_material);
|
const opengl_material &mat = GfxRenderer->Material(m_material);
|
||||||
@@ -1624,7 +1591,10 @@ void TSubModel::serialize(std::ostream &s,
|
|||||||
sn_utils::ls_int32(s, (int32_t)get_container_pos(names, pName));
|
sn_utils::ls_int32(s, (int32_t)get_container_pos(names, pName));
|
||||||
sn_utils::ls_int32(s, (int)b_Anim);
|
sn_utils::ls_int32(s, (int)b_Anim);
|
||||||
|
|
||||||
sn_utils::ls_uint32(s, iFlags);
|
uint32_t flags = iFlags;
|
||||||
|
if (m_material > 0 && (Global.iConvertModels & 16))
|
||||||
|
flags &= ~0x30; // don't save phase information, will be guessed on binary load from material
|
||||||
|
sn_utils::ls_uint32(s, flags);
|
||||||
sn_utils::ls_int32(s, (int32_t)get_container_pos(transforms, *fMatrix));
|
sn_utils::ls_int32(s, (int32_t)get_container_pos(transforms, *fMatrix));
|
||||||
|
|
||||||
sn_utils::ls_int32( s, m_geometry.vertex_count );
|
sn_utils::ls_int32( s, m_geometry.vertex_count );
|
||||||
@@ -2073,12 +2043,7 @@ void TSubModel::BinInit(TSubModel *s, float4x4 *m, std::vector<std::string> *t,
|
|||||||
if (!(iFlags & 0x30) && m_material != null_handle)
|
if (!(iFlags & 0x30) && m_material != null_handle)
|
||||||
{
|
{
|
||||||
const opengl_material &mat = GfxRenderer->Material(m_material);
|
const opengl_material &mat = GfxRenderer->Material(m_material);
|
||||||
float opacity;
|
float opacity = mat.get_or_guess_opacity();
|
||||||
if (mat.opacity)
|
|
||||||
opacity = *mat.opacity;
|
|
||||||
// if material don't have opacity set, try to guess it
|
|
||||||
else
|
|
||||||
opacity = mat.get_or_guess_opacity();
|
|
||||||
|
|
||||||
// set phase flag based on material opacity
|
// set phase flag based on material opacity
|
||||||
if (opacity == 0.0f)
|
if (opacity == 0.0f)
|
||||||
|
|||||||
11
material.cpp
11
material.cpp
@@ -443,16 +443,7 @@ float opengl_material::get_or_guess_opacity() const {
|
|||||||
return 0.5f;
|
return 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0f;
|
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.
|
// create material object from data stored in specified file.
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ struct opengl_material {
|
|||||||
void finalize(bool Loadnow);
|
void finalize(bool Loadnow);
|
||||||
bool update();
|
bool update();
|
||||||
float get_or_guess_opacity() const;
|
float get_or_guess_opacity() const;
|
||||||
bool is_translucent() const;
|
|
||||||
// members
|
// members
|
||||||
static struct path_data {
|
static struct path_data {
|
||||||
std::unordered_map<std::string, int> index_map;
|
std::unordered_map<std::string, int> index_map;
|
||||||
|
|||||||
Reference in New Issue
Block a user