From c84c092a427138e5d213a7d76a9ce15cdff6572d Mon Sep 17 00:00:00 2001
From: Sam Hocevar <sam@hocevar.net>
Date: Tue, 1 Jan 2013 19:11:43 +0000
Subject: [PATCH] tutorial: minor tweaks.

---
 tutorial/04_texture.cpp   |  4 ++--
 tutorial/04_texture.lolfx | 14 ++++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/tutorial/04_texture.cpp b/tutorial/04_texture.cpp
index 98ca4c5c..c9c63a53 100644
--- a/tutorial/04_texture.cpp
+++ b/tutorial/04_texture.cpp
@@ -18,7 +18,7 @@
 using namespace std;
 using namespace lol;
 
-static int const TEXTURE_WIDTH = 128;
+static int const TEXTURE_WIDTH = 512;
 
 extern char const *lolfx_04_texture;
 
@@ -57,7 +57,7 @@ public:
             m_heightmap[4 * i] = m_heightmap[4 * i + 4];
 
         int height = m_heightmap[4 * (TEXTURE_WIDTH - 1)];
-        height = height / 2 + 255 / 4 + rand() % 97 - 48;
+        height = (height + 127 + 40 * lol::sin(m_frames * 0.03) + rand() % 97 - 38) / 2;
         height = std::max(15, std::min(height, 240));
         m_heightmap[4 * (TEXTURE_WIDTH - 1)] = height;
 
diff --git a/tutorial/04_texture.lolfx b/tutorial/04_texture.lolfx
index a5d106a8..57f11a99 100644
--- a/tutorial/04_texture.lolfx
+++ b/tutorial/04_texture.lolfx
@@ -31,20 +31,22 @@ void main(void)
 {
     float width = 800.0;
     float height = 600.0;
-    float line_width = 1.8;
-    float dot_size = 2.0;
-    vec4 delta = vec4(1.0 / 128, 0.0,
-                      2.0 / 128, 0.0);
+    float texture_width = 512.0;
+    float line_width = 1.2;
+    float dot_size = 1.0;
+    vec4 delta = vec4(1.0 / 512, 0.0,
+                      2.0 / 512, 0.0);
 
     vec2 p = pass_Position.xy;
-    vec2 tc = vec2(floor(p.x * 128.0) / 128.0, p.y);
-    float t = p.x * 128.0 - floor(p.x * 128.0);
+    vec2 tc = vec2(floor(p.x * 512.0) / 512.0, p.y);
+    float t = p.x * 512.0 - floor(p.x * 512.0);
     vec4 c;
     c[0] = texture2D(u_Texture, tc - delta.xy).x;
     c[1] = texture2D(u_Texture, tc).x;
     c[2] = texture2D(u_Texture, tc + delta.xy).x;
     c[3] = texture2D(u_Texture, tc + delta.zw).x;
 
+    /* Find the 4 closest points in screen space */
     vec2 p0 = vec2((tc.x - delta.x) * width, c[0] * height);
     vec2 p1 = vec2((tc.x          ) * width, c[1] * height);
     vec2 p2 = vec2((tc.x + delta.x) * width, c[2] * height);