Fixing ray tracing lens

This commit is contained in:
Dynamitos
2025-06-30 21:15:14 +02:00
parent 8499d418e8
commit 59b73420d6
10 changed files with 44 additions and 39 deletions
+2 -1
View File
@@ -113,7 +113,8 @@ target_link_libraries(Benchmark PRIVATE Engine)
target_include_directories(Benchmark PRIVATE src/Benchmark) target_include_directories(Benchmark PRIVATE src/Benchmark)
if(MSVC) if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) target_compile_definitions(Engine PUBLIC _CRT_SECURE_NO_WARNINGS)
target_compile_definitions(Engine PUBLIC WIN32)
target_compile_options(Engine PUBLIC /Zi /MP14 /W4 /wd4505) target_compile_options(Engine PUBLIC /Zi /MP14 /W4 /wd4505)
target_compile_options(Editor PUBLIC /Zi /MP14 /W4) target_compile_options(Editor PUBLIC /Zi /MP14 /W4)
target_sources(Engine INTERFACE target_sources(Engine INTERFACE
+28 -24
View File
@@ -7,48 +7,52 @@
}, },
"configurePresets": [ "configurePresets": [
{ {
"name": "default", "name": "release",
"displayName": "Default (Release)", "displayName": "Release (no ASan)",
"description": "Release build without sanitizers", "description": "Release build without sanitizers",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo" "CMAKE_BUILD_TYPE": "RelWithDebInfo",
} "CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
}, },
{ {
"name": "default-asan", "name": "release-asan",
"displayName": "Default (Release + ASan)", "displayName": "Release (ASan)",
"description": "Release build with Address Sanitizer", "description": "Release build with Address Sanitizer",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer", "CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer", "CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address", "CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address" "CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address",
} "CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
}, },
{ {
"name": "debug", "name": "debug",
"displayName": "Debug (no ASan)", "displayName": "Debug (no ASan)",
"description": "Debug build without sanitizers", "description": "Debug build without sanitizers",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug" "CMAKE_BUILD_TYPE": "Debug",
} "CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
}, },
{ {
"name": "debug-asan", "name": "debug-asan",
"displayName": "Debug (ASan)", "displayName": "Debug (ASan)",
"description": "Debug build with Address Sanitizer", "description": "Debug build with Address Sanitizer",
"binaryDir": "${sourceDir}/build", "binaryDir": "${sourceDir}/build",
"cacheVariables": { "cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug", "CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer", "CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer", "CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address", "CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address" "CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address",
} "CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
} }
] ]
} }
+2 -1
View File
@@ -5,6 +5,7 @@ import Scene;
import RayTracingData; import RayTracingData;
import VertexData; import VertexData;
import Material; import Material;
import StaticMeshVertexData;
import MATERIAL_FILE_NAME; import MATERIAL_FILE_NAME;
// simplification: all BLAS only have 1 geometry // simplification: all BLAS only have 1 geometry
@@ -194,7 +195,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
} }
} }
// Indirect Illumination: cosine-weighted importance sampling // Indirect Illumination: cosine-weighted importance sampling
if(hitValue.depth < 12) { if(hitValue.depth < 1) {
float r1 = 2 * PI * rnd.x, r2 = rnd.y, r2s = sqrt(r2); float r1 = 2 * PI * rnd.x, r2 = rnd.y, r2s = sqrt(r2);
float3 w = normalLight_WS; float3 w = normalLight_WS;
float3 u = normalize(cross(abs(w.x)>0.1 ? float3(0,1,0) : float3(1,0,0), w)); float3 u = normalize(cross(abs(w.x)>0.1 ? float3(0,1,0) : float3(1,0,0), w));
+2 -1
View File
@@ -9,7 +9,6 @@ struct Ray
} }
const static float S_O = 6.9; const static float S_O = 6.9;
const static float f = 0.035;
const static float A = 0.0; const static float A = 0.0;
struct SampleParams struct SampleParams
@@ -69,6 +68,8 @@ void raygen()
float3 cx = -normalize(cross(cam.d, abs(cam.d.y) < 0.9 ? float3(0, 1, 0) : float3(0, 0, 1))), cy = cross(cam.d, cx); float3 cx = -normalize(cross(cam.d, abs(cam.d.y) < 0.9 ? float3(0, 1, 0) : float3(0, 0, 1))), cy = cross(cam.d, cx);
const float2 sdim = float2(0.036, 0.024); const float2 sdim = float2(0.036, 0.024);
float f = sdim.y / (2 * tan(70.0f * 0.5f));
float S_I = (S_O * f) / (S_O - f); float S_I = (S_O * f) / (S_O - f);
//-- sample sensor //-- sample sensor
+2 -2
View File
@@ -194,7 +194,7 @@ void BasePass::render() {
}, },
.rasterizationState = .rasterizationState =
{ {
.cullMode = twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT, .cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
}, },
.colorBlend = .colorBlend =
{ {
@@ -214,7 +214,7 @@ void BasePass::render() {
}, },
.rasterizationState = .rasterizationState =
{ {
.cullMode = twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT, .cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
}, },
.colorBlend = .colorBlend =
{ {
@@ -216,7 +216,6 @@ void RayTracingPass::publishOutputs() {
.name = "RayGenMiss", .name = "RayGenMiss",
.modules = {"RayGen", "AnyHit", "Miss"}, .modules = {"RayGen", "AnyHit", "Miss"},
.entryPoints = {{"raygen", "RayGen"}, {"anyhit", "AnyHit"}, {"miss", "Miss"}}, .entryPoints = {{"raygen", "RayGen"}, {"anyhit", "AnyHit"}, {"miss", "Miss"}},
.typeParameter = {{"IVertexData", "StaticMeshVertexData"}},
.defines = {{"RAY_TRACING", "1"}}, .defines = {{"RAY_TRACING", "1"}},
.rootSignature = pipelineLayout, .rootSignature = pipelineLayout,
}; };
+6 -4
View File
@@ -28,6 +28,7 @@ concept unique_chainable_structs = (chainable_struct<T> && ...) && is_unique<T..
template <typename... T> struct StructChain; template <typename... T> struct StructChain;
template <chainable_struct Base, VkStructureType struct_type> struct StructChain<Helper<Base, struct_type>> { template <chainable_struct Base, VkStructureType struct_type> struct StructChain<Helper<Base, struct_type>> {
StructChain() { StructChain() {
std::memset(&b, 0, sizeof(Base));
b.sType = struct_type; b.sType = struct_type;
b.pNext = nullptr; b.pNext = nullptr;
} }
@@ -50,24 +51,25 @@ template <chainable_struct Base, VkStructureType struct_type> struct StructChain
template <chainable_struct This, VkStructureType struct_type, typename... Right> template <chainable_struct This, VkStructureType struct_type, typename... Right>
struct StructChain<Helper<This, struct_type>, Right...> : StructChain<Right...> { struct StructChain<Helper<This, struct_type>, Right...> : StructChain<Right...> {
StructChain() { StructChain() {
std::memset(&t, 0, sizeof(This));
t.sType = struct_type; t.sType = struct_type;
t.pNext = &StructChain<Right...>::template get(); t.pNext = &StructChain<Right...>::template get();
} }
This t; This t;
template <chainable_struct Query> Query& get() { template <chainable_struct Query> constexpr Query& get() {
if constexpr (std::same_as<Query, This>) if constexpr (std::same_as<Query, This>)
return t; return t;
else else
return StructChain<Right...>::template get<Query>(); return StructChain<Right...>::template get<Query>();
} }
template <chainable_struct Query> const Query& get() const { template <chainable_struct Query> constexpr const Query& get() const {
if constexpr (std::same_as<Query, This>) if constexpr (std::same_as<Query, This>)
return t; return t;
else else
return StructChain<Right...>::template get<Query>(); return StructChain<Right...>::template get<Query>();
} }
This& get() { return t; } constexpr This& get() { return t; }
const This& get() const { return t; } constexpr const This& get() const { return t; }
}; };
class Graphics : public Gfx::Graphics { class Graphics : public Gfx::Graphics {
@@ -233,9 +233,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxInfo) { PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxInfo) {
uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::MeshPipelineCreateInfo), CRC::CRC_32()); uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::MeshPipelineCreateInfo), CRC::CRC_32());
std::cout << hash << std::endl;
if (graphicsPipelines.contains(hash)) { if (graphicsPipelines.contains(hash)) {
std::cout << "found exisiting" << std::endl;
return graphicsPipelines[hash]; return graphicsPipelines[hash];
} }
PPipelineLayout layout = Gfx::PPipelineLayout(gfxInfo.pipelineLayout).cast<PipelineLayout>(); PPipelineLayout layout = Gfx::PPipelineLayout(gfxInfo.pipelineLayout).cast<PipelineLayout>();
+2 -2
View File
@@ -102,8 +102,8 @@ template <typename T, typename Deleter = std::default_delete<T>> class OwningPtr
return *this; return *this;
} }
~OwningPtr() { Deleter()(pointer); } ~OwningPtr() { Deleter()(pointer); }
operator RefPtr<T>() { return RefPtr<T>(pointer); } constexpr operator RefPtr<T>() { return RefPtr<T>(pointer); }
operator RefPtr<T>() const { return RefPtr<T>(pointer); } constexpr operator RefPtr<T>() const { return RefPtr<T>(pointer); }
constexpr T* operator->() { return pointer; } constexpr T* operator->() { return pointer; }
constexpr const T* operator->() const { return pointer; } constexpr const T* operator->() const { return pointer; }
constexpr T* operator*() { return pointer; } constexpr T* operator*() { return pointer; }
@@ -1,7 +1,6 @@
#pragma once #pragma once
#include "Game.h" #include "Game.h"
#include "filesystem" #include "filesystem"
#include "dlfcn.h"
namespace Seele { namespace Seele {
class GameInterface { class GameInterface {