Commit 054d8661 authored by chili's avatar chili
Browse files

loading specular maps

parent fc18dc8b
...@@ -272,11 +272,18 @@ std::unique_ptr<Mesh> Model::ParseMesh( Graphics& gfx,const aiMesh& mesh,const a ...@@ -272,11 +272,18 @@ std::unique_ptr<Mesh> Model::ParseMesh( Graphics& gfx,const aiMesh& mesh,const a
if( mesh.mMaterialIndex >= 0 ) if( mesh.mMaterialIndex >= 0 )
{ {
using namespace std::string_literals;
auto& material = *pMaterials[mesh.mMaterialIndex]; auto& material = *pMaterials[mesh.mMaterialIndex];
using namespace std::string_literals;
const auto base = "Models\\nano_textured\\"s;
aiString texFileName; aiString texFileName;
material.GetTexture( aiTextureType_DIFFUSE,0,&texFileName ); material.GetTexture( aiTextureType_DIFFUSE,0,&texFileName );
bindablePtrs.push_back( std::make_unique<Bind::Texture>( gfx,Surface::FromFile( "Models\\nano_textured\\"s + texFileName.C_Str() ) ) ); bindablePtrs.push_back( std::make_unique<Bind::Texture>( gfx,Surface::FromFile( base + texFileName.C_Str() ) ) );
material.GetTexture( aiTextureType_SPECULAR,0,&texFileName );
bindablePtrs.push_back( std::make_unique<Bind::Texture>( gfx,Surface::FromFile( base + texFileName.C_Str() ),1 ) );
bindablePtrs.push_back( std::make_unique<Bind::Sampler>( gfx ) ); bindablePtrs.push_back( std::make_unique<Bind::Sampler>( gfx ) );
} }
......
...@@ -6,7 +6,9 @@ namespace Bind ...@@ -6,7 +6,9 @@ namespace Bind
{ {
namespace wrl = Microsoft::WRL; namespace wrl = Microsoft::WRL;
Texture::Texture( Graphics& gfx,const Surface& s ) Texture::Texture( Graphics& gfx,const Surface& s,unsigned int slot )
:
slot( slot )
{ {
INFOMAN( gfx ); INFOMAN( gfx );
...@@ -44,6 +46,6 @@ namespace Bind ...@@ -44,6 +46,6 @@ namespace Bind
void Texture::Bind( Graphics& gfx ) noexcept void Texture::Bind( Graphics& gfx ) noexcept
{ {
GetContext( gfx )->PSSetShaderResources( 0u,1u,pTextureView.GetAddressOf() ); GetContext( gfx )->PSSetShaderResources( slot,1u,pTextureView.GetAddressOf() );
} }
} }
...@@ -8,8 +8,10 @@ namespace Bind ...@@ -8,8 +8,10 @@ namespace Bind
class Texture : public Bindable class Texture : public Bindable
{ {
public: public:
Texture( Graphics& gfx,const Surface& s ); Texture( Graphics& gfx,const Surface& s,unsigned int slot = 0 );
void Bind( Graphics& gfx ) noexcept override; void Bind( Graphics& gfx ) noexcept override;
private:
unsigned int slot;
protected: protected:
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> pTextureView; Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> pTextureView;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment