API Documentation
Documentation for developing SailfishOS applicationsShaderFilter QML Type
Filters an image using a GLSL shader program. More...
Import Statement: | import Sailfish.Silica.Background 1.0 |
Properties
- fragmentShader : string
- vertexShader : string
Detailed Description
Note: This QML type is under development and is subject to change.
The vertexShader and fragmentShader properties allow the use of standard GLSL shader programs to perform image processing options on the input of a FilteredImage. Both shaders have some limited attributes they expect to be defined in order to input the source imaage but are otherwise unbounded.
Additional data may be passed from QML to a shader by defining a uniform attribute in the shader and a QML property in either the FilteredImage or ShaderFilter with a compatible value with priority given to the FilteredImage properties.
GLSL | QML property |
---|---|
float |
|
vec2 |
|
vec3 |
|
vec4 |
|
sampler2D |
|
Property Documentation
The GLSL fragment shader used to filter an image.
The input texture of the fragment shader is supplied in a uniform named sourceTexture
.
uniform lowp sampler2D sourceTexture;
The values of any QML properties in a FilteredImage or ShaderFilter definition will be used to populate a compatible uniform in the vertex shader.
Additionally the default vertex shader if used produces a varying attribute specifying the texture coordinates to sample the source texture:
varying highp vec2 sourceCoord;
The default fragment shader is as follows:
varying highp vec2 sourceCoord; uniform lowp sampler2D sourceTexture; void main() { gl_FragColor = texture2D(sourceTexture, sourceCoord); }
The GLSL vertex shader used to filter an image
The input vertex coordinates of the vertex shader are suppled in a attribute named position
and the input texture coordinates in an attribute named textureCoord
. Both are pre-transformed and there are no pre-defined uniform attributes.
attribute highp vec4 position; attribute highp vec2 textureCoord;
The values of any QML properties in a FilteredImage or ShaderFilter definition will be used to populate a compatible uniform in the vertex shader.
The default fragment shader if used expects a varying attribute specifying the texture coordinates to sample the source texture:
varying highp vec2 sourceCoord;
The default vertex shader is as follows:
attribute highp vec4 position; attribute highp vec2 textureCoord; varying highp vec2 sourceCoord; void main() { gl_Position = position; sourceCoord = textureCoord; }