(RefractionEffect) Ensure shader compiles with more strict compilers 70/34770/3 tizen_3.0.2014.q4_common tizen_3.0.2015.q1_common accepted/tizen/common/20150205.080853 submit/tizen/20150205.011244
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 2 Feb 2015 15:00:51 +0000 (15:00 +0000)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 3 Feb 2015 09:23:49 +0000 (09:23 +0000)
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

index e9a1a9c..f1325cc 100644 (file)
@@ -94,6 +94,7 @@ public:
   static NoEffect New()
   {
     std::string vertexShader = MAKE_SHADER(
+        precision mediump float;\n
         uniform mediump vec4 uTextureRect;\n
         void main()\n
         {\n
@@ -102,6 +103,7 @@ public:
         }\n
     );
     std::string fragmentShader = MAKE_SHADER(
+        precision mediump float;\n
         void main()\n
         {\n
           gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
@@ -153,6 +155,7 @@ public:
   static RefractionEffect New()
   {
     std::string vertexShader = MAKE_SHADER(
+      precision mediump float;\n
       varying mediump vec2 vTextureOffset;\n
       void main()\n
       {\n
@@ -167,6 +170,7 @@ public:
     );
 
     std::string fragmentShader = MAKE_SHADER(
+      precision mediump float;\n
       uniform mediump float uEffectStrength;\n
       uniform mediump vec3 uLightPosition;\n
       uniform mediump vec2 uLightXYOffset;\n
@@ -205,7 +209,7 @@ public:
       {\n
         vec3 normal = normalize( vNormal);\n
 
-        vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.f);\n
+        vec3 lightPosition = uLightPosition + vec3(uLightXYOffset+uLightSpinOffset, 0.0);\n
         mediump vec3 vecToLight = normalize( (lightPosition - vVertex.xyz) * 0.01 );\n
         mediump float spotEffect = pow( max(0.05, vecToLight.z ) - 0.05, 8.0);\n