|
|
@@ -1,112 +0,0 @@
|
|
|
-diff -r c6ab5032adf6 examples/Demo/data/light_fs.glsl
|
|
|
---- a/examples/Demo/data/light_fs.glsl Tue Nov 25 14:09:04 2014 +0500
|
|
|
-+++ b/examples/Demo/data/light_fs.glsl Tue Nov 25 14:09:14 2014 +0500
|
|
|
-@@ -3,10 +3,11 @@
|
|
|
- varying lowp vec4 result_color;
|
|
|
- varying mediump vec2 result_uv;
|
|
|
- varying mediump vec2 result_uv2;
|
|
|
-+varying mediump vec2 result_light;
|
|
|
-
|
|
|
- uniform lowp sampler2D base_texture;
|
|
|
- uniform lowp sampler2D normal_texture;
|
|
|
--uniform mediump vec2 light;
|
|
|
-+//uniform mediump vec2 light;
|
|
|
-
|
|
|
- void main()
|
|
|
- {
|
|
|
-@@ -14,7 +15,7 @@
|
|
|
- lowp vec3 normal = texture2D(normal_texture, result_uv2).xyz * 2.0 - 1.0;
|
|
|
-
|
|
|
-
|
|
|
-- mediump vec3 dir = normalize(vec3(result_pos.xy, 0.0) - vec3(light, 40.0));
|
|
|
-+ mediump vec3 dir = normalize(vec3(result_pos.xy, 0.0) - vec3(result_light, 40.0));
|
|
|
-
|
|
|
-
|
|
|
- dir = vec3(-dir.x, dir.y, -dir.z);
|
|
|
-diff -r c6ab5032adf6 examples/Demo/data/light_vs.glsl
|
|
|
---- a/examples/Demo/data/light_vs.glsl Tue Nov 25 14:09:04 2014 +0500
|
|
|
-+++ b/examples/Demo/data/light_vs.glsl Tue Nov 25 14:09:14 2014 +0500
|
|
|
-@@ -3,6 +3,7 @@
|
|
|
- varying mediump vec2 result_uv;
|
|
|
- varying mediump vec2 result_uv2;
|
|
|
- varying mediump vec2 result_pos;
|
|
|
-+varying mediump vec2 result_light;
|
|
|
-
|
|
|
- uniform mediump mat4 mat;
|
|
|
-
|
|
|
-@@ -10,6 +11,7 @@
|
|
|
- attribute vec4 color;
|
|
|
- attribute vec2 uv;
|
|
|
- attribute vec2 uv2;
|
|
|
-+attribute vec2 light;
|
|
|
-
|
|
|
- void main()
|
|
|
- {
|
|
|
-@@ -19,4 +21,5 @@
|
|
|
- result_uv2 = uv2;
|
|
|
-
|
|
|
- result_pos = position.xy;
|
|
|
-+ result_light = light;
|
|
|
- }
|
|
|
-\ No newline at end of file
|
|
|
-diff -r c6ab5032adf6 examples/Demo/src/TestUserShader2.h
|
|
|
---- a/examples/Demo/src/TestUserShader2.h Tue Nov 25 14:09:04 2014 +0500
|
|
|
-+++ b/examples/Demo/src/TestUserShader2.h Tue Nov 25 14:09:14 2014 +0500
|
|
|
-@@ -23,7 +23,7 @@
|
|
|
- LightningRenderer() :_light(0, 0)
|
|
|
- {
|
|
|
- //vertex declaration with 2 pairs of UV
|
|
|
-- _vdecl = getDriver()->getVertexDeclaration(vertexPCT2T2::FORMAT);
|
|
|
-+ _vdecl = getDriver()->getVertexDeclaration(vertexPCT2T2T2::FORMAT);
|
|
|
-
|
|
|
- //load vertex shader
|
|
|
- file::buffer vsdata;
|
|
|
-@@ -106,8 +106,27 @@
|
|
|
- _driver->setTexture(1, _normal);
|
|
|
- }
|
|
|
-
|
|
|
-- vertexPCT2T2 v[4];
|
|
|
-+ vertexPCT2T2T2 v[4];
|
|
|
- fillQuadT2(v, srcRect, normalSrc, destRect, rs->transform, color.rgba());
|
|
|
-+ Vector2 light = _light;
|
|
|
-+ AffineTransform t = rs->transform;
|
|
|
-+ t.invert();
|
|
|
-+ t.x = 0;
|
|
|
-+ t.y = 0;
|
|
|
-+ light = t.transform(_light);
|
|
|
-+ Vector2 d1 = light;
|
|
|
-+ Vector2 d2 = light;
|
|
|
-+ Vector2 d3 = light;
|
|
|
-+ Vector2 d4 = light;
|
|
|
-+ v[0].u3 = d1.x;
|
|
|
-+ v[0].v3 = d1.y;
|
|
|
-+ v[1].u3 = d1.x;
|
|
|
-+ v[1].v3 = d1.y;
|
|
|
-+ v[2].u3 = d1.x;
|
|
|
-+ v[2].v3 = d1.y;
|
|
|
-+ v[3].u3 = d1.x;
|
|
|
-+ v[3].v3 = d1.y;
|
|
|
-+
|
|
|
- _vertices.insert(_vertices.end(), (unsigned char*)v, (unsigned char*)v + sizeof(v));
|
|
|
- _checkDrawBatch();
|
|
|
- }
|
|
|
-@@ -160,7 +179,9 @@
|
|
|
- AnimationFrame frame = resources.getResAnim("normal")->getFrame(0);
|
|
|
- spSprite spr = new Sprite2(frame);
|
|
|
- spr->setResAnim(resources.getResAnim("tiled"));
|
|
|
-- spr->setPosition(content->getSize() / 2 - spr->getSize() / 2);
|
|
|
-+ spr->setAnchor(Vector2(0.5f, 0.5f));
|
|
|
-+ spr->setPosition(content->getSize() / 2);
|
|
|
-+ spr->addTween(Actor::TweenRotation(MATH_PI * 2), 25000, -1);
|
|
|
- spr->attachTo(lightning);
|
|
|
-
|
|
|
-
|
|
|
-@@ -170,7 +191,7 @@
|
|
|
- light->setResAnim(resources.getResAnim("light"));
|
|
|
- light->setAnchor(0.5f, 0.5f);
|
|
|
- drag.init(light.get());
|
|
|
-- light->setPosition(getSize() / 2);
|
|
|
-+ light->setPosition(getSize() / 2 - Vector2(100, 0));
|
|
|
-
|
|
|
- lightning->addChild(light);
|
|
|
- }
|