Translate the glossary section
This commit is contained in:
parent
120d047d21
commit
39a611ce5e
|
|
@ -26,4 +26,4 @@ vec4 atan(vec4 y_over_x)
|
|||
Ở phiên bản thứ hai, ```atan()``` trả về góc lượng giác (đơn vị radian) ứng với tan bằng ```y_over_x```. Kết quả trả về trong trường hợp này sẽ nằm trong khoảng [-PI/2, PI/2].
|
||||
|
||||
### Tham khảo thêm
|
||||
[cos](/glossary/?lan=vi&search=cos), [acos](/glossary/?lan=vi&search=acos), [sin](/glossary/?lan=vi&search=sin), [asin](/glossary/?lan=vi&search=asin), [atan](/glossary/?lan=vi&search=atan), [Các hàm số cơ bản (Hàm hình dạng - Shape function)](/05/?lan=vi), [Chapter 06: Color](/06/)
|
||||
[cos](/glossary/?lan=vi&search=cos), [acos](/glossary/?lan=vi&search=acos), [sin](/glossary/?lan=vi&search=sin), [asin](/glossary/?lan=vi&search=asin), [atan](/glossary/?lan=vi&search=atan), [Các hàm số cơ bản (Hàm hình dạng - Shape function)](/05/?lan=vi), [Chương 6: Màu sắc](/06/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ float distance(vec4 p0, vec4 p1)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```p0``` Điểm đầu tiên
|
||||
```p0``` Điểm thứ nhất
|
||||
|
||||
```p1``` Điểm thứ hai
|
||||
|
||||
|
|
@ -21,4 +21,4 @@ float distance(vec4 p0, vec4 p1)
|
|||
|
||||
### Tham khảo thêm
|
||||
|
||||
[length()](/glossary/?lan=vi&search=length), [normalize()](/glossary/?lan=vi&search=normalize), [Chapter 07: Shapes](/07/)
|
||||
[length()](/glossary/?lan=vi&search=length), [normalize()](/glossary/?lan=vi&search=normalize), [Chương 7: Hình dạng](/07/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Equal
|
||||
Perform a component-wise equal-to comparison of two vectors
|
||||
Thực hiện phép so sánh bằng giữa các cặp giá trị của 2 vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -13,12 +13,12 @@ bvec4 equal(ivec4 x, ivec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` Specifies the first vector to be used in the comparison operation.
|
||||
```x``` Vector thứ nhất.
|
||||
|
||||
```y``` Specifies the second vector to be used in the comparison operation.
|
||||
```y``` Vector thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```equal()``` returns a boolean vector in which each element ```i``` is computed as ```x[i] == y[i]```.
|
||||
```equal()``` trả về một vector boolean mà thành phần thứ ```i``` là kết quả của phép so sánh ```x[i] == y[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[lessThanEqual()](/glossary/?lan=vi&search=lessThanEqual), [lessThan()](/glossary/?lan=vi&search=lessThan), [greaterThanEqual()](/glossary/?lan=vi&search=greaterThanEqual), [greaterThan()](/glossary/?lan=vi&search=greaterThan), [notEqual()](/glossary/?lan=vi&search=notEqual), [any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all), [not()](/glossary/?lan=vi&search=not)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Exp
|
||||
Return the natural exponentiation of the parameter
|
||||
Tính lũy thừa tự nhiên của một số
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 exp(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value to exponentiate.
|
||||
```x``` số cần tính lũy thừa tự nhiên.
|
||||
|
||||
### Mô tả
|
||||
```exp()``` returns the natural exponentiation of ```x```.
|
||||
```exp()``` trả về kết quả của phép tính e mũ ```x``` (e là cơ số của logarith tự nhiên, xấp xỉ 2.71828)
|
||||
|
||||
<div class="simpleFunction" data="y = exp(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Exp2
|
||||
Return 2 raised to the power of the parameter
|
||||
Hàm 2 mũ x.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 exp2(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value of the power to which 2 will be raised.
|
||||
```x``` số mũ.
|
||||
|
||||
### Mô tả
|
||||
```exp2()``` returns 2 raised to the power of ```x```.
|
||||
```exp2()``` trả về kết quả của phép tính 2 mũ ```x```.
|
||||
|
||||
<div class="simpleFunction" data="y = exp2(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Faceforward
|
||||
Return a vector pointing in the same direction as another
|
||||
Tìm vector pháp tuyến cùng phía với vector tới so với một bề mặt.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,14 +10,14 @@ vec4 faceforward(vec4 N, vec4 I, vec4 Nref)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```N``` specifies the vector to orient.
|
||||
```N``` vector pháp tuyến của bề mặt sẽ va chạm (hướng trả về sẽ trùng hướng này hoặc hướng ngược lại)
|
||||
|
||||
```I``` specifies the incident vector.
|
||||
```I``` vector tới (hướng tới vị trí va chạm với bề mặt).
|
||||
|
||||
```Nref``` specifies the reference vector.
|
||||
```Nref``` vector pháp tuyến của bề mặt cần kiểm tra.
|
||||
|
||||
### Mô tả
|
||||
```faceforward()``` orients a vector to point away from a surface as defined by its normal. ```If dot(Nref, I) < 0``` faceforward returns ```N```, otherwise it returns ```-N```.
|
||||
```faceforward()``` trả về hướng của bề mặt (vector pháp tuyến) tại vị trí va chạm với tia tới. Nếu ```dot(Nref, I) < 0``` trả về ```N```, ngược lại trả về ```-N```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[reflect()](/glossary/?lan=vi&search=reflect), [refract()](/glossary/?lan=vi&search=refract)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Float
|
||||
Floating-point variable type
|
||||
Kiểu dữ liệu số thực.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -9,7 +9,7 @@ float cFloat = float(aInt);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```float``` is used for floating point values.
|
||||
```float``` lưu giá trị của số thực, bao gồm cả phần nguyên lẫn phần thập phân.
|
||||
|
||||
### Tham khảo thêm
|
||||
[void](/glossary/?lan=vi&search=void), [bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [struct](/glossary/?lan=vi&search=struct)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Floor
|
||||
Find the nearest integer less than or equal to the parameter
|
||||
Tìm số nguyên gần nhất nhỏ hơn hoặc bằng (Làm tròn xuống).
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 floor(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value to evaluate.
|
||||
```x``` số cần làm tròn xuống
|
||||
|
||||
### Mô tả
|
||||
```floor()``` returns a value equal to the nearest integer that is less than or equal to ```x```.
|
||||
```floor()``` trả về số nguyên gần nhất nhỏ hơn hoặc bằng với ```x```.
|
||||
|
||||
<div class="simpleFunction" data="y = floor(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Fract
|
||||
Compute the fractional part of the argument
|
||||
Tách phần thập phân của số thực.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 fract(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value to evaluate.
|
||||
```x``` số thực cần tách phần thập phân.
|
||||
|
||||
### Mô tả
|
||||
```fract()``` returns the fractional part of ```x```. This is calculated as ```x - floor(x)```.
|
||||
```fract()``` trả về phần thập phân của ```x``` theo công thức ```x - floor(x)```.
|
||||
|
||||
<div class="simpleFunction" data="y = fract(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## GreaterThan
|
||||
Perform a component-wise greater-than comparison of two vectors
|
||||
Thực hiện phép so sánh lớn hơn với từng cặp giá trị trong 2 vector
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -13,12 +13,12 @@ bvec4 greaterThan(ivec4 x, ivec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the first vector to be used in the comparison operation.
|
||||
```x``` Vector thứ nhất
|
||||
|
||||
```y``` specifies the second vector to be used in the comparison operation.
|
||||
```y``` Vector thứ hai
|
||||
|
||||
### Mô tả
|
||||
```greaterThan()``` returns a boolean vector in which each element ```i``` is computed as ```x[i] > y[i]```.
|
||||
```greaterThan()``` trả về một vector boolean mà thành phần thứ ```i``` là kết quả của phép so sánh ```x[i] > y[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[lessThanEqual()](/glossary/?lan=vi&search=lessThanEqual), [lessThan()](/glossary/?lan=vi&search=lessThan), [greaterThanEqual()](/glossary/?lan=vi&search=greaterThanEqual), [equal()](/glossary/?lan=vi&search=equal), [notEqual()](/glossary/?lan=vi&search=notEqual), [any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all), [not()](/glossary/?lan=vi&search=not)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## GreaterThanEqual
|
||||
Perform a component-wise greater-than-or-equal comparison of two vectors
|
||||
Thực hiện phép so sánh lớn-hơn-hoặc-bằng cho từng cặp giá trị giữa hai vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -13,12 +13,12 @@ bvec4 greaterThanEqual(ivec4 x, ivec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the first vector to be used in the comparison operation.
|
||||
```x``` Vector thứ nhất.
|
||||
|
||||
```y``` specifies the second vector to be used in the comparison operation.
|
||||
```y``` Vector thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```greaterThanEqual()``` returns a boolean vector in which each element ```i``` is computed as ```x[i] ≥ y[i]```.
|
||||
```greaterThanEqual()``` trả về một vector boolean mà thành phần thứ ```i``` là kết quả của phép so sánh ```x[i] ≥ y[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[lessThanEqual()](/glossary/?lan=vi&search=lessThanEqual), [lessThan()](/glossary/?lan=vi&search=lessThan), [greaterThan()](/glossary/?lan=vi&search=greaterThan), [equal()](/glossary/?lan=vi&search=equal), [notEqual()](/glossary/?lan=vi&search=notEqual), [any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all), [not()](/glossary/?lan=vi&search=not)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Int
|
||||
Integer data type
|
||||
Kiểu dữ liệu số nguyên.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -9,7 +9,7 @@ int cInt = int(aFloat);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```int``` is used for integer values.
|
||||
```int``` lưu giá trị của một số nguyên.
|
||||
|
||||
### Tham khảo thêm
|
||||
[void](/glossary/?lan=vi&search=void), [bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Inversesqrt
|
||||
Return the inverse of the square root of the parameter
|
||||
Phép nghịch đảo căn bậc 2.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 inversesqrt(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value of which to take the inverse of the square root.
|
||||
```x``` số cần tính nghịch đảo căn bậc 2.
|
||||
|
||||
### Mô tả
|
||||
```inversesqrt()``` returns the inverse of the square root of ```x```.
|
||||
```inversesqrt()``` trả về kết quả của biểu thức ```1 / sqrt(x)```.
|
||||
|
||||
<div class="simpleFunction" data="y = inversesqrt(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Ivec2
|
||||
2 dimensional integer vector
|
||||
Vector số nguyên 2 chiều.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -11,11 +11,10 @@ bvec2 dIvec2 = ivec2(aIvec3.x, aIvec3.y);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```ivec2``` is an integer vector with two components. It can be initialized by:
|
||||
|
||||
- Providing a scalar value for each component.
|
||||
- Providing one scalar value. This value is used for all components.
|
||||
- Providing a vector of higher dimension. The respective values are used to initialize the components.
|
||||
```ivec2``` vector số nguyên gồm 2 thành phần. Nó có thể được khởi tạo bằng các cách:
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho cả 2 thành phần
|
||||
- Lấy giá trị từ 1 vector nhiều chiều hơn. Các thành phần sẽ được khởi tạo theo thứ tự.
|
||||
|
||||
### Tham khảo thêm
|
||||
[bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4), [vec2](/glossary/?lan=vi&search=vec2), [vec3](/glossary/?lan=vi&search=vec3), [vec4](/glossary/?lan=vi&search=vec4), [mat2](/glossary/?lan=vi&search=mat2), [mat3](/glossary/?lan=vi&search=mat3), [mat4](/glossary/?lan=vi&search=mat4)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Ivec3
|
||||
3 dimensional integer vector
|
||||
Vector số nguyên 3 chiều.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,12 +14,11 @@ vec3 fIvec3 = ivec3(aIvec2.x, aIvec2.y, aInt);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```ivec3``` is an integer vector with three components. It can be initialized by:
|
||||
|
||||
- Providing a scalar value for each component.
|
||||
- Providing one scalar value. This value is used for all components.
|
||||
- Providing a vector of higher dimension. The respective values are used to initialize the components.
|
||||
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
|
||||
```ivec3``` vector số nguyên gồm 3 thành phần. Nó có thể được khởi tạo bằng các cách:
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho cả 3 thành phần
|
||||
- Lấy giá trị từ 1 vector nhiều chiều hơn. Các thành phần sẽ được khởi tạo theo thứ tự.
|
||||
- Lấy giá trị theo thứ tự lần lượt từ nhiều vector, miễn là đủ 3 thành phần.
|
||||
|
||||
### Tham khảo thêm
|
||||
[bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4), [vec2](/glossary/?lan=vi&search=vec2), [vec3](/glossary/?lan=vi&search=vec3), [vec4](/glossary/?lan=vi&search=vec4), [mat2](/glossary/?lan=vi&search=mat2), [mat3](/glossary/?lan=vi&search=mat3), [mat4](/glossary/?lan=vi&search=mat4)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Ivec4
|
||||
4 dimensional integer vector
|
||||
Vector số nguyên 4 chiều
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -11,11 +11,11 @@ vec4 dIvec4 = ivec4(aIvec2.x, aIvec2.y, aInt, aIvec3.x);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```ivec4``` is an integer vector with four components. It can be initialized by:
|
||||
```ivec4``` là một vector số nguyên gồm 4 thành phần. Nó có thể được khởi tạo bằng các cách:
|
||||
|
||||
- Providing a scalar value for each component.
|
||||
- Providing one scalar value. This value is used for all components.
|
||||
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho cả 4 thành phần
|
||||
- Lấy giá trị theo thứ tự lần lượt từ nhiều vector, miễn là đủ 4 thành phần.
|
||||
|
||||
### Tham khảo thêm
|
||||
[bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4), [vec2](/glossary/?lan=vi&search=vec2), [vec3](/glossary/?lan=vi&search=vec3), [vec4](/glossary/?lan=vi&search=vec4), [mat2](/glossary/?lan=vi&search=mat2), [mat3](/glossary/?lan=vi&search=mat3), [mat4](/glossary/?lan=vi&search=mat4)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Length
|
||||
Calculate the length of a vector
|
||||
Tính độ dài cuuar vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,13 +10,13 @@ float length(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies a vector of which to calculate the length.
|
||||
```x``` vector cần tính độ dài
|
||||
|
||||
### Mô tả
|
||||
```length()``` returns the length of the vector.
|
||||
```length()``` trả về độ dài của vector.
|
||||
|
||||
<div class="codeAndCanvas" data="../07/circle-making.frag"></div>
|
||||
|
||||
### Tham khảo thêm
|
||||
|
||||
[distance()](/glossary/?lan=vi&search=distance), [normalize()](/glossary/?lan=vi&search=normalize), [Chapter 07: Shapes](/07/)
|
||||
[distance()](/glossary/?lan=vi&search=distance), [normalize()](/glossary/?lan=vi&search=normalize), [Chương 07: Hình dạng](/07/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## LessThan
|
||||
Perform a component-wise less-than comparison of two vectors
|
||||
Thực hiện phép so sánh nhỏ-hơn giữa các cặp giá trị của 2 vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -13,12 +13,12 @@ bvec4 lessThan(ivec4 x, ivec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the first vector to be used in the comparison operation.
|
||||
```x``` Vector thứ nhất.
|
||||
|
||||
```y``` specifies the second vector to be used in the comparison operation.
|
||||
```y``` Vector thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```lessThan()``` returns a boolean vector in which each element ```i``` is computed as ```x[i] < y[i]```.
|
||||
```lessThan()``` trả về một vector boolean mà thành phần thứ ```i``` là kết quả của phép so sánh ```x[i] < y[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[lessThanEqual()](/glossary/?lan=vi&search=lessThanEqual), [greaterThan()](/glossary/?lan=vi&search=greaterThan), [greaterThanEqual()](/glossary/?lan=vi&search=greaterThanEqual), [equal()](/glossary/?lan=vi&search=equal), [notEqual()](/glossary/?lan=vi&search=notEqual), [any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all), [not()](/glossary/?lan=vi&search=not)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## LessThanEqual
|
||||
Perform a component-wise less-than-or-equal comparison of two vectors
|
||||
Thực hiện phép so sánh nhỏ-hơn-hoặc-bằng giữa các cặp giá trị của 2 vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -13,12 +13,12 @@ bvec4 lessThanEqual(ivec4 x, ivec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the first vector to be used in the comparison operation.
|
||||
```x``` Vector thứ nhất.
|
||||
|
||||
```y``` specifies the second vector to be used in the comparison operation.
|
||||
```y``` Vector thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```lessThanEqual()``` returns a boolean vector in which each element ```i``` is computed as ```x[i] ≤ y[i]```.
|
||||
```lessThanEqual()``` trả về một vector boolean mà thành phần thứ ```i``` là kết quả của phép so sánh ```x[i] ≤ y[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[lessThan()](/glossary/?lan=vi&search=lessThan), [greaterThan()](/glossary/?lan=vi&search=greaterThan), [greaterThanEqual()](/glossary/?lan=vi&search=greaterThanEqual), [equal()](/glossary/?lan=vi&search=equal), [notEqual()](/glossary/?lan=vi&search=notEqual), [any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all), [not()](/glossary/?lan=vi&search=not)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Log
|
||||
Return the natural logarithm of the parameter
|
||||
Tính logarith tự nhiên của một số
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 log(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value of which to take the natural logarithm.
|
||||
```x``` số cần tính logarith
|
||||
|
||||
### Mô tả
|
||||
```log()``` returns the natural logarithm of ```x```.
|
||||
```log()``` trả về kết quả của phép tính ```log(x)```.
|
||||
|
||||
<div class="simpleFunction" data="y = log(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Log2
|
||||
Return the base 2 logarithm of the parameter
|
||||
Tính logarith cơ số 2.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 log2(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value of which to take the base 2 logarithm.
|
||||
```x``` giá trị cần tính logarith cơ số 2.
|
||||
|
||||
### Mô tả
|
||||
```log2()``` returns the base 2 logarithm of ```x```.
|
||||
```log2()``` trả về kết quả của hàm số logarith cơ số 2 của ```x```.
|
||||
|
||||
<div class="simpleFunction" data="y = log2(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,23 @@
|
|||
## Mat2
|
||||
2x2 floating point matrix
|
||||
Ma trận số thực 2x2
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
mat2 aMat2 = mat2(1.0, 0.0, // 1. column
|
||||
0.0, 1.0); // 2. column
|
||||
mat2 aMat2 = mat2(1.0, 0.0, // Cột thứ nhất
|
||||
0.0, 1.0); // Cột thứ hai
|
||||
mat2 bMat2 = mat2(1.0);
|
||||
mat2 cMat2 = mat2(aVec2, bVec2);
|
||||
mat2 dMat2 = mat2(aVec3, aFloat);
|
||||
```
|
||||
|
||||
### Mô tả
|
||||
```mat2``` data type is compose for a 2x2 matrix of floating point. As you can see above, can be initialize in different ways:
|
||||
```mat2``` là ma trận số thực gồm 2 hàng và 2 cột. Nó có thể được khởi tạo bằng các cách:
|
||||
|
||||
- Providing a value for each component column by column.
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho các thành phần trên đường chéo chính
|
||||
- Chỉ định giá trị từng cột, mỗi cột coi như một ```vec2```
|
||||
|
||||
- Providing one value that is used for the components on the main diagonal.
|
||||
|
||||
- Providing a combination of vectors and scalars.
|
||||
|
||||
In the same way data can be accessed component-wise or column by column:
|
||||
Có thể lấy giá trị của từng thành phần trong ma trận hoặc lấy từng cột:
|
||||
|
||||
```glsl
|
||||
mat2 aMat2;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
## Mat3
|
||||
3x3 floating point matrix
|
||||
Ma trận số thực 3x3
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
mat3 aMat3 = mat3(1.0, 0.0, 0.0, // 1. column
|
||||
0.0, 1.0, 0.0, // 2. column
|
||||
0.0, 0.0, 1.0); // 3. column
|
||||
mat3 aMat3 = mat3(1.0, 0.0, 0.0, // Cột thứ 1
|
||||
0.0, 1.0, 0.0, // Cột thứ 2
|
||||
0.0, 0.0, 1.0); // Cột thứ 3
|
||||
mat3 bMat3 = mat3(1.0);
|
||||
|
||||
mat3 cMat3 = mat3(aVec3, bVec3, cVec3);
|
||||
|
|
@ -13,16 +13,13 @@ mat3 dMat3 = mat3(aVec4, aVec3, bVec4, aFloat);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```mat3``` data type is compose for a 3x3 matrix of floating point. As you can see above, can be initialize in different ways:
|
||||
```mat3``` là ma trận số thực gồm 3 hàng và 3 cột. Nó có thể được khởi tạo bằng các cách:
|
||||
|
||||
- Providing a value for each component column by column.
|
||||
|
||||
- Providing one value that is used for the components on the main diagonal.
|
||||
|
||||
- Providing a combination of vectors and scalars.
|
||||
|
||||
In the same way data can be accessed component-wise or column by column:
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho các thành phần trên đường chéo chính
|
||||
- Chỉ định giá trị từng cột, mỗi cột coi như một ```vec3```
|
||||
|
||||
Có thể lấy giá trị của từng thành phần trong ma trận hoặc lấy từng cột:
|
||||
|
||||
```glsl
|
||||
mat3 aMat3;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
## Mat4
|
||||
4x4 floating point matrix
|
||||
Ma trận số thực 4x4
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
mat4 aMat4 = mat4(1.0, 0.0, 0.0, 0.0, // 1. column
|
||||
0.0, 1.0, 0.0, 0.0, // 2. column
|
||||
0.0, 0.0, 1.0, 0.0, // 3. column
|
||||
0.0, 0.0, 0.0, 1.0); // 4. column
|
||||
mat4 aMat4 = mat4(1.0, 0.0, 0.0, 0.0, // Cột thứ 1
|
||||
0.0, 1.0, 0.0, 0.0, // Cột thứ 2
|
||||
0.0, 0.0, 1.0, 0.0, // Cột thứ 3
|
||||
0.0, 0.0, 0.0, 1.0); // Cột thứ 4
|
||||
mat4 bMat4 = mat4(1.0);
|
||||
|
||||
mat4 cMat4 = mat4(aVec4, bVec4, cVec4, dVec4);
|
||||
|
|
@ -14,15 +14,13 @@ mat4 dMat4 = mat4(aVec4, aVec3, bVec4, cVec4, aFloat);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```mat4``` data type is compose for a 4x4 matrix of floating point. As you can see above, can be initialize in different ways:
|
||||
```mat4``` là ma trận số thực gồm 4 hàng và 4 cột. Nó có thể được khởi tạo bằng các cách:
|
||||
|
||||
- Providing a value for each component column by column.
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho các thành phần trên đường chéo chính
|
||||
- Chỉ định giá trị từng cột, mỗi cột coi như một ```vec4```
|
||||
|
||||
- Providing one value that is used for the components on the main diagonal.
|
||||
|
||||
- Providing a combination of vectors and scalars.
|
||||
|
||||
In the same way data can be accessed component-wise or column by column:
|
||||
Có thể lấy giá trị của từng thành phần trong ma trận hoặc lấy từng cột:
|
||||
|
||||
```glsl
|
||||
aMat4[3][3] = 1.0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## MatrixCompMult
|
||||
Perform a component-wise multiplication of two matrices
|
||||
Nhân từng cặp giá trị tương ứng giữa 2 ma trận.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -9,12 +9,12 @@ mat4 matrixCompMult(mat4 x, mat4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the first matrix multiplicand.
|
||||
```x``` Ma trận thứ nhất.
|
||||
|
||||
```y``` specifies the second matrix multiplicand.
|
||||
```y``` Ma trận thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```matrixCompMult()``` performs a component-wise multiplication of two matrices, yielding a result matrix where each component, ```result[i][j]``` is computed as the scalar product of ```x[i][j]``` and ```y[i][j]```.
|
||||
```matrixCompMult()``` trả về ma trận kết quả, với từng thành phần ```result[i][j]``` là kết quả của phép tính ```x[i][j] * y[i][j]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[Chapter 08: Matrix](../08/)
|
||||
[Chương 08: Ma trận](../08/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Max
|
||||
Return the greater of two values
|
||||
Tìm giá trị lớn hơn giữa 2 giá trị.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,12 +14,12 @@ vec4 max(vec4 x, float y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the first value to compare.
|
||||
```x``` Giá trị thứ nhất.
|
||||
|
||||
```y``` specify the second value to compare.
|
||||
```y``` Giá trị thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```max()``` returns the maximum of the two parameters. It returns ```y``` if ```y``` is greater than ```x```, otherwise it returns ```x```.
|
||||
```max()``` thực hiện phép so sánh giữa từng cặp giá trị trong hai vector ```x``` và ```y``` để chọn ra các số lớn hơn ở mỗi cặp giá trị.
|
||||
|
||||
<div class="simpleFunction" data="y = max(x,0.5); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Min
|
||||
Return the lesser of two values
|
||||
Tìm giá trị nhỏ hơn giữa 2 giá trị.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,12 +14,12 @@ vec4 min(vec4 x, float y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the first value to compare.
|
||||
```x``` Giá trị thứ nhất.
|
||||
|
||||
```y``` specify the second value to compare.
|
||||
```y``` Giá trị thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```min()``` returns the minimum of the two parameters. It returns ```y``` if ```y``` is less than ```x```, otherwise it returns ```x```.
|
||||
```min()``` thực hiện phép so sánh giữa từng cặp giá trị trong hai vector ```x``` và ```y``` để chọn ra các số nhỏ hơn ở mỗi cặp giá trị.
|
||||
|
||||
<div class="simpleFunction" data="y = min(x,0.5); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Mix
|
||||
Constrain a value to lie between two further values
|
||||
Nội suy tuyến tính giữa 2 giá trị
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,14 +14,14 @@ vec4 mix(vec4 x, vec4 y, float a)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` Specify the start of the range in which to interpolate.
|
||||
```x``` Giá trị nhỏ hơn trong khoảng cần nội suy.
|
||||
|
||||
```y``` Specify the end of the range in which to interpolate.
|
||||
```y``` Giá trị lớn hơn trong khoảng cần nội suy.
|
||||
|
||||
```a``` Specify the value to use to interpolate between x and y.
|
||||
```a``` Tỉ lệ nội suy.
|
||||
|
||||
### Mô tả
|
||||
```mix()``` performs a linear interpolation between ```x``` and ```y``` using ```a``` to weight between them. The return value is computed as ```x×(1−a)+y×a```.
|
||||
```mix()``` nội suy giá trị giữa ```x``` và ```y``` sử dụng ```a``` làm tỉ lệ nội suy / trọng số. Kết quả của phép tính ```x×(1−a)+y×a```.
|
||||
|
||||
<div class="codeAndCanvas" data="../06/mix.frag"></div>
|
||||
|
||||
|
|
@ -29,4 +29,4 @@ vec4 mix(vec4 x, vec4 y, float a)
|
|||
|
||||
### Tham khảo thêm
|
||||
|
||||
[min](/glossary/?lan=vi&search=min), [max](/glossary/?lan=vi&search=max), [Chapter 06: Color](/06/)
|
||||
[min](/glossary/?lan=vi&search=min), [max](/glossary/?lan=vi&search=max), [Chương 6: Màu sắc](/06/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Mod
|
||||
Compute value of one parameter modulo another
|
||||
Phép tính phần dư
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,11 +14,11 @@ vec4 mod(vec4 x, float y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value to evaluate.
|
||||
```y``` specify the value to obtain the modulo of.
|
||||
```x``` số bị chia.
|
||||
```y``` số chia.
|
||||
|
||||
### Mô tả
|
||||
```mod()``` returns the value of ```x``` modulo ```y```. This is computed as ```x - y * floor(x/y)```.
|
||||
```mod()``` trả về kết quả là phần dư của phép chia ```x``` cho ```y```, theo công thức ```x - y * floor(x/y)```.
|
||||
|
||||
<div class="simpleFunction" data="y = mod(x,1.5); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Normalize
|
||||
Calculate the unit vector in the same direction as the input vector
|
||||
Chuẩn hóa vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 normalize(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the vector to normalize.
|
||||
```x``` Vector cần chuẩn hóa.
|
||||
|
||||
### Mô tả
|
||||
```normalize()``` returns a vector with the same direction as its parameter, ```x```, but with length 1.
|
||||
```normalize()``` trả về một vector cùng chiều với ```x``` và có độ dài bằng 1.
|
||||
|
||||
### Tham khảo thêm
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Not
|
||||
Logically invert a boolean vector
|
||||
Phép logic nghịch đảo.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -9,10 +9,10 @@ bvec4 not(bvec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the vector to be inverted.
|
||||
```x``` giá trị boolean cần đảo ngược.
|
||||
|
||||
### Mô tả
|
||||
```not()``` logically inverts the boolean vector ```x```. It returns a new boolean vector for which each element ```i``` is computed as ```!x[i]```.
|
||||
```not()``` đảo ngược ```x```. Kết quả là một vector boolean mà thành phần thứ ```i``` là kết quả của phép logic ```!x[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## NotEqual
|
||||
Perform a component-wise not-equal-to comparison of two vectors
|
||||
Thực hiện phép so sánh không-bằng giữa các cặp giá trị của 2 vector.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -13,12 +13,12 @@ bvec4 notEqual(ivec4 x, ivec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specifies the first vector to be used in the comparison operation.
|
||||
```x``` Vector thứ nhất.
|
||||
|
||||
```y``` specifies the second vector to be used in the comparison operation.
|
||||
```y``` Vector thứ hai.
|
||||
|
||||
### Mô tả
|
||||
```notEqual()``` returns a boolean vector in which each element ```i``` is computed as ```x[i] != y[i]```.
|
||||
```notEqual()``` trả về một vector boolean mà thành phần thứ ```i``` là kết quả của phép so sánh ```x[i] != y[i]```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[lessThanEqual()](/glossary/?lan=vi&search=lessThanEqual), [lessThan()](/glossary/?lan=vi&search=lessThan), [greaterThanEqual()](/glossary/?lan=vi&search=greaterThanEqual), [greaterThan()](/glossary/?lan=vi&search=greaterThan), [equal()](/glossary/?lan=vi&search=equal), [any()](/glossary/?lan=vi&search=any), [all()](/glossary/?lan=vi&search=all), [not()](/glossary/?lan=vi&search=not)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Pow
|
||||
Return the value of the first parameter raised to the power of the second.
|
||||
Lũy thừa.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,12 +10,12 @@ vec4 pow(vec4 x, vec4 y)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value to raise to the power ```y```.
|
||||
```x``` cơ số.
|
||||
|
||||
```y``` specify the power to which to raise ```x```.
|
||||
```y``` số mũ.
|
||||
|
||||
### Mô tả
|
||||
```pow()``` returns the value of ```x``` raised to the ```y``` power.
|
||||
```pow()``` trả về kết quả của phép toán ```x``` mũ ```y```
|
||||
|
||||
<div class="simpleFunction" data="y = pow(x,3.0); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Radians
|
||||
Convert a quantity in degrees to radians
|
||||
Chuyển đổi góc từ đơn vị độ sang radian.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 radians(vec4 degrees)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```degrees``` specify the quantity, in degrees, to be converted to radians.
|
||||
```degrees``` góc tính bằng độ, cần quy đổi.
|
||||
|
||||
### Mô tả
|
||||
```radians()``` converts a quantity, specified in degrees into radians. That is, the return value is ```(PI * degrees)/180```.
|
||||
```radians()``` trả về góc (tính bằng radian) theo công thức ```(PI * degrees)/180```.
|
||||
|
||||
### Tham khảo thêm
|
||||
[degrees](/glossary/?lan=vi&search=degrees)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Reflect
|
||||
Calculate the reflection direction for an incident vector
|
||||
Tính vector phản xạ khi tia tới va chạm với một bề mặt.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,14 +10,14 @@ vec4 reflect(vec4 I, vec4 N)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```I``` specifies the incident vector.
|
||||
```I``` Vector tới (incident vector), là vector chỉ hướng tia va chạm với bề mặt.
|
||||
|
||||
```N``` specifies the normal vector.or.
|
||||
```N``` Vector pháp tuyến của bề mặt tại điểm va chạm, là vector vuông góc với bề mặt.
|
||||
|
||||
### Mô tả
|
||||
For a given incident vector ```I``` and surface normal ```N``` reflect returns the reflection direction calculated as ```I - 2.0 * dot(N, I) * N```.
|
||||
Cho vector tới ```I``` và vector pháp tuyến của bề mặt va chạm ```N```, vector phản xạ chỉ hướng phản xạ được tính theo công thức ```I - 2.0 * dot(N, I) * N```.
|
||||
|
||||
```N``` should be normalized in order to achieve the desired result.
|
||||
```N``` nên được chuẩn hóa (normalize) để có kết quả chính xác nhất.
|
||||
|
||||
### Tham khảo thêm
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Refract
|
||||
Calculate the refraction direction for an incident vector
|
||||
Tính vector khúc xạ khi tia tới va chạm với một bề mặt.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,24 +10,23 @@ vec4 refract(vec4 I, vec4 N, float eta)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```I``` specifies the incident vector.
|
||||
```I``` Vector tới (incident vector), là vector chỉ hướng tia va chạm với bề mặt.
|
||||
|
||||
```N``` specifies the normal vector.
|
||||
```N``` Vector pháp tuyến của bề mặt tại điểm va chạm, là vector vuông góc với bề mặt.
|
||||
|
||||
```eta``` specifies the ratio of indices of refraction.
|
||||
```eta``` Tỉ lệ chiết suất giữa hai môi trường.
|
||||
|
||||
### Mô tả
|
||||
For a given incident vector ```I```, surface normal ```N``` and ratio of indices of refraction, ```eta```, refract returns the refraction vector, ```R```.
|
||||
Cho vector tới ```I```, vector pháp tuyến của bề mặt va chạm ```N``` và , vector khúc xạ chỉ hướng khúc xạ sẽ được tính theo công thức dưới đây và trả về:
|
||||
|
||||
```R``` is calculated as:
|
||||
```glsl
|
||||
k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
|
||||
if (k < 0.0)
|
||||
R = genType(0.0); // or genDType(0.0)
|
||||
R = genType(0.0); // hoặc genDType(0.0)
|
||||
else
|
||||
R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;
|
||||
```
|
||||
The input parameters ```I``` and ```N``` should be normalized in order to achieve the desired result.
|
||||
```I``` và ```N``` nên được chuẩn hóa (normalize) để có kết quả chính xác nhất.
|
||||
|
||||
### Tham khảo thêm
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Sign
|
||||
Extract the sign of the parameter
|
||||
Trả về dấu của một số.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 sign(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value from which to extract the sign.
|
||||
```x``` số cần kiểm tra dấu âm dương.
|
||||
|
||||
### Mô tả
|
||||
```sign()``` returns -1.0 if x is less than 0.0, 0.0 if x is equal to 0.0, and +1.0 if x is greater than 0.0.
|
||||
```sign()``` trả về -1.0 nếu x < 0.0, 0.0 nếu x = 0.0, và +1.0 nếu x > 0.0.
|
||||
|
||||
<div class="simpleFunction" data="y = sign(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Sin
|
||||
Return the sine of the parameter
|
||||
Hàm sin
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 sin(vec4 angle)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```angle``` specify the quantity, in radians, of which to return the sine.
|
||||
```angle``` góc cần tính sin (theo đơn vị radian)
|
||||
|
||||
### Mô tả
|
||||
```sin()``` returns the trigonometric sine of angle.
|
||||
```sin()``` trả về kết quả của biểu thức ```sin( angle )```
|
||||
|
||||
<div class="simpleFunction" data="y = sin(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Smoothstep
|
||||
Perform Hermite interpolation between two values
|
||||
Thực hiện phép nội suy Hermitte giữa 0 và 1 theo tỉ lệ.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,21 +14,21 @@ vec4 smoothstep(float edge0, float edge1, vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```edge0``` specifies the value of the lower edge of the Hermite function.
|
||||
```edge0``` cận dưới trên trục hoành của hàm Hermitte
|
||||
|
||||
```edge1``` specifies the value of the upper edge of the Hermite function.
|
||||
```edge1``` cận trên trên trục hoành của hàm Hermitte
|
||||
|
||||
```x``` specifies the source value for interpolation.
|
||||
```x``` giá trị trên trục hoành
|
||||
|
||||
### Mô tả
|
||||
```smoothstep()``` performs smooth Hermite interpolation between ```0``` and ```1``` when ```edge0 < x < edge1```. This is useful in cases where a threshold function with a smooth transition is desired. ```smoothstep()``` is equivalent to:
|
||||
```smoothstep()``` thực hiện phép nội suy giữa ```0``` và ```1``` nếu ```edge0 < x < edge1```. Nếu ```x < edge0``` thì trả về ```0```, còn nếu ```x > edge1``` thì trả về ```1```. Hàm này hay dùng khi cần chuyển tiếp giữa 2 vùng mà không muốn đột ngột thay đổi giá trị. Hàm ```smoothstep()``` tương đương với:
|
||||
```glsl
|
||||
genType t; /* Or genDType t; */
|
||||
genType t; /* Hoặc genDType t; */
|
||||
t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
|
||||
return t * t * (3.0 - 2.0 * t);
|
||||
```
|
||||
|
||||
Results are undefined ```if edge0 ≥ edge1```.
|
||||
Nếu ```edge0 ≥ edge1``` thì kết quả không xác định được.
|
||||
|
||||
<div class="simpleFunction" data="y = smoothstep(0.0,1.0,x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Sqrt
|
||||
Return the square root of the parameter
|
||||
Tính căn bậc hai của một số.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 sqrt(vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```x``` specify the value of which to take the square root.
|
||||
```x``` Số cần tính căn bậc 2.
|
||||
|
||||
### Mô tả
|
||||
```sqrt()``` returns the square root of ```x```.
|
||||
```sqrt()``` trả về căn bậc 2 của ```x```.
|
||||
|
||||
<div class="simpleFunction" data="y = sqrt(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Step
|
||||
Generate a step function by comparing two values
|
||||
Kiểm tra một biến có nhỏ hơn ngưỡng nhất định không.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,14 +14,14 @@ vec4 step(float edge, vec4 x)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```edge``` specifies the location of the edge of the step function.
|
||||
```edge``` ngưỡng cận biên.
|
||||
|
||||
```x``` specify the value to be used to generate the step function.
|
||||
```x``` giá trị cần kiểm tra xem có nằm trong ngưỡng cận biên không.
|
||||
|
||||
### Mô tả
|
||||
```step()``` generates a step function by comparing ```x``` to ```edge```.
|
||||
```step()``` so sánh ```x``` với ```edge```.
|
||||
|
||||
For element ```i``` of the return value, ```0.0``` is returned ```if x[i] < edge[i]```, and ```1.0``` is returned otherwise.
|
||||
Với mỗi thành phần thứ ```i``` trong vector kết quả, nó sẽ nhận giá trị ```0.0``` nếu ```x[i] < edge[i]```, và ngược lại nhận giá trị ```1.0```.
|
||||
|
||||
<div class="simpleFunction" data="y = step(0.5,x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Struct
|
||||
Structure variable type
|
||||
Kiểu dữ liệu cấu trúc - struct.
|
||||
|
||||
### Ví dụ
|
||||
```glsl
|
||||
|
|
@ -17,4 +17,4 @@ newMaterial = matStruct(vec4(0.1, 0.1, 0.1, 1.0),
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```struct``` declare a custom data structures based on standard types. A constructor for the structure with the same name is created automatically. The declaration of a variable (in this case "newMaterial") is optional.
|
||||
```struct``` là một kiểu dữ liệu tự do được tạo nên từ các biến dữ liệu có kiểu cơ bản. Với mỗi struct, một hàm tạo cùng tên sẽ được tạo tự động. Không nhất thiết phải khởi tạo các giá trị khi dùng hàm tạo.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Tan
|
||||
Return the tangent of the parameter
|
||||
Tính tan của một góc lượng giác (đơn vị radian)
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -10,10 +10,10 @@ vec4 tan(vec4 angle)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```angle``` specify the quantity, in radians, of which to return the tangent.
|
||||
```angle``` góc cần tính tan (đơn vị radian)
|
||||
|
||||
### Mô tả
|
||||
```tan()``` returns the trigonometric tangent of angle.
|
||||
```tan()``` tính tan của góc ```angle```
|
||||
|
||||
<div class="simpleFunction" data="y = tan(x); "></div>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Texture2D
|
||||
Retrieves texels from a texture
|
||||
Lấy màu của một vị trí bất kỳ trên texture có định dạng cube (6 mặt của khối lập phương).
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -8,18 +8,18 @@ vec4 texture2D(sampler2D sampler, vec2 coord, float bias)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```sampler``` specifies the sampler to which the texture from which texels will be retrieved is bound.
|
||||
```sampler``` là sampler đã khởi tạo với texture, sẽ giúp ta lấy được màu tại tọa độ mong muốn.
|
||||
|
||||
```coord``` specifies the texture coordinates at which texture will be sampled.
|
||||
```coord``` tọa độ vị trí cần lấy màu trên texture.
|
||||
|
||||
```bias``` specifies an optional bias to be applied during level-of-detail computation.
|
||||
```bias``` sai số cho phép nếu áp dụng cơ chế Level-Of-Detail.
|
||||
|
||||
### Mô tả
|
||||
The texture2D function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type sampler2D and one input parameter of the type ```vec2``` : sampler, the uniform the texture is bound to, and coord, the 2-dimensional coordinates of the texel to look up.
|
||||
Kết quả của hàm là 1 texel, tức màu tại vị trí chỉ định trên texture.
|
||||
|
||||
There is an optional third input parameter of the type float: bias. After calculating the appropriate level of detail for a texture with mipmaps the bias is added before the actual texture lookup operation is executed.
|
||||
Tham số thứ ba không bắt buộc. Sau khi tính toán xong Level-Of-Detail phù hợp dựa trên các cấp mipmap, ```bias``` sẽ được dùng để tìm tọa độ trên texture.
|
||||
|
||||
Side note: On iOS devices texture lookup functionality is only available in the fragment shader.
|
||||
Chú ý: Trên các thiết bị iOS, hàm này chỉ có thể dùng trong fragment shader.
|
||||
|
||||
### Tham khảo thêm
|
||||
[textureCube](/glossary/?lan=vi&search=textureCube)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Texture2D
|
||||
Retrieves texels from a texture
|
||||
## TextureCube
|
||||
Lấy màu của một vị trí bất kỳ trên texture có định dạng cube (6 mặt của khối lập phương).
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -8,18 +8,18 @@ vec4 textureCube(samplerCube sampler, vec3 coord, float bias)
|
|||
```
|
||||
|
||||
### Các tham số
|
||||
```sampler``` specifies the sampler to which the texture from which texels will be retrieved is bound.
|
||||
```sampler``` là sampler đã khởi tạo với texture, sẽ giúp ta lấy được màu tại tọa độ mong muốn.
|
||||
|
||||
```coord``` specifies the texture coordinates at which texture will be sampled.
|
||||
```coord``` tọa độ vị trí cần lấy màu trên texture.
|
||||
|
||||
```bias``` specifies an optional bias to be applied during level-of-detail computation.
|
||||
```bias``` sai số cho phép nếu áp dụng cơ chế Level-Of-Detail.
|
||||
|
||||
### Mô tả
|
||||
The textureCube function returns a texel, i.e. the (color) value of the texture for the given coordinates. The function has one input parameter of the type samplerCube and one input parameter of the type vec3 : sampler, the uniform the texture is bound to, and coord, the 3-dimensional coordinates of the texel to look up.
|
||||
Kết quả của hàm là 1 texel, tức màu tại vị trí chỉ định trên texture.
|
||||
|
||||
There is an optional third input parameter of the type float: bias. After calculating the appropriate level of detail for a texture with mipmaps the bias is added before the actual texture lookup operation is executed.
|
||||
Tham số thứ ba không bắt buộc. Sau khi tính toán xong Level-Of-Detail phù hợp dựa trên các cấp mipmap, ```bias``` sẽ được dùng để tìm tọa độ trên texture.
|
||||
|
||||
Side note: On iOS devices texture lookup functionality is only available in the fragment shader.
|
||||
Chú ý: Trên các thiết bị iOS, hàm này chỉ có thể dùng trong fragment shader.
|
||||
|
||||
### Tham khảo thêm
|
||||
[texture2D](/glossary/?lan=vi&search=texture2D)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Uniform
|
||||
Uniform variable qualifier.
|
||||
Qualifier đánh dấu biến chứa dữ liệu được gửi từ CPU sang GPU.
|
||||
|
||||
### Ví dụ
|
||||
```glsl
|
||||
|
|
@ -7,9 +7,9 @@ uniform vec4 direction;
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```uniform``` variables contain read-only data shared from WebGL/OpenGL environment to a vertex or fragment shader.
|
||||
Các biến ```uniform``` được gửi từ CPU sang cả 2 chương trình vertex shader và fragment shader chạy trên GPU. Giá trị của các biến này không thể thay đổi.
|
||||
|
||||
The value is per primitive, so is useful for variables which remain constant along a primitive, frame or scene.
|
||||
_The value is per primitive, so is useful for variables which remain constant along a primitive, frame or scene._
|
||||
|
||||
### Tham khảo thêm
|
||||
[attribute](/glossary/?lan=vi&search=attribute), [const](/glossary/?lan=vi&search=const), [varying](/glossary/?lan=vi&search=varying), [Chương 03: Uniform](/03/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Varying
|
||||
Varying variable qualifier.
|
||||
Qualifier đánh dấu biến chứa dữ liệu đã được vertex shader xử lý và chuyển tiếp sang cho fragment shader xử lý tiếp.
|
||||
|
||||
### Ví dụ
|
||||
```glsl
|
||||
|
|
@ -7,9 +7,9 @@ varying vec3 position;
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```varying``` variables contain data shared from a vertex shader to a fragment shader.
|
||||
```varying``` đánh dấu biến chứa dữ liệu đã được vertex shader xử lý và chuyển tiếp sang cho fragment shader xử lý tiếp.
|
||||
|
||||
The variable must be written in the vertex shader and the read-only value in the fragment shader is then interpolated from the vertices which make up the fragment.
|
||||
Biến này có thể được chỉnh sửa bởi vertex shader, nhưng phải là biến read-only đối với fragment shader.
|
||||
|
||||
### Tham khảo thêm
|
||||
[attribute](/glossary/?lan=vi&search=attribute), [const](/glossary/?lan=vi&search=const), [uniform](/glossary/?lan=vi&search=uniform), [Chương 03: Uniform](/03/?lan=vi)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Vec2
|
||||
2 dimensional floating point vector
|
||||
Vector số nguyên 2 chiều.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -11,11 +11,10 @@ vec2 dVec2 = vec2(aVec3.x, aVec3.y);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```vec2``` is a floating point vector with two components. It can be initialized by:
|
||||
|
||||
- Providing a scalar value for each component.
|
||||
- Providing one scalar value. This value is used for all components.
|
||||
- Providing a vector of higher dimension. The respective values are used to initialize the components.
|
||||
```vec2``` vector số nguyên gồm 2 thành phần. Nó có thể được khởi tạo bằng các cách:
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho cả 2 thành phần
|
||||
- Lấy giá trị từ 1 vector nhiều chiều hơn. Các thành phần sẽ được khởi tạo theo thứ tự.
|
||||
|
||||
### Tham khảo thêm
|
||||
[bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4), [vec2](/glossary/?lan=vi&search=vec2), [vec3](/glossary/?lan=vi&search=vec3), [vec4](/glossary/?lan=vi&search=vec4), [mat2](/glossary/?lan=vi&search=mat2), [mat3](/glossary/?lan=vi&search=mat3), [mat4](/glossary/?lan=vi&search=mat4)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Vec3
|
||||
3 dimensional floating point vector
|
||||
Vector số thực 3 chiều.
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -14,12 +14,11 @@ vec3 fVec3 = vec3(aVec2.x, aVec2.y, aFloat);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```vec3``` is a floating point vector with three components. It can be initialized by:
|
||||
|
||||
- Providing a scalar value for each component.
|
||||
- Providing one scalar value. This value is used for all components.
|
||||
- Providing a vector of higher dimension. The respective values are used to initialize the components.
|
||||
- Providing a combination of vectors and/or scalars. The respective values are used to initialize the vector. The arguments of the constructor must have at least as many components as the vector that is initialized.
|
||||
```vec3``` vector số thực gồm 3 thành phần. Nó có thể được khởi tạo bằng các cách:
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho cả 3 thành phần
|
||||
- Lấy giá trị từ 1 vector nhiều chiều hơn. Các thành phần sẽ được khởi tạo theo thứ tự.
|
||||
- Lấy giá trị theo thứ tự lần lượt từ nhiều vector, miễn là đủ 3 thành phần.
|
||||
|
||||
### Tham khảo thêm
|
||||
[bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4), [vec2](/glossary/?lan=vi&search=vec2), [vec3](/glossary/?lan=vi&search=vec3), [vec4](/glossary/?lan=vi&search=vec4), [mat2](/glossary/?lan=vi&search=mat2), [mat3](/glossary/?lan=vi&search=mat3), [mat4](/glossary/?lan=vi&search=mat4)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Vec4
|
||||
4 dimensional floating point vector
|
||||
Vector số thực 4 chiều
|
||||
|
||||
### Các phiên bản
|
||||
```glsl
|
||||
|
|
@ -11,11 +11,11 @@ vec4 dVec4 = vec4(aBvec2.x, aBvec2.y, aFloat, aBvec3.x);
|
|||
```
|
||||
|
||||
### Mô tả
|
||||
```vec4``` is a floating point vector with four components. It can be initialized by:
|
||||
```vec4``` là vector số thực gồm 4 thành phần. Nó có thể được khởi tạo bằng các cách:
|
||||
|
||||
- Providing a scalar value for each component.
|
||||
- Providing one scalar value. This value is used for all components.
|
||||
- Providing a combination of vectors and scalars. The respective values are used to initialize the components. The arguments of the constructor must have at least as many components as the vector that is initialized.
|
||||
- Chỉ định giá trị của từng thành phần
|
||||
- Chỉ định 1 giá trị chung cho cả 4 thành phần
|
||||
- Lấy giá trị theo thứ tự lần lượt từ nhiều vector, miễn là đủ 4 thành phần.
|
||||
|
||||
### Tham khảo thêm
|
||||
[bool](/glossary/?lan=vi&search=bool), [int](/glossary/?lan=vi&search=int), [float](/glossary/?lan=vi&search=float), [bvec2](/glossary/?lan=vi&search=bvec2), [bvec3](/glossary/?lan=vi&search=bvec3), [bvec4](/glossary/?lan=vi&search=bvec4), [ivec2](/glossary/?lan=vi&search=ivec2), [ivec3](/glossary/?lan=vi&search=ivec3), [ivec4](/glossary/?lan=vi&search=ivec4), [vec2](/glossary/?lan=vi&search=vec2), [vec3](/glossary/?lan=vi&search=vec3), [vec4](/glossary/?lan=vi&search=vec4), [mat2](/glossary/?lan=vi&search=mat2), [mat3](/glossary/?lan=vi&search=mat3), [mat4](/glossary/?lan=vi&search=mat4)
|
||||
|
|
|
|||
Loading…
Reference in New Issue