@@ -117,7 +117,8 @@ ServiceManager<ViewModelBase> vmFactory
117117 [
118118 typeof ( FreeUModule ) ,
119119 typeof ( ControlNetModule ) ,
120- typeof ( LayerDiffuseModule )
120+ typeof ( LayerDiffuseModule ) ,
121+ typeof ( FluxGuidanceModule )
121122 ] ;
122123 } ) ;
123124 }
@@ -286,6 +287,23 @@ private void ApplyStepsInitialSampler(ModuleApplyStepEventArgs e)
286287 var conditioning = e . Temp . Base . Conditioning . Unwrap ( ) ;
287288 var refinerConditioning = e . Temp . Refiner . Conditioning ;
288289
290+ var useFluxGuidance = ModulesCardViewModel . IsModuleEnabled < FluxGuidanceModule > ( ) ;
291+
292+ if ( useFluxGuidance )
293+ {
294+ // Flux guidance
295+ var fluxGuidance = e . Nodes . AddTypedNode (
296+ new ComfyNodeBuilder . FluxGuidance
297+ {
298+ Name = e . Nodes . GetUniqueName ( "FluxGuidance" ) ,
299+ Conditioning = conditioning . Positive ,
300+ Guidance = CfgScale
301+ }
302+ ) ;
303+
304+ conditioning = conditioning with { Positive = fluxGuidance . Output } ;
305+ }
306+
289307 // Use custom sampler if SDTurbo scheduler is selected
290308 if ( e . Builder . Connections . PrimaryScheduler == ComfyScheduler . SDTurbo )
291309 {
@@ -320,7 +338,7 @@ private void ApplyStepsInitialSampler(ModuleApplyStepEventArgs e)
320338 Model = e . Builder . Connections . Base . Model ,
321339 AddNoise = true ,
322340 NoiseSeed = e . Builder . Connections . Seed ,
323- Cfg = CfgScale ,
341+ Cfg = useFluxGuidance ? 1.0d : CfgScale ,
324342 Positive = conditioning . Positive ,
325343 Negative = conditioning . Negative ,
326344 Sampler = kSamplerSelect . Output ,
@@ -344,7 +362,7 @@ private void ApplyStepsInitialSampler(ModuleApplyStepEventArgs e)
344362 SamplerName = primarySampler . Name ,
345363 Scheduler = primaryScheduler . Name ,
346364 Steps = Steps ,
347- Cfg = CfgScale ,
365+ Cfg = useFluxGuidance ? 1.0d : CfgScale ,
348366 Positive = conditioning . Positive ,
349367 Negative = conditioning . Negative ,
350368 LatentImage = primaryLatent ,
@@ -365,7 +383,7 @@ private void ApplyStepsInitialSampler(ModuleApplyStepEventArgs e)
365383 AddNoise = true ,
366384 NoiseSeed = e . Builder . Connections . Seed ,
367385 Steps = TotalSteps ,
368- Cfg = CfgScale ,
386+ Cfg = useFluxGuidance ? 1.0d : CfgScale ,
369387 SamplerName = primarySampler . Name ,
370388 Scheduler = primaryScheduler . Name ,
371389 Positive = conditioning . Positive ,
0 commit comments