PokéRogue
    Preparing search index...

    The NormalTools Filter Controller.

    This filter controller manages the NormalTools effect for a Camera.

    NormalTools is a filter for manipulating the normals of a normal map. It has several functions:

    • Rotate or reorient the normal map.
    • Change how strongly the normals face the camera.
    • Output a grayscale texture showing how strongly the normals face the camera, or some other vector.

    The output can be used for various purposes, such as:

    • Editing a normal map for special applications.
    • Altering the apparent visual depth of a normal map by manipulating the facing power.
    • Creating a base for other effects, such as a mask for a gradient or other effect.

    You can even use the output as a normal map for regular lighting. Ordinarily, normal maps are loaded alongside the main texture, but you can override this.

    // Given a dynamic texture `dyn` where the filter output is drawn,
    // and a texture `spiderTex` with lighting enabled,
    // we can inject the WebGL texture straight into the scene lighting as a normal map.
    spiderTex.setDataSource(dyn.getWebGLTexture());

    A NormalTools effect is added to a Camera via the FilterList component:

    const camera = this.cameras.main;
    camera.filters.internal.addNormalTools({
    rotation: 0,
    facingPower: 1,
    outputRatio: false,
    ratioVector: [ 0, 0, 1 ],
    ratioRadius: 1
    });
    camera.filters.external.addNormalTools({});

    Hierarchy (View Summary)

    Index
    active: boolean

    Toggle this boolean to enable or disable this filter, without removing it from and re-adding it to the Camera's filter list.

    allowBaseDraw: boolean

    If true, this filter will be permitted to draw to the base texture. This can be unwanted if, for example, the filter doesn't actually draw anything.

    This is an internal flag used by the renderer. You should not modify this value directly.

    camera: Camera

    A reference to the Camera that owns this filter.

    currentPadding: Rectangle

    The padding currently being used by this filter. This is read during rendering via getPadding, and may be updated by subclass implementations. It is necessary for filters being used in an external list. You should not modify this value directly.

    facingPower: number

    The power of the facing effect. Higher values bend normals toward the camera; lower values bend them away. This can be useful for suggesting depth in a 2D scene.

    ignoreDestroy: boolean

    Whether this filter controller will be destroyed when the FilterList that owns it is destroyed. If you enable this, you must ensure that you clean up the filter controller at an appropriate time. This allows you to reuse a controller for multiple objects; this is not recommended unless you know what you're doing. It tends to work best with external filters.

    outputRatio: boolean

    Whether to output the ratio of the normal map. If true, the output will be a grayscale texture, with the white area being the areas where the normals are facing the camera, fading to black when they're orthogonal. You can manipulate this ratio with ratioVector and ratioRadius. This can be useful as a base for other effects.

    paddingOverride: Rectangle

    Padding override. This is on by default. If this is set, the filter will use this padding instead of calculating it. Prefer using setPaddingOverride instead of modifying this directly.

    ratioRadius: number

    How much of a hemisphere to consider for the ratio output. At 1, the ratio will be calculated for the entire hemisphere. At 0, the ratio will be calculated for a single point. This uses the same algorithm as PanoramaBlur.radius.

    This is only used if outputRatio is true.

    ratioVector: Vector3

    The vector to use for the ratio output. This is the direction in which the ratio will be calculated. The default is the camera's forward direction. Manipulate this to highlight parts of the map which are facing in a specific direction.

    This is only used if outputRatio is true.

    renderNode: string

    The ID of the RenderNode that this filter uses.

    rotationSource: GameObject | NormalToolsSourceCallback | null

    The source of the rotation. If a function, it will be called to get the rotation. If a GameObject, it will be used to get the rotation from the GameObject's world transform. If null, the rotation will not be updated by the filter.

    viewMatrix: Matrix4

    The view matrix used for the NormalTools effect. This controls the orientation of the normal map. Use this to control 3D rotation of the normal map. Ordinarily, you would just use setRotation for 2D rotation.

    • Destroys this Controller and nulls any references it holds.

      Returns void

    • Returns the raw padding required for this filter. This is typically not what you want to call; use getPaddingCeil instead. Values from this method are not rounded, which can cause quality loss.

      Override this method when creating a Filter that requires extra room, e.g. a blur or glow effect.undefined

      Returns Rectangle

      The padding required by this filter.

    • Returns the rounded padding required for this filter.

      Most filters don't need extra padding, but some may sample beyond the texture boundaries, such as a blur or glow effect.

      The bounds are encoded as a Rectangle. To enlarge the bounds, the top and left values should be negative, and the bottom and right values should be positive.

      This method calls getPadding() to get the raw padding values, and uses Math.ceil() to set the values of paddingOverride and currentPadding.undefined

      Returns Rectangle

      The rounded padding required by this filter.

    • Gets the 2D rotation of the normal map, as set by setRotation or the rotationSource.

      This value is not accurate if the viewMatrix is manipulated directly, e.g. for 3D rotation. There is no single value which can accurately represent 3D rotation.undefined

      Returns number

      The rotation in radians.

    • Sets the active state of this filter.

      A disabled filter will not be used.

      Parameters

      • value: boolean

        true to enable this filter, or false to disable it.

      Returns this

      This filter instance.

    • Sets the padding override. If this is set, the filter will use this padding instead of calculating it. Call setPaddingOverride(null) to clear the override. Call setPaddingOverride() to set the padding to 0.

      Parameters

      • Optionalleft: number | null

        The left padding. Default 0.

      • Optionaltop: number

        The top padding. Default 0.

      • Optionalright: number

        The right padding. Default 0.

      • Optionalbottom: number

        The bottom padding. Default 0.

      Returns void

    • Sets the rotation of the normal map. This sets the viewMatrix to a rotation around the Z axis, suitable for 2D rotation. For more advanced controls, manipulate the filter's viewMatrix to control 3D rotation.

      Parameters

      • rotation: number

        The rotation in radians.

      Returns this

      This NormalTools instance.

    • Updates the rotation of the normal map from the rotationSource, if it is set. This is called automatically during rendering.undefined

      Returns this

      This NormalTools instance.