Dragon in box
This commit is contained in:
@@ -142,8 +142,26 @@ void FrameBuffer::Ready() {
|
||||
|
||||
void FrameBuffer::DumpToFile(std::string path) {
|
||||
// int stbi_write_png(char const* filename, int w, int h, int comp, const void* data, int stride_in_bytes);
|
||||
// TODO: Red and Blue channels need to be swapped
|
||||
stbi_write_png(path.c_str(), this->XRes, this->YRes, sizeof(uint32_t), this->RenderData, sizeof(uint32_t) * this->XRes);
|
||||
// TODO: Red and Blue channels need to be swapped, no clue why, saving the framebuffer just doesnt work
|
||||
struct P {
|
||||
unsigned char r, g, b, a;
|
||||
};
|
||||
|
||||
P* imageData = (P*)malloc((XRes * YRes) * sizeof(P));
|
||||
|
||||
for (int x = 0; x < XRes; x++)
|
||||
for (int y = 0; y < YRes; y++) {
|
||||
uint32_t pixel = RenderData[y * this->XRes + x];
|
||||
uint8_t er = (pixel & 0x000000FF);
|
||||
uint8_t eg = (pixel & 0x0000FF00) >> 8;
|
||||
uint8_t eb = (pixel & 0x00FF0000) >> 16;
|
||||
uint8_t ea = (pixel & 0xFF000000) >> 24;
|
||||
|
||||
imageData[y * this->XRes + x] = P{ (unsigned char)eb, (unsigned char)eg, (unsigned char)er, (unsigned char)ea };
|
||||
}
|
||||
|
||||
stbi_write_png(path.c_str(), this->XRes, this->YRes, sizeof(P), imageData, sizeof(P) * this->XRes);
|
||||
free(imageData);
|
||||
}
|
||||
|
||||
void FrameBuffer::CopyData(uint32_t* dest) {
|
||||
|
||||
@@ -74,9 +74,9 @@ void ProgressiveRenderer::Input() {
|
||||
ImGui::Text(str2.str().c_str());
|
||||
|
||||
float upper = 0.0f; float lower = 0.0f;
|
||||
for (int i = 0; i < AllFrameTimes.size(); i++) {
|
||||
if (AllFrameTimes[i] > upper) upper = AllFrameTimes[i];
|
||||
if (AllFrameTimes[i] < lower) lower = AllFrameTimes[i];
|
||||
for (int i = 0; i < FrameTimes.size(); i++) {
|
||||
if (FrameTimes[i] > upper) upper = FrameTimes[i];
|
||||
if (FrameTimes[i] < lower) lower = FrameTimes[i];
|
||||
}
|
||||
ImGui::PlotLines("FrameTimes", FrameTimes.data(), FrameTimes.size(), 0, NULL, lower, upper, ImVec2(0, 40));
|
||||
|
||||
@@ -117,7 +117,7 @@ void ProgressiveRenderer::Render() {
|
||||
m_engine->Mode = m_mode;
|
||||
m_engine->PostProcess(m_threadPool->ThreadFrameBuffer->RenderTarget, m_threadPool->ThreadFrameBuffer->RenderPostProcess, m_scene->w, m_scene->h);
|
||||
|
||||
// Denoise in HDR space
|
||||
// Denoise while still in HDR space
|
||||
|
||||
m_threadPool->ThreadFrameBuffer->PostProcess((ToneMapMode)m_toneMapModeSelected);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ glm::vec3 getNormal(glm::vec3 p0, glm::vec3 p1, glm::vec3 p2) {
|
||||
return normal;
|
||||
}
|
||||
|
||||
std::vector<Triangle*> LoadTrianglesBasic(std::string path, std::string basePath) {
|
||||
std::vector<Triangle*> LoadTrianglesBasic(std::string path, std::string basePath, Material* baseMaterial) {
|
||||
tinyobj::attrib_t attrib;
|
||||
std::vector<tinyobj::shape_t> shapes;
|
||||
std::vector<tinyobj::material_t> materials;
|
||||
@@ -65,38 +65,41 @@ std::vector<Triangle*> LoadTrianglesBasic(std::string path, std::string basePath
|
||||
any[v] = attrib.normals[3 * idx.normal_index + 1];
|
||||
anz[v] = attrib.normals[3 * idx.normal_index + 2];
|
||||
}
|
||||
|
||||
Material* mat;
|
||||
if (baseMaterial == nullptr || !baseMaterial) {
|
||||
tinyobj::material_t material = materials[shapes[s].mesh.material_ids[f]];
|
||||
bool illum = false;
|
||||
if (material.illum > 0.0f) illum = true;
|
||||
mat = new Material({ material.diffuse[0], material.diffuse[1], material.diffuse[2] }, material.illum, 0.0f, 0.0f, 0.0f, false, illum);
|
||||
} else {
|
||||
mat = baseMaterial;
|
||||
}
|
||||
|
||||
// tinyobj::material_t material = materials[shapes[s].mesh.material_ids[f]];
|
||||
// glm::vec3 normal = getNormal(
|
||||
// {avx[0], avy[0], avz[0]},
|
||||
// {avx[1], avy[1], avz[1]},
|
||||
// {avx[2], avy[2], avz[2]}
|
||||
// );
|
||||
|
||||
// Material* mat = new Material({ material.diffuse[0], material.diffuse[1], material.diffuse[2] }, 0.6f, material.illum);
|
||||
Material* mat = new Material({ 0.717f, 0.792f, 0.474 }, 0.5f);
|
||||
//Material* mat = new Material({ 0.8, 0.8f, 0.8f });
|
||||
Triangle* tmp = new Triangle {
|
||||
{avx[0], avy[0], avz[0]},
|
||||
{avx[1], avy[1], avz[1]},
|
||||
{avx[2], avy[2], avz[2]},
|
||||
|
||||
// glm::vec3 normal = getNormal(
|
||||
// {avx[0], avy[0], avz[0]},
|
||||
// {avx[1], avy[1], avz[1]},
|
||||
// {avx[2], avy[2], avz[2]}
|
||||
// );
|
||||
// normal, normal, normal
|
||||
{anx[0], any[0], anz[0]},
|
||||
{anx[1], any[1], anz[1]},
|
||||
{anx[2], any[2], anz[2]},
|
||||
|
||||
mat,
|
||||
};
|
||||
|
||||
Triangle* tmp = new Triangle {
|
||||
{avx[0], avy[0], avz[0]},
|
||||
{avx[1], avy[1], avz[1]},
|
||||
{avx[2], avy[2], avz[2]},
|
||||
|
||||
// normal, normal, normal
|
||||
|
||||
{anx[0], any[0], anz[0]},
|
||||
{anx[1], any[1], anz[1]},
|
||||
{anx[2], any[2], anz[2]},
|
||||
|
||||
mat,
|
||||
};
|
||||
|
||||
triangles.push_back(tmp);
|
||||
}
|
||||
index_offset += fv;
|
||||
triangles.push_back(tmp);
|
||||
}
|
||||
|
||||
index_offset += fv;
|
||||
}
|
||||
}
|
||||
|
||||
return triangles;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
#include <string>
|
||||
|
||||
class Triangle;
|
||||
class Material;
|
||||
|
||||
std::vector<Triangle*> LoadTrianglesBasic(std::string path, std::string basePath = "");
|
||||
std::vector<Triangle*> LoadTrianglesBasic(std::string path, std::string basePath = "", Material* baseMaterial = nullptr);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user