Browse Source

working on outline

dmuratshin 9 years ago
parent
commit
ebea4222f9

+ 30 - 15
examples/Demo/data/pp_hblur_vs.glsl

@@ -5,9 +5,24 @@ attribute vec2 uv;
  
 uniform mediump float step;
 
+
 varying mediump vec2 v_texCoord;
-varying mediump vec2 v_blurTexCoords[14];
+varying mediump vec2 v_blurTexCoords0;
+varying mediump vec2 v_blurTexCoords1;
+varying mediump vec2 v_blurTexCoords2;
+varying mediump vec2 v_blurTexCoords3;
+varying mediump vec2 v_blurTexCoords4;
+varying mediump vec2 v_blurTexCoords5;
+varying mediump vec2 v_blurTexCoords6;
+varying mediump vec2 v_blurTexCoords7;
+varying mediump vec2 v_blurTexCoords8;
+varying mediump vec2 v_blurTexCoords9;
+varying mediump vec2 v_blurTexCoords10;
+varying mediump vec2 v_blurTexCoords11;
+varying mediump vec2 v_blurTexCoords12;
+varying mediump vec2 v_blurTexCoords13;
  
+
 void main()
 {
     gl_Position = vec4(position.xy, 0, 1.0);
@@ -15,18 +30,18 @@ void main()
 
 
     v_texCoord = uv;
-    v_blurTexCoords[ 0] = v_texCoord + vec2(-z * 7.0, 0.0);
-    v_blurTexCoords[ 1] = v_texCoord + vec2(-z * 6.0, 0.0);
-    v_blurTexCoords[ 2] = v_texCoord + vec2(-z * 5.0, 0.0);
-    v_blurTexCoords[ 3] = v_texCoord + vec2(-z * 4.0, 0.0);
-    v_blurTexCoords[ 4] = v_texCoord + vec2(-z * 3.0, 0.0);
-    v_blurTexCoords[ 5] = v_texCoord + vec2(-z * 2.0, 0.0);
-    v_blurTexCoords[ 6] = v_texCoord + vec2(-z      , 0.0);
-    v_blurTexCoords[ 7] = v_texCoord + vec2( z      , 0.0);
-    v_blurTexCoords[ 8] = v_texCoord + vec2( z * 2.0, 0.0);
-    v_blurTexCoords[ 9] = v_texCoord + vec2( z * 3.0, 0.0);
-    v_blurTexCoords[10] = v_texCoord + vec2( z * 4.0, 0.0);
-    v_blurTexCoords[11] = v_texCoord + vec2( z * 5.0, 0.0);
-    v_blurTexCoords[12] = v_texCoord + vec2( z * 6.0, 0.0);
-    v_blurTexCoords[13] = v_texCoord + vec2( z * 7.0, 0.0);
+    v_blurTexCoords0 = v_texCoord + vec2(-z * 7.0, 0.0);
+    v_blurTexCoords1 = v_texCoord + vec2(-z * 6.0, 0.0);
+    v_blurTexCoords2 = v_texCoord + vec2(-z * 5.0, 0.0);
+    v_blurTexCoords3 = v_texCoord + vec2(-z * 4.0, 0.0);
+    v_blurTexCoords4 = v_texCoord + vec2(-z * 3.0, 0.0);
+    v_blurTexCoords5 = v_texCoord + vec2(-z * 2.0, 0.0);
+    v_blurTexCoords6 = v_texCoord + vec2(-z      , 0.0);
+    v_blurTexCoords7 = v_texCoord + vec2( z      , 0.0);
+    v_blurTexCoords8 = v_texCoord + vec2( z * 2.0, 0.0);
+    v_blurTexCoords9 = v_texCoord + vec2( z * 3.0, 0.0);
+    v_blurTexCoords10 = v_texCoord + vec2( z * 4.0, 0.0);
+    v_blurTexCoords11 = v_texCoord + vec2( z * 5.0, 0.0);
+    v_blurTexCoords12 = v_texCoord + vec2( z * 6.0, 0.0);
+    v_blurTexCoords13 = v_texCoord + vec2( z * 7.0, 0.0);
 }

+ 32 - 16
examples/Demo/data/pp_rast_fs.glsl

@@ -3,27 +3,43 @@
  
 uniform lowp sampler2D s_texture;
  
+
 varying mediump vec2 v_texCoord;
