diff --git a/Bundled/creator/deferred_light.arm b/Bundled/creator/deferred_light.arm index 468b0a59..c02f6de0 100644 Binary files a/Bundled/creator/deferred_light.arm and b/Bundled/creator/deferred_light.arm differ diff --git a/Bundled/painter/deferred_light.arm b/Bundled/painter/deferred_light.arm index 54360170..c269d992 100644 Binary files a/Bundled/painter/deferred_light.arm and b/Bundled/painter/deferred_light.arm differ diff --git a/Shaders/std/conetrace.glsl b/Shaders/std/conetrace.glsl index 4e445a4b..4e2efd72 100644 --- a/Shaders/std/conetrace.glsl +++ b/Shaders/std/conetrace.glsl @@ -18,13 +18,14 @@ const vec3 voxelgiHalfExtents = vec3(1, 1, 1); const float voxelgiOcc = 1.0; const float voxelgiStep = 1.0; const float voxelgiRange = 2.0; -const float voxelgiOffset = 1.5; +// const float voxelgiOffset = 1.5; const float voxelgiAperture = 1.2; const float MAX_DISTANCE = 1.73205080757 * voxelgiRange; const float VOXEL_SIZE = (2.0 / voxelgiResolution.x) * voxelgiStep; // uniform sampler3D voxels; // uniform sampler3D voxelsLast; +uniform float coneOffset; // vec3 orthogonal(const vec3 u) { // // Pass normalized u @@ -42,24 +43,8 @@ vec3 tangent(const vec3 n) { float traceConeAO(sampler3D voxels, const vec3 origin, vec3 dir, const float aperture, const float maxDist) { dir = normalize(dir); float sampleCol = 0.0; - float dist = 1.5 * VOXEL_SIZE * voxelgiOffset; - float diam = dist * aperture; - vec3 samplePos; - while (sampleCol < 1.0 && dist < maxDist) { - samplePos = dir * dist + origin; - float mip = max(log2(diam * voxelgiResolution.x), 0); - float mipSample = textureLod(voxels, samplePos * 0.5 + vec3(0.5), mip).r; - sampleCol += (1 - sampleCol) * mipSample; - dist += max(diam / 2, VOXEL_SIZE); - diam = dist * aperture; - } - return sampleCol; -} - -float traceConeAOShadow(sampler3D voxels, const vec3 origin, vec3 dir, const float aperture, const float maxDist, const float offset) { - dir = normalize(dir); - float sampleCol = 0.0; - float dist = 1.5 * VOXEL_SIZE * voxelgiOffset * 2.5; // + float dist = 1.5 * VOXEL_SIZE * coneOffset; + // float dist = (0.02 + 0.02 * (1.0 - dot(dir, normal)) ) * coneOffset; float diam = dist * aperture; vec3 samplePos; while (sampleCol < 1.0 && dist < maxDist) { diff --git a/Sources/arm/render/Uniforms.hx b/Sources/arm/render/Uniforms.hx index 115793ca..f6ed7683 100644 --- a/Sources/arm/render/Uniforms.hx +++ b/Sources/arm/render/Uniforms.hx @@ -74,6 +74,9 @@ class Uniforms { #end } #end + if (link == "_coneOffset") { + return UITrait.inst.vxaoOffset; + } return null; } diff --git a/Sources/arm/ui/BoxPreferences.hx b/Sources/arm/ui/BoxPreferences.hx index 161c6776..0ef095bc 100644 --- a/Sources/arm/ui/BoxPreferences.hx +++ b/Sources/arm/ui/BoxPreferences.hx @@ -143,13 +143,19 @@ class BoxPreferences { #if (!kha_direct3d12) ui.check(UITrait.inst.hvxao, "Voxel AO"); if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows"); - #end if (UITrait.inst.hvxao.changed) { Config.applyConfig(); #if arm_creator MaterialParser.parseMeshMaterial(); #end } + + ui.enabled = UITrait.inst.hvxao.selected; + var h = Id.handle({value: UITrait.inst.vxaoOffset}); + UITrait.inst.vxaoOffset = ui.slider(h, "Cone Offset", 1.0, 4.0); + if (h.changed) Context.ddirty = 2; + ui.enabled = true; + #end ui.check(UITrait.inst.hssgi, "SSAO"); if (UITrait.inst.hssgi.changed) Config.applyConfig(); ui.check(UITrait.inst.hbloom, "Bloom"); @@ -198,7 +204,7 @@ class BoxPreferences { } ui._w = _w; - }, 400, 270); + }, 400, 290); } static function setScale() { diff --git a/Sources/arm/ui/UITrait.hx b/Sources/arm/ui/UITrait.hx index d20bbe0e..1f13b100 100644 --- a/Sources/arm/ui/UITrait.hx +++ b/Sources/arm/ui/UITrait.hx @@ -240,6 +240,7 @@ class UITrait { #else public var vxaoExt = 1.0; #end + public var vxaoOffset = 1.5; public var textureExport = false; public var textureExportPath = ""; public var projectExport = false;