Sfoglia il codice sorgente

src: fix 'selection' shader

Daniele Bartolini 2 anni fa
parent
commit
4701f53db1
2 ha cambiato i file con 9 aggiunte e 2 eliminazioni
  1. 1 1
      samples/core/shaders/default.shader
  2. 8 1
      src/world/render_world.cpp

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

@@ -327,7 +327,7 @@ bgfx_shaders = {
 
 			void main()
 			{
-				gl_FragColor.r = uint(u_unit_id.x);
+				gl_FragColor.r = u_unit_id.x;
 			}
 		"""
 	}

+ 8 - 1
src/world/render_world.cpp

@@ -39,8 +39,15 @@ static void selection_draw_override(UnitId unit_id, RenderWorld *rw)
 		return;
 	}
 
+	union
+	{
+		u32 u;
+		f32 f;
+	} u2f;
+	u2f.u = unit_id._idx;
+
 	Vector4 data;
-	data.x = f32(unit_id._idx);
+	data.x = u2f.f;
 	data.y = 0.0f;
 	data.z = 0.0f;
 	data.w = 0.0f;