Commit for 2022.07.09 22-04-13.7z

This commit is contained in:
mrq 2022-07-09 22:04:00 -05:00
parent 26a933307b
commit cbd76acbd5
19 changed files with 269 additions and 223 deletions

View File

@ -343,6 +343,8 @@ clean:
@-rm -f $(OBJS_EXT_DLL) @-rm -f $(OBJS_EXT_DLL)
@-rm -f $(OBJS) @-rm -f $(OBJS)
@-rm $(shell find $(ENGINE_SRC_DIR) -name "*.$(PREFIX).o") $(shell find $(EXT_SRC_DIR) -name "*.$(PREFIX).o") $(shell find $(DEP_SRC_DIR) -name "*.$(PREFIX).o")
ifneq (,$(findstring dreamcast,$(ARCH))) ifneq (,$(findstring dreamcast,$(ARCH)))
@-rm ./bin/dreamcast/build/* @-rm ./bin/dreamcast/build/*
@-rm ./bin/dreamcast/romdisk.* @-rm ./bin/dreamcast/romdisk.*
@ -381,11 +383,12 @@ clean-shaders:
-rm $(TARGET_SHADERS) -rm $(TARGET_SHADERS)
backup: backup:
make ARCH=dreamcast clean #make ARCH=dreamcast clean
make CC=gcc RENDERER=opengl clean #make CC=gcc RENDERER=opengl clean
make CC=gcc RENDERER=vulkan clean #make CC=gcc RENDERER=vulkan clean
make CC=clang RENDERER=opengl clean #make CC=clang RENDERER=opengl clean
make CC=clang RENDERER=vulkan clean #make CC=clang RENDERER=vulkan clean
make CC=zig RENDERER=opengl clean #make CC=zig RENDERER=opengl clean
make CC=zig RENDERER=vulkan clean #make CC=zig RENDERER=vulkan clean
@-rm $(shell find $(ENGINE_SRC_DIR) -name "*.o") $(shell find $(EXT_SRC_DIR) -name "*.o") $(shell find $(DEP_SRC_DIR) -name "*.o")
$(7Z) a -r ../misc/backups/$(shell date +"%Y.%m.%d\ %H-%M-%S").7z . $(7Z) a -r ../misc/backups/$(shell date +"%Y.%m.%d\ %H-%M-%S").7z .

View File

@ -1,11 +1,11 @@
{ {
"engine": { "engine": {
"scenes": { "scenes": {
"start": "McDonalds", "start": "SH2_McDonalds",
"meshes": { "interleaved": false }, "meshes": { "interleaved": false },
"matrix": { "reverseInfinite": true }, "matrix": { "reverseInfinite": true },
"lights": { "enabled": true, "lights": { "enabled": true,
"useLightmaps": true, "useLightmaps": false,
"max": 32 "max": 32
}, },
"shadows": { "shadows": {

View File

@ -15,6 +15,7 @@
"print": { "print": {
"tree": false, "tree": false,
"stats": false, "stats": false,
"lights": false,
"meshes": false, "meshes": false,
"materials": false, "materials": false,
"textures": false "textures": false
@ -33,7 +34,6 @@
"combined": false, "combined": false,
"encode buffers": true, "encode buffers": true,
"unwrap": true, // "tagged", "unwrap": true, // "tagged",
// "unwrap": "tagged",
"quit": true "quit": true
}, },
"baking": { "baking": {

View File

@ -14,10 +14,16 @@
"model": { "model": {
"baking": { "baking": {
"enabled": false, "enabled": false,
"resolution": 1024 "resolution": 2048,
"settings": {
"useInputMeshUvs": false
}
},
"renderer": {
"front face": "cw",
"cull mode": "back",
"filter": "linear"
}, },
"filter": "LINEAR",
"lightmap": false,
"tags": { "tags": {
"/^Mesh_/": { "/^Mesh_/": {
"physics": { "type": "mesh", "static": true }, "physics": { "type": "mesh", "static": true },

View File

@ -1,7 +1,8 @@
{ {
"import": "/scene.json", "import": "/scene.json",
"assets": [ "assets": [
"./loading.json" // "./loading.json"
"./cornell.json"
], ],
"system": { "system": {
"hot reload": { "hot reload": {
@ -28,6 +29,13 @@
"sigma": 0.8, "sigma": 0.8,
"samples": 5 "samples": 5
}, },
"rt": {
"defaultRayBounds": [ 0.001, 1024.0 ],
"alphaTestOffset": 0.001,
"samples": 1,
"paths": 4,
"frameAccumulationMinimum": 0
},
"light": { "light": {
"exposure": 1.0, "exposure": 1.0,
"gamma": 1.0, "gamma": 1.0,

View File

@ -1,6 +1,6 @@
{ {
"import": "/light.json", "import": "/light.json",
"ignore": true, "ignore": false,
"assets": [ "assets": [
], ],
"transform": { "transform": {

View File

@ -4,7 +4,16 @@
// { "filename": "./static.json", "delay": 8 }, // { "filename": "./static.json", "delay": 8 },
// { "filename": "./models/sh_mcd.glb" } // { "filename": "./models/sh_mcd.glb" }
{ "filename": "./models/sh_mcd/graph.json" } // { "filename": "./models/sh_mcd/graph.json" }
// { "filename": "./models/mcdonalds.glb" }
{ "filename": "./models/mcdonalds/graph.json" }
// { "filename": "./models/mini_mcd.glb" }
// { "filename": "./models/mini_mcd/graph.json" }
// { "filename": "/cornell/cornell.glb" }
// { "filename": "/cornell/cornell/graph.json" }
], ],
"metadata": { "metadata": {
"model": { "model": {
@ -18,7 +27,8 @@
"renderer": { "renderer": {
"front face": "cw", "front face": "cw",
"cull mode": "back", "cull mode": "back",
"filter": "linear" "filter": "linear",
"alpha mode": "blend"
}, },
"tags": { "tags": {
"/^worldspawn/": { "/^worldspawn/": {
@ -107,7 +117,8 @@
"prop_physics_override_5822": { "action": "load", "payload": { "import": "./prop.json" } }, "prop_physics_override_5822": { "action": "load", "payload": { "import": "./prop.json" } },
"prop_physics_override_5824": { "action": "load", "payload": { "import": "./prop.json" } }, "prop_physics_override_5824": { "action": "load", "payload": { "import": "./prop.json" } },
"tools/toolsnodraw": { "material": { "base": [0, 0, 0, 0] } } "tools/toolsnodraw": { "material": { "base": [0, 0, 0, 0] } },
"materials/models/props_wasteland/prison_lamp001a": { "material": { "emissive": [0, 0, 0, 0] } }
} }
} }
} }

View File

@ -37,8 +37,8 @@
// "ambient": [ 0, 0, 0 ], // "ambient": [ 0, 0, 0 ],
// "ambient": [ 0.025, 0.025, 0.025 ], // "ambient": [ 0.025, 0.025, 0.025 ],
// "ambient": [ 0.075, 0.075, 0.075 ], // "ambient": [ 0.075, 0.075, 0.075 ],
// "ambient": [ 0.1, 0.1, 0.1 ], "ambient": [ 0.1, 0.1, 0.1 ],
"ambient": [ 0.4, 0.4, 0.4 ], // "ambient": [ 0.4, 0.4, 0.4 ],
// "ambient": [ 0.8, 0.8, 0.8 ], // "ambient": [ 0.8, 0.8, 0.8 ],
"fog-": { "fog-": {

View File

@ -28,7 +28,9 @@
"info_player_spawn": { "action": "attach", "filename": "./player.json" }, "info_player_spawn": { "action": "attach", "filename": "./player.json" },
"Material.071_574B138E_c.bmp": { "material": { "modeAlpha": "BLEND" } }, "Material.071_574B138E_c.bmp": { "material": { "modeAlpha": "BLEND" } },
"Material.070_41A41EE3_c.bmp": { "material": { "modeAlpha": "BLEND" } } "Material.070_41A41EE3_c.bmp": { "material": { "modeAlpha": "BLEND" } },
"light_sun": { "light": { "power": 25000 } }
} }
} }
} }

View File

@ -15,14 +15,14 @@ float gaSchlickGGX(float cosLi, float cosLo, float roughness) {
vec3 fresnelSchlick(vec3 F0, float cosTheta) { return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); } vec3 fresnelSchlick(vec3 F0, float cosTheta) { return F0 + (1.0 - F0) * pow(1.0 - cosTheta, 5.0); }
#if (!BAKING && !COMPUTE) || RAYTRACE #if (!BAKING && !COMPUTE) || RAYTRACE
void pbr() { void pbr() {
if ( surface.material.lightmapped && validTextureIndex( surface.instance.lightmapID ) ) return; if ( surface.material.lightmapped ) return;
const float Rs = 4.0; // specular lighting looks gross without this const float Rs = 4.0; // specular lighting looks gross without this
const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic); const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic);
const vec3 Lo = normalize( -surface.position.eye ); const vec3 Lo = normalize( -surface.position.eye );
const float cosLo = max(0.0, dot(surface.normal.eye, Lo)); const float cosLo = max(0.0, dot(surface.normal.eye, Lo));
for ( uint i = 0; i < ubo.lights; ++i ) { for ( uint i = 0; i < ubo.settings.lengths.lights; ++i ) {
const Light light = lights[i]; const Light light = lights[i];
if ( light.power <= LIGHT_POWER_CUTOFF ) continue; if ( light.power <= LIGHT_POWER_CUTOFF ) continue;
const vec3 Liu = vec3(ubo.eyes[surface.pass].view * vec4(light.position, 1)) - surface.position.eye; const vec3 Liu = vec3(ubo.eyes[surface.pass].view * vec4(light.position, 1)) - surface.position.eye;

View File

@ -18,7 +18,7 @@ const vec2 poissonDisk[16] = vec2[](
); );
#ifndef SHADOW_SAMPLES #ifndef SHADOW_SAMPLES
#define SHADOW_SAMPLES ubo.shadowSamples #define SHADOW_SAMPLES ubo.settings.lighting.shadowSamples
#endif #endif
#if VXGI #if VXGI
float voxelShadowFactor( const Light, float def ); float voxelShadowFactor( const Light, float def );

View File

@ -175,6 +175,8 @@ struct SurfaceMaterial {
struct Surface { struct Surface {
uint pass; uint pass;
uint subID;
vec3 uv; vec3 uv;
vec3 st; vec3 st;
Space position; Space position;
@ -200,6 +202,27 @@ struct MSAA {
} msaa; } msaa;
#endif #endif
// UBO settings // UBO settings
struct SettingsLengths {
uint lights;
uint materials;
uint textures;
uint drawCommands;
};
struct SettingsMode {
vec4 parameters;
uint type;
uint scalar;
uint msaa;
uint frameNumber;
};
struct SettingsLighting {
vec3 ambient;
float padding1;
uint indexSkybox;
uint shadowSamples;
uint useLightmaps;
};
struct SettingsFog { struct SettingsFog {
vec3 color; vec3 color;
float stepScale; float stepScale;
@ -216,25 +239,12 @@ struct SettingsFog {
float padding2; float padding2;
float padding3; float padding3;
}; };
struct SettingsBloom {
struct SettingsMode { float exposure;
uint type; float brightnessThreshold;
uint scalar; float gamma;
vec2 padding; uint padding;
vec4 parameters;
}; };
struct SettingsRayTrace {
vec2 defaultRayBounds;
float alphaTestOffset;
float padding1;
uint samples;
uint paths;
uint frameAccumulationMinimum;
uint padding2;
};
// VXGI stuff
struct SettingsVxgi { struct SettingsVxgi {
mat4 matrix; mat4 matrix;
@ -248,10 +258,23 @@ struct SettingsVxgi {
uint padding2; uint padding2;
uint padding3; uint padding3;
}; };
struct SettingsRayTrace {
vec2 defaultRayBounds;
float alphaTestOffset;
float padding1;
uint samples;
uint paths;
uint frameAccumulationMinimum;
uint padding2;
};
struct Settings { struct Settings {
SettingsLengths lengths;
SettingsMode mode; SettingsMode mode;
SettingsLighting lighting;
SettingsFog fog; SettingsFog fog;
SettingsBloom bloom;
SettingsVxgi vxgi; SettingsVxgi vxgi;
SettingsRayTrace rt; SettingsRayTrace rt;
}; };

View File

@ -49,24 +49,6 @@ layout (binding = 5) uniform UBO {
EyeMatrices eyes[2]; EyeMatrices eyes[2];
Settings settings; Settings settings;
uint lights;
uint materials;
uint textures;
uint drawCommands;
vec3 ambient;
float gamma;
float exposure;
float brightnessThreshold;
uint msaa;
uint shadowSamples;
int indexSkybox;
uint useLightmaps;
uint frameNumber;
uint padding3;
} ubo; } ubo;
/* /*
*/ */
@ -129,16 +111,16 @@ layout(buffer_reference, scalar) buffer VID { uint v[]; };
void postProcess() { void postProcess() {
float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722)); float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722));
outFragBright = brightness > ubo.brightnessThreshold ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1); outFragBright = brightness > ubo.settings.bloom.brightnessThreshold ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1);
#if FOG #if FOG
fog( surface.ray, surface.fragment.rgb, surface.fragment.a ); fog( surface.ray, surface.fragment.rgb, surface.fragment.a );
#endif #endif
#if TONE_MAP #if TONE_MAP
surface.fragment.rgb = vec3(1.0) - exp(-surface.fragment.rgb * ubo.exposure); surface.fragment.rgb = vec3(1.0) - exp(-surface.fragment.rgb * ubo.settings.bloom.exposure);
#endif #endif
#if GAMMA_CORRECT #if GAMMA_CORRECT
surface.fragment.rgb = pow(surface.fragment.rgb, vec3(1.0 / ubo.gamma)); surface.fragment.rgb = pow(surface.fragment.rgb, vec3(1.0 / ubo.settings.bloom.gamma));
#endif #endif
#if WHITENOISE #if WHITENOISE
if ( enabled(ubo.settings.mode.type, 1) ) whitenoise(surface.fragment.rgb, ubo.settings.mode.parameters); if ( enabled(ubo.settings.mode.type, 1) ) whitenoise(surface.fragment.rgb, ubo.settings.mode.parameters);
@ -155,7 +137,7 @@ void populateSurface() {
#if !MULTISAMPLING #if !MULTISAMPLING
const float depth = subpassLoad(samplerDepth).r; const float depth = subpassLoad(samplerDepth).r;
#else #else
const float depth = subpassLoad(samplerDepth, msaa.currentID).r; // resolve(samplerDepth, ubo.msaa).r; const float depth = subpassLoad(samplerDepth, msaa.currentID).r; // resolve(samplerDepth, ubo.settings.mode.msaa).r;
#endif #endif
vec4 positionEye = ubo.eyes[surface.pass].iProjection * vec4(inUv * 2.0 - 1.0, depth, 1.0); vec4 positionEye = ubo.eyes[surface.pass].iProjection * vec4(inUv * 2.0 - 1.0, depth, 1.0);
@ -200,16 +182,16 @@ void populateSurface() {
surface.normal.world = decodeNormals( subpassLoad(samplerNormal).xy ); surface.normal.world = decodeNormals( subpassLoad(samplerNormal).xy );
const uvec2 ID = subpassLoad(samplerId).xy; const uvec2 ID = subpassLoad(samplerId).xy;
#else #else
surface.normal.world = decodeNormals( subpassLoad(samplerNormal, msaa.currentID).xy ); // decodeNormals( resolve(samplerNormal, ubo.msaa).xy ); surface.normal.world = decodeNormals( subpassLoad(samplerNormal, msaa.currentID).xy ); // decodeNormals( resolve(samplerNormal, ubo.settings.mode.msaa).xy );
const uvec2 ID = msaa.IDs[msaa.currentID]; // subpassLoad(samplerId, msaa.currentID).xy; //resolve(samplerId, ubo.msaa).xy; const uvec2 ID = msaa.IDs[msaa.currentID]; // subpassLoad(samplerId, msaa.currentID).xy; //resolve(samplerId, ubo.settings.mode.msaa).xy;
#endif #endif
surface.normal.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.normal.world, 0.0) ); surface.normal.eye = vec3( ubo.eyes[surface.pass].view * vec4(surface.normal.world, 0.0) );
const uint drawID = ID.x - 1; const uint drawID = ID.x - 1;
const uint instanceID = ID.y - 1; const uint instanceID = ID.y - 1;
if ( ID.x == 0 || ID.y == 0 ) { if ( ID.x == 0 || ID.y == 0 ) {
if ( 0 <= ubo.indexSkybox && ubo.indexSkybox < CUBEMAPS ) { if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
surface.fragment.rgb = texture( samplerCubemaps[ubo.indexSkybox], surface.ray.direction ).rgb; surface.fragment.rgb = texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], surface.ray.direction ).rgb;
} }
surface.fragment.a = 0.0; surface.fragment.a = 0.0;
postProcess(); postProcess();
@ -232,8 +214,8 @@ void populateSurface() {
const vec4 uv = subpassLoad(samplerUv); const vec4 uv = subpassLoad(samplerUv);
const vec2 mips = subpassLoad(samplerMips).xy; const vec2 mips = subpassLoad(samplerMips).xy;
#else #else
const vec4 uv = subpassLoad(samplerUv, msaa.currentID); // resolve(samplerUv, ubo.msaa); const vec4 uv = subpassLoad(samplerUv, msaa.currentID); // resolve(samplerUv, ubo.settings.mode.msaa);
const vec2 mips = subpassLoad(samplerMips, msaa.currentID).xy; // resolve(samplerUv, ubo.msaa); const vec2 mips = subpassLoad(samplerMips, msaa.currentID).xy; // resolve(samplerUv, ubo.settings.mode.msaa);
#endif #endif
surface.uv.xy = uv.xy; surface.uv.xy = uv.xy;
surface.uv.z = mips.x; surface.uv.z = mips.x;
@ -255,7 +237,7 @@ void populateSurface() {
} }
// Lightmap // Lightmap
if ( bool(ubo.useLightmaps) && validTextureIndex( surface.instance.lightmapID ) ) { if ( bool(ubo.settings.lighting.useLightmaps) && validTextureIndex( surface.instance.lightmapID ) ) {
vec4 light = sampleTexture( surface.instance.lightmapID, surface.st ); vec4 light = sampleTexture( surface.instance.lightmapID, surface.st );
surface.material.lightmapped = light.a > 0.001; surface.material.lightmapped = light.a > 0.001;
if ( surface.material.lightmapped ) surface.light += surface.material.albedo * light; if ( surface.material.lightmapped ) surface.light += surface.material.albedo * light;
@ -280,13 +262,13 @@ void populateSurface() {
#if !MULTISAMPLING #if !MULTISAMPLING
surface.material.albedo *= subpassLoad(samplerAlbedo); surface.material.albedo *= subpassLoad(samplerAlbedo);
#else #else
surface.material.albedo *= subpassLoad(samplerAlbedo, msaa.currentID); // resolve(samplerAlbedo, ubo.msaa); surface.material.albedo *= subpassLoad(samplerAlbedo, msaa.currentID); // resolve(samplerAlbedo, ubo.settings.mode.msaa);
#endif #endif
#endif #endif
} }
void directLighting() { void directLighting() {
surface.light.rgb += surface.material.albedo.rgb * ubo.ambient.rgb * surface.material.occlusion; // add ambient lighting surface.light.rgb += surface.material.albedo.rgb * ubo.settings.lighting.ambient.rgb * surface.material.occlusion; // add ambient lighting
surface.light.rgb += surface.material.indirect.rgb; // add indirect lighting surface.light.rgb += surface.material.indirect.rgb; // add indirect lighting
#if PBR #if PBR
pbr(); pbr();
@ -300,7 +282,7 @@ void directLighting() {
#if MULTISAMPLING #if MULTISAMPLING
void resolveSurfaceFragment() { void resolveSurfaceFragment() {
for ( int i = 0; i < ubo.msaa; ++i ) { for ( int i = 0; i < ubo.settings.mode.msaa; ++i ) {
msaa.currentID = i; msaa.currentID = i;
msaa.IDs[i] = subpassLoad(samplerId, msaa.currentID).xy; msaa.IDs[i] = subpassLoad(samplerId, msaa.currentID).xy;
@ -326,6 +308,6 @@ void resolveSurfaceFragment() {
msaa.fragments[msaa.currentID] = surface.fragment; msaa.fragments[msaa.currentID] = surface.fragment;
} }
surface.fragment = msaa.fragment / ubo.msaa; surface.fragment = msaa.fragment / ubo.settings.mode.msaa;
} }
#endif #endif

View File

@ -19,24 +19,6 @@ layout (binding = 0) uniform UBO {
EyeMatrices matrices[2]; EyeMatrices matrices[2];
Settings settings; Settings settings;
uint lights;
uint materials;
uint textures;
uint drawCommands;
vec3 ambient;
float gamma;
float exposure;
float brightnessThreshold;
uint msaa;
uint shadowSamples;
uint indexSkybox;
uint padding1;
uint padding2;
uint padding3;
} ubo; } ubo;
layout (std140, binding = 1) readonly buffer DrawCommands { layout (std140, binding = 1) readonly buffer DrawCommands {
DrawCommand drawCommands[]; DrawCommand drawCommands[];
@ -133,7 +115,7 @@ void main() {
surface.material.roughness = material.factorRoughness; surface.material.roughness = material.factorRoughness;
surface.material.occlusion = material.factorOcclusion; surface.material.occlusion = material.factorOcclusion;
const vec3 ambient = ubo.ambient.rgb * surface.material.occlusion; const vec3 ambient = ubo.settings.lighting.ambient.rgb * surface.material.occlusion;
if ( validTextureIndex( surface.instance.lightmapID ) ) { if ( validTextureIndex( surface.instance.lightmapID ) ) {
surface.fragment.rgb += surface.material.albedo.rgb; surface.fragment.rgb += surface.material.albedo.rgb;
} else { } else {
@ -143,7 +125,7 @@ void main() {
const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic); const vec3 F0 = mix(vec3(0.04), surface.material.albedo.rgb, surface.material.metallic);
const vec3 Lo = normalize( surface.position.world ); const vec3 Lo = normalize( surface.position.world );
const float cosLo = max(0.0, dot(surface.normal.world, Lo)); const float cosLo = max(0.0, dot(surface.normal.world, Lo));
for ( uint i = 0; i < ubo.lights; ++i ) { for ( uint i = 0; i < ubo.settings.lengths.lights; ++i ) {
const Light light = lights[i]; const Light light = lights[i];
if ( light.power <= LIGHT_POWER_CUTOFF ) continue; if ( light.power <= LIGHT_POWER_CUTOFF ) continue;
if ( light.type >= 0 && validTextureIndex( surface.instance.lightmapID ) ) continue; if ( light.type >= 0 && validTextureIndex( surface.instance.lightmapID ) ) continue;

View File

@ -13,7 +13,10 @@ layout (constant_id = 3) const uint CASCADES = 1;
#define PBR 1 #define PBR 1
#define VXGI 0 #define VXGI 0
#define RAYTRACE 1 #define RAYTRACE 1
#define FOG 0 #define FOG 1
#define FOG_RAY_MARCH 0
#define FOG_BASIC 1
#define BLOOM 0
#define WHITENOISE 0 #define WHITENOISE 0
#define MAX_TEXTURES TEXTURES #define MAX_TEXTURES TEXTURES
#define TONE_MAP 1 #define TONE_MAP 1
@ -35,24 +38,6 @@ layout (binding = 2) uniform UBO {
EyeMatrices eyes[2]; EyeMatrices eyes[2];
Settings settings; Settings settings;
uint lights;
uint materials;
uint textures;
uint drawCommands;
vec3 ambient;
float gamma;
float exposure;
float brightnessThreshold;
uint msaa;
uint shadowSamples;
int indexSkybox;
uint useLightmaps;
uint frameNumber;
uint padding3;
} ubo; } ubo;
layout (std140, binding = 3) readonly buffer Instances { layout (std140, binding = 3) readonly buffer Instances {
@ -182,7 +167,7 @@ void setupSurface( RayTracePayload payload ) {
} }
// Lightmap // Lightmap
if ( bool(ubo.useLightmaps) && validTextureIndex( surface.instance.lightmapID ) ) { if ( (surface.subID++ > 0 || bool(ubo.settings.lighting.useLightmaps)) && validTextureIndex( surface.instance.lightmapID ) ) {
vec4 light = sampleTexture( surface.instance.lightmapID, surface.st ); vec4 light = sampleTexture( surface.instance.lightmapID, surface.st );
surface.material.lightmapped = light.a > 0.001; surface.material.lightmapped = light.a > 0.001;
if ( surface.material.lightmapped ) surface.light += surface.material.albedo * light; if ( surface.material.lightmapped ) surface.light += surface.material.albedo * light;
@ -217,7 +202,7 @@ void directLighting() {
indirectLighting(); indirectLighting();
#endif #endif
surface.light.rgb += surface.material.albedo.rgb * ubo.ambient.rgb * surface.material.occlusion; // add ambient lighting surface.light.rgb += surface.material.albedo.rgb * ubo.settings.lighting.ambient.rgb * surface.material.occlusion; // add ambient lighting
surface.light.rgb += surface.material.indirect.rgb; // add indirect lighting surface.light.rgb += surface.material.indirect.rgb; // add indirect lighting
#if PBR #if PBR
pbr(); pbr();
@ -241,8 +226,10 @@ vec4 traceStep( Ray ray ) {
setupSurface( payload ); setupSurface( payload );
directLighting(); directLighting();
outFrag = surface.fragment; outFrag = surface.fragment;
} else if ( 0 <= ubo.indexSkybox && ubo.indexSkybox < CUBEMAPS ) { } else if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
outFrag = texture( samplerCubemaps[ubo.indexSkybox], ray.direction ); outFrag = texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], ray.direction );
} else {
outFrag = vec4(ubo.settings.lighting.ambient.rgb, 0);
} }
} }
@ -261,8 +248,8 @@ vec4 traceStep( Ray ray ) {
setupSurface( payload ); setupSurface( payload );
directLighting(); directLighting();
transparencyColor *= surface.fragment; transparencyColor *= surface.fragment;
} else if ( 0 <= ubo.indexSkybox && ubo.indexSkybox < CUBEMAPS ) { } else if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
transparencyColor *= texture( samplerCubemaps[ubo.indexSkybox], ray.direction ); transparencyColor *= texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], ray.direction );
} }
outFrag += transparencyColor; outFrag += transparencyColor;
@ -291,8 +278,8 @@ vec4 traceStep( Ray ray ) {
setupSurface( payload ); setupSurface( payload );
directLighting(); directLighting();
reflectionColor *= surface.fragment; reflectionColor *= surface.fragment;
} else if ( 0 <= ubo.indexSkybox && ubo.indexSkybox < CUBEMAPS ) { } else if ( 0 <= ubo.settings.lighting.indexSkybox && ubo.settings.lighting.indexSkybox < CUBEMAPS ) {
reflectionColor *= texture( samplerCubemaps[ubo.indexSkybox], reflection.direction ); reflectionColor *= texture( samplerCubemaps[ubo.settings.lighting.indexSkybox], reflection.direction );
} }
outFrag += reflectionColor; outFrag += reflectionColor;
@ -306,27 +293,29 @@ vec4 traceStep( Ray ray ) {
} }
void main() { void main() {
// if ( ubo.frameNumber > 16 ) return; // if ( ubo.settings.mode.frameNumber > 16 ) return;
// prngSeed = tea(gl_LaunchIDEXT.y * gl_LaunchSizeEXT.x + gl_LaunchIDEXT.x, ubo.frameNumber); // prngSeed = tea(gl_LaunchIDEXT.y * gl_LaunchSizeEXT.x + gl_LaunchIDEXT.x, ubo.settings.mode.frameNumber);
prngSeed = tea(gl_LaunchIDEXT.y * gl_LaunchSizeEXT.x + gl_LaunchIDEXT.x, int(clockARB())); prngSeed = tea(gl_LaunchIDEXT.y * gl_LaunchSizeEXT.x + gl_LaunchIDEXT.x, int(clockARB()));
surface.pass = PushConstant.pass; surface.pass = PushConstant.pass;
surface.subID = 0;
vec4 outFrag = vec4(0); vec4 outFrag = vec4(0);
const uint SAMPLES = ubo.settings.rt.samples; const uint SAMPLES = min(ubo.settings.rt.samples, 4);
const uint NUM_PATHS = ubo.settings.rt.paths; const uint NUM_PATHS = min(ubo.settings.rt.paths, 8);
#if 1 #if 1
const uint FRAME_ACCUMULATION_VALUE = ubo.settings.rt.frameAccumulationMinimum > 0 ? min(ubo.settings.rt.frameAccumulationMinimum, ubo.frameNumber + 1) : ubo.frameNumber + 1; const uint FRAME_ACCUMULATION_VALUE = ubo.settings.rt.frameAccumulationMinimum > 0 ? min(ubo.settings.rt.frameAccumulationMinimum, ubo.settings.mode.frameNumber + 1) : ubo.settings.mode.frameNumber + 1;
#else #else
const uint FRAME_ACCUMULATION_VALUE = min(32, ubo.frameNumber + 1); const uint FRAME_ACCUMULATION_VALUE = min(32, ubo.settings.mode.frameNumber + 1);
#endif #endif
const float BLEND_FACTOR = 1.0f / float(FRAME_ACCUMULATION_VALUE); const float BLEND_FACTOR = 1.0f / float(FRAME_ACCUMULATION_VALUE);
uint FRAME_NUMBER = ubo.frameNumber; uint FRAME_NUMBER = ubo.settings.mode.frameNumber;
#if 0
for ( uint samp = 0; samp < SAMPLES; ++samp, ++FRAME_NUMBER ) { for ( uint samp = 0; samp < SAMPLES; ++samp, ++FRAME_NUMBER ) {
{ {
const vec2 center = ( FRAME_NUMBER > 0 ) ? vec2( rnd(), rnd() ) : vec2(0.5); const vec2 center = ( FRAME_NUMBER > 0 ) ? vec2( rnd(), rnd() ) : vec2(0.5);
const vec2 inUv = (vec2(gl_LaunchIDEXT.xy) + center) / vec2(gl_LaunchSizeEXT.xy); const vec2 inUv = (vec2(gl_LaunchIDEXT.xy) + center) / vec2(gl_LaunchSizeEXT.xy);
#if 0 #if 1
vec4 target = ubo.eyes[surface.pass].iProjection * vec4(inUv.x * 2.0f - 1.0f, inUv.y * 2.0f - 1.0f, 1, 1); vec4 target = ubo.eyes[surface.pass].iProjection * vec4(inUv.x * 2.0f - 1.0f, inUv.y * 2.0f - 1.0f, 1, 1);
vec4 direction = ubo.eyes[surface.pass].iView * vec4(normalize(target.xyz), 0); vec4 direction = ubo.eyes[surface.pass].iView * vec4(normalize(target.xyz), 0);
@ -362,11 +351,77 @@ void main() {
outFrag += curValue; outFrag += curValue;
} }
} }
{ {
outFrag /= SAMPLES; outFrag /= SAMPLES;
outFrag.a = 1; }
#elif 0
{
const vec2 center = ( FRAME_NUMBER > 0 ) ? vec2( rnd(), rnd() ) : vec2(0.5);
const vec2 inUv = (vec2(gl_LaunchIDEXT.xy) + center) / vec2(gl_LaunchSizeEXT.xy);
#if 0
vec4 target = ubo.eyes[surface.pass].iProjection * vec4(inUv.x * 2.0f - 1.0f, inUv.y * 2.0f - 1.0f, 1, 1);
vec4 direction = ubo.eyes[surface.pass].iView * vec4(normalize(target.xyz), 0);
surface.ray.direction = vec3(direction);
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
#else
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
const vec4 far4 = iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
const vec3 near3 = near4.xyz / near4.w;
const vec3 far3 = far4.xyz / far4.w;
surface.ray.direction = normalize( far3 - near3 );
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
#endif
}
{
vec4 curValue = vec4(0);
vec4 curWeight = vec4(1);
for ( uint path = 0; path < NUM_PATHS; ++path ) {
vec4 stepValue = traceStep( surface.ray );
curValue += stepValue * curWeight;
if ( !payload.hit ) break;
surface.ray.origin = surface.position.world;
surface.ray.direction = samplingHemisphere( prngSeed, surface.normal.world );
curWeight *= surface.material.albedo * dot( surface.ray.direction, surface.normal.world );
if ( length(curWeight) < 0.01 ) break;
}
outFrag += curValue;
}
{
surface.fragment = outFrag;
}
#else
{
const vec2 center = ( FRAME_NUMBER > 0 ) ? vec2( rnd(), rnd() ) : vec2(0.5);
const vec2 inUv = (vec2(gl_LaunchIDEXT.xy) + center) / vec2(gl_LaunchSizeEXT.xy);
#if 0
vec4 target = ubo.eyes[surface.pass].iProjection * vec4(inUv.x * 2.0f - 1.0f, inUv.y * 2.0f - 1.0f, 1, 1);
vec4 direction = ubo.eyes[surface.pass].iView * vec4(normalize(target.xyz), 0);
surface.ray.direction = vec3(direction);
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
#else
const mat4 iProjectionView = inverse( ubo.eyes[surface.pass].projection * mat4(mat3(ubo.eyes[surface.pass].view)) );
const vec4 near4 = iProjectionView * (vec4(2.0 * inUv - 1.0, -1.0, 1.0));
const vec4 far4 = iProjectionView * (vec4(2.0 * inUv - 1.0, 1.0, 1.0));
const vec3 near3 = near4.xyz / near4.w;
const vec3 far3 = far4.xyz / far4.w;
surface.ray.direction = normalize( far3 - near3 );
surface.ray.origin = ubo.eyes[surface.pass].eyePos.xyz;
#endif
}
{
surface.fragment = traceStep( surface.ray );
}
#endif
{
#if BLOOM #if BLOOM
float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722)); float brightness = dot(surface.fragment.rgb, vec3(0.2126, 0.7152, 0.0722));
outFragBright = brightness > ubo.brightnessThreshold ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1); outFragBright = brightness > ubo.brightnessThreshold ? vec4(surface.fragment.rgb, 1.0) : vec4(0, 0, 0, 1);
@ -375,17 +430,22 @@ void main() {
fog( surface.ray, surface.fragment.rgb, surface.fragment.a ); fog( surface.ray, surface.fragment.rgb, surface.fragment.a );
#endif #endif
#if TONE_MAP #if TONE_MAP
surface.fragment.rgb = vec3(1.0) - exp(-surface.fragment.rgb * ubo.exposure); surface.fragment.rgb = vec3(1.0) - exp(-surface.fragment.rgb * ubo.settings.bloom.exposure);
#endif #endif
#if GAMMA_CORRECT #if GAMMA_CORRECT
surface.fragment.rgb = pow(surface.fragment.rgb, vec3(1.0 / ubo.gamma)); surface.fragment.rgb = pow(surface.fragment.rgb, vec3(1.0 / ubo.settings.bloom.gamma));
#endif #endif
#if WHITENOISE #if WHITENOISE
if ( enabled(ubo.settings.mode.type, 1) ) whitenoise(surface.fragment.rgb, ubo.settings.mode.parameters); if ( enabled(ubo.settings.mode.type, 1) ) whitenoise(surface.fragment.rgb, ubo.settings.mode.parameters);
#endif #endif
} }
if ( ubo.frameNumber == 0 ) { {
outFrag = surface.fragment;
outFrag.a = 1;
}
if ( ubo.settings.mode.frameNumber == 0 ) {
imageStore(outImage, ivec2(gl_LaunchIDEXT.xy), outFrag); imageStore(outImage, ivec2(gl_LaunchIDEXT.xy), outFrag);
} else { } else {
// if ( length(outFrag.rgb) < 0.01f ) return; // if ( length(outFrag.rgb) < 0.01f ) return;
@ -393,38 +453,4 @@ void main() {
imageStore(outImage, ivec2(gl_LaunchIDEXT.xy), blended); imageStore(outImage, ivec2(gl_LaunchIDEXT.xy), blended);
} }
} }
/*
{
vec4 curValue = vec4(0);
vec4 curWeight = vec4(1);
for ( uint path = 0; path < NUM_PATHS; ++path ) {
trace( surface.ray );
if ( !payload.hit ) {
if ( path == 0 && 0 <= ubo.indexSkybox && ubo.indexSkybox < CUBEMAPS ) {
curValue = texture( samplerCubemaps[ubo.indexSkybox], surface.ray.direction );
}
break;
}
setupSurface( payload );
directLighting();
curValue += surface.fragment * curWeight;
surface.ray.origin = surface.position.world;
if ( !false ) {
surface.ray.direction = reflect( surface.ray.direction, surface.normal.world );
curWeight *= (1.0 - surface.material.roughness) * surface.material.albedo * dot( surface.ray.direction, surface.normal.world );
} else {
surface.ray.direction = samplingHemisphere( prngSeed, surface.normal.world );
curWeight *= surface.material.albedo * dot( surface.ray.direction, surface.normal.world );
}
if ( length(curWeight) < 0.01 ) break;
}
outFrag += curValue;
}
*/

View File

@ -745,6 +745,7 @@ void uf::graph::process( pod::Graph& graph ) {
} }
} }
if ( graph.metadata["debug"]["print"]["lights"].as<bool>() ) for ( auto& pair : graph.lights ) UF_MSG_DEBUG("Light: {}", pair.first);
if ( graph.metadata["debug"]["print"]["meshes"].as<bool>() ) for ( auto& name : graph.meshes ) UF_MSG_DEBUG("Mesh: {}", name); if ( graph.metadata["debug"]["print"]["meshes"].as<bool>() ) for ( auto& name : graph.meshes ) UF_MSG_DEBUG("Mesh: {}", name);
if ( graph.metadata["debug"]["print"]["materials"].as<bool>() ) for ( auto& name : graph.materials ) UF_MSG_DEBUG("Material: {}", name); if ( graph.metadata["debug"]["print"]["materials"].as<bool>() ) for ( auto& name : graph.materials ) UF_MSG_DEBUG("Material: {}", name);
if ( graph.metadata["debug"]["print"]["textures"].as<bool>() ) for ( auto& name : graph.textures ) UF_MSG_DEBUG("Texture: {}", name); if ( graph.metadata["debug"]["print"]["textures"].as<bool>() ) for ( auto& name : graph.textures ) UF_MSG_DEBUG("Texture: {}", name);

