File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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 > {
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments