Cone offset option

This commit is contained in:
luboslenco
2019-10-27 08:57:51 +01:00
parent 0a04313b7b
commit 2345a05229
6 changed files with 16 additions and 21 deletions
Binary file not shown.
Binary file not shown.
+4 -19
View File
@@ -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) {
+3
View File
@@ -74,6 +74,9 @@ class Uniforms {
#end
}
#end
if (link == "_coneOffset") {
return UITrait.inst.vxaoOffset;
}
return null;
}
+8 -2
View File
@@ -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() {
+1
View File
@@ -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;