What does this line exactly do
ra.rgb * ra.w / max(ra.r, 1e-4) * (bR.r / bR);
The part I am confused about is how to translate
(bR.r / bR);
A float divided by a vec3? I want to translate this to C++ but what is that returning a float divided by all the elements of the vector? etc
(no access to graphics card to check?)
This is an example of component-wise division, and it works as follows:
If the fundamental types in the operands do not match, then the conversions from section 4.1.10 “Implicit Conversions” are applied to create matching types. [...] After conversion, the following cases are valid:
[...]
- One operand is a scalar, and the other is a vector or matrix. In this case, the scalar operation is applied independently to each component of the vector or matrix, resulting in the same size vector or matrix.
vv vec3
(bR.r / bR);
^ float
The scalar bR.r
is essentially promoted to vec3 (bR.r, bR.r, bR.r)
and then component-wise division is performed, resulting in vec3 (bR.r/bR.r, bR.r/bR.g, bR.r/bR.b)
.
vec3 (1.0, bR.r/bR.g, bR.r/bR.b)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With