Jump to: Board index » General » Fusion

How to draw by numbers (scripting question)

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

wolfgang hershey

  • Posts: 166
  • Joined: Sun Feb 07, 2016 12:41 am
  • Location: chinatowns everywhere

How to draw by numbers (scripting question)

PostSun May 12, 2019 7:01 pm

Hello
all

I'm a happy Resolve editor and am trying to learn more about the power of FUSION

I'd like to see an example or two of how to programmatically draw on a frame
and if possible how to draw on multiple frames over time

i'm looking for the easiest
most simple way to draw a point or a line on a frame
(and then increment over time)

there seems to be a number of potential ways?
scripts / macros / expressions / fuses / openGL
(also lua vs python?)

all of which I'd like to see examples of

but to start just trying to see a simple 2D solution

I offer below a Processing (or p5) example
( see https://p5js.org/examples/structure-setup-and-draw.html )
imagine the task at hand is to develop a HUD for some comic book movie
and this drawn line is one of many that would be built up to create the full GFX

Code: Select all
let y = 100;

// The statements in the setup() function
// execute once when the program begins
function setup() {
  // createCanvas must be the first statement
  createCanvas(720, 400);
  stroke(255); // Set line drawing color to white
  frameRate(30);
}
// The statements in draw() are executed until the
// program is stopped. Each statement is executed in
// sequence and after the last line is read, the first
// line is executed again.
function draw() {
  background(0); // Set the background to black
  y = y - 1;
  if (y < 0) {
    y = height;
  }
  line(width/4, y, (width/2), y);
}
MacBook Pro (16-inch 2019)
OS X 13.3.1 (a) / 18.5 beta Resolve Studio - DeckLink Studio 4k via Thunderbolt3
64GB - AMD Radeon Pro 5500M 8GB
10Gb ethernet network
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to draw by numbers (scripting question)

PostSun May 12, 2019 10:27 pm

You certainly want to be looking into Fuse writing. It is, unfortunately, not well documented. The best way to learn is to tear apart existing Fuses and puzzle out what's happening in them.

The old VFXPedia (thoughtfully rescued by Pieter/SecondMan and hosted at the We Suck Less forums) has some examples that are nice for learning from:

https://www.steakunderwater.com/VFXPedi ... arty_Fuses

Note specifically the Lines Fuse.

There are also a few in Reactor that are good to learn from. Specifically, the FUI tools by Dunn Lewis.

I had started a series of coding tutorials for OpenCL Fuses, but I'm hesitant to recommend them now because as of version 16 you can't write directly in CL any more. There's a new abstract GPU language that compiles to OpenCL, Metal and CUDA. The OpenCL Fuses never ran under Resolve, and now they won't run in Fusion, either. Still, if you're interested in that obsolete work, the articles are here:

http://www.bryanray.name/wordpress/opencl-fuses-index/
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

wolfgang hershey

  • Posts: 166
  • Joined: Sun Feb 07, 2016 12:41 am
  • Location: chinatowns everywhere

Re: How to draw by numbers (scripting question)

PostMon May 13, 2019 2:55 pm

Thank you very much Bryan

That's a lot of good information

It's too bad there's not a simple drawing API
Akin to something like SVG, Cairo or Processing

From taking a quick look around it looks like it may be easier for me to deal with what I'm trying to do inside of a ofx plugin, at least I know I'll find a fair amount of documentation
So I'll definitely look into that

Thanks for the info about the fuses
yes it does seem really hard to find information
;-((

I hope you dont mind a couple more questions
Do you have any clues as to what this new meta GPU language is that they're using?

and nosing around in the app bundle leads me to the Guides
which seem to be the kind of high level drawing i'm looking for
is there any info about how the Guides are being drawn?
and do you link there would be a way to animate the guide settings?

thanks in advance
WH

Code: Select all
Guide
{
   Name = "Thirds",

   Elements =
   {
      HLine { Y1="33%", Pattern = 0xC0C0, Color = { R = 1.0, G = 1.0, B = 1.0, A = 1.0 } },
      HLine { Y1="67%", Pattern = 0xC0C0, Color = { R = 1.0, G = 1.0, B = 1.0, A = 1.0 } },
      VLine { X1="33%", Pattern = 0xC0C0, Color = { R = 1.0, G = 1.0, B = 1.0, A = 1.0 } },
      VLine { X1="67%", Pattern = 0xC0C0, Color = { R = 1.0, G = 1.0, B = 1.0, A = 1.0 } },
   },
}
MacBook Pro (16-inch 2019)
OS X 13.3.1 (a) / 18.5 beta Resolve Studio - DeckLink Studio 4k via Thunderbolt3
64GB - AMD Radeon Pro 5500M 8GB
10Gb ethernet network
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to draw by numbers (scripting question)

PostMon May 13, 2019 3:39 pm

Guides are not renderable. They're just viewer overlays.

There are some examples of the new GPU coding language, DCTL, in the Resolve Developer folder, accessible through Resolve's help menu. That doesn't include any of the drawing API, though. There is one example Fuse that should be included with Fusion beta 16, but I'm not sure if it's there or not (I don't have the latest build, and it wasn't in the one I downloaded most recently). Just in case, I'll attach it to this message.

One other thing I meant to mention before: The Lua drawing API available through Fuses does not have a working Bezier method. The method exists, but it's either broken or has some really inscrutable argument requirements. Just in case that was something you needed.

Another interesting example Fuse from VFXPedia is Lightning:
https://www.steakunderwater.com/VFXPedi ... _v1_1.Fuse

There is also an SDK forthcoming at some point, which can be useful for teasing out information about methods available for Fuses, in addition to writing native plug-ins. I'm not sure if you could get Support to send you the v9 SDK or not at this point, but I suppose it couldn't hurt to ask.
Attachments
GPU sample.zip
(1.89 KiB) Downloaded 169 times
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

Sander de Regt

  • Posts: 3500
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: How to draw by numbers (scripting question)

PostMon May 13, 2019 3:48 pm

Bryan Ray wrote: Another interesting example Fuse from VFXPedia is Lightning:
https://www.steakunderwater.com/VFXPedi ... _v1_1.Fuse

I wish I'd understand that one a little better. It's about 1/3rd to 1/2 of the way there to being really good, but I find it to be not subtle enough for 'real' lightning effects. Too many straight lines, and not enough 'fractal' feel compared to SpeedSix' old lightning/electricity effect.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

wolfgang hershey

  • Posts: 166
  • Joined: Sun Feb 07, 2016 12:41 am
  • Location: chinatowns everywhere

Re: How to draw by numbers (scripting question)

PostMon May 13, 2019 4:12 pm

many thanks
again

lots to dive into

wh
MacBook Pro (16-inch 2019)
OS X 13.3.1 (a) / 18.5 beta Resolve Studio - DeckLink Studio 4k via Thunderbolt3
64GB - AMD Radeon Pro 5500M 8GB
10Gb ethernet network
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to draw by numbers (scripting question)

PostMon May 13, 2019 5:30 pm

Sander de Regt wrote: I find it to be not subtle enough for 'real' lightning effects. Too many straight lines, and not enough 'fractal' feel compared to SpeedSix' old lightning/electricity effect.


Yeah, that was what alerted me to BezierTo() being broken. I was trying to make a better version of it, but it turns out that straight lines is all we get unless and until either the method is repaired or someone makes a new one. One more item in a list as long as my arm. I actually abandoned it in favor of trying to do it in OCL, but now that's obviated, so I'm a little demoralized at the moment. One day I'll have some dev time and energy for it again. Unless June Yu gets there first again, of course!
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline
User avatar

Bryan Ray

  • Posts: 2478
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: How to draw by numbers (scripting question)

PostFri Aug 16, 2019 10:41 pm

I actually found the time to tackle the Bezier problem, to some degree. I just posted a Fuse over at We Suck Less that demonstrates applying De Casteljau's algorithm with Fusion's Drawing API. I hope to soon have it reduced to a function that can be used in the same fashion as the rest of the Shape methods.

https://www.steakunderwater.com/wesuckl ... 34&p=21230
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com

Return to Fusion

Who is online

Users browsing this forum: No registered users and 31 guests