I'm trying to reproduce the following effect using Direct2D1:
I thought it would be a "simple" case of using the built-in turbulence effect, and adjusting the offset property, as the documentation says:
Offset
D2D1_TURBULENCE_PROP_OFFSETThe coordinates where the turbulence output is generated. The algorithm used to generate the Perlin noise is position dependent, so a different offset results in a different output. This property is not bounded and the units are specified in DIPs.
Note: The offset does not have the same effect as a translation because the noise function output is infinite and the function will wrap around the tile.
Using my home-made C#/Wind32 framework and the Vortice wrapper around Direct2D, I coded this simple turbulence effect:
public void OnRender(ID2D1DeviceContext g, float t) {
using var turbulenceEffect = new Turbulence(g) {
Offset = new Vector2(t, 0)
};
g.Clear(Colors.Black);
g.DrawImage(turbulenceEffect);
}
However, the render outputs a turbulence image slowly crawling rightward, acting as if the turbulence offset was indeed a translation, unlike what I understand from the documentation quoted above.
Could it be a bug of the D2D wrapper? Is my understanding of the docs incorrect? If not, what would be the correct way to implement the desired effect?
Reference image source
Vortice.Direct2D1 2.4.2
.NET Target Framework: net6.0-windows10.0.19041.0