Cone offset option
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -18,13 +18,14 @@ const vec3 voxelgiHalfExtents = vec3(1, 1, 1);
|
|||||||
const float voxelgiOcc = 1.0;
|
const float voxelgiOcc = 1.0;
|
||||||
const float voxelgiStep = 1.0;
|
const float voxelgiStep = 1.0;
|
||||||
const float voxelgiRange = 2.0;
|
const float voxelgiRange = 2.0;
|
||||||
const float voxelgiOffset = 1.5;
|
// const float voxelgiOffset = 1.5;
|
||||||
const float voxelgiAperture = 1.2;
|
const float voxelgiAperture = 1.2;
|
||||||
const float MAX_DISTANCE = 1.73205080757 * voxelgiRange;
|
const float MAX_DISTANCE = 1.73205080757 * voxelgiRange;
|
||||||
const float VOXEL_SIZE = (2.0 / voxelgiResolution.x) * voxelgiStep;
|
const float VOXEL_SIZE = (2.0 / voxelgiResolution.x) * voxelgiStep;
|
||||||
|
|
||||||
// uniform sampler3D voxels;
|
// uniform sampler3D voxels;
|
||||||
// uniform sampler3D voxelsLast;
|
// uniform sampler3D voxelsLast;
|
||||||
|
uniform float coneOffset;
|
||||||
|
|
||||||
// vec3 orthogonal(const vec3 u) {
|
// vec3 orthogonal(const vec3 u) {
|
||||||
// // Pass normalized 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) {
|
float traceConeAO(sampler3D voxels, const vec3 origin, vec3 dir, const float aperture, const float maxDist) {
|
||||||
dir = normalize(dir);
|
dir = normalize(dir);
|
||||||
float sampleCol = 0.0;
|
float sampleCol = 0.0;
|
||||||
float dist = 1.5 * VOXEL_SIZE * voxelgiOffset;
|
float dist = 1.5 * VOXEL_SIZE * coneOffset;
|
||||||
float diam = dist * aperture;
|
// float dist = (0.02 + 0.02 * (1.0 - dot(dir, normal)) ) * coneOffset;
|
||||||
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 diam = dist * aperture;
|
float diam = dist * aperture;
|
||||||
vec3 samplePos;
|
vec3 samplePos;
|
||||||
while (sampleCol < 1.0 && dist < maxDist) {
|
while (sampleCol < 1.0 && dist < maxDist) {
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class Uniforms {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
|
if (link == "_coneOffset") {
|
||||||
|
return UITrait.inst.vxaoOffset;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -143,13 +143,19 @@ class BoxPreferences {
|
|||||||
#if (!kha_direct3d12)
|
#if (!kha_direct3d12)
|
||||||
ui.check(UITrait.inst.hvxao, "Voxel AO");
|
ui.check(UITrait.inst.hvxao, "Voxel AO");
|
||||||
if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows");
|
if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows");
|
||||||
#end
|
|
||||||
if (UITrait.inst.hvxao.changed) {
|
if (UITrait.inst.hvxao.changed) {
|
||||||
Config.applyConfig();
|
Config.applyConfig();
|
||||||
#if arm_creator
|
#if arm_creator
|
||||||
MaterialParser.parseMeshMaterial();
|
MaterialParser.parseMeshMaterial();
|
||||||
#end
|
#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");
|
ui.check(UITrait.inst.hssgi, "SSAO");
|
||||||
if (UITrait.inst.hssgi.changed) Config.applyConfig();
|
if (UITrait.inst.hssgi.changed) Config.applyConfig();
|
||||||
ui.check(UITrait.inst.hbloom, "Bloom");
|
ui.check(UITrait.inst.hbloom, "Bloom");
|
||||||
@@ -198,7 +204,7 @@ class BoxPreferences {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ui._w = _w;
|
ui._w = _w;
|
||||||
}, 400, 270);
|
}, 400, 290);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function setScale() {
|
static function setScale() {
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ class UITrait {
|
|||||||
#else
|
#else
|
||||||
public var vxaoExt = 1.0;
|
public var vxaoExt = 1.0;
|
||||||
#end
|
#end
|
||||||
|
public var vxaoOffset = 1.5;
|
||||||
public var textureExport = false;
|
public var textureExport = false;
|
||||||
public var textureExportPath = "";
|
public var textureExportPath = "";
|
||||||
public var projectExport = false;
|
public var projectExport = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user