ShaderPipeline* ShaderPipeline::GetDefaultPipeline() { if(!s_defaultPipeline) { s_defaultPipeline = new ShaderPipeline(); ShaderProgram defaultShader; defaultShader.LoadFromFile("Shader/RenderingShader/ZPassShader.glsl"); s_defaultPipeline->m_pipeline[RENDERPASS_ZBUFFER] = defaultShader; defaultShader.LoadFromFile("Shader/RenderingShader/DiffuseShader.glsl"); s_defaultPipeline->m_pipeline[RENDERPASS_DIFFUSE] = defaultShader; //defaultShader.LoadFromFile("Shader/RenderingShader/LightingShader.glsl"); //s_defaultPipeline->m_pipeline[RENDERPASS_LIGHTING] = defaultShader; defaultShader.LoadFromFile("Shader/RenderingShader/DirectionnalShadowCastShader.glsl"); s_defaultPipeline->m_pipeline[RENDERPASS_DIRECTIONNAL_LIGHTING_WITH_SHADOW] = defaultShader; defaultShader.LoadFromFile("Shader/RenderingShader/PointShadowCastShader.glsl"); s_defaultPipeline->m_pipeline[RENDERPASS_POINT_SHADOW_CAST] = defaultShader; defaultShader.LoadFromFile("Shader/RenderingShader/DeferredShader.glsl"); s_defaultPipeline->m_pipeline[RENDERPASS_DEFERRED] = defaultShader; } return s_defaultPipeline; }
void App::init() { pause = true; m_timer = 1000; printf("Loading..."); m_MatProj3D = glm::perspective(35.0f, (float)getScreen().x / (float)getScreen().y, 0.01f, 100.f); m_MatProj2D = ortho(0.0f,(float)getScreen().x,0.0f,(float)getScreen().y); drawMouse = false; draw = true; pause = false; DeferredRendering* mode = new DeferredRendering(getScreen()); //RenderingMode::SetRenderingMode(mode); tex[0].Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D); tex[1].Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D); m_fxaa = new AntiAliasing(); blur = new BlurMotionEffect(getScreen()); //drug = new DrugEffect(); //PostEffectMgr::Instance().AddEffect(drug); //PostEffectMgr::Instance().AddEffect(new BlurMotionEffect(getScreen())); //PostEffectMgr::Instance().AddEffect(m_fxaa); //PostEffectMgr::Instance().AddEffect(new Inverse()); m_fps = new GraphicString(ivec2(0,getScreen().y-15),"",Color::black); m_Scene = new SceneMgr(); Texture t; Texture color_gradiant; Material* mat = new Material(); mat->SetTexture(t,0,(TRenderPass)((1<<RENDERPASS_DEFERRED) | (1<<RENDERPASS_ZBUFFER))); mat->SetTexture(color_gradiant,1,(TRenderPass)(1<<RENDERPASS_DEFERRED)); Driver::Get().SetActiveScene(m_Scene); Driver::Get().SetCullFace(2); m_light = new Light(vec3(0, 0 ,10),-normalize(vec3(0,0.2,-1)),LightType::LIGHT_DIR);//new Light(vec3(0,0,10),-normalize(vec3(0,0.5,-1)),LIGHT_SPOT); m_Scene->AddLight(m_light); m_light->SetRange(2000.0f); ShaderProgram prog; ShaderProgram prog2; /*particles1 = new ParticlesEmitter("Shader/particle_1.glsl",250,new Transform(vec3(-6,0,0))); particles2 = new ParticlesEmitter("Shader/particle_2.glsl",250,new Transform(vec3(6,0,0)));*/ string cubemap[6]; /*for(int i = 0; i < 6; i++) { cubemap[i] = StringBuilder("Texture/background/")(i+1)(".png"); }*/ //Texture tex_cubemap; //tex_cubemap.CreateFromFile(cubemap,PXF_A8R8G8B8); mouse_emitter = new ParticlesEmitter(std::string("shader/particle_3.glsl"),2,new Transform()); AWindow* position =new AWindow(); AWindow* velocity = new AWindow(); AWindow* life = new AWindow(); //particles->velocity_buffer[1]); //life->SetBackground(mouse_emitter->extra_buffer[0]); //GUIMgr::Instance().AddWidget(position); //GUIMgr::Instance().AddWidget(velocity); // GUIMgr::Instance().AddWidget(life); SkyBox* box = new SkyBox(); //box->SetTexture(tex_cubemap); cam3D = new FollowCamera(m_MatProj3D,0,0,vec2(-65.7063446,0),10.f);//m_MatProj3D,4.8f,8.8f,vec2(0,-7.55264f),9.87785f); //Follow Camera Theta(4.8) _phi(8.8) angles(0,-7.55264) distance(9.87785) cam2D = new FPCamera(m_MatProj2D); velocity_program.LoadFromFile("Shader/particle_velocity_render.glsl"); mass_program.LoadFromFile("Shader/particle_mass_render.glsl"); tmass.Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D); tvelocity.Create(getScreen(),PXF_A8R8G8B8,TEXTURE_2D); position->SetBackground(tmass); velocity->SetBackground(tvelocity); Camera::setCurrent(cam3D, CAMERA_3D); Camera::setCurrent(cam2D, CAMERA_2D); m_particles.push_back(new ParticlesEmitter(std::string("shader/particle_4.glsl"),2500 ,new Transform(vec3((0),0.f,0)*30.f))); printf("Loading end"); }