Browse Source

tools: GUI should be drawn after the outlines

Daniele Bartolini 1 năm trước cách đây
mục cha
commit
ecae4af00c

+ 1 - 1
samples/core/shaders/default.shader

@@ -374,7 +374,7 @@ bgfx_shaders = {
 				if (s_depth > m_depth)
 					alpha *= 0.35;
 
-				gl_FragColor = vec4(u_outline_color.xyz, alpha);
+				gl_FragColor = vec4(toLinearAccurate(u_outline_color.xyz), alpha);
 			}
 		#else
 			void main()

+ 6 - 3
src/device/device.cpp

@@ -768,8 +768,9 @@ void Device::render(World &world, UnitId camera_unit)
 	bgfx::setViewRect(VIEW_SPRITE_7, 0, 0, _width, _height);
 	bgfx::setViewRect(VIEW_MESH, 0, 0, _width, _height);
 	bgfx::setViewRect(VIEW_DEBUG, 0, 0, _width, _height);
-	bgfx::setViewRect(VIEW_GUI, 0, 0, _width, _height);
 	bgfx::setViewRect(VIEW_SELECTION, 0, 0, _width, _height);
+	bgfx::setViewRect(VIEW_OUTLINE, 0, 0, _width, _height);
+	bgfx::setViewRect(VIEW_GUI, 0, 0, _width, _height);
 	bgfx::setViewRect(VIEW_GRAPH, 0, 0, _width, _height);
 
 	bgfx::setViewMode(VIEW_SPRITE_0, bgfx::ViewMode::DepthAscending);
@@ -793,8 +794,9 @@ void Device::render(World &world, UnitId camera_unit)
 	bgfx::setViewFrameBuffer(VIEW_SPRITE_7, _pipeline->_main_frame_buffer);
 	bgfx::setViewFrameBuffer(VIEW_MESH, _pipeline->_main_frame_buffer);
 	bgfx::setViewFrameBuffer(VIEW_DEBUG, _pipeline->_main_frame_buffer);
-	bgfx::setViewFrameBuffer(VIEW_GUI, _pipeline->_main_frame_buffer);
 	bgfx::setViewFrameBuffer(VIEW_SELECTION, _pipeline->_selection_frame_buffer);
+	bgfx::setViewFrameBuffer(VIEW_OUTLINE, _pipeline->_main_frame_buffer);
+	bgfx::setViewFrameBuffer(VIEW_GUI, _pipeline->_main_frame_buffer);
 	bgfx::setViewFrameBuffer(VIEW_GRAPH, _pipeline->_main_frame_buffer);
 	bgfx::setViewFrameBuffer(VIEW_BLIT, BGFX_INVALID_HANDLE);
 
@@ -808,8 +810,9 @@ void Device::render(World &world, UnitId camera_unit)
 	bgfx::touch(VIEW_SPRITE_7);
 	bgfx::touch(VIEW_MESH);
 	bgfx::touch(VIEW_DEBUG);
-	bgfx::touch(VIEW_GUI);
 	bgfx::touch(VIEW_SELECTION);
+	bgfx::touch(VIEW_OUTLINE);
+	bgfx::touch(VIEW_GUI);
 	bgfx::touch(VIEW_GRAPH);
 	bgfx::touch(VIEW_BLIT);
 

+ 3 - 1
src/device/pipeline.cpp

@@ -227,10 +227,12 @@ void Pipeline::render(ShaderManager &sm, StringId32 program, u8 view, u16 width,
 	bgfx::setTexture(0, _selection_texture_sampler, _selection_texture, samplerFlags);
 	bgfx::setTexture(1, _selection_depth_texture_sampler, _selection_depth_texture, samplerFlags);
 	bgfx::setTexture(2, _main_depth_texture_sampler, _main_depth_texture, samplerFlags);
+	bgfx::setViewRect(VIEW_OUTLINE, 0, 0, width, height);
+	bgfx::setViewTransform(VIEW_OUTLINE, NULL, ortho);
 	screenSpaceQuad(width, height, 0.0f, caps->originBottomLeft);
 	const f32 outline_color[] = { 1.0f, 0.37f, 0.05f, 1.0f };
 	bgfx::setUniform(_outline_color_uniform, outline_color);
-	sm.submit(STRING_ID_32("outline", UINT32_C(0xb6b58d80)), view, 0, UINT64_MAX);
+	sm.submit(STRING_ID_32("outline", UINT32_C(0xb6b58d80)), VIEW_OUTLINE, 0, UINT64_MAX);
 #endif
 }
 

+ 1 - 0
src/device/pipeline.h

@@ -18,6 +18,7 @@
 #define VIEW_SPRITE_7    8
 #define VIEW_MESH       16
 #define VIEW_SELECTION  32
+#define VIEW_OUTLINE    33
 #define VIEW_DEBUG     100
 #define VIEW_GUI       128
 #define VIEW_GRAPH     200