>  Docs Center  >  IDL Reference  >  Object Graphics - Misc.  >  IDLgrShader::Filter



The IDLgrShader::Filter function method, implemented only in an IDLgrShader subclass, provides a way to implement a software-based fallback for an image filtering shader program when the graphics card hardware does not support shading language.

This function is only available for shader objects associated with IDLgrImage objects, and is activated only when the required hardware support is not present or when the FORCE_FILTER property of the shader object or IDLgrFilterChain object is set to a non-zero value.

Note: Never call this method directly. It is called automatically in response to changes requiring a re-draw of the scene, including IDLgrShader::SetUniformVariable updates.

This method should not be included in a subclassed shader object attached to texture mapped IDLgrSurface or IDLgrPolygon object (where an image is associated via the TEXTURE_MAP property). A software fallback option is not available in such cases.


Result = Obj->[IDLgrShader subclass::]Filter( Image )

Return Value

Returns an IDL array containing the resulting filtered image. The array must have the same dimensions and type as the incoming image. If the returned array does not meet these requirements, IDL ignores the array and draws the image with its original data.

This method should apply the desired operation to the image data and return that data as its function return value. IDL clamps the returned image data to the range [0.0, 1.0] and converts this range into the pixel component range appropriate for the device. In most cases, this is [0, 255].



An array containing the image data. This array is always of type FLOAT and contains RGBA components arranged in PIXEL_INTERLEAVE format, [4, cols, rows].




The following code segment shows an implementation of the Filter method in an object, shader_rgb_doc, that subclasses from IDLgrShader. Within the method, access the RGBA floating-point, pixel-interleaved data in Image. Alter the intensity of each red, green, and blue channel based on values (s) contained in the uniform variable (scl). Return the filtered image.

Function shader_rgb_doc::Filter, Image
self->GetUniformVariable, 'scl', s
newImage[0,*,*] *= s[0]
newImage[1,*,*] *= s[1]
newImage[2,*,*] *= s[2]
RETURN, newImage

See shader_rgb_doc__define.pro for the complete, working example, which is located in the examples/doc/shaders subdirectory of the IDL distribution. Run the example by creating an instance of the object at the IDL command prompt using orgbshader=OBJ_NEW("shader_rgb_doc") or view the file in an IDL Editor window by entering shader_rgb_doc__define.pro.

Version History



See Also


© 2020 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us