Bugfix for alpha-masking sometimes not working.
This commit is contained in:
@@ -14,7 +14,7 @@ include (cmake/CPM.cmake)
|
|||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME JGL
|
NAME JGL
|
||||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-44.zip
|
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-45.zip
|
||||||
)
|
)
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
|
BIN
assets/sprites/alpha_mask.png
Normal file
BIN
assets/sprites/alpha_mask.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
@@ -10,5 +10,5 @@ class Game::Box final : public Engine::InstancedSprite {
|
|||||||
public:
|
public:
|
||||||
void Update() final;
|
void Update() final;
|
||||||
public:
|
public:
|
||||||
explicit Box(const Vector2& position, unsigned int depth = 0, float rad_rotation = 0.0f) : Engine::InstancedSprite(position, depth, "assets/sprites/Re3D.png", rad_rotation) {}
|
explicit Box(const Vector2& position, unsigned int depth = 0, float rad_rotation = 0.0f) : Engine::InstancedSprite(position, depth, "assets/sprites/Re3D.png", rad_rotation, Colors::White, nullptr, "assets/sprites/alpha_mask.png") {}
|
||||||
};
|
};
|
@@ -6,19 +6,14 @@ Texture* InstancedSprite::GetTexture() {
|
|||||||
auto* itx = Globals::CurrentScene->GetInstancedTexture(this);
|
auto* itx = Globals::CurrentScene->GetInstancedTexture(this);
|
||||||
if (itx)
|
if (itx)
|
||||||
return itx->GetTexture();
|
return itx->GetTexture();
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture* InstancedSprite::GetAlphaMask() {
|
Texture* InstancedSprite::GetAlphaMask() {
|
||||||
if (Sprite::GetAlphaMask())
|
|
||||||
return Sprite::GetAlphaMask();
|
|
||||||
|
|
||||||
auto* ita = Globals::CurrentScene->GetInstancedAlphaMask(this);
|
auto* ita = Globals::CurrentScene->GetInstancedAlphaMask(this);
|
||||||
if (ita)
|
if (ita)
|
||||||
return ita->GetTexture();
|
return ita->GetTexture();
|
||||||
|
return Sprite::GetAlphaMask();
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InstancedSprite::~InstancedSprite() {
|
InstancedSprite::~InstancedSprite() {
|
||||||
|
@@ -167,8 +167,8 @@ InstancedTexture* Scene::GetInstancedAlphaMask(const InstancedSprite* user) {
|
|||||||
if (itx->InUseBy(user))
|
if (itx->InUseBy(user))
|
||||||
return itx;
|
return itx;
|
||||||
|
|
||||||
if (!user->GetAlphaMaskFilesystemPath().empty() && !instanced_alpha_masks.empty()) {
|
if (!user->GetAlphaMaskFilesystemPath().empty()) {
|
||||||
auto *t = new Texture(user->GetTextureFilesystemPath());
|
auto *t = new Texture(user->GetAlphaMaskFilesystemPath());
|
||||||
auto *itx = new InstancedTexture(t, user);
|
auto *itx = new InstancedTexture(t, user);
|
||||||
instanced_alpha_masks.push_back(itx);
|
instanced_alpha_masks.push_back(itx);
|
||||||
return itx;
|
return itx;
|
||||||
|
Reference in New Issue
Block a user