示例#1
0
SSAOComputeTOP::SSAOComputeTOP() : TOP( 32, 32 )
{
	ssaoComputeShader = new Shader();
	ssaoComputeShader->init(SSAOComputeTOP_vs, SSAOComputeTOP_vs_size, SSAOComputeTOP_ps, SSAOComputeTOP_ps_size);
	ssaoComputeShader->finalize();


	int rndNormalsRes = 128;
	float *rndNormalsPix = (float *)mmalloc( sizeof(float) * 3 * rndNormalsRes * rndNormalsRes );
	for( int j=0; j<rndNormalsRes; ++j )
		for( int i=0; i<rndNormalsRes; ++i )
		{
			rndNormalsPix[j*rndNormalsRes*3 + i*3 + 0] = msys_frand()*2.0f - 1.0f;
			rndNormalsPix[j*rndNormalsRes*3 + i*3 + 1] = msys_frand()*2.0f - 1.0f;
			rndNormalsPix[j*rndNormalsRes*3 + i*3 + 2] = msys_frand()*2.0f - 1.0f;
		}
	Texture *rndNormals = new Texture( rndNormalsRes, rndNormalsRes, GL_RGB_FLOAT32_ATI, GL_RGB, GL_FLOAT, rndNormalsPix );

	glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
	glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
	glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
	glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

	ssaoComputeShader->setUniform( "rndnorms", rndNormals->getUniform());
}
示例#2
0
 void addTubularImage(int t, int note, int volume)
 {
   const float x = (float)(msys_rand() % 50) / 50.f - 0.3f;
   const float y = (float)(msys_rand() % 60) / 60.f;
   const float width = 0.2f + 0.4f * msys_frand();
   const float height = 5.f / 60.f;
   const int group = (msys_rand() % 2);
   const float intensity = 1.f;//0.5f + 0.5f * volume / 127.f;
   addElement(t, x, y, width, height, intensity, group);
 }