Enhance build system and project documentation
Added LICENSE file with MIT License and copyright notice. Added preview.png binary file for project assets. Changed CMakeLists.txt to include asset copying command. Changed mesh loading in Mesh.c to support smooth normals. Changed ray origin biasing in PathTracing.c and shadow rays. Changed ray-triangle intersection logic in RayIntersection.c. Changed ray_intersect_bvh_count function in Debug.c to static. Changed rendering functions in Scene.c with TODO for optimization. Updated README.md with project description and build instructions. Updated window dimensions in main.c for testing purposes.
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
#include <svpng.inc>
|
||||
#include <omp.h>
|
||||
#include <stdint.h>
|
||||
#include <svpng.inc>
|
||||
|
||||
#include "Algorithm/Sobol.h"
|
||||
#include "Debug.h"
|
||||
#include "Geometry/GeometryUtilities.h"
|
||||
// #include "Geometry/GeometryUtilities.h"
|
||||
#include "Geometry/Mesh.h"
|
||||
#include "Lighting/SkyLight.h"
|
||||
#include "Material/SimpleLit.h"
|
||||
#include "Rendering/Scene.h"
|
||||
#include "Rendering/PostProcessing.h"
|
||||
#include "Rendering/Scene.h"
|
||||
#include "Window.h"
|
||||
|
||||
static void save_img(render_target_t* source, uint32_t width, uint32_t height, const char* filename)
|
||||
static void save_img(render_target_t* source, uint32_t width, uint32_t height, const char* filename)
|
||||
{
|
||||
FILE* file_stream;
|
||||
fopen_s(&file_stream, filename, "wb");
|
||||
@@ -33,8 +33,8 @@ static void save_img(render_target_t* source, uint32_t width, uint32_t height,
|
||||
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR pCmdLine, _In_ int nCmdShow)
|
||||
{
|
||||
rendering_config_t config = {
|
||||
.width = 1920 / 1,
|
||||
.height = 1080 / 1,
|
||||
.width = 1920 / 4,
|
||||
.height = 1080 / 4,
|
||||
.sample_count = 64,
|
||||
.max_depth = 4,
|
||||
.bucket_size = 64,
|
||||
@@ -67,52 +67,50 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
sun_light->intensity = 2.0f;
|
||||
sun_light->angular_diameter = 0.53f;
|
||||
|
||||
scene.lights.sky_light = sky_create_constant_sky(&(constant_sky_data_t)
|
||||
{
|
||||
scene.lights.sky_light = sky_create_constant_sky(&(constant_sky_data_t){
|
||||
.color = (vec3s){0.73f, 0.82f, 1.0f},
|
||||
.intensity = 1.0f,
|
||||
});
|
||||
|
||||
simple_lit_data_t gray_lit_data =
|
||||
{
|
||||
.albedo = (vec3s){0.73f, 0.73f, 0.73f},
|
||||
.roughness = 0.5f,
|
||||
.metallic = 0.0f,
|
||||
};
|
||||
simple_lit_data_t blue_lit_data =
|
||||
{
|
||||
.albedo = (vec3s){0.0f, 0.0f, 1.0f},
|
||||
.roughness = 0.5f,
|
||||
.metallic = 0.0f,
|
||||
};
|
||||
simple_lit_data_t red_lit_data =
|
||||
{
|
||||
.albedo = (vec3s){1.0f, 0.0f, 0.0f},
|
||||
.roughness = 0.5f,
|
||||
.metallic = 0.0f,
|
||||
};
|
||||
simple_lit_data_t green_lit_data =
|
||||
{
|
||||
.albedo = (vec3s){0.0f, 1.0f, 0.0f},
|
||||
.roughness = 0.5f,
|
||||
.metallic = 0.0f,
|
||||
};
|
||||
simple_lit_data_t floor_lit_data =
|
||||
{
|
||||
// simple_lit_data_t gray_lit_data =
|
||||
// {
|
||||
// .albedo = (vec3s){0.73f, 0.73f, 0.73f},
|
||||
// .roughness = 0.5f,
|
||||
// .metallic = 0.0f,
|
||||
// };
|
||||
// simple_lit_data_t blue_lit_data =
|
||||
// {
|
||||
// .albedo = (vec3s){0.0f, 0.0f, 1.0f},
|
||||
// .roughness = 0.5f,
|
||||
// .metallic = 0.0f,
|
||||
// };
|
||||
// simple_lit_data_t red_lit_data =
|
||||
// {
|
||||
// .albedo = (vec3s){1.0f, 0.0f, 0.0f},
|
||||
// .roughness = 0.5f,
|
||||
// .metallic = 0.0f,
|
||||
// };
|
||||
// simple_lit_data_t green_lit_data =
|
||||
// {
|
||||
// .albedo = (vec3s){0.0f, 1.0f, 0.0f},
|
||||
// .roughness = 0.5f,
|
||||
// .metallic = 0.0f,
|
||||
// };
|
||||
simple_lit_data_t floor_lit_data = {
|
||||
.albedo = (vec3s){1.0f, 1.0f, 1.0f},
|
||||
.roughness = 0.95f,
|
||||
.metallic = 0.0f,
|
||||
};
|
||||
material_entity_t gray_material = material_create_simple_lit(&gray_lit_data, &scene.materials);
|
||||
material_entity_t gray_light_material = material_create_simple_lit(&gray_lit_data, &scene.materials);
|
||||
material_entity_t blue_material = material_create_simple_lit(&blue_lit_data, &scene.materials);
|
||||
material_entity_t red_material = material_create_simple_lit(&red_lit_data, &scene.materials);
|
||||
material_entity_t green_material = material_create_simple_lit(&green_lit_data, &scene.materials);
|
||||
// material_entity_t gray_material = material_create_simple_lit(&gray_lit_data, &scene.materials);
|
||||
// material_entity_t gray_light_material = material_create_simple_lit(&gray_lit_data, &scene.materials);
|
||||
// material_entity_t blue_material = material_create_simple_lit(&blue_lit_data, &scene.materials);
|
||||
// material_entity_t red_material = material_create_simple_lit(&red_lit_data, &scene.materials);
|
||||
// material_entity_t green_material = material_create_simple_lit(&green_lit_data, &scene.materials);
|
||||
material_entity_t floor_material = material_create_simple_lit(&floor_lit_data, &scene.materials);
|
||||
|
||||
//scene.materials.buffer[gray_light_material.id].emission = (vec3s){10.0f, 10.0f, 10.0f};
|
||||
// scene.materials.buffer[gray_light_material.id].emission = (vec3s){10.0f, 10.0f, 10.0f};
|
||||
|
||||
mesh_load("F:/c/SimpleRayTracer/assets/sponza.obj", floor_material.id, &scene.triangles, &scene.materials);
|
||||
mesh_load("./assets/sponza.obj", floor_material.id, &scene.triangles, &scene.materials);
|
||||
|
||||
// quad_create(
|
||||
// (vec3s){0.0f, 3.95f, 0.0f},
|
||||
@@ -162,16 +160,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
// BVH Debug
|
||||
for (uint32_t i = 0; i < scene.bvh_tree.node_count; i++)
|
||||
{
|
||||
bvh_node_t* node = &scene.bvh_tree.nodes[i];
|
||||
aabb_t bounds = node->bounds;
|
||||
vec3s min = bounds.min;
|
||||
vec3s max = bounds.max;
|
||||
printf("Node %u: Min: (%f, %f, %f), Max: (%f, %f, %f)\n", i, min.x, min.y, min.z, max.x, max.y, max.z);
|
||||
}
|
||||
|
||||
MSG msg;
|
||||
uint16_t tile_index = 0;
|
||||
tile_t current_tile = {0};
|
||||
@@ -190,7 +178,8 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance,
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
if (scene_render_tile(&scene, &ctx, config, tile_index, DEBUG_BVH, &img, ¤t_tile))
|
||||
// TODO: This hurt performance a lot, need to be optimized
|
||||
if (scene_render_tile(&scene, &ctx, config, tile_index, DEBUG_NONE, &img, ¤t_tile))
|
||||
{
|
||||
for (uint32_t y = current_tile.y; y < current_tile.y + current_tile.height; y++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user