-varying mediump vec2 v_blurTexCoords[14];
+varying mediump vec2 v_blurTexCoords0;
+varying mediump vec2 v_blurTexCoords1;
+varying mediump vec2 v_blurTexCoords2;
+varying mediump vec2 v_blurTexCoords3;
+varying mediump vec2 v_blurTexCoords4;
+varying mediump vec2 v_blurTexCoords5;
+varying mediump vec2 v_blurTexCoords6;
+varying mediump vec2 v_blurTexCoords7;
+varying mediump vec2 v_blurTexCoords8;
+varying mediump vec2 v_blurTexCoords9;
+varying mediump vec2 v_blurTexCoords10;
+varying mediump vec2 v_blurTexCoords11;
+varying mediump vec2 v_blurTexCoords12;
+varying mediump vec2 v_blurTexCoords13;
+ 
+ 
  
 void main()
 {
     const mediump float M = 3.0;
     gl_FragColor = vec4(0.0);
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 0])*0.0044299121055113265 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 1])*0.00895781211794 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 2])*0.0215963866053 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 3])*0.0443683338718 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 4])*0.0776744219933 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 5])*0.115876621105 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 6])*0.147308056121 * M;
-    gl_FragColor += texture2D(s_texture, v_texCoord         )*0.159576912161 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 7])*0.147308056121 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 8])*0.115876621105 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[ 9])*0.0776744219933 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[10])*0.0443683338718 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[11])*0.0215963866053 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[12])*0.00895781211794 * M;
-    gl_FragColor += texture2D(s_texture, v_blurTexCoords[13])*0.0044299121055113265 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords0)*0.0044299121055113265 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords1)*0.00895781211794 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords2)*0.0215963866053 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords3)*0.0443683338718 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords4)*0.0776744219933 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords5)*0.115876621105 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords6)*0.147308056121 * M;
+    gl_FragColor += texture2D(s_texture, v_texCoord      )*0.159576912161 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords7)*0.147308056121 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords8)*0.115876621105 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords9)*0.0776744219933 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords10)*0.0443683338718 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords11)*0.0215963866053 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords12)*0.00895781211794 * M;
+    gl_FragColor += texture2D(s_texture, v_blurTexCoords13)*0.0044299121055113265 * M;
     gl_FragColor = vec4(1.0,1.0,1.0,1.0) * gl_FragColor.a;
 }

+ 30 - 15
examples/Demo/data/pp_vblur_vs.glsl

@@ -5,8 +5,23 @@ attribute  vec2 uv;
  
 uniform mediump float step;
 
+
 varying mediump vec2 v_texCoord;
-varying mediump vec2 v_blurTexCoords[14];
+varying mediump vec2 v_blurTexCoords0;
+varying mediump vec2 v_blurTexCoords1;
+varying mediump vec2 v_blurTexCoords2;
+varying mediump vec2 v_blurTexCoords3;
+varying mediump vec2 v_blurTexCoords4;
+varying mediump vec2 v_blurTexCoords5;
+varying mediump vec2 v_blurTexCoords6;
+varying mediump vec2 v_blurTexCoords7;
+varying mediump vec2 v_blurTexCoords8;
+varying mediump vec2 v_blurTexCoords9;
+varying mediump vec2 v_blurTexCoords10;
+varying mediump vec2 v_blurTexCoords11;
+varying mediump vec2 v_blurTexCoords12;
+varying mediump vec2 v_blurTexCoords13;
+ 
  
 void main()
 {
@@ -14,18 +29,18 @@ void main()
     mediump float z = step;
 
     v_texCoord = uv;
-    v_blurTexCoords[ 0] = v_texCoord + vec2(0.0, -z * 7.0);
-    v_blurTexCoords[ 1] = v_texCoord + vec2(0.0, -z * 6.0);
-    v_blurTexCoords[ 2] = v_texCoord + vec2(0.0, -z * 5.0);
-    v_blurTexCoords[ 3] = v_texCoord + vec2(0.0, -z * 4.0);
-    v_blurTexCoords[ 4] = v_texCoord + vec2(0.0, -z * 3.0);
-    v_blurTexCoords[ 5] = v_texCoord + vec2(0.0, -z * 2.0);
-    v_blurTexCoords[ 6] = v_texCoord + vec2(0.0, -z);
-    v_blurTexCoords[ 7] = v_texCoord + vec2(0.0,  z);
-    v_blurTexCoords[ 8] = v_texCoord + vec2(0.0,  z * 2.0);
-    v_blurTexCoords[ 9] = v_texCoord + vec2(0.0,  z * 3.0);
-    v_blurTexCoords[10] = v_texCoord + vec2(0.0,  z * 4.0);
-    v_blurTexCoords[11] = v_texCoord + vec2(0.0,  z * 5.0);
-    v_blurTexCoords[12] = v_texCoord + vec2(0.0,  z * 6.0);
-    v_blurTexCoords[13] = v_texCoord + vec2(0.0,  z * 7.0);
+    v_blurTexCoords0 = v_texCoord + vec2(0.0, -z * 7.0);
+    v_blurTexCoords1 = v_texCoord + vec2(0.0, -z * 6.0);
+    v_blurTexCoords2 = v_texCoord + vec2(0.0, -z * 5.0);
+    v_blurTexCoords3 = v_texCoord + vec2(0.0, -z * 4.0);
+    v_blurTexCoords4 = v_texCoord + vec2(0.0, -z * 3.0);
+    v_blurTexCoords5 = v_texCoord + vec2(0.0, -z * 2.0);
+    v_blurTexCoords6 = v_texCoord + vec2(0.0, -z);
+    v_blurTexCoords7 = v_texCoord + vec2(0.0,  z);
+    v_blurTexCoords8 = v_texCoord + vec2(0.0,  z * 2.0);
+    v_blurTexCoords9 = v_texCoord + vec2(0.0,  z * 3.0);
+    v_blurTexCoords10 = v_texCoord + vec2(0.0,  z * 4.0);
+    v_blurTexCoords11 = v_texCoord + vec2(0.0,  z * 5.0);
+    v_blurTexCoords12 = v_texCoord + vec2(0.0,  z * 6.0);
+    v_blurTexCoords13 = v_texCoord + vec2(0.0,  z * 7.0);
 }

