Skip to content

Commit fcdb232

Browse files
committed
Solved a bug with the ORM texture loading.
1 parent 572b69d commit fcdb232

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/Shader/LightPass.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ float3 ReconstructPosition(int2 pixelCoord, uint index)
8989

9090
PixelOutput PixelMain(VertexOutput input, uint index : SV_SampleIndex)
9191
{
92-
float3 lightPos = float3(0.f, 20.f, 20.f);
93-
float3 lightColor = float3(500.f, 500.f, 500.f);
92+
float3 lightPos = float3(2.f, 2.f, 2.f);
93+
float3 lightColor = float3(50.f, 50.f, 50.f);
9494

9595
int2 pixelCoord = int2(input.position.xy);
9696

src/private/Core/GameObject/Camera/EditorCamera.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ EditorCamera::EditorCamera(std::string name) : Camera(name) {
44
this->m_fSensX = 5.f;
55
this->m_fSensY = 5.f;
66

7-
this->m_fSpeed = 15.f;
7+
this->m_fSpeed = 150.f;
88
}
99

1010
void EditorCamera::Init() {

src/private/Core/GameObject/Component/Mesh.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void Mesh::InitSampler(D3D12* renderer) {
293293
UINT nNumORMTextures = this->m_ORMTextures.size();
294294
this->m_cbv_srvHeap->Allocate(nNumTextures + nNumORMTextures);
295295
UINT nLastIndex = m_cbv_srvHeap->GetLastDescriptorIndex();
296-
UINT nFirstIndex = nLastIndex - nNumTextures;
296+
UINT nFirstIndex = nLastIndex - (nNumTextures + nNumORMTextures);
297297

298298
UINT nActualIndex = nFirstIndex;
299299
for (std::pair<UINT, ComPtr<ID3D12Resource>> resource : this->m_textures) {
@@ -351,6 +351,8 @@ void Mesh::LoadModel(std::string filename) {
351351
return;
352352
};
353353

354+
UINT nIndex = 0;
355+
354356
Assimp::Importer importer;
355357
const aiScene* scene = importer.ReadFile(filename, NULL);
356358

@@ -401,12 +403,14 @@ void Mesh::LoadModel(std::string filename) {
401403

402404
aiString texPath;
403405
aiString metalPath;
406+
nIndex++;
404407
if (material->GetTextureCount(aiTextureType_BASE_COLOR) > 0 && material->GetTexture(aiTextureType_DIFFUSE, 0, &texPath) == AI_SUCCESS) {
405408
const aiTexture* texture = scene->GetEmbeddedTexture(texPath.C_Str());
406409
if (texture != nullptr) {
407410
ResourceManager* resMgr = ResourceManager::GetInstance();
411+
std::string name = std::string(texPath.C_Str());
408412
ComPtr<ID3D12Resource> resource;
409-
resMgr->LoadTexture((BYTE*)texture->pcData, texture->mWidth, texture->mFilename.C_Str(), resource);
413+
resMgr->LoadTexture((BYTE*)texture->pcData, texture->mWidth, name, resource);
410414
resource->SetName(L"Mesh Base color");
411415
this->m_textures[i] = resource;
412416
}
@@ -417,8 +421,9 @@ void Mesh::LoadModel(std::string filename) {
417421

418422
if (texture != nullptr) {
419423
ResourceManager* resMgr = ResourceManager::GetInstance();
424+
std::string name = std::string(metalPath.C_Str());
420425
ComPtr<ID3D12Resource> resource;
421-
resMgr->LoadTexture((BYTE*)texture->pcData, texture->mWidth, texture->mFilename.C_Str(), resource);
426+
resMgr->LoadTexture((BYTE*)texture->pcData, texture->mWidth, name, resource);
422427
resource->SetName(L"Mesh Metallic Roughness");
423428
this->m_ORMTextures[i] = resource;
424429
}

src/private/Core/Scene/Scene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Scene::Scene(std::string name) {
88
void Scene::Init() {
99
Mesh* m_mesh = new Mesh("StaticMeshComponent", &m_go->transform);
1010
m_go->m_components.push_back(m_mesh);
11-
m_mesh->LoadModel("barrel.glb");
11+
m_mesh->LoadModel("sponza_atrium_3.glb");
1212
this->AddGameObject(m_go);
1313

1414
this->m_editorCamera = new EditorCamera("EditorCamera");

src/public/Core/GameObject/Component/Mesh.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <assimp/postprocess.h>
1111
#include <map>
1212
#include "Util.h"
13+
#include <string>
1314

1415
#include "Core/GameObject/Component/Component.h"
1516
#include "Core/Renderer/Shader.h"

0 commit comments

Comments
 (0)