View File

@ -1288,7 +1288,6 @@ void ext::vulkan::Graphic::generateBottomAccelerationStructures() {
// create BLAS buffer and handle // create BLAS buffer and handle
size_t blasBufferIndex = this->initializeBuffer( NULL, totalBlasBufferSize, uf::renderer::enums::Buffer::ACCELERATION_STRUCTURE | uf::renderer::enums::Buffer::ADDRESS ); size_t blasBufferIndex = this->initializeBuffer( NULL, totalBlasBufferSize, uf::renderer::enums::Buffer::ACCELERATION_STRUCTURE | uf::renderer::enums::Buffer::ADDRESS );
size_t blasBufferOffset = 0; size_t blasBufferOffset = 0;
UF_MSG_DEBUG("Blas buffer size: {}", totalBlasBufferSize);
#endif #endif
scratchBuffer.alignment = acclerationStructureProperties.minAccelerationStructureScratchOffsetAlignment; scratchBuffer.alignment = acclerationStructureProperties.minAccelerationStructureScratchOffsetAlignment;
@ -1307,7 +1306,6 @@ void ext::vulkan::Graphic::generateBottomAccelerationStructures() {
blasBufferOffset += blasData.sizeInfo.accelerationStructureSize; blasBufferOffset += blasData.sizeInfo.accelerationStructureSize;
#else #else
UF_MSG_DEBUG("Blas buffer size: {}", blasData.sizeInfo.accelerationStructureSize);
size_t blasBufferIndex = this->initializeBuffer( NULL, blasData.sizeInfo.accelerationStructureSize, uf::renderer::enums::Buffer::ACCELERATION_STRUCTURE | uf::renderer::enums::Buffer::ADDRESS ); size_t blasBufferIndex = this->initializeBuffer( NULL, blasData.sizeInfo.accelerationStructureSize, uf::renderer::enums::Buffer::ACCELERATION_STRUCTURE | uf::renderer::enums::Buffer::ADDRESS );
blasData.as.buffer = this->buffers[blasBufferIndex].alias(); blasData.as.buffer = this->buffers[blasBufferIndex].alias();
@ -1338,7 +1336,6 @@ void ext::vulkan::Graphic::generateBottomAccelerationStructures() {
&blasData.rangeInfo &blasData.rangeInfo
); );
device.flushCommandBuffer(commandBuffer, uf::renderer::Device::QueueEnum::COMPUTE); device.flushCommandBuffer(commandBuffer, uf::renderer::Device::QueueEnum::COMPUTE);
} }
for ( auto& blasData : blasDatas ) this->accelerationStructures.bottoms.emplace_back(blasData.as); for ( auto& blasData : blasDatas ) this->accelerationStructures.bottoms.emplace_back(blasData.as);

