void nebular_background_behaviour::init(resource_hub* resources, uint64_t seed) {
	// init generation
	generate_layers(seed);
	redraw();

	// create buffers
	positions = std::make_shared<vbo<vec2>>();
	uvs = std::make_shared<vbo<vec2>>();
	indicies = std::make_shared<ibo>();
	sprite_shader = resources->get<shader>("sprite-shader");

	nebular_shader = resources->create<shader>("sprite-shader", new shader());
	nebular_shader->load_source("data/Shader/NebularShader.vs", shader_type::vertex);
	nebular_shader->load_source("data/Shader/NebularShader.fs", shader_type::fragment);
	nebular_shader->compile();
	nebular_shader->bind();
	nebular_shader->set_int("source_texture", 0);
	nebular_shader->set_color("nebular_color", color::red);
	nebular_shader->set_float("scale", 1.f / float(background_texture_size));
	nebular_shader->set_float("falloff", 3.f);
	nebular_shader->set_float("noise_size", 2048.f);

	// generate fbos
	background_target_1 = std::make_shared<fbo>(background_texture_size, background_texture_size);
	background_target_2 = std::make_shared<fbo>(background_texture_size, background_texture_size);

	render_manager = resources->get<renderer>("renderer");
	renderer_job = render_manager->create_job();
	renderer_job->attach_vbo(positions.get(), render_job::slot0);
	renderer_job->attach_vbo(uvs.get(), render_job::slot1);
	renderer_job->attach_ibo(indicies.get());
	renderer_job->shader = nebular_shader;
	renderer_job->z = 0;
	renderer_job->primitiv = render_primitivs::triangles;
	renderer_job->is_visible = false;

	positions->add(vec2(-1024.f,  1024.f));
	positions->add(vec2(-1024.f, -1024.f));
	positions->add(vec2( 1024.f,  1024.f));
	positions->add(vec2( 1024.f, -1024.f));

	uvs->add(vec2(0.f, 1.f));
	uvs->add(vec2(0.f, 0.f));
	uvs->add(vec2(1.f, 1.f));
	uvs->add(vec2(1.f, 0.f));

	indicies->add(0);
	indicies->add(1);
	indicies->add(2);

	indicies->add(1);
	indicies->add(3);
	indicies->add(2);

	positions->upload();
	uvs->upload();
	indicies->upload();
	renderer_job->upload();
}
Пример #2
0
static void convert_layers(SFInfo *sf)
{
	int i;

	if (prbags.bag == NULL || prbags.gen == NULL ||
	    inbags.bag == NULL || inbags.gen == NULL) {
		fprintf(stderr, "*** illegal bags / gens\n");
		return;
	}

	for (i = 0; i < sf->npresets - 1; i++) {
		generate_layers(&sf->preset[i].hdr,
				&sf->preset[i+1].hdr,
				&prbags);
	}
	for (i = 0; i < sf->ninsts - 1; i++) {
		generate_layers(&sf->inst[i].hdr,
				&sf->inst[i+1].hdr,
				&inbags);
	}
}
Пример #3
0
void Instruments::convert_layers(SFInfo *sf)
{
	int i;

	if (prbags.bag == NULL || prbags.gen == NULL ||
		inbags.bag == NULL || inbags.gen == NULL) {
		ctl_cmsg(CMSG_WARNING, VERB_NORMAL,	"%s: *** illegal bags / gens", sf->sf_name);
		return;
	}

	for (i = 0; i < sf->npresets - 1; i++) {
		generate_layers(&sf->preset[i].hdr,
			&sf->preset[i + 1].hdr,
			&prbags);
	}
	for (i = 0; i < sf->ninsts - 1; i++) {
		generate_layers(&sf->inst[i].hdr,
			&sf->inst[i + 1].hdr,
			&inbags);
	}
}