Repository: godotengine/godot
File: drivers/gles3/rasterizer_scene_gles3.cpp (C++)

Code before:
	glViewport(0, 0, rb->internal_size.x, rb->internal_size.y);

	scene_state.reset_gl_state();

	// Do depth prepass if it's explicitly enabled
	bool use_depth_prepass = config->use_depth_prepass;

	// Don't do depth prepass we are rendering overdraw
	use_depth_prepass = use_depth_prepass && get_debug_draw_mode() != RS::VIEWPORT_DEBUG_DRAW_OVERDRAW;

	if (use_depth_prepass) {
		RENDER_TIMESTAMP("Depth Prepass");
		//pre z pass

		scene_state.enable_gl_depth_test(true);
		scene_state.enable_gl_depth_draw(true);
		scene_state.enable_gl_blend(false);
		glDepthFunc(GL_GEQUAL);
		scene_state.enable_gl_scissor_test(false);

		glColorMask(0, 0, 0, 0);
		RasterizerGLES3::clear_depth(0.0);
		glClear(GL_DEPTH_BUFFER_BIT);
		// Some desktop GL implementations fall apart when using Multiview with GL_NONE.
		GLuint db = p_camera_data->view_count > 1 ? GL_COLOR_ATTACHMENT0 : GL_NONE;
		glDrawBuffers(1, &db);

		uint64_t spec_constant = SceneShaderGLES3::DISABLE_FOG | SceneShaderGLES3::DISABLE_LIGHT_DIRECTIONAL |
				SceneShaderGLES3::DISABLE_LIGHTMAP | SceneShaderGLES3::DISABLE_LIGHT_OMNI |
				SceneShaderGLES3::DISABLE_LIGHT_SPOT;

		RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, spec_constant, use_wireframe);
		_render_list_template<PASS_MODE_DEPTH>(&render_list_params, &render_data, 0, render_list[RENDER_LIST_OPAQUE].elements.size());

		glColorMask(1, 1, 1, 1);

		fb_cleared = true;
		scene_state.used_depth_prepass = true;
	} else {
		scene_state.used_depth_prepass = false;
	}

	glBlendEquation(GL_FUNC_ADD);
	if (render_data.transparent_bg) {
		glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
		scene_state.enable_gl_blend(true);
	} else {
		glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
		scene_state.enable_gl_blend(false);
	}
	scene_state.current_blend_mode = GLES3::SceneShaderData::BLEND_MODE_MIX;

Review comment (suggestion):
```suggestion
		Transform3D transform = render_data.cam_transform;
```
Unnecessary, already a transform

Code after:
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
	glViewport(0, 0, rb->internal_size.x, rb->internal_size.y);

	scene_state.reset_gl_state();

	// Do depth prepass if it's explicitly enabled
	bool use_depth_prepass = config->use_depth_prepass;

	// Don't do depth prepass we are rendering overdraw
	use_depth_prepass = use_depth_prepass && get_debug_draw_mode() != RS::VIEWPORT_DEBUG_DRAW_OVERDRAW;

	if (use_depth_prepass) {
		RENDER_TIMESTAMP("Depth Prepass");
		//pre z pass

		scene_state.enable_gl_depth_test(true);
		scene_state.enable_gl_depth_draw(true);
		scene_state.enable_gl_blend(false);
		glDepthFunc(GL_GEQUAL);
		scene_state.enable_gl_scissor_test(false);

		glColorMask(0, 0, 0, 0);
		RasterizerGLES3::clear_depth(0.0);
		glClear(GL_DEPTH_BUFFER_BIT);
		// Some desktop GL implementations fall apart when using Multiview with GL_NONE.
		GLuint db = p_camera_data->view_count > 1 ? GL_COLOR_ATTACHMENT0 : GL_NONE;
		glDrawBuffers(1, &db);

		uint64_t spec_constant = SceneShaderGLES3::DISABLE_FOG | SceneShaderGLES3::DISABLE_LIGHT_DIRECTIONAL |
				SceneShaderGLES3::DISABLE_LIGHTMAP | SceneShaderGLES3::DISABLE_LIGHT_OMNI |
				SceneShaderGLES3::DISABLE_LIGHT_SPOT;

		RenderListParameters render_list_params(render_list[RENDER_LIST_OPAQUE].elements.ptr(), render_list[RENDER_LIST_OPAQUE].elements.size(), reverse_cull, spec_constant, use_wireframe);
		_render_list_template<PASS_MODE_DEPTH>(&render_list_params, &render_data, 0, render_list[RENDER_LIST_OPAQUE].elements.size());

		glColorMask(1, 1, 1, 1);

		fb_cleared = true;
		scene_state.used_depth_prepass = true;
	} else {
		scene_state.used_depth_prepass = false;
	}

	glBlendEquation(GL_FUNC_ADD);
	if (render_data.transparent_bg) {
		glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
		scene_state.enable_gl_blend(true);
	} else {
		glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ONE);
		scene_state.enable_gl_blend(false);
	}