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
if( mesh.mMaterialIndex >= 0 )
{
using namespace std::string_literals;
auto& material = *pMaterials[mesh.mMaterialIndex];
using namespace std::string_literals;
const auto base = "Models\\nano_textured\\"s;
aiString 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 ) );
}
......
......@@ -6,7 +6,9 @@ namespace Bind
{
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 );
......@@ -44,6 +46,6 @@ namespace Bind
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
class Texture : public Bindable
{
public:
Texture( Graphics& gfx,const Surface& s );
Texture( Graphics& gfx,const Surface& s,unsigned int slot = 0 );
void Bind( Graphics& gfx ) noexcept override;
private:
unsigned int slot;
protected:
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