@@ -639,114 +639,130 @@ endif::GLSL[]
639
639
640
640
These operate on vectors as vectors, not component-wise.
641
641
642
- [options="header"]
643
- |====
644
- | Syntax | Description
642
+ === Length
643
+ [source,glsl]
644
+ ----
645
645
ifdef::GLSL[]
646
- | float * length* (genFType _x_) +
647
- double * length* (genDType _x_ )
646
+ float length(genFType x)
647
+ double length(genDType x )
648
648
endif::GLSL[]
649
649
ifdef::ESSL[]
650
- | float * length* (genFType _x_ )
650
+ float length(genFType x )
651
651
endif::ESSL[]
652
- a| Returns the length of vector _x_, i.e.,
653
- [eq]#sqrt( x~0~^2^ + x~1~^2^ + ... )#.
652
+ ----
653
+
654
+ Returns the length of vector _x_, i.e., [eq]#sqrt( x~0~^2^ + x~1~^2^ + ... )#.
655
+
656
+ === Distance
657
+ [source,glsl]
658
+ ----
654
659
ifdef::GLSL[]
655
- | float * distance* (genFType _p0_ , genFType _p1_) +
656
- double * distance* (genDType _p0_ , genDType _p1_ )
660
+ float distance(genFType p0 , genFType p1)
661
+ double distance(genDType p0 , genDType p1 )
657
662
endif::GLSL[]
658
663
ifdef::ESSL[]
659
- | float * distance* (genFType _p0_ , genFType _p1_ )
664
+ float distance(genFType p0 , genFType p1 )
660
665
endif::ESSL[]
661
- | Returns the distance between _p0_ and _p1_, i.e.,
662
- *length*(_p0_ - _p1_)
666
+ ----
667
+
668
+ Returns the distance between _p0_ and _p1_, i.e., *length*(_p0_ - _p1_)
669
+
670
+ === Dot
671
+ [source,glsl]
672
+ ----
673
+ float dot(genFType x, genFType y)
663
674
ifdef::GLSL[]
664
- | float *dot*(genFType _x_, genFType _y_) +
665
- double *dot*(genDType _x_, genDType _y_)
675
+ double dot(genDType x, genDType y)
666
676
endif::GLSL[]
667
- ifdef::ESSL[]
668
- | float *dot*(genFType _x_, genFType _y_)
669
- endif::ESSL[]
670
- | Returns the dot product of _x_ and _y_, i.e.,
671
- [eq]#x~0~ {cdot} y~0~ + x~1~ {cdot} y~1~ + ...#
677
+ ----
678
+
679
+ Returns the dot product of _x_ and _y_, i.e., [eq]#x~0~ {cdot} y~0~ + x~1~ {cdot} y~1~ + ...#
680
+
681
+ === Cross
682
+ [source,glsl]
683
+ ----
684
+ vec3 cross(vec3 x, vec3 y)
672
685
ifdef::GLSL[]
673
- | vec3 *cross*(vec3 _x_, vec3 _y_) +
674
- dvec3 *cross*(dvec3 _x_, dvec3 _y_)
686
+ dvec3 cross(dvec3 x, dvec3 y)
675
687
endif::GLSL[]
676
- ifdef::ESSL[]
677
- | vec3 *cross*(vec3 _x_, vec3 _y_)
678
- endif::ESSL[]
679
- a| Returns the cross product of _x_ and _y_, i.e.,
688
+ ----
689
+
690
+ Returns the cross product of _x_ and _y_, i.e.,
680
691
[eq]#(x~1~ {cdot} y~2~ - y~1~ {cdot} x~2~,
681
692
x~2~ {cdot} y~0~ - y~2~ {cdot} x~0~,
682
693
x~0~ {cdot} y~1~ - y~0~ {cdot} x~1~)#.
694
+
695
+ === Normalize
696
+ [source,glsl]
697
+ ----
698
+ genFType normalize(genFType x)
683
699
ifdef::GLSL[]
684
- | genFType *normalize*(genFType _x_) +
685
- genDType *normalize*(genDType _x_)
700
+ genDType normalize(genDType x)
686
701
endif::GLSL[]
687
- ifdef::ESSL[]
688
- | genFType *normalize*(genFType _x_)
689
- endif::ESSL[]
690
- | Returns a vector in the same direction as _x_ but with a length of 1,
691
- i.e. _x_ / *length*(x).
692
- ifdef::GLSL[]
693
- | compatibility profile only +
694
- vec4 *ftransform*()
695
- a| Available only when using the compatibility profile.
696
- For core {apiname}, use *invariant*. +
697
- For vertex shaders only.
698
- This function will ensure that the incoming vertex value will be
699
- transformed in a way that produces exactly the same result as would be
700
- produced by {apiname}'s fixed functionality transform.
701
- It is intended to be used to compute _gl_Position_, e.g.
702
- --
703
- {empty}:: _gl_Position_ = *ftransform*()
702
+ ----
703
+
704
+ Returns a vector in the same direction as _x_ but with a length of 1, i.e. _x_ / *length*(x).
704
705
705
- This function should be used, for example, when an application is rendering
706
- the same geometry in separate passes, and one pass uses the fixed
707
- functionality path to render and another pass uses programmable shaders.
708
- --
709
- endif::GLSL[]
710
- | genFType *faceforward*(genFType _N_, genFType _I_, genFType _Nref_) +
711
706
ifdef::GLSL[]
712
- genDType *faceforward*(genDType _N_, genDType _I_, genDType _Nref_)
707
+ === FTransform
708
+ Compatibility profile only
709
+
710
+ [source,glsl]
711
+ ----
712
+ vec4 ftransform()
713
+ ----
714
+
715
+ Available only when using the compatibility profile. For core {apiname}, use *invariant*.
716
+
717
+ For vertex shaders only. This function will ensure that the incoming vertex value will be
718
+ transformed in a way that produces exactly the same result as would be produced by {apiname}'s
719
+ fixed functionality transform. It is intended to be used to compute _gl_Position_, e.g.
720
+
721
+ [source,glsl]
722
+ ----
723
+ gl_Position = ftransform()
724
+ ----
725
+
726
+ This function should be used, for example, when an application is rendering the same geometry in
727
+ separate passes, and one pass uses the fixed functionality path to render and another pass uses
728
+ programmable shaders.
713
729
endif::GLSL[]
714
- | If *dot*(_Nref_, _I_) < 0 return _N_, otherwise return -_N_.
730
+
731
+ === Face Forward
732
+ [source,glsl]
733
+ ----
734
+ genFType faceforward(genFType N, genFType I, genFType Nref)
715
735
ifdef::GLSL[]
716
- | genFType *reflect*(genFType _I_, genFType _N_) +
717
- genDType *reflect*(genDType _I_, genDType _N_)
736
+ genDType faceforward(genDType N, genDType I, genDType Nref)
718
737
endif::GLSL[]
719
- ifdef::ESSL[]
720
- | genFType *reflect*(genFType _I_, genFType _N_)
721
- endif::ESSL[]
722
- | For the incident vector _I_ and surface orientation _N_, returns the
723
- reflection direction: [eq]#I - 2 {cdot} *dot*(N, I) {cdot} N#.
724
- _N_ must already be normalized in order to achieve the desired result.
725
- | genFType *refract*(genFType _I_, genFType _N_, float _eta_) +
738
+ ----
739
+
740
+ If *dot*(_Nref_, _I_) < 0 return _N_, otherwise return -_N_.
741
+
742
+ === Reflect
743
+ [source,glsl]
744
+ ----
745
+ genFType reflect(genFType I, genFType N)
726
746
ifdef::GLSL[]
727
- genDType *refract* (genDType _I_ , genDType _N_, double _eta_ )
747
+ genDType reflect (genDType I , genDType N )
728
748
endif::GLSL[]
729
- a| For the incident vector _I_ and surface normal _N_, and the ratio of
730
- indices of refraction _eta_, return the refraction vector.
731
- The result is computed by the <<refraction-equation,refraction
732
- equation>> shown below.
733
-
734
- The input parameters for the incident vector _I_ and the surface
735
- normal _N_ must already be normalized to get the desired results.
736
- |====
749
+ ----
737
750
751
+ For the incident vector _I_ and surface orientation _N_, returns the reflection direction:
752
+ [eq]#I - 2 {cdot} *dot*(N, I) {cdot} N#. _N_ must already be normalized in order to achieve
753
+ the desired result.
738
754
739
- [[refraction-equation]]
740
- === Refraction Equation
755
+ === Refract
756
+ [source,glsl]
757
+ ----
758
+ genFType refract(genFType I, genFType N, float eta)
759
+ ifdef::GLSL[]
760
+ genDType refract(genDType I, genDType N, double eta)
761
+ endif::GLSL[]
762
+ ----
741
763
742
- ifdef::editing-notes[]
743
- [NOTE]
744
- .editing-note
745
- ====
746
- (Jon) Moved to new section from *refract* table entry above because
747
- asciidoctor-mathematical doesn't support math blocks in table cells yet.
748
- ====
749
- endif::editing-notes[]
764
+ For the incident vector _I_ and surface normal _N_, and the ratio of indices of refraction
765
+ _eta_, return the refraction vector. The result is computed by the refraction equation shown below.
750
766
751
767
[latexmath]
752
768
++++
@@ -764,6 +780,9 @@ result &=
764
780
\end{aligned}
765
781
++++
766
782
783
+ The input parameters for the incident vector _I_ and the surface normal _N_ must already be
784
+ normalized to get the desired results.
785
+
767
786
768
787
[[matrix-functions]]
769
788
== Matrix Functions
0 commit comments