Add linear AO spec constant
This commit is contained in:
+6
-1
@@ -21,9 +21,10 @@ pub(crate) struct PreviousDebug {
|
||||
pub(crate) show_normals: bool,
|
||||
pub(crate) show_depth: bool,
|
||||
pub(crate) show_albedo: bool,
|
||||
pub(crate) show_material: bool,
|
||||
pub(crate) show_material: bool,
|
||||
pub(crate) show_all: bool,
|
||||
pub(crate) disable_ao: bool,
|
||||
pub(crate) use_linear_ao: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -313,6 +314,10 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState, new_csg_needed: &mut boo
|
||||
&mut state.debug.disable_ao,
|
||||
"Disable ambient occlusion calculation",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.use_linear_ao,
|
||||
"Use linear falloff for occlusion calculation",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,6 +10,7 @@ layout(constant_id = 5) const bool SPEC_SHOW_ALBEDO = false;
|
||||
layout(constant_id = 6) const bool SPEC_SHOW_MATERIAL = false;
|
||||
layout(constant_id = 7) const bool SPEC_SHOW_ALL = false;
|
||||
layout(constant_id = 8) const bool SPEC_DISABLE_AO = false;
|
||||
layout(constant_id = 9) const bool SPEC_USE_LINEAR_AO = false;
|
||||
|
||||
//layout(constant_id = 30) const uint SPEC_MAXIMUM_SUBDIVISION = 64;
|
||||
const uint SPEC_MAXIMUM_SUBDIVISION = 64;
|
||||
|
||||
@@ -1867,6 +1867,7 @@ fn get_spec_constants(debug: &PreviousDebug) -> HashMap<u32, SpecializationConst
|
||||
const SPEC_SHOW_MATERIAL: u32 = 6;
|
||||
const SPEC_SHOW_ALL: u32 = 7;
|
||||
const SPEC_DISABLE_AO: u32 = 8;
|
||||
const SPEC_USE_LINEAR_AO: u32 = 9;
|
||||
const SPEC_MAXIMUM_SUBDISIVION: u32 = 30;
|
||||
|
||||
let mut spec_constants = HashMap::with_capacity(6);
|
||||
@@ -1900,6 +1901,10 @@ fn get_spec_constants(debug: &PreviousDebug) -> HashMap<u32, SpecializationConst
|
||||
SPEC_DISABLE_AO,
|
||||
SpecializationConstant::Bool(debug.disable_ao),
|
||||
);
|
||||
spec_constants.insert(
|
||||
SPEC_USE_LINEAR_AO,
|
||||
SpecializationConstant::Bool(debug.use_linear_ao),
|
||||
);
|
||||
spec_constants.insert(
|
||||
SPEC_MAXIMUM_SUBDISIVION,
|
||||
SpecializationConstant::U32(MAXIMUM_SUBDIVISION),
|
||||
|
||||
@@ -100,7 +100,13 @@ float getOcclusion(vec3 p, vec3 n) {
|
||||
#if AO_ENABLE
|
||||
for (uint i = 1; i < AO_MAX_ITER; i++) {
|
||||
hash = pcg4d(hash);
|
||||
vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * AO_STEP * i;
|
||||
float multiplier;
|
||||
if (SPEC_USE_LINEAR_AO) {
|
||||
multiplier = AO_STEP * i;
|
||||
} else {
|
||||
multiplier = pow(AO_STEP, (float(i) / AO_MAX_ITER * 2) + 0.5);
|
||||
}
|
||||
vec3 point = getPointOnSphere(vec2(floatConstruct(hash.x), floatConstruct(hash.y))) * multiplier;
|
||||
float dist = dot(point, n);
|
||||
if (dist < 0) {
|
||||
dist = abs(dist);
|
||||
|
||||
+3
-3
@@ -436,9 +436,9 @@ fn create_csg() -> SSATape {
|
||||
pos[0],
|
||||
pos[1],
|
||||
pos[2],
|
||||
SSAInput::Constant(rand::random_range(0.0..3.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..3.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..3.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
SSAInput::Constant(rand::random_range(0.0..1.0)),
|
||||
],
|
||||
);
|
||||
let sphere = tape.push_instruction(
|
||||
|
||||
Reference in New Issue
Block a user