make the shaders compliant to GLSL 1.2

Change-Id: Ic15760ca40d719ae333003c9bc241c813cb284fa
This commit is contained in:
Markus Mohrhard 2014-08-16 05:41:29 +02:00
parent b29154d85e
commit 1de0dd02c8
4 changed files with 33 additions and 12 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);