Rendered multiple racoons

This commit is contained in:
Brandon Mak 2022-09-28 20:33:29 +08:00
parent 4fcb5e313b
commit 78f216e445
7 changed files with 44 additions and 19 deletions

View File

@ -76,10 +76,10 @@ namespace Sandbox
customMat->SetProperty("data.alpha", 0.1f); customMat->SetProperty("data.alpha", 0.1f);
// Create Stress Test Objects // Create Stress Test Objects
static const SHVec3 TEST_OBJ_SCALE = { 0.2f, 0.2f, 0.2f }; static const SHVec3 TEST_OBJ_SCALE = { 0.05f, 0.05f, 0.05f };
constexpr int NUM_ROWS = 20; constexpr int NUM_ROWS = 100;
constexpr int NUM_COLS = 20; constexpr int NUM_COLS = 100;
static const SHVec3 TEST_OBJ_SPACING = { 0.2f, 0.2f, 0.2f }; static const SHVec3 TEST_OBJ_SPACING = { 0.05f, 0.05f, 0.05f };
static const SHVec3 TEST_OBJ_START_POS = { - (NUM_COLS / 2 * TEST_OBJ_SPACING.x ) + 1.0f, -2.0f, -1.0f }; static const SHVec3 TEST_OBJ_START_POS = { - (NUM_COLS / 2 * TEST_OBJ_SPACING.x ) + 1.0f, -2.0f, -1.0f };
for (int y = 0; y < NUM_ROWS; ++y) for (int y = 0; y < NUM_ROWS; ++y)
@ -92,6 +92,9 @@ namespace Sandbox
renderable.Mesh = handles.front(); renderable.Mesh = handles.front();
renderable.SetMaterial(customMat); renderable.SetMaterial(customMat);
if (y == 50)
renderable.GetModifiableMaterial()->SetProperty("data.color", SHVec4(1.0f, 0.0f, 0.0f, 1.0f));
//Set initial positions //Set initial positions
transform.SetWorldPosition(TEST_OBJ_START_POS + SHVec3{ transform.SetWorldPosition(TEST_OBJ_START_POS + SHVec3{
x * TEST_OBJ_SPACING.x, x * TEST_OBJ_SPACING.x,
@ -105,6 +108,19 @@ namespace Sandbox
stressTestObjects.emplace_back(entity); stressTestObjects.emplace_back(entity);
} }
auto entity = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(entity);
auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(entity);
renderable.Mesh = handles.front();
renderable.SetMaterial(customMat);
renderable.GetModifiableMaterial()->SetProperty("data.color", SHVec4(0.0f, 0.0f, 0.0f, 0.0f));
renderable.GetModifiableMaterial()->SetProperty("data.alpha", 1.0f);
renderable.GetModifiableMaterial()->SetProperty("data.textureIndex", 1);
transform.SetWorldPosition ({-3.0f, -1.0f, -1.0f});
transform.SetLocalScale({5.0f, 5.0f, 5.0f});
//auto entity = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>(); //auto entity = SHEntityManager::CreateEntity<SHRenderable, SHTransformComponent>();
//auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(entity); //auto& renderable = *SHComponentManager::GetComponent_s<SHRenderable>(entity);
//auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(entity); //auto& transform = *SHComponentManager::GetComponent_s<SHTransformComponent>(entity);

View File

@ -113,6 +113,9 @@ project "SHADE_Engine"
filter "configurations:Release" filter "configurations:Release"
postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""} postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""}
filter "configurations:Publish"
postbuildcommands {"xcopy /r /y /q \"%{IncludeDir.assimp}\\bin\\Release\\assimp-vc142-mt.dll\" \"$(OutDir)\""}
warnings 'Extra' warnings 'Extra'
filter "configurations:Debug" filter "configurations:Debug"

View File

@ -79,7 +79,7 @@ namespace SHADE
} }
SHTexture::PixelChannel* pixel = new SHTexture::PixelChannel[totalBytes]; SHTexture::PixelChannel* pixel = new SHTexture::PixelChannel[totalBytes];
std::memcpy(pixel, file.GetDDSData(), totalBytes); std::memcpy(pixel, file.GetImageData()->m_mem, totalBytes);
//pixel = std::move(reinterpret_cast<SHTexture::PixelChannel const*>(file.GetDDSData())); //pixel = std::move(reinterpret_cast<SHTexture::PixelChannel const*>(file.GetDDSData()));
asset.numBytes = totalBytes; asset.numBytes = totalBytes;

View File

@ -15,6 +15,11 @@ namespace SHADE
SHVertexInputState SHGraphicsGlobalData::defaultVertexInputState; SHVertexInputState SHGraphicsGlobalData::defaultVertexInputState;
Handle<SHVkPipelineLayout> SHGraphicsGlobalData::dummyPipelineLayout; Handle<SHVkPipelineLayout> SHGraphicsGlobalData::dummyPipelineLayout;
void SHGraphicsGlobalData::InitHighFrequencyGlobalData(void) noexcept
{
}
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Function Definitions */ /* Function Definitions */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -27,8 +27,9 @@ namespace SHADE
//! we create a dummy pipeline layout to use it for binding. //! we create a dummy pipeline layout to use it for binding.
static Handle<SHVkPipelineLayout> dummyPipelineLayout; static Handle<SHVkPipelineLayout> dummyPipelineLayout;
static void InitDescSetLayouts (Handle<SHVkLogicalDevice> logicalDevice) noexcept; static void InitHighFrequencyGlobalData (void) noexcept;
static void InitDefaultVertexInputState(void) noexcept; static void InitDescSetLayouts (Handle<SHVkLogicalDevice> logicalDevice) noexcept;
static void InitDefaultVertexInputState (void) noexcept;
public: public:
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/

View File

@ -81,7 +81,7 @@ namespace SHADE
if (!material) if (!material)
{ {
SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>(); SHGraphicsSystem* gfxSystem = SHSystemManager::GetSystem<SHGraphicsSystem>();
material = gfxSystem->AddOrGetBaseMaterialInstance(sharedMaterial->GetBaseMaterial()); material = gfxSystem->AddMaterialInstanceCopy(sharedMaterial);
} }
return material; return material;

View File

@ -3,6 +3,14 @@
#extension GL_ARB_shading_language_420pack : enable #extension GL_ARB_shading_language_420pack : enable
#extension GL_EXT_nonuniform_qualifier : require #extension GL_EXT_nonuniform_qualifier : require
struct MatPropData
{
vec4 color;
int textureIndex;
float alpha;
vec3 beta;
};
layout(location = 0) in struct layout(location = 0) in struct
{ {
vec4 vertColor; vec4 vertColor;
@ -16,18 +24,10 @@ layout(location = 2) flat in struct
int materialIndex; int materialIndex;
} In2; } In2;
//layout (set = 0, binding = )
layout (set = 0, binding = 1) uniform sampler2D textures[]; layout (set = 0, binding = 1) uniform sampler2D textures[]; // for textures (global)
layout (set = 3, binding = 0) buffer MaterialProperties // For materials
struct MatPropData
{
vec4 color;
int textureIndex;
float alpha;
vec3 beta;
};
layout(set = 3, binding = 0) buffer MaterialProperties
{ {
MatPropData data[]; MatPropData data[];
} MatProp; } MatProp;