瀏覽代碼

Clarify 'bgr' swizzle example in Shading language (#4868)

Saying that "order does not matter" is wrong or at least misleading.

This commit changes the comment to show that vector components can be
combined freely, and the order matters.

Co-authored-by: Hugo Locurcio <[email protected]>
Dennis Brakhane 4 年之前
父節點
當前提交
c94d1a63de
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      tutorials/shading/shading_reference/shading_language.rst

+ 2 - 2
tutorials/shading/shading_reference/shading_language.rst

@@ -162,13 +162,13 @@ is another vector type (or scalar). This is easier shown than explained:
     vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
     vec3 b = a.rgb; // Creates a vec3 with vec4 components.
     vec3 b = a.ggg; // Also valid; creates a vec3 and fills it with a single vec4 component.
-    vec3 b = a.bgr; // Order does not matter.
+    vec3 b = a.bgr; // "b" will be vec3(2.0, 1.0, 0.0).
     vec3 b = a.xyz; // Also rgba, xyzw are equivalent.
     vec3 b = a.stp; // And stpq (for texture coordinates).
     float c = b.w; // Invalid, because "w" is not present in vec3 b.
     vec3 c = b.xrt; // Invalid, mixing different styles is forbidden.
     b.rrr = a.rgb; // Invalid, assignment with duplication.
-    b.bgr = a.rgb; // Valid assignment.
+    b.bgr = a.rgb; // Valid assignment. "b"'s "blue" component will be "a"'s "red" and vice versa.
 
 Precision
 ~~~~~~~~~