View File

@ -727,13 +727,32 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
} matrices[2]; } matrices[2];
struct Settings { struct Settings {
struct Lengths {
alignas(4) uint32_t lights = 0;
alignas(4) uint32_t materials = 0;
alignas(4) uint32_t textures = 0;
alignas(4) uint32_t drawCommands = 0;
} lengths;
struct Mode { struct Mode {
alignas(4) uint8_t mode;
alignas(4) uint8_t scalar;
alignas(8) pod::Vector2ui padding;
alignas(16) pod::Vector4f parameters; alignas(16) pod::Vector4f parameters;
alignas(4) uint32_t mode;
alignas(4) uint32_t scalar;
alignas(4) uint32_t msaa;
alignas(4) uint32_t frameAccumulate;
} mode; } mode;
struct Lighting {
pod::Vector3f ambient;
alignas(4) float padding1;
alignas(4) uint32_t indexSkybox;
alignas(4) uint32_t shadowSamples;
alignas(4) uint32_t useLightmaps;
} lighting;
struct Fog { struct Fog {
pod::Vector3f color; pod::Vector3f color;
alignas(4) float stepScale; alignas(4) float stepScale;
@ -751,6 +770,13 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
alignas(4) float padding3; alignas(4) float padding3;
} fog; } fog;
struct Bloom {
alignas(4) float exposure;
alignas(4) float brightnessThreshold;
alignas(4) float gamma;
alignas(4) uint32_t padding2;
} bloom;
struct VXGI { struct VXGI {
alignas(16) pod::Matrix4f matrix; alignas(16) pod::Matrix4f matrix;
alignas(4) float cascadePower; alignas(4) float cascadePower;
@ -775,26 +801,6 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
alignas(4) uint padding2; alignas(4) uint padding2;
} rt; } rt;
} settings; } settings;
struct Lengths {
alignas(4) uint32_t lights = 0;
alignas(4) uint32_t materials = 0;
alignas(4) uint32_t textures = 0;
alignas(4) uint32_t drawCommands = 0;
} lengths;
pod::Vector3f ambient;
alignas(4) float gamma;
alignas(4) float exposure;
alignas(4) float brightnessThreshold;
alignas(4) uint32_t msaa;
alignas(4) uint32_t shadowSamples;
alignas(4) uint32_t indexSkybox;
alignas(4) uint32_t useLightmaps;
alignas(4) uint32_t frameAccumulate;
alignas(4) uint32_t padding3;
}; };
// struct that contains our skybox cubemap, noise texture, and VXGI voxels // struct that contains our skybox cubemap, noise texture, and VXGI voxels
@ -848,11 +854,27 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
.eyePos = camera.getEye( i ), .eyePos = camera.getEye( i ),
}; };
} }
uniforms.settings.lengths = UniformDescriptor::Settings::Lengths{
.lights = MIN( uf::graph::storage.lights.size(), metadata.light.max ),
.materials = MIN( uf::graph::storage.materials.keys.size(), metadata.max.textures2D ),
.textures = MIN( uf::graph::storage.textures.keys.size(), metadata.max.textures2D ),
.drawCommands = MIN( 0, metadata.max.textures2D ),
};
uniforms.settings.mode = UniformDescriptor::Settings::Mode{ uniforms.settings.mode = UniformDescriptor::Settings::Mode{
.parameters = metadata.shader.parameters,
.mode = metadata.shader.mode, .mode = metadata.shader.mode,
.scalar = metadata.shader.scalar, .scalar = metadata.shader.scalar,
.padding = pod::Vector2ui{0,0},
.parameters = metadata.shader.parameters, .msaa = ext::vulkan::settings::msaa,
.frameAccumulate = metadata.shader.frameAccumulate,
};
uniforms.settings.lighting = UniformDescriptor::Settings::Lighting{
.ambient = metadata.light.ambient,
.indexSkybox = indexSkybox,
.shadowSamples = std::min( 0, metadata.shadow.samples ),
.useLightmaps = metadata.light.useLightmaps,
}; };
uniforms.settings.fog = UniformDescriptor::Settings::Fog{ uniforms.settings.fog = UniformDescriptor::Settings::Fog{
.color = metadata.fog.color, .color = metadata.fog.color,
@ -867,7 +889,11 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
.absorbtion = metadata.fog.absorbtion, .absorbtion = metadata.fog.absorbtion,
}; };
uniforms.settings.bloom = UniformDescriptor::Settings::Bloom{
.exposure = metadata.light.exposure,
.brightnessThreshold = metadata.light.brightnessThreshold,
.gamma = metadata.light.gamma,
};
uniforms.settings.vxgi = UniformDescriptor::Settings::VXGI{ uniforms.settings.vxgi = UniformDescriptor::Settings::VXGI{
.matrix = metadataVxgi.extents.matrix, .matrix = metadataVxgi.extents.matrix,
.cascadePower = metadataVxgi.cascadePower, .cascadePower = metadataVxgi.cascadePower,
@ -878,7 +904,6 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
.traceStartOffsetFactor = metadataVxgi.traceStartOffsetFactor, .traceStartOffsetFactor = metadataVxgi.traceStartOffsetFactor,
.shadows = metadataVxgi.shadows, .shadows = metadataVxgi.shadows,
}; };
uniforms.settings.rt = UniformDescriptor::Settings::RT{ uniforms.settings.rt = UniformDescriptor::Settings::RT{
.defaultRayBounds = metadataRt.settings.defaultRayBounds, // { 0.001, 4096.0 }, .defaultRayBounds = metadataRt.settings.defaultRayBounds, // { 0.001, 4096.0 },
.alphaTestOffset = metadataRt.settings.alphaTestOffset, //0.001, .alphaTestOffset = metadataRt.settings.alphaTestOffset, //0.001,
@ -887,26 +912,7 @@ void ext::ExtSceneBehavior::bindBuffers( uf::Object& self, uf::renderer::Graphic
.paths = metadataRt.settings.paths, // 1, .paths = metadataRt.settings.paths, // 1,
.frameAccumulationMinimum = metadataRt.settings.frameAccumulationMinimum, // 0, .frameAccumulationMinimum = metadataRt.settings.frameAccumulationMinimum, // 0,
}; };
uniforms.lengths = UniformDescriptor::Lengths{
.lights = MIN( uf::graph::storage.lights.size(), metadata.light.max ),
.materials = MIN( uf::graph::storage.materials.keys.size(), metadata.max.textures2D ),
.textures = MIN( uf::graph::storage.textures.keys.size(), metadata.max.textures2D ),
.drawCommands = MIN( 0, metadata.max.textures2D ),
};
uniforms.ambient = metadata.light.ambient;
uniforms.gamma = metadata.light.gamma;
uniforms.exposure = metadata.light.exposure;
uniforms.brightnessThreshold = metadata.light.brightnessThreshold;
uniforms.msaa = ext::vulkan::settings::msaa;
uniforms.shadowSamples = std::min( 0, metadata.shadow.samples );
uniforms.indexSkybox = indexSkybox;
// use sample lightmaps during deferred pass
uniforms.useLightmaps = metadata.light.useLightmaps;
uniforms.frameAccumulate = metadata.shader.frameAccumulate;
} }
uf::stl::vector<VkImage> previousTextures; uf::stl::vector<VkImage> previousTextures;