+ 13 - 11
oxygine/src/TweenAlphaFade.cpp

@@ -8,7 +8,7 @@
 namespace oxygine
 {
 
-    TweenPostProcess::TweenPostProcess(int opt) : _actor(0), _prev(0), _options(opt)
+    TweenPostProcess::TweenPostProcess(int opt) : _actor(0), _prev(0), _options(opt), _format(TF_R4G4B4A4)
     {
     }
 
@@ -81,13 +81,13 @@ namespace oxygine
         if (!_rt)
         {
             _rt = IVideoDriver::instance->createTexture();
-            _rt->init(_screen.getWidth(), _screen.getHeight(), TF_R8G8B8A8, true);
+            _rt->init(_screen.getWidth(), _screen.getHeight(), TF_R4G4B4A4, true);
             c = true;
         }
 
         if (_rt->getWidth() < _screen.getWidth() || _rt->getHeight() < _screen.getHeight())
         {
-            _rt->init(_screen.getWidth(), _screen.getHeight(), TF_R8G8B8A8, true);
+            _rt->init(_screen.getWidth(), _screen.getHeight(), TF_R4G4B4A4, true);
             c = true;
         }
 
@@ -140,7 +140,7 @@ namespace oxygine
         mat->Material::render(_actor, rs);
 
         mat->finish();
-        driver->setRenderTarget(0);
+        //driver->setRenderTarget(0);
     }
 
     void TweenPostProcess::update(Actor& actor, float p, const UpdateState& us)
@@ -194,6 +194,10 @@ namespace oxygine
 
     void TweenGlow::render2texture()
     {
+
+        GLint prevFBO = 0;
+        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFBO);
+
         TweenPostProcess::render2texture();
         const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(IVideoDriver::instance->getVertexDeclaration(vertexPCT2::FORMAT));
 
@@ -237,8 +241,6 @@ namespace oxygine
         }
 
 
-        GLint prevFBO = 0;
-        glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFBO);
 
         Rect vp = _screen;
         vp.pos = Point(0, 0);
@@ -256,6 +258,7 @@ namespace oxygine
         /*
 
         oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt2.get())->getFboID());
+        driver->clear(0);
         driver->setViewport(Rect(0, 0, w / 2, h / 2));
         driver->setShaderProgram(shaderBlit);
         driver->setUniformInt("s_texture", 0);
@@ -275,6 +278,7 @@ namespace oxygine
 
 
         oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt.get())->getFboID());
+        driver->clear(0);
         driver->setViewport(Rect(0, 0, w / 2, h / 2));
         driver->setShaderProgram(shaderBlit);
         driver->setUniformInt("s_texture", 0);
@@ -296,9 +300,9 @@ namespace oxygine
 
 
         oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt2.get())->getFboID());
+        driver->clear(0);
 
         driver->setViewport(Rect(0, 0, w, h));
-        driver->clear(0);
         driver->setShaderProgram(shaderBlurH);
         driver->setUniform("step", 1.0f / _rt->getWidth());
         driver->setUniformInt("s_texture", 0);
@@ -318,11 +322,9 @@ namespace oxygine
 
 
         oxglBindFramebuffer(GL_FRAMEBUFFER, safeCast<NativeTextureGLES*>(_rt.get())->getFboID());
-
+        driver->clear(0);
 
         driver->setViewport(Rect(0, 0, w, h));
-        driver->clear(Color::Red);
-
         driver->setShaderProgram(shaderBlurV);
         driver->setUniform("step", 1.0f / _rt2->getHeight());
         driver->setUniformInt("s_texture", 0);
@@ -348,6 +350,6 @@ namespace oxygine
         TweenPostProcess::rtCreated();
         _rt2 = IVideoDriver::instance->createTexture();
         //_rt2->init(_screen.getWidth() / 2, _screen.getHeight() / 2, TF_R8G8B8A8, true);
-        _rt2->init(_screen.getWidth(), _screen.getHeight(), TF_R8G8B8A8, true);
+        _rt2->init(_screen.getWidth(), _screen.getHeight(), TF_R4G4B4A4, true);
     }
 }

+ 1 - 0
oxygine/src/TweenAlphaFade.h

@@ -13,6 +13,7 @@ namespace oxygine
     {
     public:
         typedef Actor type;
+        TextureFormat _format;
 
         Actor* _actor;
         Material* _prev;