shader_functions.rst 145 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988
  1. .. _doc_shader_functions:
  2. Built-in functions
  3. ==================
  4. Godot supports a large number of built-in functions, conforming roughly to the
  5. GLSL ES 3.0 specification.
  6. .. note::
  7. The following type aliases only used in documentation to reduce repetitive function declarations.
  8. They can each refer to any of several actual types.
  9. +-----------------+-----------------------------------------------------+--------------------------+
  10. | alias | actual types | glsl documentation alias |
  11. +=================+=====================================================+==========================+
  12. | vec_type | float, vec2, vec3, or vec4 | genType |
  13. +-----------------+-----------------------------------------------------+--------------------------+
  14. | vec_int_type | int, ivec2, ivec3, or ivec4 | genIType |
  15. +-----------------+-----------------------------------------------------+--------------------------+
  16. | vec_uint_type | uint, uvec2, uvec3, or uvec4 | genUType |
  17. +-----------------+-----------------------------------------------------+--------------------------+
  18. | vec_bool_type | bool, bvec2, bvec3, or bvec4 | genBType |
  19. +-----------------+-----------------------------------------------------+--------------------------+
  20. | mat_type | mat2, mat3, or mat4 | mat |
  21. +-----------------+-----------------------------------------------------+--------------------------+
  22. | gvec4_type | vec4, ivec4, or uvec4 | gvec4 |
  23. +-----------------+-----------------------------------------------------+--------------------------+
  24. | gsampler2D | sampler2D, isampler2D, or uSampler2D | gsampler2D |
  25. +-----------------+-----------------------------------------------------+--------------------------+
  26. | gsampler2DArray | sampler2DArray, isampler2DArray, or uSampler2DArray | gsampler2DArray |
  27. +-----------------+-----------------------------------------------------+--------------------------+
  28. | gsampler3D | sampler3D, isampler3D, or uSampler3D | gsampler3D |
  29. +-----------------+-----------------------------------------------------+--------------------------+
  30. If any of these are specified for multiple parameters, they must all be the same type unless otherwise noted.
  31. .. _shading_componentwise:
  32. .. note::
  33. Many functions that accept one or more vectors or matrices perform the described function on each component of the vector/matrix.
  34. Some examples:
  35. .. table::
  36. :class: nowrap-col2 nowrap-col1
  37. :widths: auto
  38. +---------------------------------------+-----------------------------------------------------+
  39. | Operation | Equivalent Scalar Operation |
  40. +=======================================+=====================================================+
  41. | ``sqrt(vec2(4, 64))`` | ``vec2(sqrt(4), sqrt(64))`` |
  42. +---------------------------------------+-----------------------------------------------------+
  43. | ``min(vec2(3, 4), 1)`` | ``vec2(min(3, 1), min(4, 1))`` |
  44. +---------------------------------------+-----------------------------------------------------+
  45. | ``min(vec3(1, 2, 3),vec3(5, 1, 3))`` | ``vec3(min(1, 5), min(2, 1), min(3, 3))`` |
  46. +---------------------------------------+-----------------------------------------------------+
  47. | ``pow(vec3(3, 8, 5 ), 2)`` | ``vec3(pow(3, 2), pow(8, 2), pow(5, 2))`` |
  48. +---------------------------------------+-----------------------------------------------------+
  49. | ``pow(vec3(3, 8, 5), vec3(1, 2, 4))`` | ``vec3(pow(3, 1), pow(8, 2), pow(5, 4))`` |
  50. +---------------------------------------+-----------------------------------------------------+
  51. The `GLSL Language Specification <http://www.opengl.org/registry/doc/GLSLangSpec.4.30.6.pdf>`_ says under section 5.10 Vector and Matrix Operations:
  52. With a few exceptions, operations are component-wise. Usually, when an operator operates on a
  53. vector or matrix, it is operating independently on each component of the vector or matrix,
  54. in a component-wise fashion. [...] The exceptions are matrix multiplied by vector,
  55. vector multiplied by matrix, and matrix multiplied by matrix. These do not operate component-wise,
  56. but rather perform the correct linear algebraic multiply.
  57. .. rst-class:: classref-section-separator
  58. ----
  59. .. rst-class:: classref-reftable-group
  60. Trigonometric functions
  61. -----------------------
  62. .. table::
  63. :class: nowrap-col2
  64. :widths: auto
  65. +-----------------+-----------------------------------------------------------------+-----------------------------+
  66. | Return Type | Function | Description / Return value |
  67. +=================+=================================================================+=============================+
  68. | |vec_type| | :ref:`radians<shader_func_radians>`\ (\ |vec_type| degrees) | Convert degrees to radians. |
  69. +-----------------+-----------------------------------------------------------------+-----------------------------+
  70. | |vec_type| | :ref:`degrees<shader_func_degrees>`\ (\ |vec_type| radians) | Convert radians to degrees. |
  71. +-----------------+-----------------------------------------------------------------+-----------------------------+
  72. | |vec_type| | :ref:`sin<shader_func_sin>`\ (\ |vec_type| x) | Sine. |
  73. +-----------------+-----------------------------------------------------------------+-----------------------------+
  74. | |vec_type| | :ref:`cos<shader_func_cos>`\ (\ |vec_type| x) | Cosine. |
  75. +-----------------+-----------------------------------------------------------------+-----------------------------+
  76. | |vec_type| | :ref:`tan<shader_func_tan>`\ (\ |vec_type| x) | Tangent. |
  77. +-----------------+-----------------------------------------------------------------+-----------------------------+
  78. | |vec_type| | :ref:`asin<shader_func_asin>`\ (\ |vec_type| x) | Arc sine. |
  79. +-----------------+-----------------------------------------------------------------+-----------------------------+
  80. | |vec_type| | :ref:`acos<shader_func_acos>`\ (\ |vec_type| x) | Arc cosine. |
  81. +-----------------+-----------------------------------------------------------------+-----------------------------+
  82. | | |vec_type| | | :ref:`atan<shader_func_atan>`\ (\ |vec_type| y_over_x) | Arc tangent. |
  83. | | |vec_type| | | :ref:`atan<shader_func_atan2>`\ (\ |vec_type| y, |vec_type| x)| |
  84. +-----------------+-----------------------------------------------------------------+-----------------------------+
  85. | |vec_type| | :ref:`sinh<shader_func_sinh>`\ (\ |vec_type| x) | Hyperbolic sine. |
  86. +-----------------+-----------------------------------------------------------------+-----------------------------+
  87. | |vec_type| | :ref:`cosh<shader_func_cosh>`\ (\ |vec_type| x) | Hyperbolic cosine. |
  88. +-----------------+-----------------------------------------------------------------+-----------------------------+
  89. | |vec_type| | :ref:`tanh<shader_func_tanh>`\ (\ |vec_type| x) | Hyperbolic tangent. |
  90. +-----------------+-----------------------------------------------------------------+-----------------------------+
  91. | |vec_type| | :ref:`asinh<shader_func_asinh>`\ (\ |vec_type| x) | Arc hyperbolic sine. |
  92. +-----------------+-----------------------------------------------------------------+-----------------------------+
  93. | |vec_type| | :ref:`acosh<shader_func_acosh>`\ (\ |vec_type| x) | Arc hyperbolic cosine. |
  94. +-----------------+-----------------------------------------------------------------+-----------------------------+
  95. | |vec_type| | :ref:`atanh<shader_func_atanh>`\ (\ |vec_type| x) | Arc hyperbolic tangent. |
  96. +-----------------+-----------------------------------------------------------------+-----------------------------+
  97. .. rst-class:: classref-descriptions-group
  98. Trigonometric function descriptions
  99. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100. .. _shader_func_radians:
  101. .. rst-class:: classref-method
  102. |vec_type| **radians**\ (\ |vec_type| degrees)
  103. |componentwise|
  104. Converts a quantity specified in degrees into radians.
  105. :param degrees:
  106. The quantity, in degrees, to be converted to radians.
  107. :return:
  108. ``degrees * (PI / 180)``
  109. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/radians.xhtml
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _shader_func_degrees:
  113. .. rst-class:: classref-method
  114. |vec_type| **degrees**\ (\ |vec_type| radians)
  115. |componentwise|
  116. Converts a quantity specified in radians into degrees.
  117. :param radians:
  118. The quantity, in radians, to be converted to degrees.
  119. :return:
  120. ``radians * (180 / PI)``
  121. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/degrees.xhtml
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _shader_func_sin:
  125. .. rst-class:: classref-method
  126. |vec_type| **sin**\ (\ |vec_type| angle)
  127. |componentwise|
  128. Return the trigonometric sine of ``angle``.
  129. :param angle:
  130. The quantity, in radians, of which to return the sine.
  131. :return:
  132. The sine of ``angle``.
  133. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/sin.xhtml
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _shader_func_cos:
  137. .. rst-class:: classref-method
  138. |vec_type| **cos**\ (\ |vec_type| angle)
  139. |componentwise|
  140. Return the trigonometric cosine of ``angle``.
  141. :param angle:
  142. The quantity, in radians, of which to return the cosine.
  143. :return:
  144. The cosine of ``angle``.
  145. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/cos.xhtml
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _shader_func_tan:
  149. .. rst-class:: classref-method
  150. |vec_type| **tan**\ (\ |vec_type| angle)
  151. |componentwise|
  152. Return the trigonometric tangent of ``angle``.
  153. :param angle:
  154. The quantity, in radians, of which to return the tangent.
  155. :return:
  156. The tangent of ``angle``.
  157. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/tan.xhtml
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _shader_func_asin:
  161. .. rst-class:: classref-method
  162. |vec_type| **asin**\ (\ |vec_type| x)
  163. |componentwise|
  164. Arcsine, or inverse sine.
  165. Calculates the angle whose sine is ``x``.
  166. The result is undefined if ``x < -1`` or ``x > 1``.
  167. :param x:
  168. The value whose arc sine to return.
  169. :return:
  170. The angle whose trigonometric sine is ``x`` and is
  171. in the range ``[-PI/2, PI/2]``.
  172. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/asin.xhtml
  173. .. rst-class:: classref-item-separator
  174. ----
  175. .. _shader_func_acos:
  176. .. rst-class:: classref-method
  177. |vec_type| **acos**\ (\ |vec_type| x)
  178. |componentwise|
  179. Arccosine, or inverse cosine.
  180. Calculates the angle whose cosine is ``x``.
  181. The result is undefined if ``x < -1`` or ``x > 1``.
  182. :param x:
  183. The value whose arc cosine to return.
  184. :return:
  185. The angle whose trigonometric cosine is ``x`` and
  186. is in the range ``[0, PI]``.
  187. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/acos.xhtml
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _shader_func_atan:
  191. .. rst-class:: classref-method
  192. |vec_type| **atan**\ (\ |vec_type| y_over_x)
  193. |componentwise|
  194. Calculate the arc tangent given a tangent value of ``y/x``.
  195. .. Note::
  196. Because of the sign ambiguity, the function cannot determine with certainty in
  197. which quadrant the angle falls only by its tangent value. If you need to know the
  198. quadrant, use :ref:`atan(vec_type y, vec_type x)<shader_func_atan2>`.
  199. :param y_over_x:
  200. The fraction whose arc tangent to return.
  201. :return:
  202. The trigonometric arc-tangent of ``y_over_x`` and is
  203. in the range ``[-PI/2, PI/2]``.
  204. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/atan.xhtml
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _shader_func_atan2:
  208. .. rst-class:: classref-method
  209. |vec_type| **atan**\ (\ |vec_type| y, |vec_type| x)
  210. |componentwise|
  211. Calculate the arc tangent given a numerator and denominator. The signs of
  212. ``y`` and ``x`` are used to determine the quadrant that the angle lies in.
  213. The result is undefined if ``x == 0``.
  214. :param y:
  215. The numerator of the fraction whose arc tangent to return.
  216. :param x:
  217. The denominator of the fraction whose arc tangent to return.
  218. :return:
  219. The trigonometric arc tangent of ``y/x`` and is in
  220. the range ``[-PI, PI]``.
  221. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/atan.xhtml
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _shader_func_sinh:
  225. .. rst-class:: classref-method
  226. |vec_type| **sinh**\ (\ |vec_type| x)
  227. |componentwise|
  228. Calculates the hyperbolic sine using ``(e^x - e^-x)/2``.
  229. :param x:
  230. The value whose hyperbolic sine to return.
  231. :return:
  232. The hyperbolic sine of ``x``.
  233. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/sinh.xhtml
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _shader_func_cosh:
  237. .. rst-class:: classref-method
  238. |vec_type| **cosh**\ (\ |vec_type| x)
  239. |componentwise|
  240. Calculates the hyperbolic cosine using ``(e^x + e^-x)/2``.
  241. :param x:
  242. The value whose hyperbolic cosine to return.
  243. :return:
  244. The hyperbolic cosine of ``x``.
  245. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/cosh.xhtml
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _shader_func_tanh:
  249. .. rst-class:: classref-method
  250. |vec_type| **tanh**\ (\ |vec_type| x)
  251. |componentwise|
  252. Calculates the hyperbolic tangent using ``sinh(x)/cosh(x)``.
  253. :param x:
  254. The value whose hyperbolic tangent to return.
  255. :return:
  256. The hyperbolic tangent of ``x``.
  257. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/tanh.xhtml
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _shader_func_asinh:
  261. .. rst-class:: classref-method
  262. |vec_type| **asinh**\ (\ |vec_type| x)
  263. |componentwise|
  264. Calculates the arc hyperbolic sine of ``x``, or the inverse of ``sinh``.
  265. :param x:
  266. The value whose arc hyperbolic sine to return.
  267. :return:
  268. The arc hyperbolic sine of ``x``.
  269. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/asinh.xhtml
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _shader_func_acosh:
  273. .. rst-class:: classref-method
  274. |vec_type| **acosh**\ (\ |vec_type| x)
  275. |componentwise|
  276. Calculates the arc hyperbolic cosine of ``x``, or the non-negative inverse of ``cosh``.
  277. The result is undefined if ``x < 1``.
  278. :param x:
  279. The value whose arc hyperbolic cosine to return.
  280. :return:
  281. The arc hyperbolic cosine of ``x``.
  282. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/acosh.xhtml
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _shader_func_atanh:
  286. .. rst-class:: classref-method
  287. |vec_type| **atanh**\ (\ |vec_type| x)
  288. |componentwise|
  289. Calculates the arc hyperbolic tangent of ``x``, or the inverse of ``tanh``.
  290. The result is undefined if ``|x| > 1``.
  291. :param x:
  292. The value whose arc hyperbolic tangent to return.
  293. :return:
  294. The arc hyperbolic tangent of ``x``.
  295. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/atanh.xhtml
  296. .. rst-class:: classref-section-separator
  297. ----
  298. .. rst-class:: classref-reftable-group
  299. Exponential and math functions
  300. ------------------------------
  301. .. table::
  302. :class: nowrap-col2
  303. :widths: auto
  304. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  305. | Return Type | Function | Description / Return value |
  306. +=====================+=================================================================================================+=================================================================+
  307. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  308. | |vec_type| | :ref:`pow<shader_func_pow>`\ (\ |vec_type| x, |vec_type| y) | Power (undefined if ``x < 0`` or if ``x == 0`` and ``y <= 0``). |
  309. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  310. | |vec_type| | :ref:`exp<shader_func_exp>`\ (\ |vec_type| x) | Base-e exponential. |
  311. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  312. | |vec_type| | :ref:`exp2<shader_func_exp2>`\ (\ |vec_type| x) | Base-2 exponential. |
  313. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  314. | |vec_type| | :ref:`log<shader_func_log>`\ (\ |vec_type| x) | Natural logarithm. |
  315. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  316. | |vec_type| | :ref:`log2<shader_func_log2>`\ (\ |vec_type| x) | Base-2 logarithm. |
  317. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  318. | |vec_type| | :ref:`sqrt<shader_func_sqrt>`\ (\ |vec_type| x) | Square root. |
  319. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  320. | |vec_type| | :ref:`inversesqrt<shader_func_inversesqrt>`\ (\ |vec_type| x) | Inverse square root. |
  321. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  322. | | |vec_type| | | :ref:`abs<shader_func_abs>`\ (\ |vec_type| x) | Absolute value (returns positive value if negative). |
  323. | | |vec_int_type| | | :ref:`abs<shader_func_abs>`\ (\ |vec_int_type| x) | |
  324. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  325. | |vec_type| | :ref:`sign<shader_func_sign>`\ (\ |vec_type| x) | returns ``1.0`` if positive, ``-1.0`` if negative, |
  326. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  327. | |vec_int_type| | :ref:`sign<shader_func_sign>`\ (\ |vec_int_type| x) | returns ``1`` if positive, ``-1`` if negative, |
  328. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  329. | |vec_type| | :ref:`floor<shader_func_floor>`\ (\ |vec_type| x) | Round to the integer below. |
  330. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  331. | |vec_type| | :ref:`round<shader_func_round>`\ (\ |vec_type| x) | Round to the nearest integer. |
  332. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  333. | |vec_type| | :ref:`roundEven<shader_func_roundEven>`\ (\ |vec_type| x) | Round to the nearest even integer. |
  334. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  335. | |vec_type| | :ref:`trunc<shader_func_trunc>`\ (\ |vec_type| x) | Truncation. |
  336. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  337. | |vec_type| | :ref:`ceil<shader_func_ceil>`\ (\ |vec_type| x) | Round to the integer above. |
  338. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  339. | |vec_type| | :ref:`fract<shader_func_fract>`\ (\ |vec_type| x) | Fractional (returns ``x - floor(x)``). |
  340. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  341. | | |vec_type| | | :ref:`mod<shader_func_mod>`\ (\ |vec_type| x, |vec_type| y) | Modulo (division remainder). |
  342. | | |vec_type| | | :ref:`mod<shader_func_mod>`\ (\ |vec_type| x, float y) | |
  343. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  344. | |vec_type| | :ref:`modf<shader_func_modf>`\ (\ |vec_type| x, out |vec_type| i) | Fractional of ``x``, with ``i`` as integer part. |
  345. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  346. | | |vec_type| | | :ref:`min<shader_func_min>`\ (\ |vec_type| a, |vec_type| b) | Lowest value between ``a`` and ``b``. |
  347. | | |vec_type| | | :ref:`min<shader_func_min>`\ (\ |vec_type| a, float b) | |
  348. | | |vec_int_type| | | :ref:`min<shader_func_min>`\ (\ |vec_int_type| a, |vec_int_type| b) | |
  349. | | |vec_int_type| | | :ref:`min<shader_func_min>`\ (\ |vec_int_type| a, int b) | |
  350. | | |vec_uint_type| | | :ref:`min<shader_func_min>`\ (\ |vec_uint_type| a, |vec_uint_type| b) | |
  351. | | |vec_uint_type| | | :ref:`min<shader_func_min>`\ (\ |vec_uint_type| a, uint b) | |
  352. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  353. | | |vec_type| | | :ref:`max<shader_func_max>`\ (\ |vec_type| a, |vec_type| b) | Highest value between ``a`` and ``b``. |
  354. | | |vec_type| | | :ref:`max<shader_func_max>`\ (\ |vec_type| a, float b) | |
  355. | | |vec_uint_type| | | :ref:`max<shader_func_max>`\ (\ |vec_uint_type| a, |vec_uint_type| b) | |
  356. | | |vec_uint_type| | | :ref:`max<shader_func_max>`\ (\ |vec_uint_type| a, uint b) | |
  357. | | |vec_int_type| | | :ref:`max<shader_func_max>`\ (\ |vec_int_type| a, |vec_int_type| b) | |
  358. | | |vec_int_type| | | :ref:`max<shader_func_max>`\ (\ |vec_int_type| a, int b) | |
  359. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  360. | | |vec_type| | | :ref:`clamp<shader_func_clamp>`\ (\ |vec_type| x, |vec_type| min, |vec_type| max) | Clamp ``x`` between ``min`` and ``max`` (inclusive). |
  361. | | |vec_type| | | :ref:`clamp<shader_func_clamp>`\ (\ |vec_type| x, float min, float max) | |
  362. | | |vec_uint_type| | | :ref:`clamp<shader_func_clamp>`\ (\ |vec_int_type| x, |vec_int_type| min, |vec_int_type| max) | |
  363. | | |vec_uint_type| | | :ref:`clamp<shader_func_clamp>`\ (\ |vec_int_type| x, float min, float max) | |
  364. | | |vec_int_type| | | :ref:`clamp<shader_func_clamp>`\ (\ |vec_type| x, |vec_type| min, |vec_type| max) | |
  365. | | |vec_int_type| | | :ref:`clamp<shader_func_clamp>`\ (\ |vec_type| x, float min, float max) | |
  366. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  367. | | |vec_type| | | :ref:`mix<shader_func_mix>`\ (\ |vec_type| a, |vec_type| b, |vec_type| c) | Linear interpolate between ``a`` and ``b`` by ``c``. |
  368. | | |vec_type| | | :ref:`mix<shader_func_mix>`\ (\ |vec_type| a, |vec_type| b, float c) | |
  369. | | |vec_type| | | :ref:`mix<shader_func_mix>`\ (\ |vec_type| a, |vec_type| b, |vec_bool_type| c) | |
  370. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  371. | |vec_type| | :ref:`fma<shader_func_fma>`\ (\ |vec_type| a, |vec_type| b, |vec_type| c) | Fused multiply-add operation: ``(a * b + c)`` |
  372. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  373. | | |vec_type| | | :ref:`step<shader_func_step>`\ (\ |vec_type| a, |vec_type| b) | ``b < a ? 0.0 : 1.0`` |
  374. | | |vec_type| | | :ref:`step<shader_func_step>`\ (\ float a, |vec_type| b) | |
  375. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  376. | | |vec_type| | | :ref:`smoothstep<shader_func_smoothstep>`\ (\ |vec_type| a, |vec_type| b, |vec_type| c) | Hermite interpolate between ``a`` and ``b`` by ``c``. |
  377. | | |vec_type| | | :ref:`smoothstep<shader_func_smoothstep>`\ (\ float a, float b, |vec_type| c) | |
  378. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  379. | |vec_bool_type| | :ref:`isnan<shader_func_isnan>`\ (\ |vec_type| x) | Returns ``true`` if scalar or vector component is ``NaN``. |
  380. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  381. | |vec_bool_type| | :ref:`isinf<shader_func_isinf>`\ (\ |vec_type| x) | Returns ``true`` if scalar or vector component is ``INF``. |
  382. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  383. | |vec_int_type| | :ref:`floatBitsToInt<shader_func_floatBitsToInt>`\ (\ |vec_type| x) | Float->Int bit copying, no conversion. |
  384. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  385. | |vec_uint_type| | :ref:`floatBitsToUint<shader_func_floatBitsToUint>`\ (\ |vec_type| x) | Float->UInt bit copying, no conversion. |
  386. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  387. | |vec_type| | :ref:`intBitsToFloat<shader_func_intBitsToFloat>`\ (\ |vec_int_type| x) | Int->Float bit copying, no conversion. |
  388. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  389. | |vec_type| | :ref:`uintBitsToFloat<shader_func_uintBitsToFloat>`\ (\ |vec_uint_type| x) | UInt->Float bit copying, no conversion. |
  390. +---------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------------------------+
  391. .. rst-class:: classref-descriptions-group
  392. Exponential and math function descriptions
  393. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  394. .. _shader_func_pow:
  395. .. rst-class:: classref-method
  396. |vec_type| **pow**\ (\ |vec_type| x, |vec_type| y)
  397. |componentwise|
  398. Raises ``x`` to the power of ``y``.
  399. The result is undefined if ``x < 0`` or if ``x == 0`` and ``y <= 0``.
  400. :param x:
  401. The value to be raised to the power ``y``.
  402. :param y:
  403. The power to which ``x`` will be raised.
  404. :return:
  405. The value of ``x`` raised to the ``y`` power.
  406. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/pow.xhtml
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _shader_func_exp:
  410. .. rst-class:: classref-method
  411. |vec_type| **exp**\ (\ |vec_type| x)
  412. |componentwise|
  413. Return the natural exponentiation of the parameter.
  414. :param x:
  415. The value to exponentiate.
  416. :return:
  417. The natural exponentiation of ``x``. i.e., e\ :sup:`x`
  418. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/exp.xhtml
  419. .. rst-class:: classref-item-separator
  420. ----
  421. .. _shader_func_exp2:
  422. .. rst-class:: classref-method
  423. |vec_type| **exp2**\ (\ |vec_type| x)
  424. |componentwise|
  425. Return ``2`` raised to the power of ``x``.
  426. :param x:
  427. The value of the power to which ``2`` will be raised.
  428. :return:
  429. ``2`` raised to the power of x, i.e., 2\ :sup:`x`
  430. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/exp2.xhtml
  431. .. rst-class:: classref-item-separator
  432. ----
  433. .. _shader_func_log:
  434. .. rst-class:: classref-method
  435. |vec_type| **log**\ (\ |vec_type| x)
  436. |componentwise|
  437. Return the natural logarithm of ``x``, i.e. the value y which satisfies x=e\ :sup:`y`.
  438. The result is undefined if ``x <= 0``.
  439. :param x:
  440. The value of which to take the natural logarithm.
  441. :return:
  442. The natural logarithm of ``x``.
  443. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/log.xhtml
  444. .. rst-class:: classref-item-separator
  445. ----
  446. .. _shader_func_log2:
  447. .. rst-class:: classref-method
  448. |vec_type| **log2**\ (\ |vec_type| x)
  449. |componentwise|
  450. Return the base 2 logarithm of ``x``.
  451. The result is undefined if ``x <= 0``.
  452. :param x:
  453. The value of which to take the base 2 logarithm.
  454. :return:
  455. The base 2 logarithm of ``x``, i.e. the value y which satisfies x=2\ :sup:`y`
  456. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/log2.xhtml
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _shader_func_sqrt:
  460. .. rst-class:: classref-method
  461. |vec_type| **sqrt**\ (\ |vec_type| x)
  462. |componentwise|
  463. Returns the square root of ``x``.
  464. The result is undefined if ``x < 0``.
  465. :param x:
  466. The value of which to take the square root.
  467. :return:
  468. The square root of ``x``.
  469. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/sqrt.xhtml
  470. .. rst-class:: classref-item-separator
  471. ----
  472. .. _shader_func_inversesqrt:
  473. .. rst-class:: classref-method
  474. |vec_type| **inversesqrt**\ (\ |vec_type| x)
  475. |componentwise|
  476. Returns the inverse of the square root of ``x``.
  477. The result is undefined if ``x <= 0``.
  478. :param x:
  479. The value of which to take the inverse of the square root.
  480. :return:
  481. The inverse of the square root of ``x``.
  482. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/inversesqrt.xhtml
  483. .. rst-class:: classref-item-separator
  484. ----
  485. .. _shader_func_abs:
  486. .. rst-class:: classref-method
  487. |vec_type| **abs**\ (\ |vec_type| x)
  488. .. rst-class:: classref-method
  489. |vec_int_type| **abs**\ (\ |vec_int_type| x)
  490. |componentwise|
  491. Returns the absolute value of ``x``. Returns ``x`` if ``x`` is positive, otherwise returns ``-1 * x``.
  492. :param x:
  493. The value of which to return the absolute.
  494. :return:
  495. The absolute value of ``x``.
  496. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/abs.xhtml
  497. .. rst-class:: classref-item-separator
  498. ----
  499. .. _shader_func_sign:
  500. .. rst-class:: classref-method
  501. |vec_type| **sign**\ (\ |vec_type| x)
  502. .. rst-class:: classref-method
  503. |vec_int_type| **sign**\ (\ |vec_int_type| x)
  504. |componentwise|
  505. Returns ``-1`` if ``x < 0``, ``0`` if ``x == 0``, and ``1`` if ``x > 0``.
  506. :param x:
  507. The value from which to extract the sign.
  508. :return:
  509. The sign of ``x``, either ``1``, ``-1`` or ``0``.
  510. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/sign.xhtml
  511. .. rst-class:: classref-item-separator
  512. ----
  513. .. _shader_func_floor:
  514. .. rst-class:: classref-method
  515. |vec_type| **floor**\ (\ |vec_type| x)
  516. |componentwise|
  517. Returns a value equal to the nearest integer that is less than or equal to ``x``.
  518. :param x:
  519. The value to evaluate.
  520. :return:
  521. The nearest integer that is less than or equal to ``x``.
  522. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/floor.xhtml
  523. .. rst-class:: classref-item-separator
  524. ----
  525. .. _shader_func_round:
  526. .. rst-class:: classref-method
  527. |vec_type| **round**\ (\ |vec_type| x)
  528. |componentwise|
  529. Rounds ``x`` to the nearest integer.
  530. .. note::
  531. Rounding of values with a fractional part of ``0.5`` is implementation-dependent.
  532. This includes the possibility that ``round(x)`` returns the same value as
  533. ``roundEven(x)``for all values of ``x``.
  534. :param x:
  535. The value to round.
  536. :return:
  537. The rounded value.
  538. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/round.xhtml
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _shader_func_roundEven:
  542. .. rst-class:: classref-method
  543. |vec_type| **roundEven**\ (\ |vec_type| x)
  544. |componentwise|
  545. Rounds ``x`` to the nearest integer. A value with a fractional part of ``0.5``
  546. will always round toward the nearest even integer.
  547. For example, both ``3.5`` and ``4.5`` will round to ``4.0``.
  548. :param x:
  549. The value to round.
  550. :return:
  551. The rounded value.
  552. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/roundEven.xhtml
  553. .. rst-class:: classref-item-separator
  554. ----
  555. .. _shader_func_trunc:
  556. .. rst-class:: classref-method
  557. |vec_type| **trunc**\ (\ |vec_type| x)
  558. |componentwise|
  559. Truncates ``x``. Returns a value equal to the nearest integer to ``x`` whose
  560. absolute value is not larger than the absolute value of ``x``.
  561. :param x:
  562. The value to evaluate.
  563. :return:
  564. The truncated value.
  565. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/trunc.xhtml
  566. .. rst-class:: classref-item-separator
  567. ----
  568. .. _shader_func_ceil:
  569. .. rst-class:: classref-method
  570. |vec_type| **ceil**\ (\ |vec_type| x)
  571. |componentwise|
  572. Returns a value equal to the nearest integer that is greater than or equal to ``x``.
  573. :param x:
  574. The value to evaluate.
  575. :return:
  576. The ceiling-ed value.
  577. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/ceil.xhtml
  578. .. rst-class:: classref-item-separator
  579. ----
  580. .. _shader_func_fract:
  581. .. rst-class:: classref-method
  582. |vec_type| **fract**\ (\ |vec_type| x)
  583. |componentwise|
  584. Returns the fractional part of ``x``.
  585. This is calculated as ``x - floor(x)``.
  586. :param x:
  587. The value to evaluate.
  588. :return:
  589. The fractional part of ``x``.
  590. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fract.xhtml
  591. .. rst-class:: classref-item-separator
  592. ----
  593. .. _shader_func_mod:
  594. .. rst-class:: classref-method
  595. |vec_type| **mod**\ (\ |vec_type| x, |vec_type| y)
  596. .. rst-class:: classref-method
  597. |vec_type| **mod**\ (\ |vec_type| x, float y)
  598. |componentwise|
  599. Returns the value of ``x modulo y``.
  600. This is also sometimes called the remainder.
  601. This is computed as ``x - y * floor(x/y)``.
  602. :param x:
  603. The value to evaluate.
  604. :return:
  605. The value of ``x modulo y``.
  606. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/mod.xhtml
  607. .. rst-class:: classref-item-separator
  608. ----
  609. .. _shader_func_modf:
  610. .. rst-class:: classref-method
  611. |vec_type| **modf**\ (\ |vec_type| x, out |vec_type| i)
  612. |componentwise|
  613. Separates a floating point value ``x`` into its integer and fractional parts.
  614. The fractional part of the number is returned from the function.
  615. The integer part (as a floating point quantity) is returned in the output parameter ``i``.
  616. :param x:
  617. The value to separate.
  618. :param out i:
  619. A variable that receives the integer part of the argument.
  620. :return:
  621. The fractional part of the number.
  622. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/modf.xhtml
  623. .. rst-class:: classref-item-separator
  624. ----
  625. .. _shader_func_min:
  626. .. rst-class:: classref-method
  627. |vec_type| **min**\ (\ |vec_type| a, |vec_type| b)
  628. .. rst-class:: classref-method
  629. |vec_type| **min**\ (\ |vec_type| a, float b)
  630. .. rst-class:: classref-method
  631. |vec_int_type| **min**\ (\ |vec_int_type| a, |vec_int_type| b)
  632. .. rst-class:: classref-method
  633. |vec_int_type| **min**\ (\ |vec_int_type| a, int b)
  634. .. rst-class:: classref-method
  635. |vec_uint_type| **min**\ (\ |vec_uint_type| a, |vec_uint_type| b)
  636. .. rst-class:: classref-method
  637. |vec_uint_type| **min**\ (\ |vec_uint_type| a, uint b)
  638. |componentwise|
  639. Returns the minimum of two values ``a`` and ``b``.
  640. Returns ``b`` if ``b < a``, otherwise returns ``a``.
  641. :param a:
  642. The first value to compare.
  643. :param b:
  644. The second value to compare.
  645. :return:
  646. The minimum value.
  647. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/min.xhtml
  648. .. rst-class:: classref-item-separator
  649. ----
  650. .. _shader_func_max:
  651. .. rst-class:: classref-method
  652. |vec_type| **max**\ (\ |vec_type| a, |vec_type| b)
  653. .. rst-class:: classref-method
  654. |vec_type| **max**\ (\ |vec_type| a, float b)
  655. .. rst-class:: classref-method
  656. |vec_uint_type| **max**\ (\ |vec_uint_type| a, |vec_uint_type| b)
  657. .. rst-class:: classref-method
  658. |vec_uint_type| **max**\ (\ |vec_uint_type| a, uint b)
  659. .. rst-class:: classref-method
  660. |vec_int_type| **max**\ (\ |vec_int_type| a, |vec_int_type| b)
  661. .. rst-class:: classref-method
  662. |vec_int_type| **max**\ (\ |vec_int_type| a, int b)
  663. |componentwise|
  664. Returns the maximum of two values ``a`` and ``b``.
  665. It returns ``b`` if ``b > a``, otherwise it returns ``a``.
  666. :param a:
  667. The first value to compare.
  668. :param b:
  669. The second value to compare.
  670. :return:
  671. The maximum value.
  672. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/max.xhtml
  673. .. rst-class:: classref-item-separator
  674. ----
  675. .. _shader_func_clamp:
  676. .. rst-class:: classref-method
  677. |vec_type| **clamp**\ (\ |vec_type| x, |vec_type| minVal, |vec_type| maxVal)
  678. .. rst-class:: classref-method
  679. |vec_type| **clamp**\ (\ |vec_type| x, float min, float max)
  680. .. rst-class:: classref-method
  681. |vec_type| **clamp**\ (\ |vec_type| x, float min, float max)
  682. .. rst-class:: classref-method
  683. |vec_uint_type| **clamp**\ (\ |vec_int_type| x, float min, float max)
  684. .. rst-class:: classref-method
  685. |vec_int_type| **clamp**\ (\ |vec_type| x, |vec_type| min, |vec_type| max)
  686. .. rst-class:: classref-method
  687. |vec_int_type| **clamp**\ (\ |vec_type| x, float min, float max)
  688. |componentwise|
  689. Returns the value of ``x`` constrained to the range ``minVal`` to ``maxVal``.
  690. The returned value is computed as ``min(max(x, minVal), maxVal)``.
  691. :param x:
  692. The value to constrain.
  693. :param minVal:
  694. The lower end of the range into which to constrain ``x``.
  695. :param maxVal:
  696. The upper end of the range into which to constrain ``x``.
  697. :return:
  698. The clamped value.
  699. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/clamp.xhtml
  700. .. rst-class:: classref-item-separator
  701. ----
  702. .. _shader_func_mix:
  703. .. rst-class:: classref-method
  704. |vec_type| **mix**\ (\ |vec_type| a, |vec_type| b, |vec_type| c)
  705. .. rst-class:: classref-method
  706. |vec_type| **mix**\ (\ |vec_type| a, |vec_type| b, float c)
  707. |componentwise|
  708. Performs a linear interpolation between ``a`` and ``b`` using ``c`` to weight between them.
  709. Computed as ``a * (1 - c) + b * c``.
  710. :param a:
  711. The start of the range in which to interpolate.
  712. :param b:
  713. The end of the range in which to interpolate.
  714. :param c:
  715. The value to use to interpolate between ``a`` and ``b``.
  716. :return:
  717. The interpolated value.
  718. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/mix.xhtml
  719. .. rst-class:: classref-item-separator
  720. ----
  721. .. rst-class:: classref-method
  722. |vec_type| **mix**\ (\ |vec_type| a, |vec_type| b, |vec_bool_type| c)
  723. |componentwise|
  724. Selects either value ``a`` or value ``b`` based on the value of ``c``.
  725. For a component of ``c`` that is false, the corresponding component of ``a`` is returned.
  726. For a component of ``c`` that is true, the corresponding component of ``b`` is returned.
  727. Components of ``a`` and ``b`` that are not selected are allowed to be invalid floating-point values and will have no effect on the results.
  728. If ``a``, ``b``, and ``c`` are vector types the operation is performed component-wise.
  729. ie. ``mix(vec2(42, 314), vec2(9.8, 6e23), vec_bool_type(true, false)))`` will return ``vec2(9.8, 314)``.
  730. :param a:
  731. Value returned when ``c`` is false.
  732. :param b:
  733. Value returned when ``c`` is true.
  734. :param c:
  735. The value used to select between ``a`` and ``b``.
  736. :return:
  737. The interpolated value.
  738. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/mix.xhtml
  739. .. rst-class:: classref-item-separator
  740. ----
  741. .. _shader_func_fma:
  742. .. rst-class:: classref-method
  743. |vec_type| **fma**\ (\ |vec_type| a, |vec_type| b, |vec_type| c)
  744. |componentwise|
  745. Performs, where possible, a fused multiply-add operation, returning ``a * b + c``. In use cases where the
  746. return value is eventually consumed by a variable declared as precise:
  747. - ``fma()`` is considered a single operation, whereas the expression ``a * b + c`` consumed by a variable declared as precise is considered two operations.
  748. - The precision of ``fma()`` can differ from the precision of the expression ``a * b + c``.
  749. - ``fma()`` will be computed with the same precision as any other ``fma()`` consumed by a precise variable,
  750. giving invariant results for the same input values of a, b and c.
  751. Otherwise, in the absence of precise consumption, there are no special constraints on the number of operations
  752. or difference in precision between ``fma()`` and the expression ``a * b + c``.
  753. :param a:
  754. The first value to be multiplied.
  755. :param b:
  756. The second value to be multiplied.
  757. :param c:
  758. The value to be added to the result.
  759. :return:
  760. The value of ``a * b + c``.
  761. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fma.xhtml
  762. .. rst-class:: classref-item-separator
  763. ----
  764. .. _shader_func_step:
  765. .. rst-class:: classref-method
  766. |vec_type| **step**\ (\ |vec_type| a, |vec_type| b)
  767. .. rst-class:: classref-method
  768. |vec_type| **step**\ (\ float a, |vec_type| b)
  769. |componentwise|
  770. Generates a step function by comparing b to a.
  771. Equivalent to ``if (b < a) { return 0.0; } else { return 1.0; }``.
  772. For element i of the return value, 0.0 is returned if b[i] < a[i], and 1.0 is returned otherwise.
  773. :param a:
  774. The location of the edge of the step function.
  775. :param b:
  776. The value to be used to generate the step function.
  777. :return:
  778. ``0.0`` or ``1.0``.
  779. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/step.xhtml
  780. .. rst-class:: classref-item-separator
  781. ----
  782. .. _shader_func_smoothstep:
  783. .. rst-class:: classref-method
  784. |vec_type| **smoothstep**\ (\ |vec_type| a, |vec_type| b, |vec_type| c)
  785. .. rst-class:: classref-method
  786. |vec_type| **smoothstep**\ (\ float a, float b, |vec_type| c)
  787. |componentwise|
  788. Performs smooth Hermite interpolation between ``0`` and ``1`` when a < c < b.
  789. This is useful in cases where a threshold function with a smooth transition is desired.
  790. Smoothstep is equivalent to::
  791. vec_type t;
  792. t = clamp((c - a) / (b - a), 0.0, 1.0);
  793. return t * t * (3.0 - 2.0 * t);
  794. Results are undefined if ``a >= b``.
  795. :param a:
  796. The value of the lower edge of the Hermite function.
  797. :param b:
  798. The value of the upper edge of the Hermite function.
  799. :param c:
  800. The source value for interpolation.
  801. :return:
  802. The interpolated value.
  803. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/smoothstep.xhtml
  804. .. rst-class:: classref-item-separator
  805. ----
  806. .. _shader_func_isnan:
  807. .. rst-class:: classref-method
  808. |vec_bool_type| **isnan**\ (\ |vec_type| x)
  809. |componentwise|
  810. For each element i of the result, returns true if x[i] is positive
  811. or negative floating point NaN (Not a Number) and false otherwise.
  812. :param x:
  813. The value to test for NaN.
  814. :return:
  815. ``true`` or ``false``.
  816. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/isnan.xhtml
  817. .. rst-class:: classref-item-separator
  818. ----
  819. .. _shader_func_isinf:
  820. .. rst-class:: classref-method
  821. |vec_bool_type| **isinf**\ (\ |vec_type| x)
  822. |componentwise|
  823. For each element i of the result, returns true if x[i] is positive or negative
  824. floating point infinity and false otherwise.
  825. :param x:
  826. The value to test for infinity.
  827. :return:
  828. ``true`` or ``false``.
  829. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/isinf.xhtml
  830. .. rst-class:: classref-item-separator
  831. ----
  832. .. _shader_func_floatBitsToInt:
  833. .. rst-class:: classref-method
  834. |vec_int_type| **floatBitsToInt**\ (\ |vec_type| x)
  835. |componentwise|
  836. Returns the encoding of the floating-point parameters as ``int``.
  837. The floating-point bit-level representation is preserved.
  838. :param x:
  839. The value whose floating point encoding to return.
  840. :return:
  841. The floating-point encoding of ``x``.
  842. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/floatBitsToInt.xhtml
  843. .. rst-class:: classref-item-separator
  844. ----
  845. .. _shader_func_floatBitsToUint:
  846. .. rst-class:: classref-method
  847. |vec_uint_type| **floatBitsToUint**\ (\ |vec_type| x)
  848. |componentwise|
  849. Returns the encoding of the floating-point parameters as ``uint``.
  850. The floating-point bit-level representation is preserved.
  851. :param x:
  852. The value whose floating point encoding to return.
  853. :return:
  854. The floating-point encoding of ``x``.
  855. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/floatBitsToUint.xhtml
  856. .. rst-class:: classref-item-separator
  857. ----
  858. .. _shader_func_intBitsToFloat:
  859. .. rst-class:: classref-method
  860. |vec_type| **intBitsToFloat**\ (\ |vec_int_type| x)
  861. |componentwise|
  862. Converts a bit encoding to a floating-point value. Opposite of `floatBitsToInt<_shader_func_floatBitsToInt>`
  863. If the encoding of a ``NaN`` is passed in ``x``, it will not signal and the resulting value will be undefined.
  864. If the encoding of a floating point infinity is passed in parameter ``x``, the resulting floating-point value is
  865. the corresponding (positive or negative) floating point infinity.
  866. :param x:
  867. The bit encoding to return as a floating point value.
  868. :return:
  869. A floating point value
  870. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/intBitsToFloat.xhtml
  871. .. rst-class:: classref-item-separator
  872. ----
  873. .. _shader_func_uintBitsToFloat:
  874. .. rst-class:: classref-method
  875. |vec_type| **uintBitsToFloat**\ (\ |vec_uint_type| x)
  876. |componentwise|
  877. Converts a bit encoding to a floating-point value. Opposite of `floatBitsToUint<_shader_func_floatBitsToUint>`
  878. If the encoding of a ``NaN`` is passed in ``x``, it will not signal and the resulting value will be undefined.
  879. If the encoding of a floating point infinity is passed in parameter ``x``, the resulting floating-point value is
  880. the corresponding (positive or negative) floating point infinity.
  881. :param x:
  882. The bit encoding to return as a floating point value.
  883. :return:
  884. A floating point value.
  885. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/uintBitsToFloat.xhtml
  886. .. rst-class:: classref-section-separator
  887. ----
  888. .. rst-class:: classref-reftable-group
  889. Geometric functions
  890. -------------------
  891. .. table::
  892. :class: nowrap-col2
  893. :widths: auto
  894. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  895. | float | :ref:`length<shader_func_length>`\ (\ |vec_type| x) | Vector length. |
  896. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  897. | float | :ref:`distance<shader_func_distance>`\ (\ |vec_type| a, |vec_type| b) | Distance between vectors i.e ``length(a - b)``. |
  898. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  899. | float | :ref:`dot<shader_func_dot>`\ (\ |vec_type| a, |vec_type| b) | Dot product. |
  900. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  901. | vec3 | :ref:`cross<shader_func_cross>`\ (\ vec3 a, vec3 b) | Cross product. |
  902. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  903. | |vec_type| | :ref:`normalize<shader_func_normalize>`\ (\ |vec_type| x) | Normalize to unit length. |
  904. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  905. | vec3 | :ref:`reflect<shader_func_reflect>`\ (\ vec3 I, vec3 N) | Reflect. |
  906. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  907. | vec3 | :ref:`refract<shader_func_refract>`\ (\ vec3 I, vec3 N, float eta) | Refract. |
  908. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  909. | |vec_type| | :ref:`faceforward<shader_func_faceforward>`\ (\ |vec_type| N, |vec_type| I, |vec_type| Nref) | If ``dot(Nref, I)`` < 0, return ``N``, otherwise ``-N``. |
  910. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  911. | |mat_type| | :ref:`matrixCompMult<shader_func_matrixCompMult>`\ (\ |mat_type| x, |mat_type| y) | Matrix component multiplication. |
  912. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  913. | |mat_type| | :ref:`outerProduct<shader_func_outerProduct>`\ (\ |vec_type| column, |vec_type| row) | Matrix outer product. |
  914. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  915. | |mat_type| | :ref:`transpose<shader_func_transpose>`\ (\ |mat_type| m) | Transpose matrix. |
  916. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  917. | float | :ref:`determinant<shader_func_determinant>`\ (\ |mat_type| m) | Matrix determinant. |
  918. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  919. | |mat_type| | :ref:`inverse<shader_func_inverse>`\ (\ |mat_type| m) | Inverse matrix. |
  920. +------------+-----------------------------------------------------------------------------------------------+----------------------------------------------------------+
  921. .. rst-class:: classref-descriptions-group
  922. Geometric function descriptions
  923. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  924. .. _shader_func_length:
  925. .. rst-class:: classref-method
  926. float **length**\ (\ |vec_type| x)
  927. Returns the length of the vector.
  928. ie. ``sqrt(x[0] * x[0] + x[1] * x[1] + ... + x[n] * x[n])``
  929. :param x:
  930. The vector
  931. :return:
  932. The length of the vector.
  933. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/length.xhtml
  934. .. rst-class:: classref-item-separator
  935. ----
  936. .. _shader_func_distance:
  937. .. rst-class:: classref-method
  938. float **distance**\ (\ |vec_type| a, |vec_type| b)
  939. Returns the distance between the two points a and b.
  940. i.e., ``length(b - a);``
  941. :param a:
  942. The first point
  943. :param b:
  944. The second point
  945. :return:
  946. The scalar distance between the points
  947. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/distance.xhtml
  948. .. rst-class:: classref-item-separator
  949. ----
  950. .. _shader_func_dot:
  951. .. rst-class:: classref-method
  952. float **dot**\ (\ |vec_type| a, |vec_type| b)
  953. Returns the dot product of two vectors, ``a`` and ``b``.
  954. i.e., ``a.x * b.x + a.y * b.y + ...``
  955. :param a:
  956. The first vector.
  957. :param b:
  958. The second vector.
  959. :return:
  960. The dot product.
  961. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dot.xhtml
  962. .. rst-class:: classref-item-separator
  963. ----
  964. .. _shader_func_cross:
  965. .. rst-class:: classref-method
  966. vec3 **cross**\ (\ vec3 a, vec3 b)
  967. Returns the cross product of two vectors.
  968. i.e.::
  969. vec2( a.y * b.z - b.y * a.z,
  970. a.z * b.x - b.z * a.x,
  971. a.x * b.z - b.x * a.y)
  972. :param a:
  973. The first vector
  974. :param b:
  975. The second vector
  976. :return:
  977. The cross product
  978. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/cross.xhtml
  979. .. rst-class:: classref-item-separator
  980. ----
  981. .. _shader_func_normalize:
  982. .. rst-class:: classref-method
  983. |vec_type| **normalize**\ (\ |vec_type| x)
  984. Returns a vector with the same direction as x but with length 1.
  985. :param x:
  986. The vector to normalize.
  987. :return:
  988. The normalized vector.
  989. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/normalize.xhtml
  990. .. rst-class:: classref-item-separator
  991. ----
  992. .. _shader_func_reflect:
  993. .. rst-class:: classref-method
  994. vec3 **reflect**\ (\ vec3 I, vec3 N)
  995. Calculate the reflection direction for an incident vector.
  996. For a given incident vector ``I`` and surface normal ``N`` reflect returns the reflection direction calculated as ``I - 2.0 * dot(N, I) * N``.
  997. .. Note::
  998. ``N`` should be normalized in order to achieve the desired result.
  999. :param I:
  1000. The incident vector.
  1001. :param N:
  1002. The normal vector.
  1003. :return:
  1004. The reflection vector.
  1005. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/reflect.xhtml
  1006. .. rst-class:: classref-item-separator
  1007. ----
  1008. .. _shader_func_refract:
  1009. .. rst-class:: classref-method
  1010. vec3 **refract**\ (\ vec3 I, vec3 N, float eta)
  1011. Calculate the refraction direction for an incident vector.
  1012. For a given incident vector ``I``, surface normal ``N`` and ratio of indices of refraction, ``eta``, refract returns the refraction vector, ``R``.
  1013. R is calculated as::
  1014. k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
  1015. if (k < 0.0)
  1016. R = genType(0.0); // or genDType(0.0)
  1017. else
  1018. R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;
  1019. .. Note::
  1020. The input parameters I and N should be normalized in order to achieve the desired result.
  1021. :param I:
  1022. The incident vector.
  1023. :param N:
  1024. The normal vector.
  1025. :param eta:
  1026. The ratio of indices of refraction.
  1027. :return:
  1028. The refraction vector.
  1029. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/refract.xhtml
  1030. .. rst-class:: classref-item-separator
  1031. ----
  1032. .. _shader_func_faceforward:
  1033. .. rst-class:: classref-method
  1034. |vec_type| **faceforward**\ (\ |vec_type| N, |vec_type| I, |vec_type| Nref)
  1035. Return a vector pointing in the same direction as another.
  1036. Orients a vector to point away from a surface as defined by its normal.
  1037. If ``dot(Nref, I) < 0`` faceforward returns ``N``, otherwise it returns ``-N``.
  1038. :param N:
  1039. The vector to orient.
  1040. :param I:
  1041. The incident vector.
  1042. :param Nref:
  1043. The reference vector.
  1044. :return:
  1045. The oriented vector.
  1046. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/faceforward.xhtml
  1047. .. rst-class:: classref-item-separator
  1048. ----
  1049. .. _shader_func_matrixCompMult:
  1050. .. rst-class:: classref-method
  1051. |mat_type| **matrixCompMult**\ (\ |mat_type| x, |mat_type| y)
  1052. Perform a component-wise multiplication of two matrices.
  1053. Performs a component-wise multiplication of two matrices, yielding a result
  1054. matrix where each component, ``result[i][j]`` is computed as the scalar
  1055. product of ``x[i][j]`` and ``y[i][j]``.
  1056. :param x:
  1057. The first matrix multiplicand.
  1058. :param y:
  1059. The second matrix multiplicand.
  1060. :return:
  1061. The resultant matrix.
  1062. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/matrixCompMult.xhtml
  1063. .. rst-class:: classref-item-separator
  1064. ----
  1065. .. _shader_func_outerProduct:
  1066. .. rst-class:: classref-method
  1067. |mat_type| **outerProduct**\ (\ |vec_type| column, |vec_type| row)
  1068. Calculate the outer product of a pair of vectors.
  1069. Does a linear algebraic matrix multiply ``column * row``, yielding a matrix whose number of
  1070. rows is the number of components in ``column`` and whose number of columns is the number of
  1071. components in ``row``.
  1072. :param column:
  1073. The column vector for multiplication.
  1074. :param row:
  1075. The row vector for multiplication.
  1076. :return:
  1077. The outer product matrix.
  1078. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/outerProduct.xhtml
  1079. .. rst-class:: classref-item-separator
  1080. ----
  1081. .. _shader_func_transpose:
  1082. .. rst-class:: classref-method
  1083. |mat_type| **transpose**\ (\ |mat_type| m)
  1084. Calculate the transpose of a matrix.
  1085. :param m:
  1086. The matrix to transpose.
  1087. :return:
  1088. A new matrix that is the transpose of the input matrix ``m``.
  1089. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/transpose.xhtml
  1090. .. rst-class:: classref-item-separator
  1091. ----
  1092. .. _shader_func_determinant:
  1093. .. rst-class:: classref-method
  1094. float **determinant**\ (\ |mat_type| m)
  1095. Calculate the determinant of a matrix.
  1096. :param m:
  1097. The matrix.
  1098. :return:
  1099. The determinant of the input matrix ``m``.
  1100. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/determinant.xhtml
  1101. .. rst-class:: classref-item-separator
  1102. ----
  1103. .. _shader_func_inverse:
  1104. .. rst-class:: classref-method
  1105. |mat_type| **inverse**\ (\ |mat_type| m)
  1106. Calculate the inverse of a matrix.
  1107. The values in the returned matrix are undefined if ``m`` is singular or poorly-conditioned (nearly singular).
  1108. :param m:
  1109. The matrix of which to take the inverse.
  1110. :return:
  1111. A new matrix which is the inverse of the input matrix ``m``.
  1112. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/inverse.xhtml
  1113. .. rst-class:: classref-section-separator
  1114. ----
  1115. .. rst-class:: classref-reftable-group
  1116. Comparison functions
  1117. --------------------
  1118. .. table::
  1119. :class: nowrap-col2
  1120. :widths: auto
  1121. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1122. | |vec_bool_type| | :ref:`lessThan<shader_func_lessThan>`\ (\ |vec_type| x, |vec_type| y) | Bool vector comparison on < int/uint/float vectors. |
  1123. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1124. | |vec_bool_type| | :ref:`greaterThan<shader_func_greaterThan>`\ (\ |vec_type| x, |vec_type| y) | Bool vector comparison on > int/uint/float vectors. |
  1125. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1126. | |vec_bool_type| | :ref:`lessThanEqual<shader_func_lessThanEqual>`\ (\ |vec_type| x, |vec_type| y) | Bool vector comparison on <= int/uint/float vectors. |
  1127. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1128. | |vec_bool_type| | :ref:`greaterThanEqual<shader_func_greaterThanEqual>`\ (\ |vec_type| x, |vec_type| y) | Bool vector comparison on >= int/uint/float vectors. |
  1129. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1130. | |vec_bool_type| | :ref:`equal<shader_func_equal>`\ (\ |vec_type| x, |vec_type| y) | Bool vector comparison on == int/uint/float vectors. |
  1131. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1132. | |vec_bool_type| | :ref:`notEqual<shader_func_notEqual>`\ (\ |vec_type| x, |vec_type| y) | Bool vector comparison on != int/uint/float vectors. |
  1133. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1134. | bool | :ref:`any<shader_func_any>`\ (\ |vec_bool_type| x) | ``true`` if any component is ``true``, ``false`` otherwise. |
  1135. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1136. | bool | :ref:`all<shader_func_all>`\ (\ |vec_bool_type| x) | ``true`` if all components are ``true``, ``false`` otherwise. |
  1137. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1138. | |vec_bool_type| | :ref:`not<shader_func_not>`\ (\ |vec_bool_type| x) | Invert boolean vector. |
  1139. +-----------------+-----------------------------------------------------------------------------------------+---------------------------------------------------------------+
  1140. .. rst-class:: classref-descriptions-group
  1141. Comparison function descriptions
  1142. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1143. .. _shader_func_lessThan:
  1144. .. rst-class:: classref-method
  1145. |vec_bool_type| **lessThan**\ (\ |vec_type| x, |vec_type| y)
  1146. Perform a :ref:`component-wise<shading_componentwise>` less-than comparison of two vectors.
  1147. :param x:
  1148. The first vector for comparison.
  1149. :param y:
  1150. The first vector for comparison.
  1151. :return:
  1152. A boolean vector in which each element i is computed as ``x[i] < y[i]``.
  1153. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/lessThan.xhtml
  1154. .. rst-class:: classref-item-separator
  1155. ----
  1156. .. _shader_func_greaterThan:
  1157. .. rst-class:: classref-method
  1158. |vec_bool_type| **greaterThan**\ (\ |vec_type| x, |vec_type| y)
  1159. Perform a :ref:`component-wise<shading_componentwise>` greater-than comparison of two vectors.
  1160. :param x:
  1161. The first vector for comparison.
  1162. :param y:
  1163. The first vector for comparison.
  1164. :return:
  1165. A boolean vector in which each element i is computed as ``x[i] > y[i]``.
  1166. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/greaterThan.xhtml
  1167. .. rst-class:: classref-item-separator
  1168. ----
  1169. .. _shader_func_lessThanEqual:
  1170. .. rst-class:: classref-method
  1171. |vec_bool_type| **lessThanEqual**\ (\ |vec_type| x, |vec_type| y)
  1172. Perform a :ref:`component-wise<shading_componentwise>` less-than-or-equal comparison of two vectors.
  1173. :param x:
  1174. The first vector for comparison.
  1175. :param y:
  1176. The first vector for comparison.
  1177. :return:
  1178. A boolean vector in which each element i is computed as ``x[i] <= y[i]``.
  1179. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/lessThanEqual.xhtml
  1180. .. rst-class:: classref-item-separator
  1181. ----
  1182. .. _shader_func_greaterThanEqual:
  1183. .. rst-class:: classref-method
  1184. |vec_bool_type| **greaterThanEqual**\ (\ |vec_type| x, |vec_type| y)
  1185. Perform a :ref:`component-wise<shading_componentwise>` greater-than-or-equal comparison of two vectors.
  1186. :param x:
  1187. The first vector for comparison.
  1188. :param y:
  1189. The first vector for comparison.
  1190. :return:
  1191. A boolean vector in which each element i is computed as ``x[i] >= y[i]``.
  1192. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/greaterThanEqual.xhtml
  1193. .. rst-class:: classref-item-separator
  1194. ----
  1195. .. _shader_func_equal:
  1196. .. rst-class:: classref-method
  1197. |vec_bool_type| **equal**\ (\ |vec_type| x, |vec_type| y)
  1198. Perform a :ref:`component-wise<shading_componentwise>` equal-to comparison of two vectors.
  1199. :param x:
  1200. The first vector for comparison.
  1201. :param y:
  1202. The first vector for comparison.
  1203. :return:
  1204. A boolean vector in which each element i is computed as ``x[i] == y[i]``.
  1205. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/equal.xhtml
  1206. .. rst-class:: classref-item-separator
  1207. ----
  1208. .. _shader_func_notEqual:
  1209. .. rst-class:: classref-method
  1210. |vec_bool_type| **notEqual**\ (\ |vec_type| x, |vec_type| y)
  1211. Perform a :ref:`component-wise<shading_componentwise>` not-equal-to comparison of two vectors.
  1212. :param x:
  1213. The first vector for comparison.
  1214. :param y:
  1215. The second vector for comparison.
  1216. :return:
  1217. A boolean vector in which each element i is computed as ``x[i] != y[i]``.
  1218. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/notEqual.xhtml
  1219. .. rst-class:: classref-item-separator
  1220. ----
  1221. .. _shader_func_any:
  1222. .. rst-class:: classref-method
  1223. bool **any**\ (\ |vec_bool_type| x)
  1224. Check whether any element of a boolean vector is true.
  1225. Functionally equivalent to::
  1226. bool any(bvec x) { // bvec can be bvec2, bvec3 or bvec4
  1227. bool result = false;
  1228. int i;
  1229. for (i = 0; i < x.length(); ++i) {
  1230. result |= x[i];
  1231. }
  1232. return result;
  1233. }
  1234. :param x:
  1235. The vector to be tested for truth.
  1236. :return:
  1237. True if any element of x is true and false otherwise.
  1238. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/any.xhtml
  1239. .. rst-class:: classref-item-separator
  1240. ----
  1241. .. _shader_func_all:
  1242. .. rst-class:: classref-method
  1243. bool **all**\ (\ |vec_bool_type| x)
  1244. Check whether all elements of a boolean vector are true.
  1245. Functionally equivalent to::
  1246. bool all(bvec x) // bvec can be bvec2, bvec3 or bvec4
  1247. {
  1248. bool result = true;
  1249. int i;
  1250. for (i = 0; i < x.length(); ++i)
  1251. {
  1252. result &= x[i];
  1253. }
  1254. return result;
  1255. }
  1256. :param x:
  1257. The vector to be tested for truth.
  1258. :return:
  1259. True if all elements of x are true and false otherwise.
  1260. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/all.xhtml
  1261. .. rst-class:: classref-item-separator
  1262. ----
  1263. .. _shader_func_not:
  1264. .. rst-class:: classref-method
  1265. |vec_bool_type| **not**\ (\ |vec_bool_type| x)
  1266. Logically invert a boolean vector.
  1267. :param x:
  1268. The vector to be inverted.
  1269. :return:
  1270. A new boolean vector for which each element i is computed as !x[i].
  1271. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/not.xhtml
  1272. .. rst-class:: classref-section-separator
  1273. ----
  1274. .. rst-class:: classref-reftable-group
  1275. Texture functions
  1276. -----------------
  1277. .. table::
  1278. :class: nowrap-col2
  1279. :widths: auto
  1280. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1281. | | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler2D| s, int lod) | Get the size of a texture. |
  1282. | | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ samplerCube s, int lod) | |
  1283. | | ivec2 | | :ref:`textureSize<shader_func_textureSize>`\ (\ samplerCubeArray s, int lod) | |
  1284. | | ivec3 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler2DArray| s, int lod) | |
  1285. | | ivec3 | | :ref:`textureSize<shader_func_textureSize>`\ (\ |gsampler3D| s, int lod) | |
  1286. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1287. | | vec2 | | :ref:`textureQueryLod<shader_func_textureQueryLod>`\ (\ |gsampler2D| s, vec2 p) | Compute the level-of-detail that would be used to sample from a |
  1288. | | vec3 | | :ref:`textureQueryLod<shader_func_textureQueryLod>`\ (\ |gsampler2DArray| s, vec2 p) | texture. |
  1289. | | vec2 | | :ref:`textureQueryLod<shader_func_textureQueryLod>`\ (\ |gsampler3D| s, vec3 p) | |
  1290. | | vec2 | | :ref:`textureQueryLod<shader_func_textureQueryLod>`\ (\ samplerCube s, vec3 p) | |
  1291. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1292. | | int | | :ref:`textureQueryLevels<shader_func_textureQueryLevels>`\ (\ |gsampler2D| s) | Get the number of accessible mipmap levels of a texture. |
  1293. | | int | | :ref:`textureQueryLevels<shader_func_textureQueryLevels>`\ (\ |gsampler2DArray| s) | |
  1294. | | int | | :ref:`textureQueryLevels<shader_func_textureQueryLevels>`\ (\ |gsampler3D| s) | |
  1295. | | int | | :ref:`textureQueryLevels<shader_func_textureQueryLevels>`\ (\ samplerCube s) | |
  1296. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1297. | | |gvec4_type| | | :ref:`texture<shader_func_texture>`\ (\ |gsampler2D| s, vec2 p [, float bias] ) | Perform a texture read. |
  1298. | | |gvec4_type| | | :ref:`texture<shader_func_texture>`\ (\ |gsampler2DArray| s, vec3 p [, float bias] ) | |
  1299. | | |gvec4_type| | | :ref:`texture<shader_func_texture>`\ (\ |gsampler3D| s, vec3 p [, float bias] ) | |
  1300. | | vec4 | | :ref:`texture<shader_func_texture>`\ (\ samplerCube s, vec3 p [, float bias] ) | |
  1301. | | vec4 | | :ref:`texture<shader_func_texture>`\ (\ samplerCubeArray s, vec4 p [, float bias] ) | |
  1302. | | vec4 | | :ref:`texture<shader_func_texture>`\ (\ samplerExternalOES s, vec2 p [, float bias] ) | |
  1303. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1304. | | |gvec4_type| | | :ref:`textureProj<shader_func_textureProj>`\ (\ |gsampler2D| s, vec3 p [, float bias] ) | Perform a texture read with projection. |
  1305. | | |gvec4_type| | | :ref:`textureProj<shader_func_textureProj>`\ (\ |gsampler2D| s, vec4 p [, float bias] ) | |
  1306. | | |gvec4_type| | | :ref:`textureProj<shader_func_textureProj>`\ (\ |gsampler3D| s, vec4 p [, float bias] ) | |
  1307. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1308. | | |gvec4_type| | | :ref:`textureLod<shader_func_textureLod>`\ (\ |gsampler2D| s, vec2 p, float lod) | Perform a texture read at custom mipmap. |
  1309. | | |gvec4_type| | | :ref:`textureLod<shader_func_textureLod>`\ (\ |gsampler2DArray| s, vec3 p, float lod) | |
  1310. | | |gvec4_type| | | :ref:`textureLod<shader_func_textureLod>`\ (\ |gsampler3D| s, vec3 p, float lod) | |
  1311. | | vec4 | | :ref:`textureLod<shader_func_textureLod>`\ (\ samplerCube s, vec3 p, float lod) | |
  1312. | | vec4 | | :ref:`textureLod<shader_func_textureLod>`\ (\ samplerCubeArray s, vec4 p, float lod) | |
  1313. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1314. | | |gvec4_type| | | :ref:`textureProjLod<shader_func_textureProjLod>`\ (\ |gsampler2D| s, vec3 p, float lod) | Performs a texture read with projection/LOD. |
  1315. | | |gvec4_type| | | :ref:`textureProjLod<shader_func_textureProjLod>`\ (\ |gsampler2D| s, vec4 p, float lod) | |
  1316. | | |gvec4_type| | | :ref:`textureProjLod<shader_func_textureProjLod>`\ (\ |gsampler3D| s, vec4 p, float lod) | |
  1317. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1318. | | |gvec4_type| | | :ref:`textureGrad<shader_func_textureGrad>`\ (\ |gsampler2D| s, vec2 p, vec2 dPdx, vec2 dPdy) | Performs a texture read with explicit gradients. |
  1319. | | |gvec4_type| | | :ref:`textureGrad<shader_func_textureGrad>`\ (\ |gsampler2DArray| s, vec3 p, vec2 dPdx, vec2 dPdy) | |
  1320. | | |gvec4_type| | | :ref:`textureGrad<shader_func_textureGrad>`\ (\ |gsampler3D| s, vec3 p, vec2 dPdx, vec2 dPdy) | |
  1321. | | vec4 | | :ref:`textureGrad<shader_func_textureGrad>`\ (\ samplerCube s, vec3 p, vec3 dPdx, vec3 dPdy) | |
  1322. | | vec4 | | :ref:`textureGrad<shader_func_textureGrad>`\ (\ samplerCubeArray s, vec3 p, vec3 dPdx, vec3 dPdy) | |
  1323. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1324. | | |gvec4_type| | | :ref:`textureProjGrad<shader_func_textureProjGrad>`\ (\ |gsampler2D| s, vec3 p, vec2 dPdx, vec2 dPdy) | Performs a texture read with projection/LOD and with explicit |
  1325. | | |gvec4_type| | | :ref:`textureProjGrad<shader_func_textureProjGrad>`\ (\ |gsampler2D| s, vec4 p, vec2 dPdx, vec2 dPdy) | |
  1326. | | |gvec4_type| | | :ref:`textureProjGrad<shader_func_textureProjGrad>`\ (\ |gsampler3D| s, vec4 p, vec3 dPdx, vec3 dPdy) | |
  1327. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1328. | | |gvec4_type| | | :ref:`texelFetch<shader_func_texelFetch>`\ (\ |gsampler2D| s, ivec2 p, int lod) | Fetches a single texel using integer coordinates. |
  1329. | | |gvec4_type| | | :ref:`texelFetch<shader_func_texelFetch>`\ (\ |gsampler2DArray| s, ivec3 p, int lod) | |
  1330. | | |gvec4_type| | | :ref:`texelFetch<shader_func_texelFetch>`\ (\ |gsampler3D| s, ivec3 p, int lod) | |
  1331. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1332. | | |gvec4_type| | | :ref:`textureGather<shader_func_textureGather>`\ (\ |gsampler2D| s, vec2 p [, int comps] ) | Gathers four texels from a texture. |
  1333. | | |gvec4_type| | | :ref:`textureGather<shader_func_textureGather>`\ (\ |gsampler2DArray| s, vec3 p [, int comps] ) | |
  1334. | | vec4 | | :ref:`textureGather<shader_func_textureGather>`\ (\ samplerCube s, vec3 p [, int comps] ) | |
  1335. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1336. | |vec_type| | :ref:`dFdx<shader_func_dFdx>`\ (\ |vec_type| p) | Derivative with respect to ``x`` window coordinate, |
  1337. | | | automatic granularity. |
  1338. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1339. | |vec_type| | :ref:`dFdxCoarse<shader_func_dFdxCoarse>`\ (\ |vec_type| p) | Derivative with respect to ``x`` window coordinate, |
  1340. | | | course granularity. |
  1341. | | | |
  1342. | | | Not available when using the Compatibility renderer. |
  1343. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1344. | |vec_type| | :ref:`dFdxFine<shader_func_dFdxFine>`\ (\ |vec_type| p) | Derivative with respect to ``x`` window coordinate, |
  1345. | | | fine granularity. |
  1346. | | | |
  1347. | | | Not available when using the Compatibility renderer. |
  1348. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1349. | |vec_type| | :ref:`dFdy<shader_func_dFdy>`\ (\ |vec_type| p) | Derivative with respect to ``y`` window coordinate, |
  1350. | | | automatic granularity. |
  1351. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1352. | |vec_type| | :ref:`dFdyCoarse<shader_func_dFdyCoarse>`\ (\ |vec_type| p) | Derivative with respect to ``y`` window coordinate, |
  1353. | | | course granularity. |
  1354. | | | |
  1355. | | | Not available when using the Compatibility renderer. |
  1356. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1357. | |vec_type| | :ref:`dFdyFine<shader_func_dFdyFine>`\ (\ |vec_type| p) | Derivative with respect to ``y`` window coordinate, |
  1358. | | | fine granularity. |
  1359. | | | |
  1360. | | | Not available when using the Compatibility renderer. |
  1361. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1362. | |vec_type| | :ref:`fwidth<shader_func_fwidth>`\ (\ |vec_type| p) | Sum of absolute derivative in ``x`` and ``y``. |
  1363. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1364. | |vec_type| | :ref:`fwidthCoarse<shader_func_fwidthCoarse>`\ (\ |vec_type| p) | Sum of absolute derivative in ``x`` and ``y``. |
  1365. | | | |
  1366. | | | Not available when using the Compatibility renderer. |
  1367. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1368. | |vec_type| | :ref:`fwidthFine<shader_func_fwidthFine>`\ (\ |vec_type| p) | Sum of absolute derivative in ``x`` and ``y``. |
  1369. | | | |
  1370. | | | Not available when using the Compatibility renderer. |
  1371. +------------------+---------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1372. .. rst-class:: classref-descriptions-group
  1373. Texture function descriptions
  1374. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1375. .. _shader_func_textureSize:
  1376. .. rst-class:: classref-method
  1377. ivec2 **textureSize**\ (\ |gsampler2D| s, int lod)
  1378. .. rst-class:: classref-method
  1379. ivec2 **textureSize**\ (\ samplerCube s, int lod)
  1380. .. rst-class:: classref-method
  1381. ivec2 **textureSize**\ (\ samplerCubeArray s, int lod)
  1382. .. rst-class:: classref-method
  1383. ivec3 **textureSize**\ (\ |gsampler2DArray| s, int lod)
  1384. .. rst-class:: classref-method
  1385. ivec3 **textureSize**\ (\ |gsampler3D| s, int lod)
  1386. Retrieve the dimensions of a level of a texture.
  1387. Returns the dimensions of level lod (if present) of the texture bound to sampler.
  1388. The components in the return value are filled in, in order, with the width, height and depth
  1389. of the texture. For the array forms, the last component of the return value is
  1390. the number of layers in the texture array.
  1391. :param s:
  1392. The sampler to which the texture whose dimensions to retrieve is bound.
  1393. :param lod:
  1394. The level of the texture for which to retrieve the dimensions.
  1395. :return:
  1396. The dimensions of level lod (if present) of the texture bound to sampler.
  1397. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureSize.xhtml
  1398. .. rst-class:: classref-item-separator
  1399. ----
  1400. .. _shader_func_textureQueryLod:
  1401. .. rst-class:: classref-method
  1402. vec2 **textureQueryLod**\ (\ |gsampler2D| s, vec2 p)
  1403. Compute the level-of-detail that would be used to sample from a texture.
  1404. Available only in the fragment shader, textureQueryLod computes the level-of-detail
  1405. that would be used to sample from a texture. The mipmap array(s) that would be
  1406. accessed is returned in the x component of the return value. The computed level-of-detail
  1407. relative to the base level is returned in the y component of the return value.
  1408. If called on an incomplete texture, the result of the operation is undefined.
  1409. :param s:
  1410. The sampler to which the texture whose level-of-detail will be queried is bound.
  1411. :param p:
  1412. The texture coordinates at which the level-of-detail will be queried.
  1413. :return:
  1414. See description.
  1415. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureQueryLod.xhtml
  1416. .. rst-class:: classref-item-separator
  1417. ----
  1418. .. rst-class:: classref-method
  1419. vec2 **textureQueryLod**\ (\ |gsampler2D| s, vec2 p)
  1420. .. rst-class:: classref-method
  1421. vec2 **textureQueryLod**\ (\ |gsampler2DArray| s, vec2 p)
  1422. .. rst-class:: classref-method
  1423. vec2 **textureQueryLod**\ (\ |gsampler3D| s, vec3 p)
  1424. .. rst-class:: classref-method
  1425. vec2 **textureQueryLod**\ (\ samplerCube s, vec3 p)
  1426. .. note:: Available only in the fragment shader.
  1427. Compute the level-of-detail that would be used to sample from a texture.
  1428. The mipmap array(s) that would be accessed is returned in the x component of
  1429. the return value. The computed level-of-detail relative to the base level is
  1430. returned in the y component of the return value.
  1431. If called on an incomplete texture, the result of the operation is undefined.
  1432. :param s:
  1433. The sampler to which the texture whose level-of-detail will be queried is bound.
  1434. :param p:
  1435. The texture coordinates at which the level-of-detail will be queried.
  1436. :return:
  1437. See description.
  1438. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureQueryLod.xhtml
  1439. .. rst-class:: classref-item-separator
  1440. ----
  1441. .. _shader_func_textureQueryLevels:
  1442. .. rst-class:: classref-method
  1443. int **textureQueryLevels**\ (\ |gsampler2D| s)
  1444. .. rst-class:: classref-method
  1445. int **textureQueryLevels**\ (\ |gsampler2DArray| s)
  1446. .. rst-class:: classref-method
  1447. int **textureQueryLevels**\ (\ |gsampler3D| s)
  1448. .. rst-class:: classref-method
  1449. int **textureQueryLevels**\ (\ samplerCube s)
  1450. Compute the number of accessible mipmap levels of a texture.
  1451. If called on an incomplete texture, or if no texture is associated with sampler, ``0`` is returned.
  1452. :param s:
  1453. The sampler to which the texture whose mipmap level count will be queried is bound.
  1454. :return:
  1455. The number of accessible mipmap levels in the texture, or ``0``.
  1456. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureQueryLevels.xhtml
  1457. .. rst-class:: classref-item-separator
  1458. ----
  1459. .. _shader_func_texture:
  1460. .. rst-class:: classref-method
  1461. |gvec4_type| **texture**\ (\ |gsampler2D| s, vec2 p [, float bias] )
  1462. .. rst-class:: classref-method
  1463. |gvec4_type| **texture**\ (\ |gsampler2DArray| s, vec3 p [, float bias] )
  1464. .. rst-class:: classref-method
  1465. |gvec4_type| **texture**\ (\ |gsampler3D| s, vec3 p [, float bias] )
  1466. .. rst-class:: classref-method
  1467. vec4 **texture**\ (\ samplerCube s, vec3 p [, float bias] )
  1468. .. rst-class:: classref-method
  1469. vec4 **texture**\ (\ samplerCubeArray s, vec4 p [, float bias] )
  1470. .. rst-class:: classref-method
  1471. vec4 **texture**\ (\ samplerExternalOES s, vec2 p [, float bias] )
  1472. Retrieves texels from a texture.
  1473. Samples texels from the texture bound to ``s`` at texture coordinate ``p``. An optional bias, specified in ``bias`` is
  1474. included in the level-of-detail computation that is used to choose mipmap(s) from which to sample.
  1475. For shadow forms, the last component of ``p`` is used as Dsub and the array layer is specified in the second to last
  1476. component of ``p``. (The second component of ``p`` is unused for 1D shadow lookups.)
  1477. For non-shadow variants, the array layer comes from the last component of P.
  1478. :param s:
  1479. The sampler to which the texture from which texels will be retrieved is bound.
  1480. :param p:
  1481. The texture coordinates at which texture will be sampled.
  1482. :param bias:
  1483. An optional bias to be applied during level-of-detail computation.
  1484. :return:
  1485. A texel.
  1486. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/texture.xhtml
  1487. .. rst-class:: classref-item-separator
  1488. ----
  1489. .. _shader_func_textureProj:
  1490. .. rst-class:: classref-method
  1491. |gvec4_type| **textureProj**\ (\ |gsampler2D| s, vec3 p [, float bias] )
  1492. .. rst-class:: classref-method
  1493. |gvec4_type| **textureProj**\ (\ |gsampler2D| s, vec4 p [, float bias] )
  1494. .. rst-class:: classref-method
  1495. |gvec4_type| **textureProj**\ (\ |gsampler3D| s, vec4 p [, float bias] )
  1496. Perform a texture lookup with projection.
  1497. The texture coordinates consumed from ``p``, not including the last component of ``p``, are
  1498. divided by the last component of ``p``. The resulting 3rd component of ``p`` in the shadow
  1499. forms is used as Dref. After these values are computed, the texture lookup proceeds as in texture.
  1500. :param s:
  1501. The sampler to which the texture from which texels will be retrieved is bound.
  1502. :param p:
  1503. The texture coordinates at which texture will be sampled.
  1504. :param bias:
  1505. Optional bias to be applied during level-of-detail computation.
  1506. :return:
  1507. A texel.
  1508. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureProj.xhtml
  1509. .. rst-class:: classref-item-separator
  1510. ----
  1511. .. _shader_func_textureLod:
  1512. .. rst-class:: classref-method
  1513. |gvec4_type| **textureLod**\ (\ |gsampler2D| s, vec2 p, float lod)
  1514. .. rst-class:: classref-method
  1515. |gvec4_type| **textureLod**\ (\ |gsampler2DArray| s, vec3 p, float lod)
  1516. .. rst-class:: classref-method
  1517. |gvec4_type| **textureLod**\ (\ |gsampler3D| s, vec3 p, float lod)
  1518. .. rst-class:: classref-method
  1519. vec4 **textureLod**\ (\ samplerCube s, vec3 p, float lod)
  1520. .. rst-class:: classref-method
  1521. vec4 **textureLod**\ (\ samplerCubeArray s, vec4 p, float lod)
  1522. Performs a texture lookup at coordinate ``p`` from the texture bound to sampler with
  1523. an explicit level-of-detail as specified in ``lod``. ``lod`` specifies λbase and sets the
  1524. partial derivatives as follows::
  1525. δu/δx=0, δv/δx=0, δw/δx=0
  1526. δu/δy=0, δv/δy=0, δw/δy=0
  1527. :param s:
  1528. The sampler to which the texture from which texels will be retrieved is bound.
  1529. :param p:
  1530. The texture coordinates at which texture will be sampled.
  1531. :param lod:
  1532. The explicit level-of-detail.
  1533. :return:
  1534. A texel.
  1535. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureLod.xhtml
  1536. .. rst-class:: classref-item-separator
  1537. ----
  1538. .. _shader_func_textureProjLod:
  1539. .. rst-class:: classref-method
  1540. |gvec4_type| **textureProjLod**\ (\ |gsampler2D| s, vec3 p, float lod)
  1541. .. rst-class:: classref-method
  1542. |gvec4_type| **textureProjLod**\ (\ |gsampler2D| s, vec4 p, float lod)
  1543. .. rst-class:: classref-method
  1544. |gvec4_type| **textureProjLod**\ (\ |gsampler3D| s, vec4 p, float lod)
  1545. Performs a texture lookup with projection from an explicitly specified level-of-detail.
  1546. The texture coordinates consumed from P, not including the last component of ``p``, are
  1547. divided by the last component of ``p``. The resulting 3rd component of ``p`` in the shadow
  1548. forms is used as Dref. After these values are computed, the texture lookup proceeds as in
  1549. `textureLod<shader_func_textureLod>`, with ``lod`` used to specify the level-of-detail from
  1550. which the texture will be sampled.
  1551. :param s:
  1552. The sampler to which the texture from which texels will be retrieved is bound.
  1553. :param p:
  1554. The texture coordinates at which texture will be sampled.
  1555. :param lod:
  1556. The explicit level-of-detail from which to fetch texels.
  1557. :return:
  1558. a texel
  1559. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureProjLod.xhtml
  1560. .. rst-class:: classref-item-separator
  1561. ----
  1562. .. _shader_func_textureGrad:
  1563. .. rst-class:: classref-method
  1564. |gvec4_type| **textureGrad**\ (\ |gsampler2D| s, vec2 p, vec2 dPdx, vec2 dPdy)
  1565. .. rst-class:: classref-method
  1566. |gvec4_type| **textureGrad**\ (\ |gsampler2DArray| s, vec3 p, vec2 dPdx, vec2 dPdy)
  1567. .. rst-class:: classref-method
  1568. |gvec4_type| **textureGrad**\ (\ |gsampler3D| s, vec3 p, vec2 dPdx, vec2 dPdy)
  1569. .. rst-class:: classref-method
  1570. vec4 **textureGrad**\ (\ samplerCube s, vec3 p, vec3 dPdx, vec3 dPdy)
  1571. .. rst-class:: classref-method
  1572. vec4 **textureGrad**\ (\ samplerCubeArray s, vec3 p, vec3 dPdx, vec3 dPdy)
  1573. Performs a texture lookup at coordinate ``p`` from the texture bound to sampler with explicit texture coordinate gradiends as specified in ``dPdx`` and ``dPdy``. Set:
  1574. - ``δs/δx=δp/δx`` for a 1D texture, ``δp.s/δx`` otherwise
  1575. - ``δs/δy=δp/δy`` for a 1D texture, ``δp.s/δy`` otherwise
  1576. - ``δt/δx=0.0`` for a 1D texture, ``δp.t/δx`` otherwise
  1577. - ``δt/δy=0.0`` for a 1D texture, ``δp.t/δy`` otherwise
  1578. - ``δr/δx=0.0`` for a 1D or 2D texture, ``δp.p/δx`` otherwise
  1579. - ``δr/δy=0.0`` for a 1D or 2D texture, ``δp.p/δy`` otherwise
  1580. For the cube version, the partial derivatives of ``p`` are assumed to be in the coordinate system used before texture coordinates are projected onto the appropriate cube face.
  1581. :param s:
  1582. The sampler to which the texture from which texels will be retrieved is bound.
  1583. :param p:
  1584. The texture coordinates at which texture will be sampled.
  1585. :param dPdx:
  1586. The partial derivative of P with respect to window x.
  1587. :param dPdy:
  1588. The partial derivative of P with respect to window y.
  1589. :return:
  1590. A texel.
  1591. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureGrad.xhtml
  1592. .. rst-class:: classref-item-separator
  1593. ----
  1594. .. _shader_func_textureProjGrad:
  1595. .. rst-class:: classref-method
  1596. |gvec4_type| **textureProjGrad**\ (\ |gsampler2D| s, vec3 p, vec2 dPdx, vec2 dPdy)
  1597. .. rst-class:: classref-method
  1598. |gvec4_type| **textureProjGrad**\ (\ |gsampler2D| s, vec4 p, vec2 dPdx, vec2 dPdy)
  1599. .. rst-class:: classref-method
  1600. |gvec4_type| **textureProjGrad**\ (\ |gsampler3D| s, vec4 p, vec3 dPdx, vec3 dPdy)
  1601. Perform a texture lookup with projection and explicit gradients.
  1602. The texture coordinates consumed from ``p``, not including the last component of ``p``, are divided by the last component of ``p``.
  1603. After these values are computed, the texture lookup proceeds as in `textureGrad<shader_func_textureGrad>`, passing ``dPdx`` and ``dPdy`` as gradients.
  1604. :param s:
  1605. The sampler to which the texture from which texels will be retrieved is bound.
  1606. :param p:
  1607. The texture coordinates at which texture will be sampled.
  1608. :param dPdx:
  1609. The partial derivative of ``p`` with respect to window x.
  1610. :param dPdy:
  1611. The partial derivative of ``p`` with respect to window y.
  1612. :return:
  1613. A texel.
  1614. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureProjGrad.xhtml
  1615. .. rst-class:: classref-item-separator
  1616. ----
  1617. .. _shader_func_texelFetch:
  1618. .. rst-class:: classref-method
  1619. |gvec4_type| **texelFetch**\ (\ |gsampler2D| s, ivec2 p, int lod)
  1620. .. rst-class:: classref-method
  1621. |gvec4_type| **texelFetch**\ (\ |gsampler2DArray| s, ivec3 p, int lod)
  1622. .. rst-class:: classref-method
  1623. |gvec4_type| **texelFetch**\ (\ |gsampler3D| s, ivec3 p, int lod)
  1624. Performs a lookup of a single texel from texture coordinate ``p`` in the texture bound to sampler.
  1625. :param s:
  1626. The sampler to which the texture from which texels will be retrieved is bound.
  1627. :param p:
  1628. The texture coordinates at which texture will be sampled.
  1629. :param lod:
  1630. Specifies the level-of-detail within the texture from which the texel will be fetched.
  1631. :return:
  1632. A texel.
  1633. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/texelFetch.xhtml
  1634. .. rst-class:: classref-item-separator
  1635. ----
  1636. .. _shader_func_textureGather:
  1637. .. rst-class:: classref-method
  1638. |gvec4_type| **textureGather**\ (\ |gsampler2D| s, vec2 p [, int comps] )
  1639. .. rst-class:: classref-method
  1640. |gvec4_type| **textureGather**\ (\ |gsampler2DArray| s, vec3 p [, int comps] )
  1641. .. rst-class:: classref-method
  1642. vec4 **textureGather**\ (\ samplerCube s, vec3 p [, int comps] )
  1643. Gathers four texels from a texture.
  1644. Returns the value::
  1645. vec4(Sample_i0_j1(p, base).comps,
  1646. Sample_i1_j1(p, base).comps,
  1647. Sample_i1_j0(p, base).comps,
  1648. Sample_i0_j0(p, base).comps);
  1649. :param s:
  1650. The sampler to which the texture from which texels will be retrieved is bound.
  1651. :param p:
  1652. The texture coordinates at which texture will be sampled.
  1653. :param comps:
  1654. *optional* the component of the source texture (0 -> x, 1 -> y, 2 -> z, 3 -> w) that will be used to generate the resulting vector. Zero if not specified.
  1655. :return:
  1656. The gathered texel.
  1657. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/textureGather.xhtml
  1658. .. rst-class:: classref-item-separator
  1659. ----
  1660. .. _shader_func_dFdx:
  1661. .. rst-class:: classref-method
  1662. |vec_type| **dFdx**\ (\ |vec_type| p)
  1663. .. note:: Available only in the fragment shader.
  1664. Return the partial derivative of ``p`` with respect to the window x coordinate using local differencing.
  1665. Returns either :ref:`dFdxCoarse<shader_func_dFdxCoarse>` or :ref:`dFdxFine<shader_func_dfdxFine>`. The implementation may choose which calculation to perform based upon factors
  1666. such as performance or the value of the API ``GL_FRAGMENT_SHADER_DERIVATIVE_HINT`` hint.
  1667. .. warning::
  1668. Expressions that imply higher order derivatives such as ``dFdx(dFdx(n))`` have undefined results, as do mixed-order derivatives such as ``dFdx(dFdy(n))``.
  1669. :param p:
  1670. The expression of which to take the partial derivative.
  1671. .. note:: It is assumed that the expression ``p`` is continuous and therefore expressions evaluated via non-uniform control flow may be undefined.
  1672. :return:
  1673. The partial derivative of ``p``.
  1674. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdx.xhtml
  1675. .. rst-class:: classref-item-separator
  1676. ----
  1677. .. _shader_func_dFdxCoarse:
  1678. .. rst-class:: classref-method
  1679. |vec_type| **dFdxCoarse**\ (\ |vec_type| p)
  1680. .. note::
  1681. Available only in the fragment shader.
  1682. Not available when using the Compatibility renderer.
  1683. Return the partial derivative of ``p`` with respect to the window x coordinate.
  1684. Calculates derivatives using local differencing based on the value of ``p`` for the current fragment's neighbors, and will possibly,
  1685. but not necessarily, include the value for the current fragment. That is, over a given area, the implementation can compute derivatives in fewer unique locations than
  1686. would be allowed for the corresponding `dFdxFine<shader_func_dfdxFine>`` function.
  1687. .. warning::
  1688. Expressions that imply higher order derivatives such as ``dFdx(dFdx(n))`` have undefined results, as do mixed-order derivatives such as ``dFdx(dFdy(n))``.
  1689. :param p:
  1690. The expression of which to take the partial derivative.
  1691. .. note:: It is assumed that the expression ``p`` is continuous and therefore expressions evaluated via non-uniform control flow may be undefined.
  1692. :return:
  1693. The partial derivative of ``p``.
  1694. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdxCoarse.xhtml
  1695. .. rst-class:: classref-item-separator
  1696. ----
  1697. .. _shader_func_dFdxFine:
  1698. .. rst-class:: classref-method
  1699. |vec_type| **dFdxFine**\ (\ |vec_type| p)
  1700. .. note::
  1701. Available only in the fragment shader.
  1702. Not available when using the Compatibility renderer.
  1703. Return the partial derivative of ``p`` with respect to the window x coordinate.
  1704. Calculates derivatives using local differencing based on the value of ``p`` for the current fragment and its immediate neighbor(s).
  1705. .. warning:: Expressions that imply higher order derivatives such as ``dFdx(dFdx(n))`` have undefined results, as do mixed-order derivatives such as ``dFdx(dFdy(n))``.
  1706. :param p:
  1707. The expression of which to take the partial derivative.
  1708. .. note:: It is assumed that the expression ``p`` is continuous and therefore expressions evaluated via non-uniform control flow may be undefined.
  1709. :return:
  1710. The partial derivative of ``p``.
  1711. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdxFine.xhtml
  1712. .. rst-class:: classref-item-separator
  1713. ----
  1714. .. _shader_func_dFdy:
  1715. .. rst-class:: classref-method
  1716. |vec_type| **dFdy**\ (\ |vec_type| p)
  1717. .. note:: Available only in the fragment shader
  1718. Return the partial derivative of ``p`` with respect to the window y coordinate using local differencing.
  1719. Returns either `dFdyCoarse<shader_func_dFdyCoarse>` or `dFdyFine<shader_func_dfdyFine>`. The implementation may choose which calculation to perform based upon factors
  1720. such as performance or the value of the API GL_FRAGMENT_SHADER_DERIVATIVE_HINT hint.
  1721. .. warning:: Expressions that imply higher order derivatives such as ``dFdx(dFdx(n))`` have undefined results, as do mixed-order derivatives such as ``dFdx(dFdy(n))``.
  1722. :param p:
  1723. The expression of which to take the partial derivative.
  1724. .. note:: It is assumed that the expression ``p`` is continuous and therefore expressions evaluated via non-uniform control flow may be undefined.
  1725. :return:
  1726. The partial derivative of ``p``.
  1727. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdy.xhtml
  1728. .. rst-class:: classref-item-separator
  1729. ----
  1730. .. _shader_func_dFdyCoarse:
  1731. .. rst-class:: classref-method
  1732. |vec_type| **dFdyCoarse**\ (\ |vec_type| p)
  1733. .. note::
  1734. Available only in the fragment shader.
  1735. Not available when using the Compatibility renderer.
  1736. Return the partial derivative of ``p`` with respect to the window y coordinate.
  1737. Calculates derivatives using local differencing based on the value of ``p`` for the current fragment's neighbors, and will possibly,
  1738. but not necessarily, include the value for the current fragment. That is, over a given area, the implementation can compute derivatives in fewer unique locations than
  1739. would be allowed for the corresponding dFdyFine and dFdyFine functions.
  1740. .. warning:: Expressions that imply higher order derivatives such as ``dFdx(dFdx(n))`` have undefined results, as do mixed-order derivatives such as ``dFdx(dFdy(n))``.
  1741. :param p:
  1742. The expression of which to take the partial derivative.
  1743. .. note:: It is assumed that the expression ``p`` is continuous and therefore expressions evaluated via non-uniform control flow may be undefined.
  1744. :return:
  1745. The partial derivative of ``p``.
  1746. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdyCoarse.xhtml
  1747. .. rst-class:: classref-item-separator
  1748. ----
  1749. .. _shader_func_dFdyFine:
  1750. .. rst-class:: classref-method
  1751. |vec_type| **dFdyFine**\ (\ |vec_type| p)
  1752. .. note::
  1753. Available only in the fragment shader.
  1754. Not available when using the Compatibility renderer.
  1755. Return the partial derivative of ``p`` with respect to the window y coordinate.
  1756. Calculates derivatives using local differencing based on the value of ``p`` for the current fragment and its immediate neighbor(s).
  1757. .. warning:: Expressions that imply higher order derivatives such as ``dFdx(dFdx(n))`` have undefined results, as do mixed-order derivatives such as ``dFdx(dFdy(n))``.
  1758. :param p:
  1759. The expression of which to take the partial derivative.
  1760. .. note:: It is assumed that the expression ``p`` is continuous and therefore expressions evaluated via non-uniform control flow may be undefined.
  1761. :return:
  1762. The partial derivative of ``p``.
  1763. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/dFdyFine.xhtml
  1764. .. rst-class:: classref-item-separator
  1765. ----
  1766. .. _shader_func_fwidth:
  1767. .. rst-class:: classref-method
  1768. |vec_type| **fwidth**\ (\ |vec_type| p)
  1769. Return the sum of the absolute value of derivatives in x and y.
  1770. Uses local differencing for the input argument p.
  1771. Equivalent to ``abs(dFdx(p)) + abs(dFdy(p))``.
  1772. :param p:
  1773. The expression of which to take the partial derivative.
  1774. :return:
  1775. The partial derivative.
  1776. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fwidth.xhtml
  1777. .. rst-class:: classref-item-separator
  1778. ----
  1779. .. _shader_func_fwidthCoarse:
  1780. .. rst-class:: classref-method
  1781. |vec_type| **fwidthCoarse**\ (\ |vec_type| p)
  1782. .. note::
  1783. Available only in the fragment shader.
  1784. Not available when using the Compatibility renderer.
  1785. Return the sum of the absolute value of derivatives in x and y.
  1786. Uses local differencing for the input argument p.
  1787. Equivalent to ``abs(dFdxCoarse(p)) + abs(dFdyCoarse(p))``.
  1788. :param p:
  1789. The expression of which to take the partial derivative.
  1790. :return:
  1791. The partial derivative.
  1792. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fwidthCoarse.xhtml
  1793. .. rst-class:: classref-item-separator
  1794. ----
  1795. .. _shader_func_fwidthFine:
  1796. .. rst-class:: classref-method
  1797. |vec_type| **fwidthFine**\ (\ |vec_type| p)
  1798. .. note::
  1799. Available only in the fragment shader.
  1800. Not available when using the Compatibility renderer.
  1801. Return the sum of the absolute value of derivatives in x and y.
  1802. Uses local differencing for the input argument p.
  1803. Equivalent to ``abs(dFdxFine(p)) + abs(dFdyFine(p))``.
  1804. :param p:
  1805. The expression of which to take the partial derivative.
  1806. :return:
  1807. The partial derivative.
  1808. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/fwidthFine.xhtml
  1809. .. rst-class:: classref-section-separator
  1810. ----
  1811. .. rst-class:: classref-reftable-group
  1812. Packing and unpacking functions
  1813. -------------------------------
  1814. These functions convert floating point numbers into various sized integers and then pack those integers into a single 32bit unsigned integer.
  1815. The 'unpack' functions perform the opposite operation, returning the original floating point numbers.
  1816. .. table::
  1817. :class: nowrap-col2
  1818. :widths: auto
  1819. +------------+------------------------------------------------------------------------+--------------------------------------------------------------+
  1820. | | uint | | :ref:`packHalf2x16<shader_func_packHalf2x16>`\ (\ vec2 v) | Convert two 32-bit floats to 16 bit floats and pack them. |
  1821. | | vec2 | | :ref:`unpackHalf2x16<shader_func_unpackHalf2x16>`\ (\ uint v) | |
  1822. +------------+------------------------------------------------------------------------+--------------------------------------------------------------+
  1823. | | uint | | :ref:`packUnorm2x16<shader_func_packUnorm2x16>`\ (\ vec2 v) | Convert two normalized (range 0..1) 32-bit floats |
  1824. | | vec2 | | :ref:`unpackUnorm2x16<shader_func_unpackUnorm2x16>`\ (\ uint v) | to 16-bit floats and pack them. |
  1825. +------------+------------------------------------------------------------------------+--------------------------------------------------------------+
  1826. | | uint | | :ref:`packSnorm2x16<shader_func_packSnorm2x16>`\ (\ vec2 v) | Convert two signed normalized (range -1..1) 32-bit floats |
  1827. | | vec2 | | :ref:`unpackSnorm2x16<shader_func_unpackSnorm2x16>`\ (\ uint v) | to 16-bit floats and pack them. |
  1828. +------------+------------------------------------------------------------------------+--------------------------------------------------------------+
  1829. | | uint | | :ref:`packUnorm4x8<shader_func_packUnorm4x8>`\ (\ vec4 v) | Convert four normalized (range 0..1) 32-bit floats |
  1830. | | vec4 | | :ref:`unpackUnorm4x8<shader_func_unpackUnorm4x8>`\ (\ uint v) | into 8-bit floats and pack them. |
  1831. +------------+------------------------------------------------------------------------+--------------------------------------------------------------+
  1832. | | uint | | :ref:`packSnorm4x8<shader_func_packSnorm4x8>`\ (\ vec4 v) | Convert four signed normalized (range -1..1) 32-bit floats |
  1833. | | vec4 | | :ref:`unpackSnorm4x8<shader_func_unpackSnorm4x8>`\ (\ uint v) | into 8-bit floats and pack them. |
  1834. +------------+------------------------------------------------------------------------+--------------------------------------------------------------+
  1835. .. rst-class:: classref-descriptions-group
  1836. Packing and unpacking function descriptions
  1837. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1838. .. _shader_func_packHalf2x16:
  1839. .. rst-class:: classref-method
  1840. uint **packHalf2x16**\ (\ vec2 v)
  1841. Convert two 32-bit floating-point quantities to 16-bit floating point quantities and pack them into a single 32-bit integer.
  1842. Returns an unsigned integer obtained by converting the components of a two-component floating-point vector to
  1843. the 16-bit floating-point representation found in the OpenGL Specification, and then packing these two
  1844. 16-bit integers into a 32-bit unsigned integer. The first vector component specifies the 16 least-significant
  1845. bits of the result; the second component specifies the 16 most-significant bits.
  1846. :param v:
  1847. A vector of two 32-bit floating point values that are to be converted to 16-bit representation and packed into the result.
  1848. :return:
  1849. The packed value.
  1850. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/packHalf2x16.xhtml
  1851. .. rst-class:: classref-item-separator
  1852. ----
  1853. .. _shader_func_unpackHalf2x16:
  1854. .. rst-class:: classref-method
  1855. vec2 **unpackHalf2x16**\ (\ uint v)
  1856. Inverse of :ref:`packHalf2x16<shader_func_packHalf2x16>`.
  1857. Unpack a 32-bit integer into two 16-bit floating-point values, convert them to 32-bit floating-point values, and put them into a vector.
  1858. The first component of the vector is obtained from the 16 least-significant bits of ``v``; the second component is obtained from the
  1859. 16 most-significant bits of ``v``.
  1860. :param v:
  1861. A single 32-bit unsigned integer containing 2 packed 16-bit floating point values.
  1862. :return:
  1863. Two unpacked floating point values.
  1864. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/unpackHalf2x16.xhtml
  1865. .. rst-class:: classref-item-separator
  1866. ----
  1867. .. _shader_func_packUnorm2x16:
  1868. .. rst-class:: classref-method
  1869. uint **packUnorm2x16**\ (\ vec2 v)
  1870. Pack floating-point values into an unsigned integer.
  1871. Converts each component of the normalized floating-point value v into 16-bit integer values and then packs the results into a 32-bit unsigned integer.
  1872. The conversion for component c of ``v`` to fixed-point is performed as follows::
  1873. round(clamp(c, 0.0, 1.0) * 65535.0)
  1874. The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.
  1875. :param v:
  1876. A vector of values to be packed into an unsigned integer.
  1877. :return:
  1878. Unsigned 32 bit integer containing the packed encoding of the vector.
  1879. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/packUnorm.xhtml
  1880. .. rst-class:: classref-item-separator
  1881. ----
  1882. .. _shader_func_unpackUnorm2x16:
  1883. .. rst-class:: classref-method
  1884. vec2 **unpackUnorm2x16**\ (\ uint v)
  1885. Unpack floating-point values from an unsigned integer.
  1886. Unpack single 32-bit unsigned integers into a pair of 16-bit unsigned integers.
  1887. Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
  1888. The conversion for unpacked fixed point value f to floating-point is performed as follows:
  1889. f / 65535.0
  1890. The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.
  1891. :param v:
  1892. An unsigned integer containing packed floating-point values.
  1893. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/unpackUnorm.xhtml
  1894. .. rst-class:: classref-item-separator
  1895. ----
  1896. .. _shader_func_packSnorm2x16:
  1897. .. rst-class:: classref-method
  1898. uint **packSnorm2x16**\ (\ vec2 v)
  1899. Pack floating-point values into an unsigned integer.
  1900. Convert each component of the normalized floating-point value ``v`` into 16-bit integer values and then packs the results into a 32-bit unsigned integer.
  1901. The conversion for component c of ``v`` to fixed-point is performed as follows::
  1902. round(clamp(c, -1.0, 1.0) * 32767.0)
  1903. The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.
  1904. :param v:
  1905. A vector of values to be packed into an unsigned integer.
  1906. :return:
  1907. Unsigned 32 bit integer containing the packed encoding of the vector.
  1908. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/packUnorm.xhtml
  1909. .. rst-class:: classref-item-separator
  1910. ----
  1911. .. _shader_func_unpackSnorm2x16:
  1912. .. rst-class:: classref-method
  1913. vec2 **unpackSnorm2x16**\ (\ uint v)
  1914. Unpack floating-point values from an unsigned integer.
  1915. Unpack single 32-bit unsigned integers into a pair of 16-bit signed integers.
  1916. Then, each component is converted to a normalized floating-point value to generate the returned two-component vector.
  1917. The conversion for unpacked fixed point value f to floating-point is performed as follows:
  1918. clamp(f / 32727.0, -1.0, 1.0)
  1919. The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.
  1920. :param v:
  1921. An unsigned integer containing packed floating-point values.
  1922. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/unpackUnorm.xhtml
  1923. .. rst-class:: classref-item-separator
  1924. ----
  1925. .. _shader_func_packUnorm4x8:
  1926. .. rst-class:: classref-method
  1927. uint **packUnorm4x8**\ (\ vec4 v)
  1928. Pack floating-point values into an unsigned integer.
  1929. Convert each component of the normalized floating-point value ``v`` into 16-bit integer values and then packs the results into a 32-bit unsigned integer.
  1930. The conversion for component c of ``v`` to fixed-point is performed as follows::
  1931. round(clamp(c, 0.0, 1.0) * 255.0)
  1932. The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.
  1933. :param v:
  1934. A vector of values to be packed into an unsigned integer.
  1935. :return:
  1936. Unsigned 32 bit integer containing the packed encoding of the vector.
  1937. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/packUnorm.xhtml
  1938. .. rst-class:: classref-item-separator
  1939. ----
  1940. .. _shader_func_unpackUnorm4x8:
  1941. .. rst-class:: classref-method
  1942. vec4 **unpackUnorm4x8**\ (\ uint v)
  1943. Unpack floating-point values from an unsigned integer.
  1944. Unpack single 32-bit unsigned integers into four 8-bit unsigned integers.
  1945. Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
  1946. The conversion for unpacked fixed point value f to floating-point is performed as follows:
  1947. f / 255.0
  1948. The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.
  1949. :param v:
  1950. An unsigned integer containing packed floating-point values.
  1951. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/unpackUnorm.xhtml
  1952. .. rst-class:: classref-item-separator
  1953. ----
  1954. .. _shader_func_packSnorm4x8:
  1955. .. rst-class:: classref-method
  1956. uint **packSnorm4x8**\ (\ vec4 v)
  1957. Pack floating-point values into an unsigned integer.
  1958. Convert each component of the normalized floating-point value ``v`` into 16-bit integer values and then packs the results into a 32-bit unsigned integer.
  1959. The conversion for component c of ``v`` to fixed-point is performed as follows::
  1960. round(clamp(c, -1.0, 1.0) * 127.0)
  1961. The first component of the vector will be written to the least significant bits of the output; the last component will be written to the most significant bits.
  1962. :param v:
  1963. A vector of values to be packed into an unsigned integer.
  1964. :return:
  1965. Unsigned 32 bit integer containing the packed encoding of the vector.
  1966. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/packUnorm.xhtml
  1967. .. rst-class:: classref-item-separator
  1968. ----
  1969. .. _shader_func_unpackSnorm4x8:
  1970. .. rst-class:: classref-method
  1971. vec4 **unpackSnorm4x8**\ (\ uint v)
  1972. Unpack floating-point values from an unsigned integer.
  1973. Unpack single 32-bit unsigned integers into four 8-bit signed integers.
  1974. Then, each component is converted to a normalized floating-point value to generate the returned four-component vector.
  1975. The conversion for unpacked fixed point value f to floating-point is performed as follows:
  1976. clamp(f / 127.0, -1.0, 1.0)
  1977. The first component of the returned vector will be extracted from the least significant bits of the input; the last component will be extracted from the most significant bits.
  1978. :param v:
  1979. An unsigned integer containing packed floating-point values.
  1980. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/unpackUnorm.xhtml
  1981. .. rst-class:: classref-section-separator
  1982. ----
  1983. .. rst-class:: classref-reftable-group
  1984. Bitwise functions
  1985. -------------------
  1986. .. table::
  1987. :class: nowrap-col2
  1988. :widths: auto
  1989. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1990. | | |vec_int_type| | | :ref:`bitfieldExtract<shader_func_bitfieldExtract>`\ (\ |vec_int_type| value, int offset, int bits) | Extracts a range of bits from an integer. |
  1991. | | |vec_uint_type| | | :ref:`bitfieldExtract<shader_func_bitfieldExtract>`\ (\ |vec_uint_type| value, int offset, int bits) | |
  1992. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1993. | | |vec_int_type| | | :ref:`bitfieldInsert<shader_func_bitfieldInsert>`\ (\ |vec_int_type| base, |vec_int_type| insert, int offset, int bits) | Insert a range of bits into an integer. |
  1994. | | |vec_uint_type| | | :ref:`bitfieldInsert<shader_func_bitfieldInsert>`\ (\ |vec_uint_type| base, |vec_uint_type| insert, int offset, int bits) | |
  1995. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1996. | | |vec_int_type| | | :ref:`bitfieldReverse<shader_func_bitfieldReverse>`\ (\ |vec_int_type| value) | Reverse the order of bits in an integer. |
  1997. | | |vec_uint_type| | | :ref:`bitfieldReverse<shader_func_bitfieldReverse>`\ (\ |vec_uint_type| value) | |
  1998. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  1999. | | |vec_int_type| | | :ref:`bitCount<shader_func_bitCount>`\ (\ |vec_int_type| value) | Counts the number of 1 bits in an integer. |
  2000. | | |vec_uint_type| | | :ref:`bitCount<shader_func_bitCount>`\ (\ |vec_uint_type| value) | |
  2001. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2002. | | |vec_int_type| | | :ref:`findLSB<shader_func_findLSB>`\ (\ |vec_int_type| value) | Find the index of the least significant bit set to 1 in an integer. |
  2003. | | |vec_uint_type| | | :ref:`findLSB<shader_func_findLSB>`\ (\ |vec_uint_type| value) | |
  2004. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2005. | | |vec_int_type| | | :ref:`findMSB<shader_func_findMSB>`\ (\ |vec_int_type| value) | Find the index of the most significant bit set to 1 in an integer. |
  2006. | | |vec_uint_type| | | :ref:`findMSB<shader_func_findMSB>`\ (\ |vec_uint_type| value) | |
  2007. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2008. | | |void| | | :ref:`imulExtended<shader_func_imulExtended>`\ (\ |vec_int_type| x, |vec_int_type| y, out |vec_int_type| msb, out |vec_int_type| lsb) | Multiplies two 32-bit numbers and produce a 64-bit result. |
  2009. | | |void| | | :ref:`umulExtended<shader_func_umulExtended>`\ (\ |vec_uint_type| x, |vec_uint_type| y, out |vec_uint_type| msb, out |vec_uint_type| lsb) | |
  2010. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2011. | |vec_uint_type| | :ref:`uaddCarry<shader_func_uaddCarry>`\ (\ |vec_uint_type| x, |vec_uint_type| y, out |vec_uint_type| carry) | Adds two unsigned integers and generates carry. |
  2012. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2013. | |vec_uint_type| | :ref:`usubBorrow<shader_func_usubBorrow>`\ (\ |vec_uint_type| x, |vec_uint_type| y, out |vec_uint_type| borrow) | Subtracts two unsigned integers and generates borrow. |
  2014. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2015. | |vec_type| | :ref:`ldexp<shader_func_ldexp>`\ (\ |vec_type| x, out |vec_int_type| exp) | Assemble a floating-point number from a value and exponent. |
  2016. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2017. | |vec_type| | :ref:`frexp<shader_func_frexp>`\ (\ |vec_type| x, out |vec_int_type| exp) | Splits a floating-point number (``x``) into significand integral |
  2018. | | | components |
  2019. +-------------------+---------------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------+
  2020. .. rst-class:: classref-descriptions-group
  2021. Bitwise function descriptions
  2022. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2023. .. _shader_func_bitfieldExtract:
  2024. .. rst-class:: classref-method
  2025. |vec_int_type| **bitfieldExtract**\ (\ |vec_int_type| value, int offset, int bits)
  2026. Extracts a subset of the bits of ``value`` and returns it in the least significant bits of the result.
  2027. The range of bits extracted is ``[offset, offset + bits - 1]``.
  2028. The most significant bits of the result will be set to zero.
  2029. .. note::
  2030. If bits is zero, the result will be zero.
  2031. .. warning::
  2032. The result will be undefined if:
  2033. - offset or bits is negative.
  2034. - if the sum of offset and bits is greater than the number of bits used to store the operand.
  2035. :param value:
  2036. The integer from which to extract bits.
  2037. :param offset:
  2038. The index of the first bit to extract.
  2039. :param bits:
  2040. The number of bits to extract.
  2041. :return:
  2042. Integer with the requested bits.
  2043. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/bitfieldExtract.xhtml
  2044. .. rst-class:: classref-item-separator
  2045. ----
  2046. .. rst-class:: classref-method
  2047. |vec_uint_type| **bitfieldExtract**\ (\ |vec_uint_type| value, int offset, int bits)
  2048. |componentwise|
  2049. Extracts a subset of the bits of ``value`` and returns it in the least significant bits of the result.
  2050. The range of bits extracted is ``[offset, offset + bits - 1]``.
  2051. The most significant bits will be set to the value of ``offset + base - 1`` (i.e., it is sign extended to the width of the return type).
  2052. .. note::
  2053. If bits is zero, the result will be zero.
  2054. .. warning::
  2055. The result will be undefined if:
  2056. - offset or bits is negative.
  2057. - if the sum of offset and bits is greater than the number of bits used to store the operand.
  2058. :param value:
  2059. The integer from which to extract bits.
  2060. :param offset:
  2061. The index of the first bit to extract.
  2062. :param bits:
  2063. The number of bits to extract.
  2064. :return:
  2065. Integer with the requested bits
  2066. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/bitfieldExtract.xhtml
  2067. .. rst-class:: classref-item-separator
  2068. ----
  2069. .. _shader_func_bitfieldInsert:
  2070. .. rst-class:: classref-method
  2071. |vec_uint_type| **bitfieldExtract**\ (\ |vec_uint_type| value, int offset, int bits)
  2072. .. rst-class:: classref-method
  2073. |vec_uint_type| **bitfieldInsert**\ (\ |vec_uint_type| base, |vec_uint_type| insert, int offset, int bits)
  2074. |componentwise|
  2075. Inserts the ``bits`` least significant bits of ``insert`` into ``base`` at offset ``offset``.
  2076. The returned value will have bits [offset, offset + bits + 1] taken from [0, bits - 1] of ``insert`` and
  2077. all other bits taken directly from the corresponding bits of base.
  2078. .. note:: If bits is zero, the result will simply be the original value of base.
  2079. .. warning::
  2080. The result will be undefined if:
  2081. - offset or bits is negative.
  2082. - if the sum of offset and bits is greater than the number of bits used to store the operand.
  2083. :param base:
  2084. The integer into which to insert ``insert``.
  2085. :param insert:
  2086. The value of the bits to insert.
  2087. :param offset:
  2088. The index of the first bit to insert.
  2089. :param bits:
  2090. The number of bits to insert.
  2091. :return:
  2092. ``base`` with inserted bits.
  2093. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/bitfieldInsert.xhtml
  2094. .. rst-class:: classref-item-separator
  2095. ----
  2096. .. _shader_func_bitfieldReverse:
  2097. .. rst-class:: classref-method
  2098. |vec_int_type| **bitfieldReverse**\ (\ |vec_int_type| value)
  2099. .. rst-class:: classref-method
  2100. |vec_uint_type| **bitfieldReverse**\ (\ |vec_uint_type| value)
  2101. |componentwise|
  2102. Reverse the order of bits in an integer.
  2103. The bit numbered n will be taken from bit (bits - 1) - n of ``value``, where bits is the total number of bits used to represent ``value``.
  2104. :param value:
  2105. The value whose bits to reverse.
  2106. :return:
  2107. ``value`` but with its bits reversed.
  2108. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/bitfieldReverse.xhtml
  2109. .. rst-class:: classref-item-separator
  2110. ----
  2111. .. _shader_func_bitCount:
  2112. .. rst-class:: classref-method
  2113. |vec_int_type| **bitCount**\ (\ |vec_int_type| value)
  2114. .. rst-class:: classref-method
  2115. |vec_uint_type| **bitCount**\ (\ |vec_uint_type| value)
  2116. |componentwise|
  2117. Counts the number of 1 bits in an integer.
  2118. :param value:
  2119. The value whose bits to count.
  2120. :return:
  2121. The number of bits that are set to 1 in the binary representation of ``value``.
  2122. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/bitCount.xhtml
  2123. .. rst-class:: classref-item-separator
  2124. ----
  2125. .. _shader_func_findLSB:
  2126. .. rst-class:: classref-method
  2127. |vec_int_type| **findLSB**\ (\ |vec_int_type| value)
  2128. .. rst-class:: classref-method
  2129. |vec_uint_type| **findLSB**\ (\ |vec_uint_type| value)
  2130. |componentwise|
  2131. Find the index of the least significant bit set to 1.
  2132. .. note:: If ``value`` is zero, -1 will be returned.
  2133. :param value:
  2134. The value whose bits to scan.
  2135. :return:
  2136. The bit number of the least significant bit that is set to 1 in the binary representation of value.
  2137. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/findLSB.xhtml
  2138. .. rst-class:: classref-item-separator
  2139. ----
  2140. .. _shader_func_findMSB:
  2141. .. rst-class:: classref-method
  2142. |vec_int_type| **findMSB**\ (\ |vec_int_type| value)
  2143. .. rst-class:: classref-method
  2144. |vec_uint_type| **findMSB**\ (\ |vec_uint_type| value)
  2145. |componentwise|
  2146. Find the index of the most significant bit set to 1.
  2147. .. note::
  2148. For signed integer types, the sign bit is checked first and then:
  2149. - For positive integers, the result will be the bit number of the most significant bit that is set to 1.
  2150. - For negative integers, the result will be the bit number of the most significant bit set to 0.
  2151. .. note:: For a value of zero or negative 1, -1 will be returned.
  2152. :param value:
  2153. The value whose bits to scan.
  2154. :return:
  2155. The bit number of the most significant bit that is set to 1 in the binary representation of value.
  2156. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/findMSB.xhtml
  2157. .. rst-class:: classref-item-separator
  2158. ----
  2159. .. _shader_func_imulExtended:
  2160. .. rst-class:: classref-method
  2161. |void| **imulExtended**\ (\ |vec_int_type| x, |vec_int_type| y, out |vec_int_type| msb, out |vec_int_type| lsb)
  2162. |componentwise|
  2163. Perform 32-bit by 32-bit signed multiplication to produce a 64-bit result.
  2164. The 32 least significant bits of this product are returned in ``lsb`` and the 32 most significant bits are returned in ``msb``.
  2165. :param x:
  2166. The first multiplicand.
  2167. :param y:
  2168. The second multiplicand.
  2169. :param msb:
  2170. The variable to receive the most significant word of the product.
  2171. :param lsb:
  2172. The variable to receive the least significant word of the product.
  2173. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/umulExtended.xhtml
  2174. .. rst-class:: classref-item-separator
  2175. ----
  2176. .. _shader_func_umulExtended:
  2177. .. rst-class:: classref-method
  2178. |void| **umulExtended**\ (\ |vec_uint_type| x, |vec_uint_type| y, out |vec_uint_type| msb, out |vec_uint_type| lsb)
  2179. |componentwise|
  2180. Perform 32-bit by 32-bit unsigned multiplication to produce a 64-bit result.
  2181. The 32 least significant bits of this product are returned in ``lsb`` and the 32 most significant bits are returned in ``msb``.
  2182. :param x:
  2183. The first multiplicand.
  2184. :param y:
  2185. The second multiplicand.
  2186. :param msb:
  2187. The variable to receive the most significant word of the product.
  2188. :param lsb:
  2189. The variable to receive the least significant word of the product.
  2190. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/umulExtended.xhtml
  2191. .. rst-class:: classref-item-separator
  2192. ----
  2193. .. _shader_func_uaddCarry:
  2194. .. rst-class:: classref-method
  2195. |vec_uint_type| **uaddCarry**\ (\ |vec_uint_type| x, |vec_uint_type| y, out |vec_uint_type| carry)
  2196. |componentwise|
  2197. Add unsigned integers and generate carry.
  2198. adds two 32-bit unsigned integer variables (scalars or vectors) and generates a 32-bit unsigned integer result, along with a carry output.
  2199. The value carry is .
  2200. :param x:
  2201. The first operand.
  2202. :param y:
  2203. The second operand.
  2204. :param carry:
  2205. 0 if the sum is less than 2\ :sup:`32`, otherwise 1.
  2206. :return:
  2207. ``(x + y) % 2^32``.
  2208. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/uaddCarry.xhtml
  2209. .. rst-class:: classref-item-separator
  2210. ----
  2211. .. _shader_func_usubBorrow:
  2212. .. rst-class:: classref-method
  2213. |vec_uint_type| **usubBorrow**\ (\ |vec_uint_type| x, |vec_uint_type| y, out |vec_uint_type| borrow)
  2214. |componentwise|
  2215. Subtract unsigned integers and generate borrow.
  2216. :param x:
  2217. The first operand.
  2218. :param y:
  2219. The second operand.
  2220. :param borrow:
  2221. ``0`` if ``x >= y``, otherwise ``1``.
  2222. :return:
  2223. The difference of ``x`` and ``y`` if non-negative, or 2\ :sup:`32` plus that difference otherwise.
  2224. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/usubBorrow.xhtml
  2225. .. rst-class:: classref-item-separator
  2226. ----
  2227. .. _shader_func_ldexp:
  2228. .. rst-class:: classref-method
  2229. |vec_type| **ldexp**\ (\ |vec_type| x, out |vec_int_type| exp)
  2230. |componentwise|
  2231. Assemble a floating point number from a value and exponent.
  2232. .. warning::
  2233. If this product is too large to be represented in the floating point type, the result is undefined.
  2234. :param x:
  2235. The value to be used as a source of significand.
  2236. :param exp:
  2237. The value to be used as a source of exponent.
  2238. :return:
  2239. ``x * 2^exp``
  2240. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/ldexp.xhtml
  2241. .. rst-class:: classref-item-separator
  2242. ----
  2243. .. _shader_func_frexp:
  2244. .. rst-class:: classref-method
  2245. |vec_type| **frexp**\ (\ |vec_type| x, out |vec_int_type| exp)
  2246. |componentwise|
  2247. Extracts ``x`` into a floating-point significand in the range ``[0.5, 1.0)`` and in integral exponent of two, such that::
  2248. x = significand * 2 ^ exponent
  2249. For a floating-point value of zero, the significand and exponent are both zero.
  2250. .. warning:: For a floating-point value that is an infinity or a floating-point NaN, the results are undefined.
  2251. :param x:
  2252. The value from which significand and exponent are to be extracted.
  2253. :param exp:
  2254. The variable into which to place the exponent of ``x``.
  2255. :return:
  2256. The significand of ``x``.
  2257. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/frexp.xhtml
  2258. .. rst-class:: classref-section-separator
  2259. ----
  2260. .. |void| replace:: :abbr:`void (No return value.)`
  2261. .. |vec_type| replace:: :abbr:`vec_type (Any of: float, vec2, vec3, vec4)`
  2262. .. |vec_int_type| replace:: :abbr:`vec_int_type (Any of: int, ivec2, ivec3, ivec4)`
  2263. .. |vec_uint_type| replace:: :abbr:`vec_uint_type (Any of: float, uvec2, uvec3, uvec4)`
  2264. .. |vec_bool_type| replace:: :abbr:`vec_bool_type (Any of: bool, bvec2, bvec3, bvec4)`
  2265. .. |gsampler2D| replace:: :abbr:`gsampler2D (Any of: sampler2D, isampler2D, uSampler2D)`
  2266. .. |gsampler2DArray| replace:: :abbr:`gsampler2DArray (Any of: sampler2DArray, isampler2DArray, uSampler2DArray)`
  2267. .. |gsampler3D| replace:: :abbr:`gsampler3D (Any of: sampler3D, isampler3D, uSampler3D)`
  2268. .. |mat_type| replace:: :abbr:`mat_type (Any of: mat2, mat3, mat4)`
  2269. .. |gvec4_type| replace:: :abbr:`gvec4_type (Any of: vec4, ivec4, uvec4)`
  2270. .. |componentwise| replace:: :ref:`Component-wise Function<shading_componentwise>`.