Using MSAPerlin.cpp do i have to use the whole physics package?

Hi guys,

i want to use memo aktens msaPerlin, do i have to use the whole msaphysics? i get the typical “cairo-features.h” error. (I am on a windows vs2010) It’s really weired, i just added this tiny script into the addons and linked them, even when i delete the link and build newly, i get this error.

https://github.com/memo/msalibs/tree/master/MSAPerlin/src
the link to the tiny script

thanks

i tried MSAPerlin in linux and as a i knonw it’s not needed MSAPhysics. How did you import MSAPerlin into your code?
in testApp.h should be:

  
  
#include "MSAPerlin.h"  
///all the code here  
MSA::Perlin perlin;  
  

in testApp.cpp

  
  
  
/// code in setup()  
  
for (int y=0; y<h; y++) {  
        for (int x=0; x<w; x++) {  
            float FBM;  
          
            FBM = perlin.get(x,y);  
  
            float color = FBM;  
  
            img.getPixels()[y*w+x] = color;  
  
}  
}  
  
  

Hi kalwalt,

thank you for your detailed reply, actually there was a problem with visual studi 2010 as it has not included cairo-feature.h. As far as i added a new addon, this error popped out, now i added cairo-feature.h into my include directory, its gone and i can use the perlin class.

by the way, if you used msaperlin, do you have any examples for clouds or other stuff? Does it work in real-time? there is a weired thing, when i generate the noise in the setup, than it works, but when i am in the draw call, it will return 0 all the time (Black). I thought maybe it cannot handle the noise functions in real-time…but i cannot believe it.

  
ofFill();  
	for (int i = 1; i < 200; i++){  
  
		for(int j=1; j < 200; j++){  
			  
	  
			ofSetColor(abs(perlinNoise.get(sin((float)i), cos((float)j))*512));  
			ofRect(i,j,1,1);  
		}  
	}  

weired weired…

nice that you solved the problem. i m sorry but i’haven’t any example for clouds. i think it’s a bit resource consuming that kind of things from a performance side. i tried to do textures with noise algorithm in C++(so with cpu) and it cost a lot. better to use shader for realtime. there are some post about in the forum somewhere. I have also some example. I will post or put on github as soon as possible.
regards
Walter

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…

Strange that you can’t use exp2f function in windows , this is new for me, i will test it when i have a bit of time.

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

yes, i was thinking exactly about this post. I used that code.

Why you receive a black screen?
maybe the texture is not power of two ? read carefully the post…
or as you say the values are too low, check with a “cout” your values in a console. This generally help a lot.

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.

yes , i think should be equivalent.

can you post also the shader code?, maybe we can understand better the issue.

Hi kalwalt,

i’ve had started a topic yesterday as i thought the passing values to the shader was not working. But roxlu grasped what the error was, while porting the 006 code to 007 i was calling the shader, after passing the values.

http://forum.openframeworks.cc/t/passing-variables-to-the-shader,-not-working-black/9884/0

Anyway, i don’t know why exp2f is not working but the result should be fine now.

thanks for your time :wink:

i saw after your other topic. Sometimes we are unable to find errors that other people see immediately! happens sometimes…

about exp2f function : i googling i found this http://publib.boulder.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.bpxbd00%2Frexp2.htm can you use

  
float exp2  

instead?