Hi Kalwalt,
thank you for your time btw…
I tried to use this example
http://forum.openframeworks.cc/smf-attachments/803/filename
from this post
http://forum.openframeworks.cc/t/ofxshader:-mesh-displacement,-perlin-noise/4256/0
But even i have changed some fbo and gl specific thinks correctly, i just get a black screen.
There was a exp2f function which i don’t have on my windows, so i think pow(2, n) is the equivalent. All other stuff i’ve changed was straight forward.
#include "testApp.h"
#include <stdio.h>
#include <math.h>
void testApp::setup() {
width = ofGetWidth();
height = ofGetHeight();
fbo.allocate(width, height);
setupNoise();
shader.load("noise.vert", "noise.frag");
}
void testApp::setupNoise() {
shader.begin();
const int octaves = 8;
const float dropoff = .5;
float total = 0;
float weights[octaves];
float scaling[octaves];
for(int i = 0; i < octaves; i++) {
weights[i] = 1. / pow(2, dropoff * i);
scaling[i] = pow(2, (float)i);
total += weights[i];
}
shader.setUniform1fv("weights", weights, octaves);
shader.setUniform1fv("scaling", scaling, octaves);
shader.setUniform1f("normalization", 1.f / total);
shader.setUniform1f("seed", ofRandom(8, 32));
shader.end();
}
void testApp::update() {
fbo.begin();
shader.begin();
float n = 32 * ofDist(mouseX, mouseY, width / 2, height / 2) / width;
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(-n, -n);
glVertex2f(0, 0);
glTexCoord2f(-n, n);
glVertex2f(0, height);
glTexCoord2f(n, -n);
glVertex2f(width, 0);
glTexCoord2f(n, n);
glVertex2f(width, height);
glEnd();
shader.end();
fbo.end();
}
void testApp::draw() {
ofSetColor(255, 255, 255);
fbo.draw(0, 0, width, height);
ofSetColor(255, 0, 0);
ofDrawBitmapString(ofToString((int) ofGetFrameRate()), 10, 20);
}
When i change the color in the frag shader, it is applying, so i think that the noise function gives me a very low number, thas why it turns black…