Welcome, Guest
Username Password: Remember me

TOPIC: Documentation for developing Lightworks effects (Post # 1 contains summary links)

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229136

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 months ago
schrauber wrote:
In preparation for Lightworks 2021:
[..]
bool CanSize = true;

[..]
I can see that there are currently still restrictions if the original aspect ratio differs from the sequence / export aspect ratio,..

[EDIT] In the current beta this has been solved for effects with two inputs. I think that means that effects which only have one input, but should use `bool CanSize = true;`, an input should be added.
I have now updated the documentation regarding file header:
github.com/FxSchrauber/Code_for_developing_Lightworks_effects/blob/master/Basics/File_Header.md
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 2 months ago by schrauber.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229145

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 months ago
New Auto-synced parameters regarding the new scaling in effects:
www.lwks.com/index.php?option=com_kunena&func=view&catid=12&id=228948&Itemid=81#229128

The name of the variable contains the name of the input, and can apparently be replaced if necessary. In the linked examples the input "Fg" was used. In a test with an input named "Fg2", I could read the horizontal width of the texture at this input with the variable 'Fg2Width'.

All known auto-synced parameters
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229167

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13397
  • 2 months ago
For what it's worth, this has a serious impact on backwards compatibility. I know that you can compile an effect with CanSize set in 14.5 because I've tested it. It's ignored.

However for backward compatibility reasons we will need to work out a way of dealing with these new variables with a method that supports them where they are available and ignores them where they're not. Quite frankly, at the moment I don't have the vaguest idea of how to do that in a failsafe foolproof way. It may be necessary to lock the existing library and start afresh.
Last Edit: 1 month, 2 weeks ago by jwrl.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229179

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 months ago
I don't know in how many effects we will use these variables. It may be that some new effects are only possible with the 2021 features, so that a backward compatibility would be useless.

During a zoom test effect in a project created with 2020.1, I noticed that after switching to 2021 for the first time, the position did not quite match the original position (manual readjustment required). The original had a different aspect ratio than the sequence.
In the changelog I also see:
Cross Platform Limitations and Known Issues
[..]
- DVEs may change position when switching to a different sequence output

Perhaps these variables could be used to compensate for such shifts? Then this would increase compatibility. However, I have not tested whether a reinstallation of the effect is necessary when new auto-synced variables are added to the code. But I have not tested if a reinstallation of the effect is necessary when new auto-synced variables are added to the code.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229182

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 27336
  • 2 months ago
schrauber wrote:

In the changelog I also see:
Cross Platform Limitations and Known Issues
[..]
- DVEs may change position when switching to a different sequence output

Perhaps these variables could be used to compensate for such shifts? Then this would increase compatibility.

I would prefer to see such an elementary flaw fixed on application level, not within user effects.

Edit: But perhaps, I don't understand exactly what this sentence in the changelog means.
It's better to travel well than to arrive...
Last Edit: 2 months ago by hugly.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229184

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 months ago
hugly wrote:
But perhaps, I don't understand exactly what this sentence in the changelog means.

Neither did I, but I have not tested it.

To avoid misunderstandings: I did not mean to create a fix for an original Lightworks DVE effect with a user effect.
It was just a thought, in case similar things will be noticed in user effects, if these variables were a potential option to improve the behavior.


[EDIT:]I've edited my post #229136 I now noticed that the automatic translation was incomplete, so that the meaning was alienated.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 2 months ago by schrauber.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229192

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13397
  • 2 months ago
schrauber wrote:
In the current beta this has been solved for effects with two inputs. I think that means that effects which only have one input, but should use `bool CanSize = true;`, an input should be added.

Really? That sounds highly unlikely to me - enforcing the use of two inputs when only one is ever going to be needed doesn't seem like reasonable design decision. Redundant inputs which are never intended to be connected to anything may also have unintended routing issues.
Last Edit: 2 months ago by jwrl.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229198

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 months ago
Only if all of the following conditions are met:
- `bool CanSize = true;`
- The aspect ratio of the input differs from the sequence / export aspect ratio (tested with a high resolution image that had black bars on the left and right in the sequence viewer)
- The resolution at the input is higher than the sequence resolution
- Foll zoom is not set in the project settings.
- The effect changes the sampler position so that it expands into the black bars, borders, etc. (Zooming in, probably also position shifts, some distortions etc.). But I have tested it so far only with zoom.

jwrl wrote:
Really? That sounds highly unlikely to me

My two zoom test effects.
One with only one input, the other with an unused second input.

This attachment is hidden for guests. Please log in or register to see it.


jwrl wrote:
Redundant inputs which are never intended to be connected to anything may also have unintended routing issues.


Therefore I had asked in the old DVE beta thread:
www.lwks.com/index.php?option=com_kunena&func=view&catid=526&id=227436&limit=15&limitstart=15&Itemid=81#228808

If this is not realized, I should replace my simple zoom effects or, if already similar alternatives with two inputs are available, withdraw them.

I hadn't reported it in the current beta thread, because it probably doesn't concern the effects developed by Lightworks. Also I suspect that the current behavior has a reason. If each effect would behave like with two inputs, then all vertical images in the effect chain would immediately change to the sequence aspect ratio in the first effect (extended by wide black bars). Probably this black border (no original aspect ratio) could lead to undesired behavior in subsequent effects, if this texture is mixed with textures of other aspect ratios? Maybe unwanted black borders would also unnecessarily increase GPU load and GPU memory usage (especially for very high resolution images)?
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 2 months ago by schrauber.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 months ago #229252

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13397
  • 2 months ago
jwrl wrote:
Redundant inputs which are never intended to be connected to anything may also have unintended routing issues.

schrauber wrote:

That's probably not going to get a lot of attention. That's four builds back - it may not be noticed at all.

schrauber wrote:
I hadn't reported it in the current beta thread, because it probably doesn't concern the effects developed by Lightworks. Also I suspect that the current behavior has a reason.

Nonetheless, if you want it noticed and it affects the behaviour of the current beta in any way at all you should post in the current beta forum. That way it will be noticed.

Given that we're likely to get a new build today it would be worthwhile waiting until that's up, and posting in the forums associated with that build.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 3 weeks, 5 days ago #231173

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 3 weeks, 5 days ago
Hello,

Here is my attempt to create a sampler function optimized for Lightworks 2021.
Purpose:
- Nearly perfect edge interpolation , even with very slow keyfaming (e.g. 1 pixel per second). This even when changing the scaling settings in the associated shader.
- Adjustable edge softness.
- Output interpolation and softness as alpha value (RGB values are not changed by the function.
EDIT, old code!
:pinch: Warning: Spoiler!
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 2 days, 11 hours ago by schrauber.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 3 weeks, 5 days ago #231175

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 13397
  • 3 weeks, 5 days ago
I'm not sure that I would want to build all of that into a function to recover a pixel though. It's perhaps a little too complex for general use. But then I've never been entirely comfortable with the very much simpler technique that I currently use either.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 weeks ago #231756

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 weeks ago
jwrl wrote:
It's perhaps a little too complex for general use.

I don't want to use the function in general, but only where I think there is a potential improvement in quality.
Simplifications are also possible if, for example, no manual softness is needed or no significant scaling is carried out.

In my test effect, I have now made small changes to the function:
I now pass the input dimensions from the shader to the function instead of using the global auto-sync variables directly in the code. This makes the function flexible to use with different inputs and naming.
Also with the manual softness, I now use the input aspect ratio instead of the output aspect ratio for correction:
float4 fn_tex2Dp1 (sampler s,    // Pass 1 - Sampler function with alpha-softness of edges (use only for the first pass)
                 float2 xy,      // Sampler Coordinates
                 float inWidth,  // Width of the texture in pixels at the input of the sampler used .
                 float inHeight, // Height of the texture in pixels at the input of the sampler used .
                 float scale)    // Linear scaling value of the shader (0 = 0% scaling , 1 = 100% unchanged scaling, etc.) 

{
   float2 inter = 1.0.xx / float2 ( _InWidth, _InHeight);             // Dimensions of the interpolation areas (Dimensions of an input text)
   inter /= max (1.0e-9.xx, scale.xx);                                // Adjust input interpolation dimensions to scale so that the interpolation width remains constant relative to the output pixel dimension.
   inter = min (0.5.xx, inter);                                       // Limitation of the scaling-dependent interpolation softness in order to avoid unexpected behavior with extremely small scalings.
   float2 distEdge   = 0.5.xx - abs(xy - 0.5.xx);                     // Distance from the edges of the source frame (negative values are outside)
   distEdge += inter;                                                 // Shift edges outward to avoid seeing interpolated lines at output frame edges when full screen.
   float2 soft = inter + float2 (Soft, Soft * (_InWidth/ _InHeight)); // In addition to the interpolation an adjustable softness. (`Soft` Range: 0 = 1 pixel interpolation, 0.25: Softness to approximately frame center at 16/9 media.). `(_InWidth/ _InHeight)` is for a uniform border softness thickness. 
   soft = min( 1.0.xx, distEdge * (1.0.xx / max (1e-9.xx, soft) ));   // Reverses the direction of action, and scales with the distance of the sampler position from the source frame edge.
   float4 retval = tex2D (s, xy);                                     // Take a texture sample
   retval.a *= saturate( min (soft.x, soft.y));                       // Alpha edge softness 
   return retval;
}


..................................


Here is a version when the function is not used in the first pass, but for internally rendered textures, which can have a different aspect ratio than the input texture:
EDIT, incorrect old code!
:pinch: Warning: Spoiler!


In other words, for cases in which the input texture coordinates used in the shader have to be adjusted in order to avoid distortions.
Tested with a two-input zoom effect using only the first input (forces textures in sequence aspect ratio for zooming in without unnecessary black bars). Not tested when using a background input. Probably partly worse results with only one input (not tested), because then the aspect ratio of the rendered intermediate textures is undefined.

EDIT: Designed for cases where the edges of a particular input texture are to be interpolated within the rendered texture (possibly different aspect ratios).
In cases where the edges of the rendered texture itself are to be interpolated, this function is probably unsuitable.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 2 days, 11 hours ago by schrauber.

Re: Documentation for developing Lightworks effects (Post # 1 contains summary links) 2 days, 12 hours ago #232446

  • schrauber
  • Pro User
  • OFFLINE
  • Platinum Boarder
  • Posts: 4872
  • 2 days, 12 hours ago
I need to fix my code at least for internally rendered textures.

I used the frame edges of the input frame as reference. I noticed now that this causes problems with different aspect ratios, with "Full zoom" project setting enabled at the same time. (Illegal positions outside the rendered frame become visible). The reason is that with zooming project settings, rendered textures do not contain the full dimensions of the original texture (at least for effects with more than one input).

I have now changed the code to take into account the edge that has the smallest distance from the frame center (either the edge of the original frame, or the edge of the rendered texture.

Here is my code for rendered textures:
float4 fn_tex2DRendered (sampler s, float2 xy, float inWidth, float inHeight, float scale)    
{
   float2 inter = 1.0.xx / float2 ( inWidth, inHeight);    
   inter /= max (1.0e-9.xx, scale.xx);                                
   inter = min (0.5.xx, inter);
   float2 distEdgeCenter = min (0.5.xx, 0.5 * float2 (_InXScale,_InYScale));
   float2 distEdge = (distEdgeCenter + inter) - abs (0.5.xx - xy); 
   float2 soft = inter + float2 (Soft, Soft * (inWidth/ inHeight));
   soft = min( 1.0.xx, distEdge * (1.0.xx / max (1e-9.xx, soft) ));   
   float4 retval = tex2D (s, xy);                                   
   retval.a *= saturate( min (soft.x, soft.y)); 
   return retval;
}


Here is the functionally identical code, but perhaps more clearly structured and with comments for better understanding:
:pinch: Warning: Spoiler!


Regarding my old first pass code in my previous post:
The visible areas are not illegal, but when minimizing, the visible aspect ratio of the minimized foreground frame changes in front of the background (because under these test conditions more areas of the original frame become visible when minimizing).
Whether this is desired probably depends on the associated effect.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1.1 & Beta 2021.x; || Windows 10 Home 1909, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 2 days, 11 hours ago by schrauber.
Time to create page: 0.51 seconds
Scroll To Top