### Define 10 Pixel Guide Format Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1063_Custom_Guide_Format.md This snippet illustrates the basic structure for defining a guide named '10 Pixels' in the custom guide format. It shows how to declare a 'Guide' object and its initial properties. ```custom Guide { Name = '10 Pixels', Elements = { } ``` -------------------------------- ### Define Safe Frame Guide with Lines Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1063_Custom_Guide_Format.md This snippet demonstrates how to define a 'Safe Frame' guide using the custom format. It includes examples of horizontal and vertical lines with specified positions, patterns, and colors. ```custom Guide { Name = 'Safe Frame', Elements = { HLine { Y1='10%', Pattern = 0xF0F0 }, HLine { Y1='90%', Pattern = 0xF0F0 }, HLine { Y1='95%' }, HLine { Y1='5%' }, VLine { X1='10%', Pattern = 0xF0F0 }, VLine { X1='90%', Pattern = 0xF0F0 }, VLine { X1='95%' }, VLine { X1='5%' }, HLine { Y1='50%', Pattern = 0xF0F0, Color = { R = 1.0, G = 0.75, B = 0.05, A=1.0 } }, VLine { X1='50%', Pattern = 0xF0F0, Color = { R = 1.0, G = 0.75, B = 0.05, A=1.0 } }, } } ``` -------------------------------- ### Batch Motion Tracking with Fusion CLI Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This example shows how to initiate a batch motion tracking operation using the Fusion Studio command-line interface (CLI). It specifies the project file to be processed. ```bash # Using Fusion Studio command line to batch track "C:\\Program Files\\Blackmagic Design\\Fusion 20\\Fusion.exe" /comp "C:\\projects\\shot001.comp" /track # Interactive tracking workflow: # 1. Add Tracker node after footage # 2. Position tracker in viewer over feature # 3. Set search width/height for motion range # 4. Click Track Forward button ``` -------------------------------- ### Lua: Programmatic Tracking Setup in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This script demonstrates how to programmatically set up and run a tracker node in Fusion. It loads footage, configures tracker parameters, and initiates tracking. The output is analyzed frame data. ```lua -- Programmatic tracking setup comp = fu:GetCurrentComp() loader = comp:AddTool("Loader") loader.Clip = "C:/footage/plate.mov" tracker = comp:AddTool("Tracker") tracker.Input = loader.Output -- Configure tracker 1 tracker:SetInput("Tracker1.Center", {0.5, 0.5}, 0) tracker:SetInput("Tracker1.Width", 0.1) tracker:SetInput("Tracker1.Height", 0.1) tracker:SetInput("Tracker1.AdaptiveMode", 1) -- Track automatically tracker:DoAction("Track1Forward") -- Output: Tracker analyzes frames and generates position data ``` -------------------------------- ### Basic Command Line Rendering with Fusion Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/301_Command_Line_Rendering.md Example of invoking the Fusion Render Node from the command line to render a specific composition and frame range. This command starts the render node, specifies the composition file, initiates rendering from frame 101 to 110, and then quits upon completion. It's useful for automated workflows and integration with render farm managers. ```Shell //pathtoRN/FusionRenderNode.exe //pathtoProject/exampleV001.comp -render -start 101 -end 110 -quit ``` -------------------------------- ### Frame Range Export with FusionScript (Python) Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt Provides a Python script example for exporting a specific frame range from a Fusion composition. It shows how to connect to Fusion via DaVinci Resolve scripting, set the start and end frames for rendering, configure the output format to EXR, and specify the output path. ```python # Python scripting example for frame range export import DaVinciResolveScript as dvr resolve = dvr.scriptapp("Resolve") fusion = resolve.Fusion() comp = fusion.GetCurrentComp() # Get frame range from user start_frame = 1001 end_frame = 1100 # Find Saver node savers = comp.GetToolList(False, "Saver").values() for saver in savers: # Configure frame range comp.SetAttrs({"COMPN_RenderStart": start_frame}) comp.SetAttrs({"COMPN_RenderEnd": end_frame}) # Set output format saver.SetAttrs({"OutputFormat": "exr"}) saver.Clip = f"//server/renders/shot_{start_frame:04d}-{end_frame:04d}.exr" # Execute render comp.Render() # Output: Frames 1001-1100 rendered as EXR sequence to network path ``` -------------------------------- ### Fusion Server Command Line Arguments Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/301_Command_Line_Rendering.md Demonstrates command line arguments for managing the Fusion Server, including installation as a service and running it persistently in the background. These commands are essential for setting up license servers and ensuring background availability. ```Shell Fusion Server -i Fusion Server -S ``` -------------------------------- ### Batch script for copying files Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5190_Example.md This batch script copies a source file to a destination. It takes two parameters: the source file path and the destination file path. Ensure this script is saved as 'copyfile.bat' in your C directory. ```batch @echo off set parm=%1 %2 copy %1 %2 set parm= ``` -------------------------------- ### Optimized Rotation with Setup and Intermediate Expressions (Fusion) Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5143_Rotation.md Demonstrates optimizing rotation calculations in Fusion using Setup and Intermediate expressions. Setup expressions (s1, s2) calculate constants like cos(n1) and sin(n1) once per frame. Intermediate expressions (i1, i2) use these constants to calculate the rotated coordinates once per pixel, improving performance by reducing redundant calculations. ```Fusion Script s1 = cos(n1) s2 = sin(n1) i1 = x * s1 - y * s2 i2 = x * s2 + y * s1 getr1b(i1, i2) ``` -------------------------------- ### Handling Image Sequences (Fusion) Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/4334_Filename.md This example illustrates how Fusion recognizes and loads image sequences based on numeric file naming conventions. It assumes a common setup where image sequences are prevalent in compositing workflows. ```fusion or image151.exr , image152.exr, image153.exr … ``` -------------------------------- ### Fusion Rectangle Drawing with Patterns Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1065_Examples_for_such_patterns_include:.md Illustrates how to draw a rectangle in Fusion, supporting pattern and color settings. It requires two X and two Y values for extent and specifies a pattern using the Rectangle attribute. ```Fusion Script ``` -------------------------------- ### Run Command node script for file copying Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5190_Example.md This command, to be entered into Fusion's Run Command node, executes the 'copyfile.bat' script to copy the rendered frame. It passes the source file path (Saver output) and the destination path as arguments to the batch script. This ensures that the file is copied only after the Saver has finished writing the frame. ```batch copyfile.bat "D:\test0000.exr" "C:\destination\path\test0000.exr" ``` -------------------------------- ### Fusion Render Node Command Line Arguments Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/301_Command_Line_Rendering.md Provides examples of various command line arguments for the Fusion Render Node to control rendering behavior, frame ranges, logging, and process priority. These arguments allow for fine-grained control over render jobs. ```Shell -frames -start -end -step -quit -join -listen -log -cleanlog -verbose -quiet -version -pri high|above|normal|below|idle -args [, ...] ``` -------------------------------- ### Fusion Line Drawing Patterns Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1065_Examples_for_such_patterns_include:.md This snippet demonstrates various line drawing patterns in Fusion, including solid, dashed, dash-dot, dash-dot-dot, and dotted lines. These patterns are defined using specific character sequences. ```Fusion Script >>FFFF draws a solid line ________________ >>EEEE a dashed line ------------------>>ECEC dash-dot line -.-.-.-.-.-.-.-.-.-.-. >>ECCC dash-dot-dot -..-..-..-..-..-..-.. >>AAAA dotted line …………… ``` -------------------------------- ### Fusion Color Definition Example Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1065_Examples_for_such_patterns_include:.md Explains the structure of a Color value in Fusion, composed of four pairs of hex values. The first three pairs represent RGB, and the last pair represents transparency. Provides examples for pure red and lime green. ```Fusion Documentation The Color value is composed of four groups of two hex values each. The first three groups define the RGB colors; the last group defines the transparency. For instance, the hex value for pure red would be #FF000000, and pure lime green would be #00FF0000 ``` -------------------------------- ### Fusion Rectangle Fill Color Example Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1065_Examples_for_such_patterns_include:.md Specifies the FillColor attribute for rectangles in Fusion, defining the color of the filled area as determined by FillMode. An example of red with transparency is provided. ```Fusion Script >>FillColor='FF000020' ``` -------------------------------- ### Lua: Animated Gradient Background Creation in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This script details the creation of an animated gradient background using the Background node in Fusion via Lua. It sets resolution, defines gradient colors, and animates the start and end points of the gradient over time. ```lua -- Create animated gradient background comp = fu:GetCurrentComp() bg = comp:AddTool("Background") -- Set resolution bg:SetInput("Width", 1920) bg:SetInput("Height", 1080) bg:SetInput("Depth", 1) -- 8-bit per channel -- Configure gradient bg:SetInput("Type", "Gradient") bg:SetInput("Gradient", { Colors = { [0] = {0.1, 0.1, 0.3, 1}, -- Dark blue [0.5] = {0.5, 0.2, 0.6, 1}, -- Purple [1] = {0.9, 0.5, 0.2, 1} -- Orange } }) -- Animate gradient position bg:SetInput("Start", {0.5, 0}, 0) bg:SetInput("Start", {0.5, 1}, 100) bg:SetInput("End", {0.5, 1}, 0) bg:SetInput("End", {0.5, 0}, 100) -- Output: Animated gradient transitioning through color spectrum ``` -------------------------------- ### Define Horizontal Line Style (Fusion) Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1064_Guide_Styles.md Defines a horizontal line for guide styles. Requires a Y-value (percentage or pixels) and can include pattern and color attributes for visual customization. ```FusionGuideStyle ``` -------------------------------- ### Disparity Vector Mapping Example Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1849_Vector_and_Disparity_Channels.md Illustrates the mathematical relationship between disparity vectors in left and right images for mapping pixels between stereo views. This example shows how to calculate corresponding pixel coordinates in the other eye using disparity values. ```text (xleft, yleft) + (Dleft. x, Dleft. y) -> (xright, yright) (xright, yright) + (Dright. x, Dright. y) -> (xleft, yleft) ``` -------------------------------- ### Fusion Simple Expressions: Basic Syntax and Examples Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md This snippet demonstrates the basic syntax and common expressions used in Fusion's Simple Expressions. These expressions can be used to drive parameter values, reference other parameters, or implement conditional logic. They are written in Lua with Fusion-specific shorthand. ```lua time Merge1.Blend Merge1:GetValue("Blend", time-5) sin(time/20)/2+.5 iif(Merge1.Blend == 0, 0, 1) iif(Input.Metadata.ColorSpaceID == "sRGB", 0, 1) ``` -------------------------------- ### Dynamic Parameter Linking with SimpleExpressions (Lua) Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt Explains how to use SimpleExpressions in Fusion to create dynamic parameter relationships using inline Lua scripts. Examples include creating pulsating text size with a sine wave, linking text position to another node's blend value, time-offsetting parameters, and using conditional expressions for automated behavior based on metadata or other parameter values. ```lua -- Create pulsating animation using sine wave comp = fu:GetCurrentComp() text = comp:AddTool("TextPlus") text.StyledText = "PULSE" -- Add SimpleExpression to Size parameter -- In UI: Enter "=" in Size field, then type: -- sin(time/20)/2+0.5 -- Link text position to another node's blend value merge = comp:AddTool("Merge") -- In Text+ Center.X field: Merge1.Blend * 0.8 + 0.1 -- Time-offset parameter reference -- In parameter field: Merge1:GetValue("Blend", time-5) -- Conditional expression for automated behavior -- In parameter field: iif(Merge1.Blend > 0.5, 1, 0) -- Metadata-based color space detection -- In parameter field: iif(Input.Metadata.ColorSpaceID == "sRGB", 0, 1) -- Output: Parameters update automatically based on expressions ``` -------------------------------- ### Fusion Script: Get Current Date and Time Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Retrieves the current date and time formatted as hours and minutes using the OS library. This is a common requirement for timestamps in logs or rendered output. ```Lua os.date("%H:%M") ``` -------------------------------- ### Fusion Rectangle Fill Mode Options Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1065_Examples_for_such_patterns_include:.md Defines the FillMode attribute for rectangles in Fusion, which determines whether the inside or outside of the rectangle is filled. Options include 'None', 'Inside', and 'Outside'. ```Fusion Script >>FillMode = ('None'|'Inside'|'Outside') ``` -------------------------------- ### Fusion Script: Calculate Point with Y-Axis Offset Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Returns a Point object representing a location relative to another element's center. This example calculates a point 1/10 of the image height below the center of 'Text1', useful for creating linked positional animations. ```Lua Point(Text1.Center.X, Text1.Center.Y-.1) ``` -------------------------------- ### 2D Rotation using Fusion Expressions Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5143_Rotation.md Applies a 2D rotation to an image using Fusion's expression system. It utilizes the 'getr1b' function to sample the source image at rotated coordinates. The angle is controlled by the 'n1' slider. This example shows the basic rotation around the origin. ```Fusion Script getr1b(x * cos(n1) - y * sin(n1), x * sin(n1) + y * cos(n1)) ``` -------------------------------- ### Fusion Expression for Directional Blur Length Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/780_An_Example_of_Customizing_Directional_Blur.md This expression calculates the blur length based on the Center control's position. It uses the distance from the Center point in the viewer to determine the blur magnitude, providing an intuitive way to control the effect's intensity. It assumes a standard Fusion composition setup. ```Fusion Script -sqrt(((Center.X-.5)*(Input.XScale))^2+((Center.Y-.5)*(Input.YScale)*(Input. Height/Input. Width))^2) ``` -------------------------------- ### Fusion Custom Tool: Red Channel Averaging Expression Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5145_1.0_h1.md This Fusion expression calculates the average value of the red channel for a 3x3 pixel neighborhood around the current pixel. It uses the getr1w() function to sample pixels and sums them up, dividing by 9 to get the average. It also includes the original red channel value (r1). ```Fusion Script (getr1w(x-s1, y-s2) + getr1w(x, y-s2) + getr1w(x+s1, y-s2) + getr1w(x+s1, y) + getr1w(x-s1, y) + r1 +getr1w(x-s1, y+s2) + getr1w(x, y+s2) + getr1w(x+s1, y+s2)) / 9 ``` -------------------------------- ### Fusion Expression for Directional Blur Angle Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/780_An_Example_of_Customizing_Directional_Blur.md This expression calculates the blur angle based on the Center control's position. It utilizes the atan2 function to determine the angle derived from the Center control's coordinates relative to the viewer's center. This allows for directional control of the blur. It assumes a standard Fusion composition setup and requires the 'pi' variable to be defined or accessible. ```Fusion Script atan2(Center.Y-.5)/(Input.OriginalWidth/Input.X , .5-Center.X) * 180 / pi ``` -------------------------------- ### Configuring Network Bins Server Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt Provides instructions on how to set up a Bin Server for collaborative workflows in Fusion Studio. This involves configuring the Bin Server port within the Fusion preferences on the network host machine. ```bash # Configure Bin Server on network host # Edit Fusion preferences: Bins > Network > Bin Server Port: 1234 ``` -------------------------------- ### Set Fusion License Server via Environment Variable (Fusion Script) Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/270_Setting_Up_a_License_Server_with_Environment_Varia.md This script snippet demonstrates how to set the FUSION_LICENSE_SERVER environment variable using Fusion's scripting functions. It allows specifying multiple license servers or performing a broadcast search. Ensure correct quoting. ```Fusion Script fu:SetPrefs("Global.EnvironmentVars.FUSION_LICENSE_SERVER", "192.168.1.12; 192.168.10.55;*") fu:SavePrefs() ``` ```Fusion Script fu:SetPrefs("Global.EnvironmentVars.FUSION_LICENSE_SERVER", "10.0.0.23;*") fu:SavePrefs() ``` -------------------------------- ### 3D Scene Rendering with Renderer 3D Node Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt Demonstrates creating a 3D scene with a camera, image plane, and lighting, then rendering it to a 2D image using either OpenGL or software rendering. This involves setting up scene geometry, camera properties, and renderer settings like supersampling and shadows. ```lua -- Create basic 3D scene with camera and render comp = fu:GetCurrentComp() -- Create 3D camera cam = comp:AddTool("Camera3D") cam.Transform3DOp.Translate.X[0] = 0 cam.Transform3DOp.Translate.Y[0] = 0 cam.Transform3DOp.Translate.Z[0] = -5 cam.AoV = 45 -- Field of view -- Create 3D image plane imgplane = comp:AddTool("ImagePlane3D") loader = comp:AddTool("Loader") loader.Clip = "C:/textures/wall.jpg" imgplane.Input = loader.Output -- Merge 3D elements merge3d = comp:AddTool("Merge3D") merge3d.SceneInput1 = cam.Output merge3d.SceneInput2 = imgplane.Output -- Render to 2D renderer = comp:AddTool("Renderer3D") renderer.Input = merge3d.Output renderer.Camera = cam.Output renderer.RendererType = "RendererOpenGL" -- or "RendererSoftware" renderer.SoftwareSSAA = 4 -- Supersampling renderer.Lighting = true renderer.Shadows = "On" -- Output: 2D rendered image from 3D scene with lighting and shadows ``` -------------------------------- ### Render Output with Lua in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This Lua script shows how to create a Saver node in Fusion, define the output file path and format (e.g., EXR sequence), configure compression, and initiate the rendering process. It supports specifying frame ranges and output formats. ```lua -- Create Saver node and configure output comp = fu:GetCurrentComp() saver = comp:AddTool("Saver", -32768, -32768) saver.Clip = "C:/render/output.[0000-0100].exr" -- Configure format and compression saver:SetAttrs({ TOOLB_PassThrough = false, TOOLST_Clip_ForceRes = true, }) saver.ProcessMode = "On" saver.OutputFormat = "exr" saver.Compression = "ZIP (1 scanline)" -- Render the composition comp:Render() -- Output: Renders frames 0-100 as compressed EXR sequence ``` -------------------------------- ### Load Media with Lua in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This script demonstrates how to add a Loader node in Fusion using Lua, specify a footage clip (including image sequences), set the frame range, and configure looping. It also shows how to set attributes like pixel aspect ratio. ```lua comp = fu:GetCurrentComp() loader = comp:AddTool("Loader", -32768, -32768) loader.Clip = "C:/footage/sequence.[0001-0100].exr" loader.GlobalIn = 1 loader.GlobalOut = 100 loader.Loop = 1 -- Enable looping -- Set field order and pixel aspect loader:SetAttrs({TOOLB_PassThrough = false}) loader.ImageFormat.PixelAspect = {1.0, 1.0} -- Output: Loader node created at specified position with footage loaded ``` -------------------------------- ### Fusion Connect Workflow with Avid Media Composer Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This Bash script outlines the steps for using Fusion Connect to export Avid Media Composer timeline clips as image sequences for VFX work in Fusion Studio. It details the export configuration in Avid and the expected directory structure for rendered assets. ```bash # In Avid Media Composer: # 1. Select clip(s) in timeline # 2. Apply Effect > Fusion Connect (from AVX2 plugins) # 3. Configure export settings: # - Render Location: \\vfx-server\renders\ # - Format: OpenEXR 16-bit # - Frame Range: Handles +8 frames # 4. Click Export # 5. Fusion Studio launches automatically (if installed) # Expected output directory structure: # \\vfx-server\renders\ # └── SequenceName_V1\ # ├── shot001\ # │ ├── shot001.comp # Fusion composition # │ ├── shot001_A.exr # Layer A frames # │ └── shot001_B.exr # Layer B frames # └── shot002\ # └── ... # After VFX work in Fusion: # 1. Render composition via Saver node to same directory # 2. Return to Avid Media Composer # 3. Fusion Connect auto-imports rendered frames to timeline # 4. Refresh Fusion Connect effect to update with new renders ``` -------------------------------- ### Creating Particle Systems with pEmitter and pRender Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt Details the creation of particle systems for dynamic effects like fire or smoke. It covers setting up particle emission properties such as count and lifespan, defining particle appearance and size over life, and rendering the particles with motion blur, compositing them over a background. ```lua -- Create particle system with emitter comp = fu:GetCurrentComp() -- Particle emitter emitter = comp:AddTool("pEmitter") emitter.Number = 100 -- Particles per frame emitter.Lifespan = 50 emitter.LifespanVariance = 10 emitter.VelocityY = 0.05 emitter.VelocityVariance = 0.02 -- Particle appearance pimage = comp:AddTool("pImageEmitter") pimage.Input = emitter.Output pimage.Style = "ParticleStyle.BlobbyParticle" pimage.Size = 0.01 pimage.SizeOverLife[0] = {0, 0.01} pimage.SizeOverLife[1] = {1, 0.001} -- Particle rendering prender = comp:AddTool("pRender") prender.Input = pimage.Output prender.Width = 1920 prender.Height = 1080 prender.MotionBlur = 1.0 -- Composite over background bg = comp:AddTool("Background") merge = comp:AddTool("Merge") merge.Background = bg.Output merge.Foreground = prender.Output merge.BlendMode = "Add" -- Output: Rising particle stream with motion blur composited additively ``` -------------------------------- ### Fusion Script: Generate Dynamic Text with Date, Time, and System Info Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Constructs a detailed text string by concatenating literal text with the current date, time, computer name, operating system, and composition filename. This allows for dynamic logging or status displays. ```Lua Text("Rendered "..os.date("%b %d, %Y").." at "..os.date("%H:%M").."\n on the computer "..os.getenv("COMPUTERNAME").." running "..os.getenv("OS").."\n from the comp "..ToUNC(comp.Filename)) ``` -------------------------------- ### Lua: Animated Text+ Node Creation in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This script shows how to create and animate text using the Text+ node in Fusion via Lua. It covers setting text content, font, size, color gradients, and applying a drop shadow, with animation on the text's position. ```lua -- Create animated text with styling comp = fu:GetCurrentComp() text = comp:AddTool("TextPlus") -- Set basic text properties text:SetInput("StyledText", "FUSION 20") text:SetInput("Font", "Arial") text:SetInput("Size", 0.15) text:SetInput("Tracking", 1.05) -- Enable and configure shading text:SetInput("ShadingGradient1", 1) text:SetInput("ColorGradient1", { Colors = { [0] = {1, 0, 0, 1}, -- Red [1] = {0, 0, 1, 1} -- Blue } }) -- Animate position text.Center[0] = {0.5, 0.8} text.Center[100] = {0.5, 0.2} -- Add drop shadow text:SetInput("ShadowEnabled", 1) text:SetInput("ShadowOffset", {0.02, -0.02}) text:SetInput("ShadowBlur", 0.01) -- Output: Gradient text animates from top to bottom with shadow ``` -------------------------------- ### Create Fusion Macro from Node Selection Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This Lua script demonstrates how to group selected nodes in a Fusion composition, create a macro from them, and save it to disk for reusability. It assumes the user has selected the nodes they wish to include in the macro. ```lua comp = fu:GetCurrentComp() -- Select nodes to include (e.g., blur + color correction + merge) blur = comp:AddTool("Blur") cc = comp:AddTool("ColorCorrector") merge = comp:AddTool("Merge") blur.Output:ConnectTo(cc.Input) cc.Output:ConnectTo(merge.Input) -- Select all three nodes, right-click > Macro > Create Macro -- Or via script: comp:Copy({blur, cc, merge}) comp:Paste() macro_group = comp:Paste() -- Paste as macro -- Save macro to disk macro_path = "C:/Users/username/AppData/Roaming/Blackmagic Design/DaVinci Resolve/Fusion/Macros/GlowEffect.setting" comp:SaveAs(macro_path) -- Output: Reusable macro appears in Effects Library > Macros category ``` -------------------------------- ### Batch Processing Compositions with FusionScript (Lua) Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt Illustrates how to automate batch processing of multiple Fusion compositions using Lua scripting. The script iterates through a list of composition files, finds 'Saver' nodes within each, updates their output paths to replace 'draft' with 'final', and then renders and saves each composition. ```lua -- Batch process multiple compositions fusion = Fusion() -- Define composition files comp_files = { "C:/projects/shot001.comp", "C:/projects/shot002.comp", "C:/projects/shot003.comp" } -- Process each composition for i, filepath in ipairs(comp_files) do print("Processing: " .. filepath) comp = fusion:LoadComp(filepath) -- Find all Saver nodes savers = comp:GetToolList(false, "Saver") for j, saver in pairs(savers) do -- Update render paths local oldpath = saver.Clip[1] local newpath = oldpath:gsub("draft", "final") saver.Clip = newpath end -- Render composition comp:Render() comp:Save() comp:Close() print("Completed: " .. filepath) end -- Output: All compositions rendered with updated output paths ``` -------------------------------- ### Compositing Layers with Lua in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This Lua script illustrates how to composite two image layers (background and foreground) using the Merge node in Fusion. It covers connecting loader nodes to the merge node, setting blend modes, and animating the blend amount over time. ```lua -- Create basic composite setup comp = fu:GetCurrentComp() bg = comp:AddTool("Loader") bg.Clip = "C:/plates/background.exr" fg = comp:AddTool("Loader") fg.Clip = "C:/plates/foreground.exr" merge = comp:AddTool("Merge") merge.Background = bg.Output merge.Foreground = fg.Output merge.Blend = 1.0 merge.Operator = "Over" -- Standard over composite merge.ApplyMode = "Multiply" -- Blend mode -- Animate blend over time merge.Blend[0] = 0.0 merge.Blend[100] = 1.0 -- Output: Foreground composited over background with multiply blend ``` -------------------------------- ### Matrix Default Settings Mathematical Representation Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/3237_Matrix.md This represents the default settings of the matrix operation in mathematical equations. It shows how input channels are multiplied by coefficients and summed to produce output channels. There are no external dependencies, and it takes input channel values to produce output channel values. ```mathematics [R out] = 1 * [R in] + 0 * [G in] + 0 * [B in] + 0 * [A in] + 0 [G out] = 0 * [R in] + 1 * [G in] + 0 * [B in] + 0 * [A in] + 0 [B out] = 0 * [R in] + 0 * [G in] + 1 * [B in] + 0 * [A in] + 0 [A out] = 0 * [R in] + 0 * [G in] + 0 * [B in] + 1 * [A in] + 0 ``` -------------------------------- ### Fusion Script: Read Environment Variables Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Accesses system environment variables, such as the computer name and operating system name, using the OS library. This enables dynamic configuration based on the execution environment. ```Lua ..os.getenv("COMPUTERNAME").." running "..os.getenv("OS")) ``` -------------------------------- ### Fetching Color Channels with Optimized Rotation (Fusion) Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5143_Rotation.md Shows how to fetch the red, green, blue, and alpha channels of an image using optimized rotation calculations in Blackmagic Fusion. It leverages pre-calculated intermediate expressions (i1, i2) for the rotated coordinates to efficiently sample the source image. ```Fusion Script getr1b(i1, i2) getg1b(i1, i2) getb1b(i1, i2) geta1b(i1, i2) ``` -------------------------------- ### Transform Images with Lua in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This Lua script demonstrates how to use the Transform node in Fusion to manipulate image properties such as position, scale, and rotation. It also shows how to animate these properties over time and enable motion blur. ```lua -- Create and animate transform comp = fu:GetCurrentComp() loader = comp:AddTool("Loader") loader.Clip = "C:/elements/logo.png" xf = comp:AddTool("Transform") xf.Input = loader.Output -- Set initial position and scale xf.Center = {0.5, 0.5} xf.Size = 0.5 -- Animate position across screen xf.Center[0] = {0.1, 0.5} xf.Center[100] = {0.9, 0.5} -- Animate rotation xf.Angle[0] = 0 xf.Angle[100] = 360 -- Enable motion blur xf:SetAttrs({TOOLB_MotionBlur = true}) xf.MotionBlur = 1.0 -- Output: Logo moves left to right with full rotation and motion blur ``` -------------------------------- ### Create Fusion Composition from DaVinci Resolve Clip via Python Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This Python script utilizes the DaVinci Resolve Scripting API to create a Fusion composition from a selected clip on the timeline. It demonstrates how to add basic VFX nodes like Blur and Merge, connect them, and update the composition. The script assumes the DaVinci Resolve Scripting API is accessible. ```python import DaVinciResolveScript as dvr resolve = dvr.scriptapp("Resolve") project = resolve.GetProjectManager().GetCurrentProject() timeline = project.GetCurrentTimeline() # Get selected clip on timeline track_item = timeline.GetCurrentVideoItem() if track_item: # Create Fusion composition from clip clip_created = track_item.AddFusionComp() if clip_created: # Switch to Fusion page resolve.OpenPage("fusion") # Access Fusion composition fusion = resolve.Fusion() comp = fusion.GetCurrentComp() # MediaIn nodes automatically created for timeline clip media_in = comp.GetToolList(False, "MediaIn") # Add VFX nodes blur = comp.AddTool("Blur", -32768, -32768) merge = comp.AddTool("Merge") media_out = comp.GetToolList(False, "MediaOut") # Connect nodes for key, mi in media_in.items(): blur.Input = mi.Output break merge.Foreground = blur.Output for key, mo in media_out.items(): mo.Input = merge.Output break print("Fusion comp created and configured") # Switch back to Edit page when done # resolve.OpenPage("edit") ``` -------------------------------- ### Lua: Animated Polygon Mask Creation in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This script illustrates the creation of an animated polygon mask using Fusion's Lua scripting. It defines a mask's shape and animates its points over time, which can then be applied to footage for rotoscoping or effects. ```lua -- Create polygon mask with animated points comp = fu:GetCurrentComp() mask = comp:AddTool("PolygonMask") -- Define initial shape (pentagon) mask:SetAttrs({TOOLB_ShowPath = true}) mask:SetInput("MaskWidth", 1920) mask:SetInput("MaskHeight", 1080) -- Add polygon points at frame 0 polyline = mask:GetInput("Polyline") polyline:SetKeyFrame(0, { Points = { {0.5, 0.3}, {0.7, 0.5}, {0.6, 0.7}, {0.4, 0.7}, {0.3, 0.5}, {0.5, 0.3} }, Closed = true }) -- Animate shape at frame 50 polyline:SetKeyFrame(50, { Points = { {0.5, 0.2}, {0.8, 0.5}, {0.5, 0.8}, {0.2, 0.5}, {0.5, 0.2} }, Closed = true }) -- Apply mask to footage loader = comp:AddTool("Loader") loader.Clip = "C:/footage/subject.exr" loader.EffectMask = mask.Mask -- Output: Animated polygon mask applied to footage ``` -------------------------------- ### Fusion Script: Format Text with Newlines and UNC Paths Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Demonstrates how to insert newline characters (`\n`) within text strings and access composition attributes like the filename, converting it to a Universal Naming Convention (UNC) path. This is useful for creating multi-line text elements and referencing files on a network. ```Lua "\n from the comp "..ToUNC(comp.Filename)) ``` -------------------------------- ### Pixel Access Methods in Fusion Custom Tools Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5141_Custom_Tool_Node_Syntax.md Demonstrates different methods for reading pixel values from image inputs within Fusion custom tools. These methods handle out-of-bounds access by returning 0, the edge pixel, or by wrapping around the image. ```Fusion Script getr1b(x,y) -- Outputs the red value of the pixel at position x, y, returning 0.0 if out of bounds. getr1d(x,y) -- Outputs the red value of the pixel at position x, y, using the edge pixel if out of bounds. getr1w(x,y) -- Outputs the red value of the pixel at position x, y, wrapping around if out of bounds. geta2b(0.5, 0.5) -- Outputs the alpha value of the pixel at the center (0.5, 0.5) of image input 2, returning 0.0 if out of bounds. ``` -------------------------------- ### Fusion Script: Offset Point Input Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Applies a positional offset to a point. This expression subtracts a Point offset from 'Text1.Center', returning a new Point value. This is a simpler way to achieve positional links compared to individual X and Y manipulation. ```Lua Text1.Center - Point(0,.1) ``` -------------------------------- ### Fusion Script: Concatenate Text and Metadata Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1003_Using_SimpleExpressions.md Combines literal strings with dynamic metadata, such as ColorSpaceID, to create informative text outputs. This is useful for labeling or displaying properties of media elements. ```Lua Text("Colorspace: "..(Merge1.Background.Metadata.ColorSpaceID)) ``` -------------------------------- ### Lua: Color Correction with ColorCorrector Node in Fusion Source: https://context7.com/apvlv/blackmagic-fusion-20-docs/llms.txt This script demonstrates applying color correction to footage using the ColorCorrector node in Fusion via Lua. It adjusts master RGB gain and gamma, saturation, and suppresses specific hues, like a blue screen. ```lua -- Apply color correction to footage comp = fu:GetCurrentComp() loader = comp:AddTool("Loader") loader.Clip = "C:/footage/raw_plate.exr" cc = comp:AddTool("ColorCorrector") cc.Input = loader.Output -- Master adjustments cc:SetInput("MasterRGBGain", {1.2, 1.1, 1.0, 1}) cc:SetInput("MasterRGBGamma", {1.0, 0.95, 0.9, 1}) cc:SetInput("MasterRGBLift", {0, -0.05, -0.1, 1}) -- Adjust saturation cc:SetInput("Saturation", 1.3) -- Suppress specific color (blue screen) cc:SetInput("SuppressionEnabled", 1) cc:SetInput("SuppressionHue", 0.58) -- Blue hue cc:SetInput("SuppressionRange", 0.15) cc:SetInput("SuppressionAmount", 0.5) -- Output: Color corrected image with enhanced warmth and reduced blue ``` -------------------------------- ### Operator Mode Formulas in Fusion 20 Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/3790_Operator.md This snippet shows the mathematical formulas for 'x' and 'y' that define the behavior of different operator modes in Blackmagic Fusion 20. These formulas dictate how foreground and background pixels are blended. ```plaintext x = 1, y = 1 - [foreground object Alpha] ``` ```plaintext x = [background Alpha], y = 0 ``` ```plaintext x = 1 - [background Alpha], y = 0 ``` ```plaintext x = [background Alpha], y = 1 - [foreground Alpha] ``` ```plaintext x = 1 - [background Alpha], y = 1 - [foreground Alpha] ``` -------------------------------- ### Fusion Duplicate Node - XOr Operator Mode Formulas Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/3640_Operator.md This snippet shows the formulas for the 'XOr' operation mode in the Fusion Duplicate node. It presents multiple conditions for combining foreground and background objects based on their alpha channels, where pixels are included if either has a matte but not if both do. ```text x = 1 - [background Alpha], y = 0 ``` ```text x = [background Alpha], y = 1 - [foreground Alpha] ``` ```text x = 1 - [background Alpha], y = 1-[foreground Alpha] ``` -------------------------------- ### Fusion Operator Mode Formulas Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/3397_The_Operator_modes_are_as_follows:.md Mathematical representations of different operator modes in Blackmagic Fusion. These formulas define how foreground and background layers are combined based on their alpha channels. They are crucial for understanding and implementing custom compositing operations. ```text Over: x = 1, y = 1-[foreground Alpha] ``` ```text In: x = [background Alpha], y = 0 ``` ```text Held Out: x = 1-[background Alpha], y = 0 ``` ```text Atop: x = [background Alpha], y = 1-[foreground Alpha] ``` ```text XOr: x = 1-[background Alpha], y = 1-[foreground Alpha] ``` ```text Conjoint: X= 1, Y= X+Y(1-af)/ab, if af>ab ``` -------------------------------- ### Accessing LUT Values with Expressions Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/1946_LUTs_1-4.md Demonstrates how to use the `getlut#` functions within expressions to retrieve values from the Custom Vertex 3D node's LUT splines. These functions take a float input between 0 and 1 and return a height value from the corresponding LUT. This allows for dynamic control of node properties based on LUT data. ```Fusion Script getlut1(float x) getlut2(float x) getlut3(float x) getlut4(float x) ``` ```Fusion Script R = getlut1(r1) G = getlut2(g1) B = getlut3(b1) A = getlut4(a1) ``` -------------------------------- ### Fusion Custom Tool: Green, Blue, and Alpha Channel Averaging Expressions Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5145_1.0_h1.md These Fusion expressions similarly calculate the average values for the green, blue, and alpha channels using their respective sampling functions (getg1w, getb1w, geta1w) and the original channel values (g1, b1, a1). Each expression averages a 3x3 neighborhood. ```Fusion Script (getg1w(x-s1, y-s2) + getg1w(x, y-s2) + getg1w(x+s1, y-s2) + getg1w(x+s1, y) + getg1w(x-s1, y) + g1 +getg1w(x-s1, y+s2) + getg1w(x, y+s2) + getg1w(x+s1, y+s2)) / 9 ``` ```Fusion Script (getb1w(x-s1, y-s2) + getb1w(x, y-s2) + getb1w(x+s1, y-s2) + getb1w(x+s1, y) + getb1w(x-s1, y) + b1 +getb1w(x-s1, y+s2) + getb1w(x, y+s2) + getb1w(x+s1, y+s2)) / 9 ``` ```Fusion Script (geta1w(x-s1, y-s2) + geta1w(x, y-s2) + geta1w(x+s1, y-s2) + geta1w(x+s1, y) + geta1w(x-s1, y) + a1 + geta1w(x-s1, y+s2) + geta1w(x, y+s2) + geta1w(x+s1, y+s2)) / 9 ``` -------------------------------- ### Fusion Custom Tool: Pixel Sampling Expressions Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/5145_1.0_h1.md These expressions are evaluated at the beginning of each frame in Fusion's Custom Tool node. They define variables 's1' and 's2' representing the distance between pixels along the width and height, respectively. These are crucial for sampling adjacent pixels accurately. ```Fusion Script s1 = 1.0 / width s2 = 1.0 / height ``` -------------------------------- ### Custom Node Equation for Black Rolloff Scaling Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/3853_Black_Rolloff.md This equation is used within a Custom node in Blackmagic Fusion to scale very small color values (between 0.0 and 1e-16) to a slightly different range (1e-18 to 1e-16). It ensures that values below a certain threshold are processed to create a gentle ramp in extreme black levels. The input 'c1' represents the color channel value. ```fusion if (c1< 1e-16, 1e-18 + (c1/1e-16)*(1e-16 - 1e-18), c1) ``` -------------------------------- ### Hypotenuse Blend Mode Formula Source: https://github.com/apvlv/blackmagic-fusion-20-docs/blob/main/docs/3396_Compositing_Mode_and_Adjustment_Controls.md This blend mode is designed for HDR images with out-of-range colors above 1. It calculates the output color by taking the square root of the sum of the squares of the foreground and background color components. ```text Out = sqrt (Fc*Fc +Bc*Bc) ```