s, t, p and q are valid swizzle indices?

  • Posts: 176
1 year 7 months ago #1 by Daodan
I made a typo and wrote 'variable.t' instead of 'variable.z' (on a qwertz keyboard that is... i'm not that bad of a writer ;) ) and was baffled that this isn't an error as I'm only aware of the '.rgba' and '.xyzw' indices. That made me curious and it seems like '.stp' is the same as '.rgb' and it is also possible to use '.q'. Is there some meaning to this or is it just some leftover from writing the new compiler?

Please Log in or Create an account to join the conversation.

  • Posts: 1221
1 year 7 months ago #2 by Marty McFly
OpenGL uses these, having them available here makes porting code from OGL easier.
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.

  • Posts: 3740
1 year 7 months ago #3 by crosire
Correct. There are three types of swizzle sets which can be used in different scenarios to make it cleaner what your swizzle accomplishes:
xyzw = geometry vectors
rgba = colors
stpq = texture coordinates

They are just syntactic sugar of course, so you don't have to use them for rhese purposes (it is common that xyzw is used for almost everything).
The following user(s) said Thank You: Daodan

Please Log in or Create an account to join the conversation.