瀏覽代碼

move shaders to system zip
improved demo

dmuratshin 9 年之前
父節點
當前提交
6836f56ad1

+ 0 - 1
examples/Demo/proj.win32/Demo.vcxproj

@@ -145,7 +145,6 @@
     <ClInclude Include="../src/example.h" />
     <ClInclude Include="../src/test.h" />
     <ClInclude Include="..\src\TestEdges.h" />
-    <ClInclude Include="..\src\TestTweenAlphaFade.h" />
     <ClInclude Include="..\src\TestTweenPostProcessing.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

+ 0 - 1
examples/Demo/proj.win32/Demo.vcxproj.filters

@@ -34,7 +34,6 @@
     <ClInclude Include="../src/TestUserShader2.h" />
     <ClInclude Include="../src/example.h" />
     <ClInclude Include="../src/test.h" />
-    <ClInclude Include="..\src\TestTweenAlphaFade.h" />
     <ClInclude Include="..\src\TestEdges.h" />
     <ClInclude Include="..\src\TestTweenPostProcessing.h" />
   </ItemGroup>

+ 0 - 44
examples/Demo/src/TestTweenAlphaFade.h

@@ -1,44 +0,0 @@
-#pragma once
-#include "test.h"
-#include "TweenAlphaFade.h"
-#undef OUT
-
-
-class TestTweenAlphaFade : public Test
-{
-public:
-    spActor _test;
-    TestTweenAlphaFade()
-    {
-        spSprite sprite = new Sprite;
-        sprite->setResAnim(resources.getResAnim("t2p"));
-        sprite->attachTo(content);
-
-        sprite->setPosition(getStage()->getSize() / 2);
-        sprite->addEventListener(TouchEvent::CLICK,
-                                 CLOSURE(this, &TestTweenAlphaFade::onClick));
-
-        spSprite anim = new Sprite;
-        anim->attachTo(sprite);
-        anim->addTween(Actor::TweenScale(3), 4000, -1, true);
-        anim->setPosition(sprite->getSize() / 2);
-        anim->setAnchor(0.5f, 0.5f);
-        anim->setScale(10);
-        anim->setResAnim(resources.getResAnim("anim"));
-        anim->addTween(TweenAnim(resources.getResAnim("anim")), 1500, -1);
-
-        sprite->addTween(Actor::TweenRotationDegrees(360), 10000, -1);
-        sprite->setAnchor(0.5f, 0.5f);
-        _test = sprite;
-    }
-
-    void onClick(Event*)
-    {
-        _test->addTween(TweenAlphaFade(false), 5500, 1, true);
-    }
-
-    void clicked(string id)
-    {
-        //   _test->addTween(TweenFade(), 1500);
-    }
-};

+ 78 - 4
examples/Demo/src/TestTweenPostProcessing.h

@@ -7,6 +7,10 @@
 class TestTweenPostProcessing : public Test
 {
 public:
+    bool _fullscreen;
+    bool _singleRender;
+    int _type;
+
     spActor _test;
     TestTweenPostProcessing()
     {
@@ -18,22 +22,92 @@ public:
 
         spSprite anim = new Sprite;
         anim->attachTo(sprite);
-        anim->addTween(Actor::TweenScale(6), 4000, -1, true);
+        anim->addTween(Actor::TweenScale(3), 4000, -1, true);
         anim->setPosition(sprite->getSize() / 2);
         anim->setAnchor(0.5f, 0.5f);
-        anim->setScale(10);
         anim->setResAnim(resources.getResAnim("anim"));
         anim->addTween(TweenAnim(resources.getResAnim("anim")), 1500, -1);
 
-        sprite->addTween(Actor::TweenRotationDegrees(360), 10000, -1);
+        sprite->addTween(Actor::TweenRotationDegrees(360), 30000, -1);
         sprite->setAnchor(0.5f, 0.5f);
 
-        sprite->addTween(TweenOutline(Color::Blue, PostProcessOptions().fullscreen().singleRender()), 55000, 1, true);
+
         _test = sprite;
+
+
+        _fullscreen = false;
+        _singleRender = false;
+        _type = 0;
+
+        toggle t[] =
+        {
+            toggle("bounds: fullscreen", 0),
+            toggle("bounds: actor", 1),
+        };
+
+        addToggle("mode.fs", t, 2);
+
+
+        toggle t2[] =
+        {
+            toggle("render: dynamic", 0),
+            toggle("render: single", 1),
+        };
+
+        addToggle("mode.rn", t2, 2);
+
+
+        toggle t3[] =
+        {
+            toggle("tween: Outline", 1),
+            toggle("tween: AlphaFade", 0),
+        };
+
+        addToggle("type", t3, 2);
+
+        addTween();
+    }
+
+    void addTween()
+    {
+        _test->removeTweensByName("pp");
+
+        PostProcessOptions opt;
+        opt.fullscreen(_fullscreen);
+        opt.singleRender(_singleRender);
+
+        spTween t;
+        if (_type == 0)
+            t = _test->addTween(TweenOutline(Color::YellowGreen, opt), 5000, -1, true, 0, Tween::ease_inOutCubic);
+        else
+            t = _test->addTween(TweenAlphaFade(true, opt), 5000, -1, true, 0, Tween::ease_inOutCubic);
+
+        t->setName("pp");
+    }
+
+    void toggleClicked(string id, const toggle* data)
+    {
+        if (id == "mode.fs")
+        {
+            _fullscreen = data->value ? true : false;
+        }
+
+        if (id == "mode.rn")
+        {
+            _singleRender = data->value ? true : false;
+        }
+
+        if (id == "type")
+        {
+            _type = data->value;
+        }
+
+        addTween();
     }
 
     void clicked(string id)
     {
+
         //   _test->addTween(TweenFade(), 1500);
     }
 };

