Browse Source

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 years ago
parent
commit
c94d1a63de
1 changed files with 2 additions and 2 deletions
  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
 ~~~~~~~~~