/** * Generates a shadow map into the specified framebuffer. * @param rstate RenderState with rendering parameters * @param camera camera with light viewpoint * @param framebufferId ID of framebuffer to render shadow map into * @param scene_objects temporary storage for culling * @see Light::makeShadowMap Renderer::makeShadowMaps */ void GLRenderer::renderShadowMap(RenderState& rstate, Camera* camera, GLuint framebufferId, std::vector<SceneObject*>& scene_objects) { cullFromCamera(rstate.scene, camera, rstate.shader_manager, scene_objects); GLint drawFbo = 0, readFbo = 0; glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFbo); glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFbo); const GLenum attachments[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT}; GL(glBindFramebuffer(GL_FRAMEBUFFER, framebufferId)); GL(glInvalidateFramebuffer(GL_FRAMEBUFFER, 3, attachments)); GL(glViewport(rstate.viewportX, rstate.viewportY, rstate.viewportWidth, rstate.viewportHeight)); glClearColor(0,0,0,1); GL(glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)); rstate.shadow_map = true; for (auto it = render_data_vector.begin(); it != render_data_vector.end(); ++it) { RenderData* rdata = *it; if (rdata->cast_shadows()) { GL(renderRenderData(rstate, rdata)); } } rstate.shadow_map = false; GL(glInvalidateFramebuffer(GL_FRAMEBUFFER, 2, &attachments[1])); glBindFramebuffer(GL_READ_FRAMEBUFFER, readFbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, drawFbo); }
/** * Generates a shadow map into the specified framebuffer. * @param rstate RenderState with rendering parameters * @param camera camera with light viewpoint * @param framebufferId ID of framebuffer to render shadow map into * @param scene_objects temporary storage for culling * @see Light::makeShadowMap Renderer::makeShadowMaps */ void Renderer::renderShadowMap(RenderState& rstate, Camera* camera, GLuint framebufferId, std::vector<SceneObject*>& scene_objects) { cullFromCamera(rstate.scene, camera, rstate.shader_manager, scene_objects); GL(glBindFramebuffer(GL_FRAMEBUFFER, framebufferId)); GL(glViewport(rstate.viewportX, rstate.viewportY, rstate.viewportWidth, rstate.viewportHeight)); glClearColor(0,0,0,1); GL(glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT)); for (auto it = render_data_vector.begin(); it != render_data_vector.end(); ++it) { GL(renderRenderData(rstate, *it)); } }
void Renderer::cull(Scene *scene, Camera *camera, ShaderManager* shader_manager) { if (camera->owner_object() == 0 || camera->owner_object()->transform() == nullptr) { return; } cullFromCamera(scene, camera, shader_manager); // Note: this needs to be scaled to sort on N states state_sort(); if(do_batching && !gRenderer->isVulkanInstace()){ batch_manager->batchSetup(render_data_vector); } }
void Renderer::cull(Scene *scene, Camera *camera, ShaderManager* shader_manager) { if (camera->owner_object() == 0 || camera->owner_object()->transform() == nullptr) { return; } std::vector<SceneObject*> scene_objects; scene_objects.reserve(1024); // makeShadowMaps(scene, shader_manager); cullFromCamera(scene, camera, shader_manager, scene_objects); // Note: this needs to be scaled to sort on N states state_sort(); }