+ 1 - 4
examples/Demo/src/example.cpp

@@ -25,7 +25,6 @@
 #include "TestTweenShine.h"
 #include "TestTouches.h"
 #include "TestColorFont.h"
-#include "TestTweenAlphaFade.h"
 #include "TestTweenPostProcessing.h"
 
 #ifdef __S3E__
@@ -81,8 +80,7 @@ public:
         addButton("inputtext", "Input Text");
         addButton("openbrowser", "Open Browser");
         addButton("http", "Http requests");
-        addButton("tweenfade", "Tween Alpha Fade");
-        addButton("tweenpp", "Post Processing Tweens");
+		addButton("tweenpp", "Post Processing Tweens");
 
         _color = Color::Red;
         _txtColor = Color::White;
@@ -132,7 +130,6 @@ public:
         if (id == "tweentext") showTest(new TestTweenText);
         if (id == "tweenshine") showTest(new TestTweenShine);
         if (id == "multicolorfont") showTest(new TestColorFont);
-        if (id == "tweenfade") showTest(new TestTweenAlphaFade);
         if (id == "tweenpp") showTest(new TestTweenPostProcessing);
         if (id == "openbrowser")
         {

+ 9 - 3
oxygine/src/PostProcess.cpp

@@ -6,6 +6,8 @@
 #include "RenderState.h"
 #include "STDMaterial.h"
 #include "core/file.h"
+#include "core/system_data.h"
+#include "core/ZipFileSystem.h"
 
 namespace oxygine
 {
@@ -18,14 +20,18 @@ namespace oxygine
         if (PostProcess::shaderBlurH)
             return;
 
+        file::Zips zp;
+        zp.add(system_data, system_size);
+
+
         const VertexDeclarationGL* decl = static_cast<const VertexDeclarationGL*>(IVideoDriver::instance->getVertexDeclaration(vertexPCT2::FORMAT));
 
         file::buffer vs_h;
         file::buffer vs_v;
         file::buffer fs_blur;
-        file::read("pp_hblur_vs.glsl", vs_h);
-        file::read("pp_vblur_vs.glsl", vs_v);
-        file::read("pp_rast_fs.glsl", fs_blur);
+        zp.read("system/pp_hblur_vs.glsl", vs_h);
+        zp.read("system/pp_vblur_vs.glsl", vs_v);
+        zp.read("system/pp_rast_fs.glsl", fs_blur);
 
         vs_h.push_back(0);
         vs_v.push_back(0);

File diff suppressed because it is too large
+ 0 - 1
oxygine/src/core/system_data.cpp


+ 11 - 0
oxygine/system_data/original/system/pp_blit_fs.glsl

@@ -0,0 +1,11 @@
+/* BlurFragmentShader.glsl */
+//precision mediump float;
+ 
+uniform mediump sampler2D s_texture;
+ 
+varying mediump vec2 v_texCoord;
+ 
+void main()
+{
+    gl_FragColor = texture2D(s_texture, v_texCoord);
+}

+ 16 - 0
oxygine/system_data/original/system/pp_blit_vs.glsl

@@ -0,0 +1,16 @@
+/* VBlurVertexShader.glsl */
+attribute  vec3 position;
+attribute  vec4 color;
+attribute  vec2 uv;
+ 
+uniform mediump float step;
+
+varying mediump vec2 v_texCoord;
+varying mediump vec4 v_color;
+ 
+void main()
+{
+    gl_Position = vec4(position.xyz, 1.0);
+    v_texCoord = uv;
+    v_color = color;
+}

+ 48 - 0
oxygine/system_data/original/system/pp_hblur_vs.glsl

@@ -0,0 +1,48 @@
+/* VBlurVertexShader.glsl */
+attribute vec3 position;
+attribute vec4 color;
+attribute vec2 uv;
+ 
+uniform mediump float step;
+
+
+varying mediump vec4 v_color;
+varying mediump vec2 v_texCoord;
+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);
+    mediump float z = step;
+
+    v_color = color;
+    v_texCoord = uv;
+    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);
+}

+ 45 - 0
oxygine/system_data/original/system/pp_rast_fs.glsl

@@ -0,0 +1,45 @@
+/* BlurFragmentShader.glsl */
+//precision mediump float;
+ 
+uniform lowp sampler2D s_texture;
+ 
+varying mediump vec4 v_color;
+varying mediump vec2 v_texCoord;
+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_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 = v_color * min(gl_FragColor.a, 1.0);
+}

+ 47 - 0
oxygine/system_data/original/system/pp_vblur_vs.glsl

@@ -0,0 +1,47 @@
+/* VBlurVertexShader.glsl */
+attribute  vec3 position;
+attribute  vec4 color;
+attribute  vec2 uv;
+ 
+uniform mediump float step;
+
+varying mediump vec4 v_color;
+varying mediump vec2 v_texCoord;
+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);
+    mediump float z = step;
+
+    v_color = color;
+    v_texCoord = uv;
+    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);
+}

Some files were not shown because too many files changed in this diff