~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to NuxGraphics/RenderingPipeGLSL.cpp

  • Committer: Nic d'Offay
  • Date: 2012-08-20 09:45:20 UTC
  • Revision ID: nicolas.doffay@canonical.com-20120820094520-92d2ss8pdme8zik5
Fixed shader compilation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
 
125
125
    std::string vertexString = 
126
126
    NUX_VERTEX_SHADER_HEADER
127
 
    "attribute vec4 vertex;                                                 \n\
128
 
    attribute vec4 textureCoord0;                                           \n\
129
 
    uniform mat4 viewProjectionMatrix;                                      \n\
130
 
    varying vec4 varyTexCoord0;                                             \n\
131
 
    void main()                                                             \n\
132
 
    {                                                                       \n\
133
 
        gl_Position =  viewProjectionMatrix * vertex;                       \n\
134
 
        varyTexCoord0 = textureCoord0;                                      \n\
 
127
    "attribute vec4 vertex;                             \n\
 
128
    attribute vec4 textureCoord0;                       \n\
 
129
    uniform mat4 viewProjectionMatrix;                  \n\
 
130
    uniform float gamma;                                \n\
 
131
    varying vec4 varyTexCoord0;                         \n\
 
132
    void main()                                         \n\
 
133
    {                                                   \n\
 
134
        gl_Position =  viewProjectionMatrix * vertex;   \n\
 
135
        varyTexCoord0 = textureCoord0;                  \n\
135
136
    }";
136
137
 
137
138
    std::string pixelString =
138
139
    NUX_FRAGMENT_SHADER_HEADER
139
 
    "uniform sampler2D textureObject;                                       \n\
140
 
    uniform float gamma;                                                    \n\
141
 
    varying vec4 varyTexCoord0;                                             \n\
142
 
    void main()                                                             \n\
143
 
    {                                                                       \n\
144
 
        vec2 uv             = varyTexCoord0.xy;                             \n\
145
 
        texture2D tempTex   = texture2D(textureObject, uv);                 \n\
146
 
        gl_FragColor.rgb    = pow(tempTex.rgb, 1 / gamma);                  \n\
147
 
        gl_FragColor.a      = tempTex.a;                                    \n\
 
140
    "uniform sampler2D textureObject;                           \n\
 
141
    uniform float gamma;                                        \n\
 
142
    varying vec4 varyTexCoord0;                                 \n\
 
143
    void main()                                                 \n\
 
144
    {                                                           \n\
 
145
        vec2 uv             = varyTexCoord0.st;                 \n\
 
146
        vec4 tempTex        = texture2D(textureObject, uv);     \n\
 
147
        gl_FragColor.rgb    = pow(tempTex.rgb, 1 / gamma);      \n\
 
148
        gl_FragColor.a      = tempTex.a;                        \n\
148
149
    }";
149
150
 
150
151
    m_sRGBTexture = _graphics_display.m_DeviceFactory->CreateShaderProgram();