Exemplo n.º 1
0
/*===========================================================================*/
void StochasticUniformGridRenderer::Engine::create( kvs::ObjectBase* object, kvs::Camera* camera, kvs::Light* light )
{
    kvs::StructuredVolumeObject* volume = kvs::StructuredVolumeObject::DownCast( object );

    attachObject( object );
    createRandomTexture();
    this->create_shader_program( volume );
    this->create_volume_texture( volume );
    this->create_transfer_function_texture();
    this->create_bounding_cube_buffer( volume );
    this->create_framebuffer( camera->windowWidth(), camera->windowHeight() );
}
Exemplo n.º 2
0
/*
	Name		ParticleSystem::initialise
	Syntax		ParticleSystem::initialise(ID3D10Device* device, 
										   ID3D10ShaderResourceView* texArrayRV, 
										   UINT maxParticles)
	Param		ID3D10Device* device - The D3D device
	Param		ID3D10ShaderResourceView* texArrayRV - Handle to textures used
				by the particle system
	Param		UINT maxParticles - The maximum number of particles this system
				should emit
	Brief		Initialises the particle system
*/
void ParticleSystem::initialise(ID3D10Device* device, 
								ID3D10ShaderResourceView* texArrayRV,

								UINT maxParticles)
{
	d3dDevice_ = device;

	particleShader_ = new ParticleShader;
	particleShader_->initialise(particle_);

	maxParticles_ = maxParticles;

	texArrayRV_  = texArrayRV;
	randomTexRV_ = createRandomTexture(); 

	buildVertexBuffer();
}
Exemplo n.º 3
0
void OglRenderer::init(uint wi,uint he)
{
	texVelocity.intFormat = GL_RG;
	texVelocity.format = GL_RG;
	//texVelocity.type = GL_FLOAT;

	texColor.intFormat = GL_RGBA;
	texColor.format = GL_RGBA;

	vector<OglTexTarget*> textars;
	textars.push_back( &texColor );
	textars.push_back( &texNormal );
	textars.push_back( &texVelocity );
	GBuffer.init( textars, DEPTHBUF_TEXTURE, wi, he );

	textars.clear( );
	DirLBuffer.init( textars, DEPTHBUF_TEXTURE | DEPTHBUF_LINEAR | DEPTHBUF_SHADOW, 1024, 1024 );

	texNum = 2;
	cnt = 0;

	for ( int i = 0; i < texNum; i++ )
	{
		textars.clear();
		texAA[i].intFormat = GL_RGBA;
		texAA[i].format = GL_RGBA;
		texAA[i].magFilter = GL_LINEAR;
		texAA[i].minFilter = GL_LINEAR;
		texAA[i].clampBorder = true;
		textars.push_back( &texAA[i] );
		AABuffer[i].init( textars, 0, wi, he );
	}
	AAp = 0;

	textars.clear( );
	texAATemp.intFormat = GL_RGBA;
	texAATemp.format = GL_RGBA;
	texAATemp.magFilter = GL_LINEAR;
	texAATemp.minFilter = GL_LINEAR;
	textars.push_back( &texAATemp );
	AATemp.init( textars, 0, wi, he );

	textars.clear( );
	texAO.intFormat = GL_RG32F;
	texAO.format = GL_RG;
	//texAO.type = GL_FLOAT;
	texAO.magFilter = GL_LINEAR;
	texAO.minFilter = GL_LINEAR;
	texAO.clampBorder = true;
	textars.push_back( &texAO );
	AOBuffer.init( textars, 0, wi/2-1, he/2-1 );

	createRandomTexture();
	floorTex.magFilter = GL_LINEAR;
	floorTex.minFilter = GL_LINEAR;
	floorTex.init("floor.jpg",true);

	DIR *d;
	struct dirent *dir;
	d = opendir( "shaders" );
	int i = 0;
	if ( d )
	{
		while ( (dir = readdir( d )) != NULL )
		{
			if ( i > 1 )
			{
				string name = dir->d_name;
				string subname = name.substr( name.length() - 4, 4 );
				if ( subname == ".vsh" )
				{
					cout << "vertex: " << name << endl;
					string compileName = "shaders\\" + name;
					OglVertexShader vsh; vsh.compile( compileName.c_str() );
					vsh.notDelete();
					shVertex[name] = vsh;
				}
				else if ( subname == ".fsh" )
				{
					cout << "fragment: " << name << endl;
					string compileName = "shaders\\" + name;
					OglFragmentShader fsh; fsh.compile( compileName.c_str( ) );
					fsh.notDelete();
					shFragment[name] = fsh;
				}
				else
					cout << "error reading shader " << name << endl;
			}
			i++;
		}

		closedir( d );
	}

	buildShader( "GBuff", "GBuff.vsh", "GBuff.fsh" );
	buildShader( "GBuffFloor", "GBuff.vsh", "GBuffFloor.fsh" );
	buildShader( "GBuffAA", "GBuffAA.vsh", "GBuffAA.fsh" );
	buildShader( "AmbQ", "Quad.vsh", "AmbQ.fsh" );
	buildShader( "AmbDirQ", "Quad.vsh", "AmbDirQ.fsh" );
	buildShader( "AmbDirShadowQ", "QuadInv.vsh", "AmbDirShadowQ.fsh" );
	buildShader( "Quad", "Quad.vsh", "Quad.fsh" );
	buildShader( "QuadFXAA", "Quad.vsh", "QuadFXAA.fsh");
	buildShader( "QuadAA", "Quad.vsh", "QuadAA.fsh" );
	buildShader( "Blur", "Quad.vsh", "Blur.fsh" );
	buildShader( "ShadowMap", "ShadowMap.vsh", "ShadowMap.fsh" );
	buildShader( "EVSMGauss", "Quad.vsh", "EVSMGauss.fsh" );
	buildShader( "EVSMGaussV", "Quad.vsh", "EVSMGaussV.fsh" );
	buildShader( "AO", "QuadInv.vsh", "AO.fsh" );

	activeShader = 0;

	MeshFullscreenQuad quad;
	quad.init( BUF_POS | BUF_UV );
	bufQuad.init( BUF_POS | BUF_UV );

	quad.toBuffs( bufQuad );
	bufQuad.postInit( );

	lastWiggle = glm::vec3( 0, 0, 0 );
	wp = 0;
	rx[0] = 0.16; ry[0] = 0.35;
	rx[1] = 0.82; ry[1] = 0.20;
	rx[2] = 0.40; ry[2] = 0.88;
	rx[3] = 0.84; ry[3] = 0.69;

	enableBuffer( &AABuffer[0], true );
	enableBuffer( &AABuffer[1], true );
}
Exemplo n.º 4
0
 Handle<Device::RTMaterial> createRandomMaterial(Device *device)
 {
   switch (random<int>() % 8)
   {
   case 0: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("Matte");
     device->rtSetFloat3(material, "reflectance", random<float>(), random<float>(), random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 1: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("Plastic");
     device->rtSetFloat3(material, "pigmentColor", random<float>(), random<float>(), random<float>());
     device->rtSetFloat1(material, "eta", 1.0f + random<float>());
     device->rtSetFloat1(material, "roughness", 0.1f * random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 2: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("Dielectric");
     device->rtSetFloat3(material, "transmission", 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f);
     device->rtSetFloat1(material, "etaOutside", 1.0f);
     device->rtSetFloat1(material, "etaInside", 1.0f + random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 3: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("ThinDielectric");
     device->rtSetFloat3(material, "transmission", 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f);
     device->rtSetFloat1(material, "eta", 1.0f + random<float>());
     device->rtSetFloat1(material, "thickness", 0.5f * random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 4: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("Mirror");
     device->rtSetFloat3(material, "reflectance", 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f);
     device->rtCommit(material);
     return(material);
   }
   case 5: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("Metal");
     device->rtSetFloat3(material, "reflectance", 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f);
     device->rtSetFloat3(material, "eta", 1.0f + random<float>(), 1.0f + random<float>(), 1.0f + random<float>());
     device->rtSetFloat3(material, "k", 0.3f * random<float>(), 0.3f * random<float>(), 0.3f * random<float>());
     device->rtSetFloat1(material, "roughness", 0.3f * random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 6: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("MetallicPaint");
     device->rtSetFloat3(material, "shadeColor", 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f, 0.5f * random<float>() + 0.5f);
     device->rtSetFloat3(material, "glitterColor", random<float>(), random<float>(), random<float>());
     device->rtSetFloat1(material, "glitterSpread", 0.5f + random<float>());
     device->rtSetFloat1(material, "eta", 1.0f + random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 7: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("MatteTextured");
     device->rtSetTexture(material, "Kd", createRandomTexture(device, 32, 32));
     device->rtSetFloat2(material, "s0", random<float>(), random<float>());
     device->rtSetFloat2(material, "ds", 5.0f * random<float>(), 5.0f * random<float>());
     device->rtCommit(material);
     return(material);
   }
   case 8: {
     Handle<Device::RTMaterial> material = device->rtNewMaterial("Obj");
     device->rtSetFloat1(material, "d", random<float>());
     if (random<bool>()) device->rtSetTexture(material, "map_d", createRandomTexture(device, 32, 32));
     device->rtSetFloat3(material, "Tf", random<float>(), random<float>(), random<float>());
     device->rtSetFloat3(material, "Kd", random<float>(), random<float>(), random<float>());
     if (random<bool>()) device->rtSetTexture(material, "map_Kd", createRandomTexture(device, 32, 32));
     device->rtSetFloat3(material, "Ks", random<float>(), random<float>(), random<float>());
     if (random<bool>()) device->rtSetTexture(material, "map_Ks", createRandomTexture(device, 32, 32));
     device->rtSetFloat1(material, "Ns", 10.0f * random<float>());
     if (random<bool>()) device->rtSetTexture(material, "map_Ns", createRandomTexture(device, 32, 32));
     device->rtCommit(material);
     return(material);
   }
   }
   return(NULL);
 }
Exemplo n.º 5
0
ID3D10ShaderResourceView* SimplexNoise::getRandomTex()
{
	if (!randomTex_)
		randomTex_ = createRandomTexture();
	return randomTex_;
}