Welcome, Guest
Username Password: Remember me

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

Documentation for developing Lightworks effects 3 years, 4 months ago #144840

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 4454
  • 3 years, 4 months ago
Great White wrote:
Lightworks always arranges for texcoord0 to be in the range 0..1, whereas texcoord1 and above are modified to include the necessary half texel adjustments that you need for DirectX (when running on Windows).

Many Thanks.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1; || Windows 10, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || shared RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)

Documentation for developing Lightworks effects 3 years, 4 months ago #144882

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 12887
  • 3 years, 4 months ago
What that immediately makes apparent to me is that I may have been doing exactly the wrong thing with my recent declarations. I'd better go back and check all my effects and correct any use of TEXCOORD or TEXCOORD0 then. That could be fun.
Last Edit: 3 years, 4 months ago by jwrl.

Documentation for developing Lightworks effects 3 years, 4 months ago #144917

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 12887
  • 3 years, 4 months ago
I haven't just checked my effects, I've been through the entire library. There are 27 files with that problem. I've corrected them, and I'll update the library files and the individual zips over the weekend. The individual effects are these (mine are in blue):

  • AlphaGranMix.fx
  • BigBlur.fx
  • bilateral_blur.fx
  • Bokeh.fx
  • CameraShake.fx
  • CCHelper2.fx
  • CloneStamp_03.fx
  • Deco_DVE.fx
  • DualDVE.fx
  • FxTiltShift.fx
  • IrisBokeh.fx
  • Lissajou.fx
  • MaskBlur.fx
  • MaskedMotionBlur.fx
  • OutputSelect.fx
  • PeakDesat.fx
  • PolyGrad.fx
  • RC3001_Cyclic_Remote.fx
  • SimpleCrop.fx
  • SineLights.fx
  • Sketch.fx
  • SkinSmooth.fx
  • TheDarkSide.fx
  • UnsharpMask.fx
  • VariGrain.fx
  • vicrop.fx
  • ZebraStripes.fx
Last Edit: 3 years, 4 months ago by jwrl.

Documentation for developing Lightworks effects 3 years, 4 months ago #144934

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 4454
  • 3 years, 4 months ago
