Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few extended functions for GLSL do not clarify what should happen if given a scalar operand #254

Open
expenses opened this issue Nov 21, 2021 · 1 comment

Comments

@expenses
Copy link

expenses commented Nov 21, 2021

The extension instructions in question are:

  • Length - The documentation states:

    Result is the length of vector x, i.e., sqrt(x [0] 2 + x [1] 2 + …).'

    However, this is contradicted by the next lines, which imply that the result may also be a vector:

    The operand x must be a scalar or vector whose component type is floating-point.

    Result Type must be a scalar of the same type as the component type of x.

    Presumably, implementors implement the scalar version of this as abs(x)? This could be clarified.

  • Distance - Same thing. Presumably this is implemented as abs(a - b)?

  • Normalize - Also has contradictory docs:

    Result is the vector in the same direction as x but with a length of 1.

    The operand x must be a scalar or vector whose component type is floating-point.

    Result Type and the type of x must be the same type.

    From my testing on shadertoy, normalize(scalar) is just x / abs(x)?

@johnkslang
Copy link
Member

johnkslang commented Feb 23, 2022

  • Length, yes it could probably say vector or scalar in both places. And, the formula is still correct: sqrt(x*x), which I'm sure many vendors could substitute abs(x) for.

  • Distance: which part is not right? It's different in never claiming to only support vectors, right?

  • Normalize: Like Length, could more clearly say scalar or vector in both places, but again the vector formula degenerates to the scalar formula, so there should not be an issue regarding that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants