{ "QEN": { "description": "Moves the pixels of the source item according to the given displacement map. The format for the displacement map is similar to the tangent space normal maps.", "fragmentCode": [ "float linearstep(float e0, float e1, float x)", "{", " return clamp((x - e0) / (e1 - e0), 0.0, 1.0);", "}", "@main", "{", " vec4 offset = texture(displaceDisplacementSource, texCoord);", " offset.xy -= vec2(0.5, 0.5);", " offset.xy = offset.xy * step(vec2(1.0/256.0), abs(offset.xy));", " vec2 tx = texCoord + (vec2(-offset.x, offset.y) * displaceDisplacement);", " float e1 = linearstep(0.0, texCoord.x, tx.x);", " float e2 = linearstep(0.0, texCoord.y, tx.y);", " float e3 = 1.0 - linearstep(1.0, 1.0 + texCoord.x, tx.x);", " float e4 = 1.0 - linearstep(1.0, 1.0 + texCoord.y, tx.y);", " vec4 samp = texture(iSource, tx);", " samp.rgb *= e1 * e2 * e3 * e4;", " fragColor = samp * offset.a;", "}" ], "name": "Displace", "properties": [ { "defaultValue": "", "description": "This property defines the item that is going to be used as the displacement map. The displacementSource item gets rendered into the intermediate pixel buffer. The red and green component values from the result determine the displacement of the pixels from the source item.\n\nThe format for the displacement map is similar to the tangent space normal maps, which can be created with most 3D-modeling tools. Many image processing tools include the support for generating normal maps. Alternatively, the displacement map for this effect can also be a QML element which is colored appropriately. Like any QML element, it can be animated. It is recommended that the size of the diplacement map matches the size of the \\l{Displace::source}{source}.\n\nThe displace data is interpreted in the RGBA format. For every pixel: the red channel stores the x-axis displacement, and the green channel stores the y-axis displacement. Blue and alpha channels are ignored for this effect.\n\nAssuming that red channel value 1.0 is fully red (0.0 having no red at all), this effect considers pixel component value 0.5 to cause no displacement at all. Values above 0.5 shift pixels to the left, values below 0.5 do the shift to the right. In a similar way, green channel values above 0.5 displace the pixels upwards, and values below 0.5 shift the pixels downwards. The actual amount of displacement in pixels depends on the \\l displacement property.", "name": "displaceDisplacementSource", "type": "image" }, { "defaultValue": "0", "description": "This property defines the scale for the displacement. The bigger scale, the bigger the displacement of the pixels. The value set to 0.0 causes no displacement.\n\nThe value ranges from -1.0 (inverted maximum shift, according to displacementSource) to 1.0 (maximum shift, according to displacementSource). By default, the property is set to 0.0 (no displacement).", "maxValue": "1", "minValue": "-1", "name": "displaceDisplacement", "type": "float" } ], "version": 1 } }