void Optimizer::TwoPassZbuffer(const CameraParameter& rho, const IlluminationParameter& lamda, MeshPtr mesh, ModelPtr model, bool segment) { int width = model->Rows(); int height = model->Cols(); mesh->UpdateVertexNormal(); shared_ptr<Camera> camera = make_shared<PinholeCamera>(rho, width, height); shared_ptr<Camera> light = make_shared<PinholeCamera>(rho, lamda, width, height); shared_ptr<Illumination> illumination = make_shared<PhongIllumination>(lamda); HardwareRender render(camera, illumination); vector<float> depth_map(width*height); render.Rendering(mesh, lamda, depth_map); HardwareRender render2(light, illumination); vector<float> shadow_map(width*height); render2.Rendering(mesh, lamda, shadow_map); shared_ptr<DepthBuffer> object_depth = nullptr; shared_ptr<BoxRaster> raster = nullptr; SoftwareRender object_render(camera, illumination, object_depth, raster); if (segment) { object_render.TwoPassZbufferSegment(light, mesh, model, depth_map, shadow_map); } else { object_render.TwoPassZbuffer(light, mesh, model, depth_map, shadow_map); } }
void Optimizer::CpuRendering(const CameraParameter& rho, const IlluminationParameter& lamda, MeshPtr mesh, ModelPtr model) { int width = model->Rows(); int height = model->Cols(); shared_ptr<Camera> camera = make_shared<PinholeCamera>(rho, width, height); shared_ptr<Illumination> illumination = make_shared<PhongIllumination>(lamda); shared_ptr<DepthBuffer> depth = make_shared<DepthBuffer>(width, height); shared_ptr<BoxRaster> raster = make_shared<BoxRaster>(); SoftwareRender cpu_render(camera, illumination, depth, raster); cpu_render.Rending(mesh, model); }
void Optimizer::GpuRendering(const CameraParameter& rho, const IlluminationParameter& lamda, MeshPtr mesh, ModelPtr model) { int width = model->Rows(); int height = model->Cols(); mesh->UpdateVertexNormal(); shared_ptr<Camera> camera = make_shared<PinholeCamera>(rho, width, height); shared_ptr<Camera> light = make_shared<PinholeCamera>(rho, lamda, ShadowResolution, ShadowResolution); shared_ptr<Illumination> illumination = make_shared<PhongIllumination>(lamda); //HardwareRender gpu_render(camera, light,illumination); HardwareRender gpu_render(camera, illumination); gpu_render.RenderingWithBackground(mesh, model, lamda); //gpu_render.RenderingWithShadow(mesh, lamda); }