Пример #1
0
void TerrainWrapper::Enable()
{




	Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));
	DataManager * dm = static_cast<DataManager*>(GetManager()->Get("DataManager"));



	Techniques * tech = static_cast<Techniques*>(dm->Get("Techniques"));
	ResourceLoader * res = static_cast<ResourceLoader*>(dm->Get("Resources"));
	Environment * env = static_cast<Environment*>(res->Get("Environment"));
	Camera * camera = static_cast<Camera*>(ctrl->Get("Camera"));
	View * view = camera->GetView();
	ViewInfo * info = camera->GetInfo();



	Shader::Enable();
	Shader::Set("myTextureSampler", 0);
	Shader::Set("myTextureSampler2", 1);
	Shader::Set("myTextureSampler3", 2);
	Shader::Set("shadow_map", 3);
	TerrainShader::SendTextureAttributes(terra->GetTextureAttributes(), 4);


	/**
	Raising to power for gamma correction
	*/
	getLight()->SetFog(glm::pow(env->fog_color, glm::vec3(2.2)), env->fog_density);
	getLight()->SetDirectionalLight(env->terrain_bright*
		glm::pow(env->sun_color, glm::vec3(2.2)),
		env->sun_dir,
		env->terrain_ambient,
		env->terrain_diffuse);





	Set("LightMatrix", Math::GetBiasMatrix()*
		tech->GetShadow()->GetDirectionalShadow(env, info, view));



	tech->GetShadow()->GetShadowMap()->BindTexture(0, GL_TEXTURE3);
	tech->GetShadow()->GetShadowMap()->ResetTextureState();




	ManagePlayerCollision(ctrl, false);



}
Пример #2
0
void TerrainWrapper::Render()
{




	Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));
	DataManager * dm = static_cast<DataManager*>(GetManager()->Get("DataManager"));


	Techniques * tech = static_cast<Techniques*>(dm->Get("Techniques"));
	ResourceLoader * res = static_cast<ResourceLoader*>(dm->Get("Resources"));
	Environment * env = static_cast<Environment*>(res->Get("Environment"));
	Camera * camera = static_cast<Camera*>(ctrl->Get("Camera"));
	View * view = camera->GetView();
	ViewInfo * info = camera->GetInfo();





	if (tech->GetSSAO()->OnGeometryPass())
	{


		tech->GetSSAO()->SetGeometryPassUniforms(view->getCamera(),
			view->getViewMatrix());


	}
	else if (tech->GetShadow()->OnShadowPass())
	{

		tech->GetShadow()->UniformMVP(tech->GetShadow()->GetDirectionalShadow(env, info, view));


	}
	else
	{


		Space(glm::mat4(1.0), view);


	}



	terra->Render(camera->GetFrustum(), false);




}
Пример #3
0
void SkyWrapper::Enable()
{
	


	Controller * ctrl = static_cast<Controller*>(GetManager()->Get("Controller"));
	DataManager * dm = static_cast<DataManager*>(GetManager()->Get("DataManager"));




	ResourceLoader * res = static_cast<ResourceLoader*>(dm->Get("Resources"));
	Environment * env = static_cast<Environment*>(res->Get("Environment"));
	Camera * camera = static_cast<Camera*>(ctrl->Get("Camera"));
	ViewInfo * info = camera->GetInfo();
	View * view = camera->GetView();





	glm::mat4 m_rot = Math::Rotate(0, glfwGetTime() / 150.0, 0);
	glm::mat4 ModelMatrix = Math::Translation(info->getCameraPos() - info->getDirection()*info->getDistance())*
		m_rot*
		Math::Scale(glm::vec3(info->getRenderDistance()));




	Shader::Enable();
	Shader::Set("cube", 0);
    Shader::Set("MVP", view->getCamera()*ModelMatrix);
	Shader::Set("MV", view->getViewMatrix() * ModelMatrix);
	glm::vec4 f = glm::vec4(env->fog_color, 1.0);
	Shader::Set("fog_color", f);



	SkyRender::Enable();
	Shader::Stop();



}