From 331d4116d904bd36381df70a1c2520375f5ae636 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 7 May 2013 11:14:12 -0700 Subject: [PATCH] Finished noiseTest example (in util.h) that uses Perlin noise to draw a bitmap in 2D. --- interface/src/Util.cpp | 7 ++++--- interface/src/main.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp index 58cf1f61ad..b4c7f3d6b0 100644 --- a/interface/src/Util.cpp +++ b/interface/src/Util.cpp @@ -115,16 +115,17 @@ void drawVector(glm::vec3 * vector) { // Render a 2D set of squares using perlin/fractal noise void noiseTest(int w, int h) { - const float CELLS = 100; + const float CELLS = 500; + const float NOISE_SCALE = 10.0; float xStep = (float) w / CELLS; float yStep = (float) h / CELLS; glBegin(GL_QUADS); for (float x = 0; x < (float)w; x += xStep) { for (float y = 0; y < (float)h; y += yStep) { // Generate a vector varying between 0-1 corresponding to the screen location - glm::vec2 position(x / (float) w, y / (float) h); + glm::vec2 position(NOISE_SCALE * x / (float) w, NOISE_SCALE * y / (float) h); // Set the cell color using the noise value at that location - float color = glm::simplex(position); + float color = glm::perlin(position); glColor4f(color, color, color, 1.0); glVertex2f(x, y); glVertex2f(x + xStep, y); diff --git a/interface/src/main.cpp b/interface/src/main.cpp index a341835206..a448a1c2fa 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -893,7 +893,7 @@ void displayOverlay() { audioScope.render(); #endif - // noiseTest(WIDTH, HEIGHT); + //noiseTest(WIDTH, HEIGHT); if (displayHeadMouse && !::lookingInMirror && statsOn) { // Display small target box at center or head mouse target that can also be used to measure LOD