Nothing works again
This commit is contained in:
@@ -25,10 +25,10 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
{
|
||||
result += pLightEnv.directionalLights[i].illuminate(lightingParams, brdf);
|
||||
}
|
||||
for(uint i = 0; i < lightCount; ++i)
|
||||
for(uint i = 0; i < pLightEnv.numPointLights; ++i)
|
||||
{
|
||||
uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||
result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf);
|
||||
//uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||
result += pLightEnv.pointLights[i].illuminate(lightingParams, brdf);
|
||||
}
|
||||
result += brdf.evaluateAmbient();
|
||||
// gamma correction
|
||||
|
||||
+12
-12
@@ -19,7 +19,7 @@ AssetRegistry* _instance = new AssetRegistry();
|
||||
int main(int, char**) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene* scene =
|
||||
importer.ReadFile("C:\\Users\\Dynamitos\\MeshShadingDemo\\import\\models\\after-the-rain-vr-sound\\source\\WhitechapelSrc.fbx",
|
||||
importer.ReadFile("C:\\Users\\Dynamitos\\MeshShadingDemo\\import\\models\\after-the-rain-vr-sound\\source\\WhitechapelSrc.glb",
|
||||
(uint32)(aiProcess_FlipUVs | aiProcess_Triangulate | aiProcess_ImproveCacheLocality));
|
||||
|
||||
auto interpolate = [](Vector p0, Vector p1, Vector p2) { return (p0 + p1 + p2) / 3.0f; };
|
||||
@@ -103,15 +103,15 @@ int main(int, char**) {
|
||||
// stats << calcArea(tris[i]) << std::endl;
|
||||
//}
|
||||
bool tess = false;
|
||||
while (!tess) {
|
||||
tess = true;
|
||||
for (uint32 i = 0; i < tris.size(); ++i) {
|
||||
if (calcArea(tris[i]) > 100.f) {
|
||||
tesselate(i);
|
||||
tess = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//while (!tess) {
|
||||
// tess = true;
|
||||
// for (uint32 i = 0; i < tris.size(); ++i) {
|
||||
// if (calcArea(tris[i]) > 100.f) {
|
||||
// tesselate(i);
|
||||
// tess = false;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
aiVector3D* newPos = new aiVector3D[positions.size()];
|
||||
std::memcpy(newPos, positions.data(), positions.size() * sizeof(Vector));
|
||||
@@ -160,8 +160,8 @@ int main(int, char**) {
|
||||
}
|
||||
|
||||
Assimp::Exporter exporter;
|
||||
exporter.Export(scene, "fbx",
|
||||
"C:\\Users\\Dynamitos\\MeshShadingDemo\\import\\models\\after-the-rain-vr-sound\\source\\Whitechapel.fbx");
|
||||
exporter.Export(scene, "glb2",
|
||||
"C:\\Users\\Dynamitos\\MeshShadingDemo\\import\\models\\after-the-rain-vr-sound\\source\\Whitechapel.glb");
|
||||
for (uint32 i = 0; i < exporter.GetExportFormatCount(); ++i) {
|
||||
auto desc = exporter.GetExportFormatDescription(i);
|
||||
std::cout << desc->description << " " << desc->fileExtension << " " << desc->id << " " << std::endl;
|
||||
|
||||
@@ -379,7 +379,10 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
|
||||
bool twoSided = true;
|
||||
material->Get(AI_MATKEY_TWOSIDED, twoSided);
|
||||
float opacity = 1.0f;
|
||||
material->Get(AI_MATKEY_OPACITY, opacity);
|
||||
if (std::strcmp(material->GetName().C_Str(), "3td_Africa_Grass01") == 0)
|
||||
{
|
||||
opacity = 0.5f;
|
||||
}
|
||||
OMaterialAsset baseMat = new MaterialAsset(importPath, materialName);
|
||||
baseMat->material = new Material(graphics, numTextures, numSamplers, numFloats, twoSided, opacity, materialName,
|
||||
std::move(expressions), std::move(parameters), std::move(brdf));
|
||||
|
||||
@@ -57,23 +57,9 @@ PTextureAsset TextureLoader::getPlaceholderTexture() { return placeholderAsset;
|
||||
|
||||
void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
|
||||
int totalWidth = 0, totalHeight = 0, n = 0;
|
||||
unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 0);
|
||||
unsigned char* data = stbi_load(args.filePath.string().c_str(), &totalWidth, &totalHeight, &n, 4);
|
||||
ktxTexture2* kTexture = nullptr;
|
||||
VkFormat format;
|
||||
switch (n) {
|
||||
case 1:
|
||||
format = VK_FORMAT_R8_UNORM;
|
||||
break;
|
||||
case 2:
|
||||
format = VK_FORMAT_R8G8_UNORM;
|
||||
break;
|
||||
case 3:
|
||||
format = VK_FORMAT_R8G8B8_UNORM;
|
||||
break;
|
||||
case 4:
|
||||
format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
break;
|
||||
}
|
||||
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
ktxTextureCreateInfo createInfo = {
|
||||
.vkFormat = (uint32)format,
|
||||
.baseDepth = 1,
|
||||
@@ -94,13 +80,13 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
|
||||
|
||||
KTX_ASSERT(ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, &kTexture));
|
||||
|
||||
auto loadCubeFace = [n, &kTexture, faceWidth, totalWidth, &data](int xPos, int yPos, int faceName) {
|
||||
std::vector<unsigned char> vec(faceWidth * faceWidth * n);
|
||||
auto loadCubeFace = [&kTexture, faceWidth, totalWidth, &data](int xPos, int yPos, int faceName) {
|
||||
std::vector<unsigned char> vec(faceWidth * faceWidth * 4);
|
||||
for (uint32 y = 0; y < faceWidth; ++y) {
|
||||
for (uint32 x = 0; x < faceWidth; ++x) {
|
||||
int imgX = x + (xPos * faceWidth);
|
||||
int imgY = y + (yPos * faceWidth);
|
||||
std::memcpy(&vec[(x + (faceWidth * y)) * n], &data[(imgX + (totalWidth * imgY)) * n], n);
|
||||
std::memcpy(&vec[(x + (faceWidth * y)) * 4], &data[(imgX + (totalWidth * imgY)) * 4], 4);
|
||||
}
|
||||
}
|
||||
ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, 0, faceName, vec.data(), vec.size());
|
||||
@@ -119,7 +105,7 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
|
||||
|
||||
ktxTexture2_Create(&createInfo, KTX_TEXTURE_CREATE_ALLOC_STORAGE, &kTexture);
|
||||
|
||||
ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, 0, 0, data, totalWidth * totalHeight * n * sizeof(unsigned char));
|
||||
ktxTexture_SetImageFromMemory(ktxTexture(kTexture), 0, 0, 0, data, totalWidth * totalHeight * 4 * sizeof(unsigned char));
|
||||
}
|
||||
ktxBasisParams basisParams = {
|
||||
.structSize = sizeof(ktxBasisParams),
|
||||
@@ -128,9 +114,9 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
|
||||
.uastcFlags = KTX_PACK_UASTC_LEVEL_DEFAULT,
|
||||
.uastcRDO = true,
|
||||
};
|
||||
KTX_ASSERT(ktxTexture2_CompressBasisEx(kTexture, &basisParams));
|
||||
|
||||
KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 15));
|
||||
//KTX_ASSERT(ktxTexture2_CompressBasisEx(kTexture, &basisParams));
|
||||
//
|
||||
//KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 15));
|
||||
|
||||
char writer[100];
|
||||
snprintf(writer, sizeof(writer), "%s version %s", "SeeleEngine", "0.0.1");
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ int main() {
|
||||
.type = TextureImportType::TEXTURE_CUBEMAP,
|
||||
});
|
||||
AssetImporter::importMesh(MeshImportArgs{
|
||||
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.fbx",
|
||||
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb",
|
||||
.importPath = "Whitechapel",
|
||||
});
|
||||
// AssetImporter::importMesh(MeshImportArgs{
|
||||
|
||||
@@ -44,6 +44,13 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics) : graphics(graphics)
|
||||
.numElements = INIT_POINT_LIGHTS,
|
||||
.dynamic = true,
|
||||
});
|
||||
lightEnvBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
directionalLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
pointLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
}
|
||||
|
||||
LightEnvironment::~LightEnvironment() {}
|
||||
@@ -78,7 +85,7 @@ void LightEnvironment::commit() {
|
||||
.numElements = dirs.size(),
|
||||
});
|
||||
directionalLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
pointLights->rotateBuffer(sizeof(Component::PointLight) * points.size());
|
||||
pointLights->updateContents({
|
||||
@@ -89,7 +96,7 @@ void LightEnvironment::commit() {
|
||||
},
|
||||
.numElements = points.size(),
|
||||
});
|
||||
pointLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_UNIFORM_READ_BIT,
|
||||
pointLights->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||
set->updateBuffer(0, lightEnvBuffer);
|
||||
set->updateBuffer(1, directionalLights);
|
||||
|
||||
Reference in New Issue
Block a user