View File

@ -828,9 +828,6 @@ void EXT_API ext::terminate() {
/* Terminate controllers */ { /* Terminate controllers */ {
spec::controller::terminate(); spec::controller::terminate();
} }
/* Kill physics */ {
uf::physics::terminate();
}
#if UF_USE_IMGUI #if UF_USE_IMGUI
if ( ::config.engine.ext.imgui.enabled ) { if ( ::config.engine.ext.imgui.enabled ) {
ext::imgui::terminate(); ext::imgui::terminate();
@ -860,7 +857,9 @@ void EXT_API ext::terminate() {
{ {
uf::scene::destroy(); uf::scene::destroy();
} }
/* Kill physics */ {
uf::physics::terminate();
}
/* Garbage collection */ if ( false ) { // segfaults, for some reason /* Garbage collection */ if ( false ) { // segfaults, for some reason
size_t collected = uf::instantiator::collect( ::config.engine.gc.mode ); size_t collected = uf::instantiator::collect( ::config.engine.gc.mode );
if ( ::config.engine.gc.announce && collected > 0 ) UF_MSG_DEBUG("GC collected {} unused entities", (int) collected); if ( ::config.engine.gc.announce && collected > 0 ) UF_MSG_DEBUG("GC collected {} unused entities", (int) collected);