Advanced Computer Graphics: Laboratory Project

<< PREV | INDEX | NEXT >>

Task 3A: Create an 'Invert' Effect

Preparation

Study the technique 'red' and its fragment shader 'psRed' in the CgFX file 'postprocessing.fx', to understand how the framebuffer information can be accessed and manipulated.

Description

Create a new technique called 'invert', which uses a fragment shader 'psInvert' that samples the framebuffer texture, inverts the value and outputs the result.

Hint

A RECT texture does not use normal texture coordinates with a range of [0..1]. Instead, texture coordinates ranging from 0 to the texture width/height are used. This means that in order to bias the sampling, we can simply add the value corresponding to the number of texels we want to bias with.

Since the techniques are loaded in the same order as they appear in the effect file, you can add the new technique above the already present techniques in order to make it the first one loaded.

Build/run the application when you think you have completed this task. Try moving and resizing the post-processing window.


<< PREV | INDEX | NEXT >>