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)
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(Editor PUBLIC /Zi /MP14 /W4)
target_sources(Engine INTERFACE
+28 -24
View File
@@ -7,48 +7,52 @@
},
"configurePresets": [
{
"name": "default",
"displayName": "Default (Release)",
"name": "release",
"displayName": "Release (no ASan)",
"description": "Release build without sanitizers",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
},
{
"name": "default-asan",
"displayName": "Default (Release + ASan)",
"name": "release-asan",
"displayName": "Release (ASan)",
"description": "Release build with Address Sanitizer",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address"
}
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
},
{
"name": "debug",
"displayName": "Debug (no ASan)",
"description": "Debug build without sanitizers",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_INSTALL_PREFIX": "C:/Program Files/Seele"
}
},
{
"name": "debug-asan",
"displayName": "Debug (ASan)",
"description": "Debug build with Address Sanitizer",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_LINKER_FLAGS": "-fsanitize=address",
"CMAKE_SHARED_LINKER_FLAGS": "-fsanitize=address"
}
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_CXX_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_C_FLAGS": "-fsanitize=address -fno-omit-frame-pointer",
"CMAKE_EXE_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 VertexData;
import Material;
import StaticMeshVertexData;
import MATERIAL_FILE_NAME;
// simplification: all BLAS only have 1 geometry
@@ -194,7 +195,7 @@ void closestHit(inout RayPayload hitValue, in BuiltInTriangleIntersectionAttribu
}
}
// 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);
float3 w = normalLight_WS;
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 f = 0.035;
const static float A = 0.0;
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);
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);
//-- sample sensor
+2 -2
View File
@@ -194,7 +194,7 @@ void BasePass::render() {
},
.rasterizationState =
{
.cullMode = twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT,
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
},
.colorBlend =
{
@@ -214,7 +214,7 @@ void BasePass::render() {
},
.rasterizationState =
{
.cullMode = twoSided ? Gfx::SE_CULL_MODE_NONE : Gfx::SE_CULL_MODE_BACK_BIT,
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
},
.colorBlend =
{
@@ -216,7 +216,6 @@ void RayTracingPass::publishOutputs() {
.name = "RayGenMiss",
.modules = {"RayGen", "AnyHit", "Miss"},
.entryPoints = {{"raygen", "RayGen"}, {"anyhit", "AnyHit"}, {"miss", "Miss"}},
.typeParameter = {{"IVertexData", "StaticMeshVertexData"}},
.defines = {{"RAY_TRACING", "1"}},
.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 <chainable_struct Base, VkStructureType struct_type> struct StructChain<Helper<Base, struct_type>> {
StructChain() {
std::memset(&b, 0, sizeof(Base));
b.sType = struct_type;
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>
struct StructChain<Helper<This, struct_type>, Right...> : StructChain<Right...> {
StructChain() {
std::memset(&t, 0, sizeof(This));
t.sType = struct_type;
t.pNext = &StructChain<Right...>::template get();
}
This t;
template <chainable_struct Query> Query& get() {
template <chainable_struct Query> constexpr Query& get() {
if constexpr (std::same_as<Query, This>)
return t;
else
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>)
return t;
else
return StructChain<Right...>::template get<Query>();
}
This& get() { return t; }
const This& get() const { return t; }
constexpr This& get() { return t; }
constexpr const This& get() const { return t; }
};
class Graphics : public Gfx::Graphics {
@@ -233,9 +233,7 @@ PGraphicsPipeline PipelineCache::createPipeline(Gfx::LegacyPipelineCreateInfo gf
PGraphicsPipeline PipelineCache::createPipeline(Gfx::MeshPipelineCreateInfo gfxInfo) {
uint32 hash = CRC::Calculate(&gfxInfo, sizeof(Gfx::MeshPipelineCreateInfo), CRC::CRC_32());
std::cout << hash << std::endl;
if (graphicsPipelines.contains(hash)) {
std::cout << "found exisiting" << std::endl;
return graphicsPipelines[hash];
}
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;
}
~OwningPtr() { Deleter()(pointer); }
operator RefPtr<T>() { return RefPtr<T>(pointer); }
operator RefPtr<T>() const { return RefPtr<T>(pointer); }
constexpr operator RefPtr<T>() { return RefPtr<T>(pointer); }
constexpr operator RefPtr<T>() const { return RefPtr<T>(pointer); }
constexpr T* operator->() { return pointer; }
constexpr const T* operator->() const { return pointer; }
constexpr T* operator*() { return pointer; }
@@ -1,7 +1,6 @@
#pragma once
#include "Game.h"
#include "filesystem"
#include "dlfcn.h"
namespace Seele {
class GameInterface {