Skip to content

Commit

Permalink
Refine coloring in perlin function. Make it easier to tweak resolutio…
Browse files Browse the repository at this point in the history
…n of generated noise. Sane default for grass size.
  • Loading branch information
fadookie committed Aug 16, 2012
1 parent 8143f64 commit ce41eff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Twities.pde
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PVector minCityBounds = new PVector();
Quads roads;
PImage roadImage;
float roadVerticalTextureTileSize = 10;
float groundTextureScale = 90000;
float groundTextureScale = 670;
//PImage testImage;
PImage[] grassImages;
int currentGrassImage = 0;
Expand Down
20 changes: 13 additions & 7 deletions VisualizerState.pde
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class VisualizerState implements GameState {
Bang searchUsernameButton;
//Bang searchHideButton;
PImage cloudTexture;
int cloudResolution = 512;

void setup() {
//Default processing camera perspective, but move the near clip plane in and far clip plane out
Expand Down Expand Up @@ -41,11 +42,13 @@ class VisualizerState implements GameState {
;

//slider for ground texture scale
//Dafuq... why was it messing with my value? Oh well, here's a weird workaround...
float groundTexScale = groundTextureScale;
cp5.addSlider("groundTextureScale")
.setSize(width, 10)
.setPosition(0,50)
.setRange(1,90000)
.setValue(90000)
.setValue(groundTexScale)
;

/*
Expand Down Expand Up @@ -135,18 +138,21 @@ class VisualizerState implements GameState {
pushMatrix();
translate(0, -1100, 0);
scale(40, 0, 40);
noStroke();
beginShape(QUADS);
pgl.textureSampling(Texture.LINEAR);
pgl.textureWrap(Texture.REPEAT); //Set texture wrap mode to GL_REPEAT. See http://code.google.com/p/processing/issues/detail?id=94
textureMode(NORMAL);
texture(cloudTexture);
//texture(grassImages[currentGrassImage]);

vertex(minCityBounds.x, 0, minCityBounds.z, 0, 0);
vertex(maxCityBounds.x, 0, minCityBounds.z, groundTextureScale, 0);
vertex(maxCityBounds.x, 0, maxCityBounds.z, groundTextureScale, groundTextureScale);
vertex(minCityBounds.x, 0, maxCityBounds.z, 0, groundTextureScale);
vertex(maxCityBounds.x, 0, minCityBounds.z, 1, 0);
vertex(maxCityBounds.x, 0, maxCityBounds.z, 1, 1);
vertex(minCityBounds.x, 0, maxCityBounds.z, 0, 1);
endShape();
popMatrix();

pgl.textureSampling(Texture.BILINEAR);

if (DEBUG) {
calculateAxis(50); //For debug drawing
Expand Down Expand Up @@ -184,7 +190,7 @@ class VisualizerState implements GameState {

PImage randomCloudTexture() {
float noiseScale=0.02;
PImage tex = createImage(512, 512, ARGB);
PImage tex = createImage(cloudResolution, cloudResolution, ARGB);

tex.loadPixels();
{
Expand All @@ -194,7 +200,7 @@ class VisualizerState implements GameState {
while (x < tex.width) {
int i = x + (y * tex.width);
float pixelColor = noise(x * noiseScale, y * noiseScale) * 255;
tex.pixels[i] = color(pixelColor, pixelColor, pixelColor, pixelColor);
tex.pixels[i] = color(255, 255, 255, pixelColor);
x++;
}
x = 0;
Expand Down

0 comments on commit ce41eff

Please sign in to comment.