-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
3D Tiles Styling - add vector support to the built-in functions #4865
Comments
Please link to this from #3241 (and link future short-term 3D Tiles issues) so we can track our progress. |
Unary functions PR here: #4867 |
Hi, I'm working on adding the length and distance functions but couldn't find anything in CesiumMath that support either of those two functions. Are there any other functions in the repo that could possibly help me? |
Look into |
@glee2244, @Jane-Of-Art, @Dylan-Brown Just a heads up that |
Finished. Thanks @Jane-Of-Art and @glee2244 for the work here! |
Now that vector types are supported in the styling language (#4759) the built-in functions should support the
vec2
,vec3
, andvec4
types in addition to supporting numbers as they currently do.Unary functions can accept either a number,
vec2
,vec3
, orvec4
. If the type is a vector, the function should be applied to every component of the vector and return the resulting vector. This rule applies to the other functions as well.The function signatures for all these look like:
fract(vecx x)
fract(float x)
For
atan
andpow
, both arguments must be the same type.atan2(float x, float y)
atan2(vecx x, vecx y)
pow(float x, float y)
pow(vecx x, vecx y)
For
min
andmax
, the second argument may be a number. Otherwise the types should match.min(float x, float y)
min(vecx x, vecx y)
min(vecx x, float y)
max(float x, float y)
max(vecx x, vecx y)
max(vecx x, float y)
Example:
min(vec4(1.0), vec4(2.0))
andmin(vec4(1.0), 2.0)
are both valid, butmin(vec4(1.0), vec3(1.0))
is notSimilar rules for
mix
andclamp
:mix(float x, float y, float a)
mix(vecx x, vecx y, vecx a)
mix(vecx x, vecx y, float a)
clamp(float x, float minVal, float maxVal)
clamp(vecx x, vecx minVal, vecx maxVal)
clamp(vecx x, float minVal, float maxVal)
Below are functions that haven't been added to the styling language yet.
length(vecx x)
length(float x)
distance(vecx x, vecx y)
distance(float x, float y)
dot(vecx x, vecx y)
dot(float x, float y)
normalize(vecx x)
normalize(float x)
-- always return 1.0vec3
is supported. Throw aDeveloperError
otherwise.cross(vec3 x, vec3 y)
As usual, this is a good reference: http://www.shaderific.com/glsl-functions/
I'll open a PR for one of these. And then possibly @Dylan-Brown or others can finish it off.
The text was updated successfully, but these errors were encountered: