Skip to content

Commit beeff03

Browse files
committed
Don't disable OIT if SSAO is off
1 parent 6c105a2 commit beeff03

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

rust/kcl-lib/src/engine/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,6 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
234234
&ModelingCmd::SceneClearAll(mcmd::SceneClearAll::default()),
235235
)
236236
.await?;
237-
self.batch_modeling_cmd(
238-
id_generator.next_uuid(),
239-
source_range,
240-
&ModelingCmd::from(mcmd::SetOrderIndependentTransparency::builder().enabled(false).build()),
241-
)
242-
.await?;
243237

244238
// Flush the batch queue, so clear is run right away.
245239
// Otherwise the hooks below won't work.

rust/kcl-lib/src/execution/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,19 @@ impl ExecutorContext {
791791

792792
self.engine
793793
.clear_scene(&mut exec_state.mod_local.id_generator, source_range)
794-
.await
794+
.await?;
795+
// The engine errors out if you toggle OIT with SSAO off.
796+
// So ignore OIT settings if SSAO is off.
797+
if self.settings.enable_ssao {
798+
self.engine
799+
.batch_modeling_cmd(
800+
exec_state.mod_local.id_generator.next_uuid(),
801+
source_range,
802+
&ModelingCmd::from(mcmd::SetOrderIndependentTransparency::builder().enabled(false).build()),
803+
)
804+
.await?;
805+
}
806+
Ok(())
795807
}
796808

797809
pub async fn bust_cache_and_reset_scene(&self) -> Result<ExecOutcome, KclErrorWithOutputs> {

rust/kcl-lib/src/std/appearance.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,13 @@ async fn inner_appearance(
123123
}
124124
}
125125

126+
// OIT (order-independent transparency) is required to show transparency.
127+
// But it degrades engine performance. So only enable it if necessary,
128+
// i.e. if user has chosen to make something transparent.
126129
let mut needs_oit = false;
127130
let opacity_param = if let Some(opacity) = opacity {
131+
// The engine errors out if you toggle OIT with SSAO off.
132+
// So ignore OIT settings if SSAO is off.
128133
if opacity < 100.0 && args.ctx.settings.enable_ssao {
129134
needs_oit = true;
130135
}

0 commit comments

Comments
 (0)