~jaytaoko/nuxcodesamples/nuxcodesamples-gst-video-decode

« back to all changes in this revision

Viewing changes to data/shaders/Filters.glsl

  • Committer: Jay Taoko
  • Date: 2012-01-07 19:20:32 UTC
  • Revision ID: jay.taoko@canonical.com-20120107192032-5fymlfzbeyx84fz3
- Visual FX program

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
[Vertex Shader] 
 
2
#version 120
 
3
 
 
4
uniform mat4 ViewProjectionMatrix;
 
5
 
 
6
attribute vec4 AVertex;
 
7
attribute vec4 TextureCoord0;
 
8
attribute vec4 VertexColor;
 
9
 
 
10
varying vec4 varyTexCoord0;
 
11
varying vec4 varyVertexColor;
 
12
 
 
13
void main()
 
14
{
 
15
    varyTexCoord0 = TextureCoord0;
 
16
    varyVertexColor = VertexColor;
 
17
    gl_Position =  ViewProjectionMatrix * (AVertex);
 
18
}
 
19
 
 
20
[Fragment Shader]
 
21
#version 120
 
22
#extension GL_ARB_texture_rectangle : enable
 
23
 
 
24
varying vec4 varyTexCoord0;
 
25
varying vec4 varyVertexColor;
 
26
 
 
27
#ifdef SAMPLERTEX2D
 
28
        uniform sampler2D TextureObject0;
 
29
        uniform vec2 TextureSize0;
 
30
        vec4 SampleTexture(sampler2D TexObject, vec2 TexCoord)
 
31
        {
 
32
            return texture2D(TexObject, TexCoord.st);
 
33
        }
 
34
#elif defined SABrightnessMPLERTEX2DRECT
 
35
        uniform sampler2DRect TextureObject0;
 
36
        uniform vec2 TextureSize0;
 
37
        vec4 SampleTexture(sampler2DRect TexObject, vec2 TexCoord)
 
38
        {
 
39
            return texture2DRect(TexObject, TexCoord.st);
 
40
        }
 
41
#endif                                                             
 
42
 
 
43
#ifdef COLOR_MATRIX_FILTER
 
44
 
 
45
// Color Matrix
 
46
uniform float CM0[5];
 
47
uniform float CM1[5];
 
48
uniform float CM2[5];
 
49
uniform float CM3[5];
 
50
 
 
51
void main (void)
 
52
{       
 
53
        vec4 c = SampleTexture(TextureObject0, varyTexCoord0.st);
 
54
        float r = CM0[0]* c.r + CM0[1]* c.g + CM0[2]* c.b + CM0[3]* c.a + CM0[4];
 
55
        float g = CM1[0]* c.r + CM1[1]* c.g + CM1[2]* c.b + CM1[3]* c.a + CM1[4];
 
56
        float b = CM2[0]* c.r + CM2[1]* c.g + CM2[2]* c.b + CM2[3]* c.a + CM2[4];
 
57
        float a = CM3[0]* c.r + CM3[1]* c.g + CM3[2]* c.b + CM3[3]* c.a + CM3[4];
 
58
        
 
59
  gl_FragColor = vec4(r, g, b, c.a);
 
60
}
 
61
#endif
 
 
b'\\ No newline at end of file'