Graphics: Fix TextureLoader
This commit is contained in:
@@ -29,12 +29,15 @@ namespace Nz
|
||||
TextureParams texParams;
|
||||
texParams.renderDevice = Graphics::Instance()->GetRenderDevice();
|
||||
|
||||
std::shared_ptr<Texture> texture = Texture::LoadFromStream(stream, {});
|
||||
std::shared_ptr<Texture> texture = Texture::LoadFromStream(stream, texParams);
|
||||
if (!texture)
|
||||
return Err(ResourceLoadingError::Unrecognized);
|
||||
|
||||
std::shared_ptr<Material> material = std::make_shared<Material>();
|
||||
|
||||
bool hasAlphaTest = false;
|
||||
parameters.custom.GetBooleanParameter("EnableAlphaTest", &hasAlphaTest);
|
||||
|
||||
// ForwardPass
|
||||
{
|
||||
std::shared_ptr<MaterialPass> matPass;
|
||||
@@ -50,7 +53,7 @@ namespace Nz
|
||||
BasicMaterial forwardPass(*matPass);
|
||||
forwardPass.SetBaseColorMap(texture);
|
||||
|
||||
if (PixelFormatInfo::HasAlpha(texture->GetFormat()))
|
||||
if (hasAlphaTest && PixelFormatInfo::HasAlpha(texture->GetFormat()))
|
||||
forwardPass.EnableAlphaTest(true);
|
||||
|
||||
material->AddPass("ForwardPass", std::move(matPass));
|
||||
@@ -59,8 +62,9 @@ namespace Nz
|
||||
// DepthPass
|
||||
{
|
||||
std::shared_ptr<MaterialPass> matPass = std::make_shared<MaterialPass>(DepthMaterial::GetSettings());
|
||||
matPass->EnableDepthBuffer(true);
|
||||
|
||||
if (PixelFormatInfo::HasAlpha(texture->GetFormat()))
|
||||
if (hasAlphaTest && PixelFormatInfo::HasAlpha(texture->GetFormat()))
|
||||
{
|
||||
BasicMaterial depthPass(*matPass);
|
||||
depthPass.SetBaseColorMap(texture);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
|
||||
#include <Nazara/Graphics/MaterialPipeline.hpp>
|
||||
#include <Nazara/Graphics/PredefinedShaderStructs.hpp>
|
||||
#include <Nazara/Graphics/Formats/TextureLoader.hpp>
|
||||
#include <Nazara/Utility/Font.hpp>
|
||||
#include <NZSL/Ast/AstSerializer.hpp>
|
||||
#include <NZSL/Ast/Module.hpp>
|
||||
@@ -119,6 +120,8 @@ namespace Nz
|
||||
MaterialPipeline::Initialize();
|
||||
|
||||
Font::SetDefaultAtlas(std::make_shared<GuillotineTextureAtlas>(*m_renderDevice));
|
||||
|
||||
m_materialLoader.RegisterLoader(Loaders::GetMaterialLoader_Texture()); // texture to material loader
|
||||
}
|
||||
|
||||
Graphics::~Graphics()
|
||||
|
||||
Reference in New Issue
Block a user