diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-08-16 05:41:29 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-09-02 01:08:47 +0200 |
commit | 1de0dd02c8102f20ae9acea8af141eccaa20d5b6 (patch) | |
tree | 5dd33b69baec00a2389e2bd217ea8e801d8561fe | |
parent | use generic implementation for OSX (diff) | |
download | core-1de0dd02c8102f20ae9acea8af141eccaa20d5b6.tar.gz core-1de0dd02c8102f20ae9acea8af141eccaa20d5b6.zip |
make the shaders compliant to GLSL 1.2
Change-Id: Ic15760ca40d719ae333003c9bc241c813cb284fa
4 files changed, 33 insertions, 12 deletions
diff --git a/canvas/opengl/linearMultiColorGradientFragmentShader.glsl b/canvas/opengl/linearMultiColorGradientFragmentShader.glsl index a3f3358c592b..7ad881368ac5 100644 --- a/canvas/opengl/linearMultiColorGradientFragmentShader.glsl +++ b/canvas/opengl/linearMultiColorGradientFragmentShader.glsl @@ -15,6 +15,13 @@ uniform sampler1D t_stopArray1d; uniform mat3x2 m_transform; varying vec2 v_textureCoords2d; +int max(int x, int y) +{ + if(x > y) + return x; + return y; +} + int findBucket(float t) { int nMinBucket=0; @@ -26,13 +33,13 @@ int findBucket(float t) void main(void) { - const float fAlpha = + float fAlpha = clamp( (m_transform * vec3(v_textureCoords2d,1)).s, 0.0, 1.0 ); - const int nMinBucket=findBucket( fAlpha ); + int nMinBucket = findBucket( fAlpha ); - const float fLerp = + float fLerp = (fAlpha-texture1D(t_stopArray1d, nMinBucket).s) / (texture1D(t_stopArray1d, nMinBucket+1).s - texture1D(t_stopArray1d, nMinBucket).s); diff --git a/canvas/opengl/radialMultiColorGradientFragmentShader.glsl b/canvas/opengl/radialMultiColorGradientFragmentShader.glsl index 6f61a766fed3..ebc6d6f5fe10 100644 --- a/canvas/opengl/radialMultiColorGradientFragmentShader.glsl +++ b/canvas/opengl/radialMultiColorGradientFragmentShader.glsl @@ -16,6 +16,13 @@ uniform mat3x2 m_transform; varying vec2 v_textureCoords2d; const vec2 v_center2d = vec2(0,0); +int max(int x, int y) +{ + if(x > y) + return x; + return y; +} + int findBucket(float t) { int nMinBucket=0; @@ -27,15 +34,15 @@ int findBucket(float t) void main(void) { - const float fAlpha = + float fAlpha = clamp( 1.0 - distance( vec2( m_transform * vec3(v_textureCoords2d,1)), v_center2d), 0.0, 1.0 ); - const int nMinBucket=findBucket( fAlpha ); + int nMinBucket=findBucket( fAlpha ); - const float fLerp = + float fLerp = (fAlpha-texture1D(t_stopArray1d, nMinBucket).s) / (texture1D(t_stopArray1d, nMinBucket+1).s - texture1D(t_stopArray1d, nMinBucket).s); diff --git a/canvas/opengl/rectangularMultiColorGradientFragmentShader.glsl b/canvas/opengl/rectangularMultiColorGradientFragmentShader.glsl index 05a8ae513f02..ea17565c18aa 100644 --- a/canvas/opengl/rectangularMultiColorGradientFragmentShader.glsl +++ b/canvas/opengl/rectangularMultiColorGradientFragmentShader.glsl @@ -15,6 +15,13 @@ uniform sampler1D t_stopArray1d; uniform mat3x2 m_transform; varying vec2 v_textureCoords2d; +int max(int x, int y) +{ + if(x > y) + return x; + return y; +} + int findBucket(float t) { int nMinBucket=0; @@ -26,12 +33,12 @@ int findBucket(float t) void main(void) { - const vec2 v = abs( vec2(m_transform * vec3(v_textureCoords2d,1)) ); - const float fAlpha = 1 - max(v.x, v.y); + vec2 v = abs( vec2(m_transform * vec3(v_textureCoords2d,1)) ); + float fAlpha = 1 - max(v.x, v.y); - const int nMinBucket=findBucket( fAlpha ); + int nMinBucket=findBucket( fAlpha ); - const float fLerp = + float fLerp = (fAlpha-texture1D(t_stopArray1d, nMinBucket).s) / (texture1D(t_stopArray1d, nMinBucket+1).s - texture1D(t_stopArray1d, nMinBucket).s); diff --git a/canvas/opengl/rectangularTwoColorGradientFragmentShader.glsl b/canvas/opengl/rectangularTwoColorGradientFragmentShader.glsl index a92a53342975..038cdffd24ad 100644 --- a/canvas/opengl/rectangularTwoColorGradientFragmentShader.glsl +++ b/canvas/opengl/rectangularTwoColorGradientFragmentShader.glsl @@ -15,8 +15,8 @@ uniform mat3x2 m_transform; varying vec2 v_textureCoords2d; void main(void) { - const vec2 v = abs( vec2(m_transform * vec3(v_textureCoords2d,1)) ); - const float t = max(v.x, v.y); + vec2 v = abs( vec2(m_transform * vec3(v_textureCoords2d,1)) ); + float t = max(v.x, v.y); gl_FragColor = mix(v_startColor4d, v_endColor4d, 1.0-t); |