some small vxgi tweaks
This commit is contained in:
parent
d519af9cc3
commit
85696bd8f6
@ -31,7 +31,7 @@
|
|||||||
"vxgi": {
|
"vxgi": {
|
||||||
"limiter": 0,
|
"limiter": 0,
|
||||||
// "limiter": 0.5,
|
// "limiter": 0.5,
|
||||||
"size": 256,
|
"size": 128,
|
||||||
"dispatch": 8,
|
"dispatch": 8,
|
||||||
"cascades": 3,
|
"cascades": 3,
|
||||||
"cascadePower": 2.0,
|
"cascadePower": 2.0,
|
||||||
@ -155,6 +155,7 @@
|
|||||||
"instance": [
|
"instance": [
|
||||||
"VK_KHR_get_physical_device_properties2"
|
"VK_KHR_get_physical_device_properties2"
|
||||||
,"VK_KHR_get_surface_capabilities2"
|
,"VK_KHR_get_surface_capabilities2"
|
||||||
|
,"VK_EXT_swapchain_colorspace"
|
||||||
],
|
],
|
||||||
"device": [
|
"device": [
|
||||||
"VK_EXT_memory_budget"
|
"VK_EXT_memory_budget"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
[ 0, 0, 0, 0 ]
|
[ 0, 0, 0, 0 ]
|
||||||
],
|
],
|
||||||
"shader": {
|
"shader": {
|
||||||
"mode": 10,
|
"mode": 0,
|
||||||
"scalar": 16,
|
"scalar": 16,
|
||||||
"parameters": [ 0, 0, 0, "time" ]
|
"parameters": [ 0, 0, 0, "time" ]
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#if BARYCENTRIC
|
#if BARYCENTRIC
|
||||||
#ifndef BARYCENTRIC_CALCULATE
|
#ifndef BARYCENTRIC_CALCULATE
|
||||||
#define BARYCENTRIC_CALCULATE 0
|
#define BARYCENTRIC_CALCULATE 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef BUFFER_REFERENCE
|
#ifndef BUFFER_REFERENCE
|
||||||
#define BUFFER_REFERENCE 1
|
#define BUFFER_REFERENCE 1
|
||||||
|
@ -29,6 +29,7 @@ vec4 voxelTrace( inout Ray ray, float aperture, float maxDistance ) {
|
|||||||
const float tStart = rayBoxInfoA.x;
|
const float tStart = rayBoxInfoA.x;
|
||||||
const float tEnd = maxDistance > 0 ? min(maxDistance, rayBoxInfoB.y) : rayBoxInfoB.y;
|
const float tEnd = maxDistance > 0 ? min(maxDistance, rayBoxInfoB.y) : rayBoxInfoB.y;
|
||||||
const float tDelta = voxelInfo.radianceSizeRecip * granularityRecip;
|
const float tDelta = voxelInfo.radianceSizeRecip * granularityRecip;
|
||||||
|
const uint MIN_VOXEL_MIP_LEVEL = 1;
|
||||||
// marcher
|
// marcher
|
||||||
ray.distance = tStart + tDelta * ubo.settings.vxgi.traceStartOffsetFactor;
|
ray.distance = tStart + tDelta * ubo.settings.vxgi.traceStartOffsetFactor;
|
||||||
ray.position = vec3(0);
|
ray.position = vec3(0);
|
||||||
@ -41,7 +42,9 @@ vec4 voxelTrace( inout Ray ray, float aperture, float maxDistance ) {
|
|||||||
float occlusion = 0.0;
|
float occlusion = 0.0;
|
||||||
uint stepCounter = 0;
|
uint stepCounter = 0;
|
||||||
while ( color.a < 1.0 && occlusion < 1.0 && ray.distance < tEnd && stepCounter++ < maxSteps ) {
|
while ( color.a < 1.0 && occlusion < 1.0 && ray.distance < tEnd && stepCounter++ < maxSteps ) {
|
||||||
ray.distance += tDelta * cascadePower(cascade) * max(1, coneDiameter);
|
float stepScale = max(1.0, coneDiameter * cascadePower(cascade));
|
||||||
|
ray.distance += tDelta * stepScale;
|
||||||
|
// ray.distance += tDelta * cascadePower(cascade) * max(1, coneDiameter);
|
||||||
ray.position = ray.origin + ray.direction * ray.distance;
|
ray.position = ray.origin + ray.direction * ray.distance;
|
||||||
|
|
||||||
#if VXGI_NDC
|
#if VXGI_NDC
|
||||||
@ -54,6 +57,7 @@ vec4 voxelTrace( inout Ray ray, float aperture, float maxDistance ) {
|
|||||||
if ( cascade >= CASCADES || uvw.x < 0.0 || uvw.y < 0.0 || uvw.z < 0.0 || uvw.x >= 1.0 || uvw.y >= 1.0 || uvw.z >= 1.0 ) break;
|
if ( cascade >= CASCADES || uvw.x < 0.0 || uvw.y < 0.0 || uvw.z < 0.0 || uvw.x >= 1.0 || uvw.y >= 1.0 || uvw.z >= 1.0 ) break;
|
||||||
coneDiameter = coneCoefficient * ray.distance;
|
coneDiameter = coneCoefficient * ray.distance;
|
||||||
level = aperture > 0 ? log2( coneDiameter ) : 0;
|
level = aperture > 0 ? log2( coneDiameter ) : 0;
|
||||||
|
// level = clamp(level, MIN_VOXEL_MIP_LEVEL, voxelInfo.mipmapLevels - 1);
|
||||||
if ( level >= voxelInfo.mipmapLevels ) break;
|
if ( level >= voxelInfo.mipmapLevels ) break;
|
||||||
radiance = textureLod(voxelOutput[nonuniformEXT(cascade)], uvw.xzy, level);
|
radiance = textureLod(voxelOutput[nonuniformEXT(cascade)], uvw.xzy, level);
|
||||||
color += (1.0 - color.a) * radiance;
|
color += (1.0 - color.a) * radiance;
|
||||||
|
@ -292,6 +292,9 @@ void directLighting() {
|
|||||||
|
|
||||||
surface.material.albedo.rgb = radiance.rgb;
|
surface.material.albedo.rgb = radiance.rgb;
|
||||||
surface.material.indirect.rgb = vec3(0);
|
surface.material.indirect.rgb = vec3(0);
|
||||||
|
surface.fragment.rgb = radiance.rgb;
|
||||||
|
surface.fragment.a = radiance.a;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ layout (binding = 15, r32ui) uniform volatile coherent uimage3D voxelRadianceG[C
|
|||||||
layout (binding = 16, r32ui) uniform volatile coherent uimage3D voxelRadianceB[CASCADES];
|
layout (binding = 16, r32ui) uniform volatile coherent uimage3D voxelRadianceB[CASCADES];
|
||||||
layout (binding = 17, r32ui) uniform volatile coherent uimage3D voxelRadianceA[CASCADES];
|
layout (binding = 17, r32ui) uniform volatile coherent uimage3D voxelRadianceA[CASCADES];
|
||||||
layout (binding = 18, r32ui) uniform volatile coherent uimage3D voxelCount[CASCADES];
|
layout (binding = 18, r32ui) uniform volatile coherent uimage3D voxelCount[CASCADES];
|
||||||
layout (binding = 19, rgba16f) uniform volatile coherent image3D voxelOutput[CASCADES];
|
layout (binding = 19, rgba8) uniform volatile coherent image3D voxelOutput[CASCADES];
|
||||||
|
|
||||||
#include "../../common/functions.h"
|
#include "../../common/functions.h"
|
||||||
#include "../../common/light.h"
|
#include "../../common/light.h"
|
||||||
|
@ -46,7 +46,7 @@ layout (binding = 17, r32ui) uniform volatile coherent uimage3D voxelRadianceG[C
|
|||||||
layout (binding = 18, r32ui) uniform volatile coherent uimage3D voxelRadianceB[CASCADES];
|
layout (binding = 18, r32ui) uniform volatile coherent uimage3D voxelRadianceB[CASCADES];
|
||||||
layout (binding = 19, r32ui) uniform volatile coherent uimage3D voxelRadianceA[CASCADES];
|
layout (binding = 19, r32ui) uniform volatile coherent uimage3D voxelRadianceA[CASCADES];
|
||||||
layout (binding = 20, r32ui) uniform volatile coherent uimage3D voxelCount[CASCADES];
|
layout (binding = 20, r32ui) uniform volatile coherent uimage3D voxelCount[CASCADES];
|
||||||
layout (binding = 21, rgba16f) uniform volatile coherent image3D voxelOutput[CASCADES];
|
layout (binding = 21, rgba8) uniform volatile coherent image3D voxelOutput[CASCADES];
|
||||||
|
|
||||||
layout (location = 0) flat in uvec4 inId;
|
layout (location = 0) flat in uvec4 inId;
|
||||||
layout (location = 1) flat in vec4 inPOS0;
|
layout (location = 1) flat in vec4 inPOS0;
|
||||||
@ -133,6 +133,4 @@ void main() {
|
|||||||
imageAtomicAdd(voxelRadianceB[CASCADE], ivec3(uvw), uint( A.b * 256 ) );
|
imageAtomicAdd(voxelRadianceB[CASCADE], ivec3(uvw), uint( A.b * 256 ) );
|
||||||
imageAtomicAdd(voxelRadianceA[CASCADE], ivec3(uvw), uint( A.a * 256 ) );
|
imageAtomicAdd(voxelRadianceA[CASCADE], ivec3(uvw), uint( A.a * 256 ) );
|
||||||
imageAtomicAdd(voxelCount[CASCADE], ivec3(uvw), uint( 1 ) );
|
imageAtomicAdd(voxelCount[CASCADE], ivec3(uvw), uint( 1 ) );
|
||||||
|
|
||||||
imageStore(voxelOutput[CASCADE], uvw, vec4(N.x, N.y, N.z, A.a) );
|
|
||||||
}
|
}
|
@ -15,10 +15,12 @@
|
|||||||
#include <uf/engine/graph/graph.h>
|
#include <uf/engine/graph/graph.h>
|
||||||
#include <uf/ext/ext.h>
|
#include <uf/ext/ext.h>
|
||||||
|
|
||||||
|
// to-do: fix this
|
||||||
#define BARYCENTRIC 0
|
#define BARYCENTRIC 0
|
||||||
#if BARYCENTRIC
|
#if BARYCENTRIC
|
||||||
|
// agnostic for all devices, setting to 0 is only supported on AMD for little differences anyways
|
||||||
#ifndef BARYCENTRIC_CALCULATE
|
#ifndef BARYCENTRIC_CALCULATE
|
||||||
#define BARYCENTRIC_CALCULATE 0
|
#define BARYCENTRIC_CALCULATE 1
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -71,7 +71,8 @@ void ext::VoxelizerSceneBehavior::initialize( uf::Object& self ) {
|
|||||||
output.sampler.descriptor.filter.min = uf::renderer::enums::Filter::NEAREST;
|
output.sampler.descriptor.filter.min = uf::renderer::enums::Filter::NEAREST;
|
||||||
output.sampler.descriptor.filter.mag = uf::renderer::enums::Filter::NEAREST;
|
output.sampler.descriptor.filter.mag = uf::renderer::enums::Filter::NEAREST;
|
||||||
}
|
}
|
||||||
output.fromBuffers( NULL, 0, uf::renderer::settings::pipelines::hdr ? uf::renderer::enums::Format::HDR : uf::renderer::enums::Format::SDR, metadata.voxelSize.x, metadata.voxelSize.y, metadata.voxelSize.z, 1, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_IMAGE_LAYOUT_GENERAL );
|
// output.fromBuffers( NULL, 0, uf::renderer::settings::pipelines::hdr ? uf::renderer::enums::Format::HDR : uf::renderer::enums::Format::SDR, metadata.voxelSize.x, metadata.voxelSize.y, metadata.voxelSize.z, 1, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_IMAGE_LAYOUT_GENERAL );
|
||||||
|
output.fromBuffers( NULL, 0, uf::renderer::enums::Format::R8G8B8A8_UNORM, metadata.voxelSize.x, metadata.voxelSize.y, metadata.voxelSize.z, 1, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, VK_IMAGE_LAYOUT_GENERAL );
|
||||||
}
|
}
|
||||||
// initialize render mode
|
// initialize render mode
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user