Commit e6f2fd5c274926b98c1a189650e7f9548eca74ac

Authored by Adeel Kazmi
1 parent 6ffb190b

(RefractionEffect) Ensure shader compiles with more strict compilers

Shader does not compile with latest Nvidia driver on Ubuntu as we did not set the default precision
and used an f at the end of a float in the shader. Other shader compilers are more permissive so
this was not spotted before.

Change-Id: I235b901f08a73086b8b581a8c40bb4ed517ba35d
examples/shader-effect/refraction-effect-example.cpp
... ... @@ -94,6 +94,7 @@ public:
94 94 static NoEffect New()
95 95 {
96 96 std::string vertexShader = MAKE_SHADER(
  97 + precision mediump float;\n
97 98 uniform mediump vec4 uTextureRect;\n
98 99 void main()\n
99 100 {\n
... ... @@ -102,6 +103,7 @@ public:
102 103 }\n
103 104 );
104 105 std::string fragmentShader = MAKE_SHADER(
  106 + precision mediump float;\n
105 107 void main()\n
106 108 {\n
107 109 gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
... ... @@ -153,6 +155,7 @@ public:
153 155 static RefractionEffect New()
154 156 {
155 157 std::string vertexShader = MAKE_SHADER(
  158 + precision mediump float;\n
156 159 varying mediump vec2 vTextureOffset;\n
157 160 void main()\n
158 161 {\n
... ... @@ -167,6 +170,7 @@ public:
167 170 );
168 171  
169 172 std::string fragmentShader = MAKE_SHADER(
  173 + precision mediump float;\n
170 174 uniform mediump float uEffectStrength;\n
171 175 uniform mediump vec3 uLightPosition;\n
172 176 uniform mediump vec2 uLightXYOffset;\n
... ... @@ -205,7 +209,7 @@ public:
205 209 {\n
206 210 vec3 normal = normalize( vNormal);\n
207 211  
208   - vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.f);\n
  212 + vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.0);\n
209 213 mediump vec3 vecToLight = normalize( (lightPosition - vVertex.xyz) * 0.01 );\n
210 214 mediump float spotEffect = pow( max(0.05, vecToLight.z ) - 0.05, 8.0);\n
211 215  
... ...