Remember, that "TEXCOORD0" can also be useful.
Also, Lightworks originalaleffeke use this texture when the effect has no input (for example, "bars.fx).
Even for effects that should work even if nothing is connected to the input, "TEXCOORD0" can be useful because an open input can cause larger texture errors.

Example: RC3001_Cyclic_Remote.fx (note the comments in the code)
float4 singleRemoteControl (float2 xy : TEXCOORD0) : COLOR   // "TEXCOORD0" is used Because the effect can also be operated without a connected input, and the graphically encoded color signal is generated by the effect itself.


For internal rendering, the correct filter setting can prevent the addition of inaccuracies:
sampler remoteImput = sampler_state
{
   Texture = <remote>;
   AddressU = Clamp;
   AddressV = Clamp;
   MinFilter = PYRAMIDALQUAD;		// (MinFilter settings seem to have no influence on this user effect?)
   MagFilter = PYRAMIDALQUAD;	// IMPORTANT: MagFilter setting when the sampler uses the pixel coordinates of "TEXCOORD0" .       The settings "PYRAMIDALQUAD" and "GAUSSIANQUAD" worked well in tests.  All other tested settings ("NONE", "POINT", "LINEAR", "ANISOTROPIC" ) caused small deterioration of image quality, which increased with each new rendering (even if the effect is only to pass the pixels unchanged).
   MipFilter = PYRAMIDALQUAD;		// (MipFilter settings seem to have no influence on this user effect?)
};

The effect only outputs color points as a remote control signal for other effects. The size of these color points is so dimensioned that a minimal texture error lies in tolerance. If the texture of an input is used, which remains open in many cases, the texture error can exceed this tolerance.
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1; || Windows 10, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || shared RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 3 years, 4 months ago by schrauber.

Documentation for developing Lightworks effects 3 years, 4 months ago #144946

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 4454
  • 3 years, 4 months ago
schrauber wrote:
... For internal rendering, the correct filter setting can prevent the addition of inaccuracies...

I had also tested the quad filer setting for the effects inputs (when using TEXCOORD0).
Then I had many test effects in the routing connected in series, and could not see any problems.

If the effect calculates geometric structures without input only internally mathematically, then there is no filtering in the first shader pass. In this case, the problem might become visible (if no complex correction calculation is programmed).


Another thing: I wonder if the use of the associated input texture coordinates is particularly important when using interlaced media?
Mainly automatically translated
--------------------------------------------
Software: Lightworks 2020.1; || Windows 10, 64 Bit
Hardware: Intel i5-4440 (3,1 GHz); || shared RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
Last Edit: 3 years, 4 months ago by schrauber.

Documentation for developing Lightworks effects 3 years, 4 months ago #145001

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 12887
  • 3 years, 4 months ago
However, you list in your example PyramidalQuad as a setting for MagFilter. According to the list I extracted from the Cg 3.1 reference manual release 3.1, PyramidalQuad isn't valid for MagFilter. The valid enumerants are:

  1. MagFilter
    • Point
    • Nearest
    • Linear
  2. MinFilter
    • Anisotropic
    • GaussianQuad
    • Linear
    • LinearMipMapLinear
    • LinearMipMapNearest
    • Nearest
    • NearestMipMapLinear
    • NearestMipMapNearest
    • None
    • Point
    • PyramidalQuad
  3. MipFilter
    • None
    • Point
    • Linear
    • Anisotropic
    • PyramidalQuad
    • GaussianQuad

The fact that you appear to have had success may be dependent on the hardware used. If so it's a dangerous setting to use.

In the early stages when I was learning the language I tested the various settings, and found that I got errors when compiling with anything other than the MagFilter settings. It may be that my tests were at fault or, again, a hardware issue. I'll revisit them. GaussianQuad could be a very useful filter for resizing operations, for example.

The other question to answer would then be how processor intensive the various settings would be. I would imagine that PyramidalQuad or GaussianQuad would be likely to bog down sooner than Nearest or None, for example.
Last Edit: 2 years, 7 months ago by jwrl.

Documentation for developing Lightworks effects 3 years, 4 months ago #145003

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 12887
  • 3 years, 4 months ago
Referring to the same Cg manual, the valid enumerants for AddressU and AddressV are:

  • Repeat
  • Wrap
  • Clamp
  • ClampToEdge
  • ClampToBorder
  • Border
  • MirroredRepeat
  • Mirror
  • MirrorClamp
  • MirrorClampToEdge
  • MirrorClampToBorder
  • MirrorOnce

Room for testing there, but given the various functionality requirements I'm not sure what the cross-platform constraints would be. It would probably be a good idea to set up a Linux system as a test bed if you want to experiment with some of the less common settings.
Last Edit: 3 years, 4 months ago by jwrl.

Documentation for developing Lightworks effects 3 years, 4 months ago #145006

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 12887
  • 3 years, 4 months ago
schrauber wrote:
Remember, that "TEXCOORD0" can also be useful.
Also, Lightworks originalaleffeke use this texture when the effect has no input (for example, "bars.fx).

Good point. That, and the fact that on a blur effect a half-texel offset wouldn't be important allows me to drop the following from that list.

  • BigBlur.fx
  • bilateral_blur.fx
  • Bokeh.fx
  • IrisBokeh.fx
  • Lissajou.fx
  • MaskBlur.fx
  • MaskedMotionBlur.fx
  • RC3001_Cyclic_Remote.fx
  • SineLights.fx
  • SkinSmooth.fx

That's cut the list to 17. Great. And arguably TheDarkSide.fx and UnsharpMask could also be included, since they both use blurs to get their result.

schrauber wrote:
I wonder if the use of the associated input texture coordinates is particularly important when using interlaced media?

I would think that it would be. I used "Linear" when writing my de-interlace effect because I specifically wanted to interpolate between interlaced pixels. In hindsight a better result could possibly have been obtained by using PyramidalQuad or GaussianQuad for MipFilter.
Last Edit: 3 years, 4 months ago by jwrl.

Documentation for developing Lightworks effects 3 years, 4 months ago #145215

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 4454
  • 3 years, 4 months ago
jwrl wrote:
...The valid enumerants are:

[ol]
  • MagFilter
    • Point
    • Nearest
    • Linear

  • Strange, "Nearest" and much of the other filter combinations does not accept the compiler (Windows):
    This image is hidden for guests. Please log in or register to see it.

    The error message is obtained with MinFilter, MagFilter, and MipFilter.
    I have the impression that the compiler accepts only those filter settings, which are compatible with Nvidia's Cg and at the same time HLSL?

    jwrl wrote:
    However, you list in your example PyramidalQuad as a setting for MagFilter. According to the list I extracted from the Cg 3.1 reference manual release 3.1, PyramidalQuad isn't valid for MagFilter.[/url]?


    According to the Microsoft HLSL page, it is undefined in Mip filtering.
    The Lightworks compiler accepts the following filter but for Min and Mag and Mip filtering:
    • None
    • Point
    • Linear
    • Anisotropic
    • PyramidalQuad
    • GaussianQuad

    Is the question of whether the compiler ignores or replaces some settings?


    jwrl wrote:
    ... The other question to answer would then be how processor intensive the various settings would be.

    This I had also suspected, and in my effects used "None", when no filtering was necessary.
    I tried to check with this test:
    This attachment is hidden for guests. Please log in or register to see it.
    and www.gpu-z.de/
    I could not find any differences.
    Perhaps under other test conditions? I thought I'd get contradictory results at short notice?
    Mainly automatically translated
    --------------------------------------------
    Software: Lightworks 2020.1; || Windows 10, 64 Bit
    Hardware: Intel i5-4440 (3,1 GHz); || shared RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
    Last Edit: 3 years, 4 months ago by schrauber.

    Documentation for developing Lightworks effects 3 years, 4 months ago #145238

    • jwrl
    • Moderator
      Pro User
    • OFFLINE
    • Moderator
    • Posts: 12887
    • 3 years, 4 months ago
    From the NVIDIA Corporation Cg 3.1 Reference Manual, Release 3.1, May 01, 2012 (HLSL matches shown in RED by me):

    11.10 MagFilter

    NAME

    MagFilter - 3D API mag filter

    USAGE
    MagFilter = int(type)

    VALID ENUMERANTS
    type: Point, Linear, Nearest

    According to Microsoft, in HLSL None, Anisotropic, PyramidalQuad and GaussianQuad are also valid. In GLSL Nearest and Linear are the two supported values - jwrl

    DESCRIPTION
    Set the sampler magnification filter type. See the GL_TEXTURE_MAG_FILTER description on the OpenGL glTex-Parameter manual page for details. See the D3DSAMP_MAGFILTER sampler state description for DirectX 9.

    The standard reset callback sets the MagFilter state to int(Point).

    OPENGL FUNCTIONALITY REQUIREMENTS
    Not applicable.

    DIRECT3D FUNCTIONALITY REQUIREMENTS
    DirectX 9

    This is apparently the most recent version, since Cg has undergone no further development as far as I can determine. Since Editshare use Cg for compatibility reasons it would probably be smart to ignore HLSL and concentrate on Cg. If you use something that works in HLSL but doesn't in Cg (or for that matter GLSL) then you have a bugged effect.
    Last Edit: 3 years, 2 months ago by jwrl.

    Documentation for developing Lightworks effects 3 years, 4 months ago #145239

    • lghtwrks
    • OFFLINE
    • Platinum Boarder
    • Posts: 3332
    • 3 years, 4 months ago
    MAME is still alive ,)
    docs.mamedev.org/advanced/hlsl.html

    Documentation for developing Lightworks effects 3 years, 4 months ago #145240

    • jwrl
    • Moderator
      Pro User
    • OFFLINE
    • Moderator
    • Posts: 12887
    • 3 years, 4 months ago
    Further reading (HLSL matches shown in RED by me):

    11.13 MinFilter

    NAME

    MinFilter - 3D API min filter

    USAGE
    MinFilter = int(type)

    VALID ENUMERANTS
    type: None, Point, Linear, Anisotropic, GaussianQuad, PyramidalQuad, LinearMipMapLinear, LinearMipMapNearest, Nearest, NearestMipMapLinear, NearestMipMapNearest

    Anisotropic, GaussianQuad, None, and PyramidalQuad are only supported on Direct3D.

    In GLSL the supported values are Linear, Nearest, LinearMipMapNearest, LinearMipMapLinear, NearestMipMapNearest and NearestMipMapLinear - jwrl.

    DESCRIPTION
    Set the Direct3D sampler minification filter type. See the D3DSAMP_MINFILTER sampler state description for DirectX 9. See the GL_TEXTURE_MIN_FILTER description on the OpenGL glTexParameter manual page for details.

    The standard reset callback sets the MinFilter state to int(Point) on Direct3D and to int(NearestMipMapLinear) on OpenGL.

    OPENGL FUNCTIONALITY REQUIREMENTS
    OpenGL 1.0

    DIRECT3D FUNCTIONALITY REQUIREMENTS
    DirectX 9

    11.15 MipFilter


    NAME

    MipFilter - 3D API mip filter

    USAGE
    MipFilter = int(type)

    VALID ENUMERANTS
    type: None, Point, Linear, Anisotropic, PyramidalQuad, GaussianQuad

    Only the first three are valid for Mip filter settings in HLSL. See schrauber's post #145263 over the page - jwrl.

    DESCRIPTION
    Set the Direct3D minification mipmap filter. See the D3DSAMP_MIPFILTER sampler state description for DirectX 9.

    The standard reset callback sets the MipFilter state to int(None).

    OPENGL FUNCTIONALITY REQUIREMENTS
    Not applicable.

    DIRECT3D FUNCTIONALITY REQUIREMENTS
    DirectX 9
    Last Edit: 3 years, 4 months ago by jwrl.

    Documentation for developing Lightworks effects 3 years, 4 months ago #145241

    • jwrl
    • Moderator
      Pro User
    • OFFLINE
    • Moderator
    • Posts: 12887
    • 3 years, 4 months ago
    lghtwrks wrote:

    I don't believe that is relevant in this context. As stated several times right from the outset, we aren't talking about HLSL here, we're talking about Cg because that's what Lightworks effects use. They do that because:

    A) HLSL is a language developed for Windows.

    B) When developing the cross platform versions a cross-platform language was required.

    So just to restate: If you write your effect as HLSL code and compile it on Windows there is no guarantee that it will work the same way or at all on Linux or OS-X systems. DO NOT DO IT!
    Last Edit: 3 years, 4 months ago by jwrl.

    Documentation for developing Lightworks effects 3 years, 4 months ago #145265

    • schrauber
    • OFFLINE
    • Platinum Boarder
    • Posts: 4454
    • 3 years, 4 months ago
    jwrl wrote:
    ... we're talking about Cg because that's what Lightworks effects use.

    But many Cg filters does not accept my Lightworks compiler.
    But I have no NVIDIA graphics card.
    Does "Nearest" work on your system?
    Mainly automatically translated
    --------------------------------------------
    Software: Lightworks 2020.1; || Windows 10, 64 Bit
    Hardware: Intel i5-4440 (3,1 GHz); || shared RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
    Last Edit: 3 years, 4 months ago by schrauber.

    Documentation for developing Lightworks effects 3 years, 4 months ago #145267

    • schrauber
    • OFFLINE
    • Platinum Boarder
    • Posts: 4454
    • 3 years, 4 months ago
    jwrl wrote:
    MipFilter = int(type)

    VALID ENUMERANTS
    type: None, Point, Linear, Anisotropic, PyramidalQuad, GaussianQuad

    I'm unsure about the last three. As I read other posts on forums about this issue, only the first three are valid for Mip filter settings in HLSL. Microsoft seems to say not though - jwrl.

    msdn.microsoft.com/de-de/library/windows/desktop/bb172615.aspx
    Use with D3DSAMP_MIPFILTER is undefined.
    Mainly automatically translated
    --------------------------------------------
    Software: Lightworks 2020.1; || Windows 10, 64 Bit
    Hardware: Intel i5-4440 (3,1 GHz); || shared RAM: 8 GB; || Intel HD Graphics 4600 (can use max. 2 GB of shared RAM)
    Time to create page: 0.66 seconds
    Scroll To Top