UUSL Data Types and Common Intrinsic Functions
This documentation article contains information about data types, functions, pre-defined variables and other features of the UUSL. This information can be used as the reference document for writing shaders.
To start using UUSL functions, include the core/shaders/common/common.h file.
#include <core/shaders/common/common.h>
For fragment shader functions, use the core/shaders/common/fragment.h file.
Data Types
UUSL | OpenGL | Direct3D | Description |
---|---|---|---|
int2 | ivec2 | int2 | A vector with two 32-bit signed integer components. |
int3 | ivec3 | int3 | A vector with three 32-bit signed integer components. |
int4 | ivec4 | int4 | A vector with four 32-bit signed integer components. |
uint2 | uvec4 | int2 | A vector with two 32-bit unsigned integer components. |
uint3 | uvec4 | uint3 | A vector with three 32-bit unsigned integer components. |
uint4 | uvec4 | uint4 | A vector with four 32-bit unsigned integer components. |
float | float | float | A 32-bit floating point value. |
float2 | vec2 | float2 | A vector with two 32-bit floating point value components. |
float3 | vec3 | float3 | A vector with three 32-bit floating point value components. |
float4 | vec4 | float4 | A vector with four 32-bit floating point value components. |
float2x2 | mat2 | float2x2 | A matrix with 2 rows, 2 column of 32-bit floating point value components. |
float3x3 | mat3 | float3x3 | A matrix with 3 rows, 3 column of 32-bit floating point value components. |
float4x4 | mat4 | float4x4 | A matrix with 4 rows, 4 column of 32-bit floating point value components. |
UUSL | OpenGL | Direct3D | Description |
---|---|---|---|
TYPE_R | float | float | A 32-bit floating point value. |
TYPE_RG | float2 | float2 | A vector with two 32-bit floating point value components. |
TYPE_RGB | float3 | float3 | A vector with three 32-bit floating point value components. |
TYPE_RGBA | float4 | float4 | A vector with four 32-bit floating point value components. |
UUSL | OpenGL | Direct3D | Description |
---|---|---|---|
FLOAT(X) | float(X) | X | Converts the value to float. |
FLOAT2(X) | vec2(X) | X | Converts the value to the two-component vector. |
FLOAT3(X) | vec3(X) | X | Converts the value to the three-component vector. |
FLOAT4(X) | vec4(X) | X | Converts the value to the four-component vector. |
INT(X) | int(X) | X | Converts the value to int. |
INT2(X) | int2(X) | X | Converts the value to the two component vector. |
INT3(X) | int3(X) | X | Converts the value to the three-component vector. |
INT4(X) | int4(X) | X | Converts the value to the three-component vector. |
BOOL2(X) | bvec2(X) | X | Converts the value to the two component boolean vector. |
BOOL3(X) | bvec3(X) | X | Converts the value to the three-component boolean vector. |
BOOL4(X) | bvec4(X) | X | Converts the value to the three-component boolean vector. |
Predefined Values
UUSL | Value |
---|---|
float_srgb | 1.0f / 2.2f |
float_isrgb | 2.2f |
float4_zero | float4(0.0f,0.0f,0.0f,0.0f) |
float4_one | float4(1.0f,1.0f,1.0f,1.0f) |
float4_neg_one | float4(-1.0f,-1.0f,-1.0f,-1.0f) |
float4_srgb | float4(1.0f / 2.2f,1.0f / 2.2f,1.0f / 2.2f,1.0f / 2.2f) |
float4_isrgb | float4(2.2f,2.2f,2.2f,2.2f) |
float3_zero | float3(0.0f,0.0f,0.0f) |
float3_one | float3(1.0f,1.0f,1.0f) |
float3_neg_one | float3(-1.0f,-1.0f,-1.0f) |
float3_up | float3(0.0f,0.0f,1.0f) |
float3_srgb | float3(1.0f / 2.2f,1.0f / 2.2f,1.0f / 2.2f) |
float3_isrgb | float3(2.2f,2.2f,2.2f) |
float2_zero | float3(2.2f,2.2f,2.2f) |
float2_one | float2(1.0f,1.0f) |
float2_neg_one | float2(-1.0f,-1.0f) |
float2_srgb | float2(1.0f / 2.2f,1.0f / 2.2f) |
float2_isrgb | float2(2.2f,2.2f) |
int4_zero | int4(0,0,0,0) |
int4_one | int4(1,1,1,1) |
int4_neg_one | int4(-1,-1,-1,-1) |
int3_zero | int3(0,0,0) |
int3_one | int3(1,1,1) |
int3_neg_one | int3(-1,-1,-1) |
int2_zero | int2(0,0) |
int2_one | int2(1,1) |
int2_neg_one | int2(-1,-1) |
PI | 3.141592654f |
PI2 | 6.283185308f |
PI05 | 1.570796327f |
LOG2 | 0.693147181f |
LOG10 | 2.302585093f |
SQRT2 | 1.414213562f |
EPSILON | 1e-6f |
INFINITY | 1e+9f |
Main Function
Void Main Function
To start and end the void Main function of the fragment shader (when you don't need to provide the output color value but depth), use the following instructions:
MAIN_VOID_BEGIN(STRUCT_IN)
<your code here>
MAIN_VOID_END
This code is equivalent to:
void main() {
<your code here>
}
void main(STRUCT_IN IN) {
<your code here>
}
Main Function with Return Value
To start and end the Main function with return value, use the following instructions:
MAIN_BEGIN(STRUCT_IN,STRUCT_OUT)
<your code here>
MAIN_END
This code is equivalent to:
void main() {
<your code here>
}
STRUCT_OUT main(STRUCT_IN IN) {
STRUCT_OUT OUT;
<your code here>
return OUT; }
Geometry Shader Main Function
To start and end the Main function of the geometry shader, use the following instructions:
MAIN_GEOM_BEGIN(STRUCT_OUT,STRUCT_IN)
<your code here>
END_GEOM
This code is equivalent to:
layout(TYPE_GEOM_IN) in;
layout(TYPE_GEOM_OUT,max_vertices = MAX_VERTICES_GEOM) out;
void main() {
<your code here>
}
[maxvertexcount(MAX_VERTICES_GEOM)]
void main(TYPE_GEOM_IN STRUCT_IN IN[COUNT_GEOM_IN],inout TYPE_GEOM_OUT<STRUCT_OUT> stream) {
STRUCT_OUT OUT;
<your code here>
}
Static Variables and Arrays
Static Variables
To define a static variable, use the following syntax:
STATICVAR <your var>
This is equal to the following GLSL and HLSL commands:
const <your var>
static const <your var>
Static Arrays
To work with static arrays by using UUSL, use the following instructions:
STATICARRAY(TYPE,NAME,SIZE)
<your array members>
ENDARRAY
- TYPE - the type of the array (float, etc.).
- NAME - the name of the array.
- SIZE - the size of the array.
This code block is equivalent to:
TYPE NAME [SIZE] = TYPE[](<your array members>);
static const TYPE NAME [SIZE] = {<your array members>};
Blending Presets
UUSL contains blending presets. When you specify the type of blending in material, the USSL wrapper automatically defines a new definition, that you can use in your shader:
Blending type | UUSL |
---|---|
BLEND_SRC_FUNC_SRC_ALPHA && BLEND_DEST_FUNC_ONE_MINUS_SRC_ALPHA | BLEND_ALPHABLEND |
BLEND_SRC_FUNC_ONE && BLEND_DEST_FUNC_ONE | BLEND_ADDITIVE |
BLEND_SRC_FUNC_DEST_COLOR && BLEND_DEST_FUNC_ZERO | BLEND_MULTIPLICATIVE |
BLEND_SRC_FUNC_NONE && BLEND_DEST_FUNC_NONE | BLEND_NONE |
HLSL features
HLSL Flow Control Attributes
UUSL | OpenGL | Direct3D | Description |
---|---|---|---|
branch | - | [branch] | Performs branching using control flow instructions. |
call | - | [call] | Prevents inlining of a function. |
flatten | - | [flatten] | Performs branching using conditional move instructions. |
ifAll | - | [ifAll] | Executes the conditional part of an if statement when the condition is true for all threads on which the current shader is running. |
ifAny | - | [ifAny] | Executes the conditional part of an if statement when the condition is true for any thread on which the current shader is running. |
isolate | - | [isolate] | Optimizes the specified HLSL code independently of the surrounding code. |
loop | - | [loop] | Gives preference to flow control constructs. |
maxexports | - | [maxexports] | Specifies the maximum number of export instructions that will execute along any path from the entry point to an exit. |
maxInstructionCount | - | [maxInstructionCount] | Sets the maximum number of instructions available to a shader. |
maxtempreg | - | [maxtempreg] | Restricts temporary register usage to the number of registers specified. Generates a compiler error if unsuccessful. |
noExpressionOptimizations | - | [noExpressionOptimizations] | Avoids optimization of expressions. |
predicate | - | [predicate] | Performs branching by using predication. |
predicateBlock | - | [predicateBlock] | Performs branching by using predicated exec blocks. |
reduceTempRegUsage | - | [reduceTempRegUsage] | Restricts temporary register usage to the number of registers specified. Generates a compiler warning if unsuccessful. |
removeUnusedInputs | - | [removeUnusedInputs] | Removes unused interpolator inputs from pixel shaders. |
sampreg | - | [sampreg] | Sets the ranges of pixel sampler and vertex sampler registers used by the compiler. |
unroll | - | [unroll] | Avoids flow control constructs. |
unused | - | [unused] | Suppresses warnings about unused shader parameters. |
xps | - | [xps] | Specifies that all vertex fetch operations are done after the last vfetch instruction. This instruction is used to reduce the latency back to the command processor to free the vertex buffer. |
earlydepthstencil | - | [earlydepthstencil] | Forces depth-stencil testing before a shader executes. Doesn't work with custom depth. |
Interpolation Modifiers
UUSL | OpenGL | Direct3D | Description |
---|---|---|---|
MODIFER_LINEAR | - | linear | Interpolate between shader inputs; linear is the default value if no interpolation modifier is specified. |
MODIFER_CENTROID | - | centroid | Interpolate between samples that are somewhere within the covered area of the pixel (this may require extrapolating end points from a pixel center). Centroid sampling may improve antialiasing if a pixel is partially covered (even if the pixel center is not covered). The centroid modifier must be combined with either the linear or noperspective modifier. |
MODIFER_NOINTERPOLATION | - | nointerpolation | Do not interpolate. |
MODIFER_NOPERSPECTIVE | - | noperspective | Do not perform perspective-correction during interpolation. The noperspective modifier can be combined with the centroid modifier. |
MODIFER_SAMPLE | - | sample | Interpolate at sample location rather than at the pixel center. This causes the pixel shader to execute per-sample rather than per-pixel. |
See Also
See also the article on Interpolation Modifiers.
Constants and Structs
In USSL structures is the way to organize the bunch of input and output data.
To start using structures in your shader code, use the following instructions:
STRUCT(NAME)
<your data>
END
- NAME - the name of the struct.
Here is an example of vertex shader input structure:
// Input vertex data
STRUCT(VERTEX_IN)
INIT_ATTRIBUTE(float4,0,POSITION) // Vertex position
INIT_ATTRIBUTE(float4,1,TEXCOORD0) // Vertex texcoord (uv)
INIT_ATTRIBUTE(float4,2,TEXCOORD1) // Vertex basis tangent
INIT_ATTRIBUTE(float4,3,TEXCOORD2) // Vertex color
END
After that, you should pass the VERTEX_IN structure to the main function of the vertex shader.
For using constant buffer in your shader code, use the following instructions:
CBUFFER(NAME)
<your data>
END
- NAME - the name of the cbuffer.
Here is an example of using constant buffer:
CBUFFER(parameters)
UNIFORM float grayscale_power;
END
If you defined this parameter in the material, you'll be able to specify this value.
See Also
- How we use CBUFFER instruction in the tutorial on shaders for post-process pass.
Shader Export
To export shader, use the following command:
EXPORT_SHADER(FILE)
- FILE - The name of the file.
This command exports the shader program into a file: for Direct3D the file will have an .hlsl extension, for OpenGL the file will have an .glsl extension.
The command expands all of the predefined UUSL syntax and creates shader files in native languages for both graphic APIs.
Common Intrinsic Functions
fmod (X, Y)
Returns the floating-point remainder of x/y.Equivalents
mod(X,Y)
fmod(X,Y)
Arguments
- X - The dividend value.
- Y - The divisor value.
frac (value)
Returns the fractional (or decimal) part of x; which is greater than or equal to 0 and less than 1.Equivalents
fract(value)
frac(value)
Arguments
- value - The specified value.
lerp (X, Y, value)
Performs a linear interpolation.Equivalents
mix(X,Y,value)
lerp(X,Y,value)
Arguments
- X - The first value.
- Y - The second value.
- value - A value that linearly interpolates between the x parameter and the y parameter.
rsqrt (value)
Returns the reciprocal of the square root of the specified value.Equivalents
inversesqrt(value)
rsqrt(value)
Arguments
- value - The specified value.
saturate (value)
Clamps the specified value within the range of 0 to 1.Equivalents
clamp(value,0.0f,1.0f)
saturate(value)
Arguments
- value - The specified value.
ddx (value)
Returns the partial derivative of the specified value with respect to the screen-space x-coordinate.Equivalents
dFdx(value)
ddx(value)
Arguments
- value - The specified value.
ddy (value)
Returns the partial derivative of the specified value with respect to the screen-space y-coordinate.Equivalents
dFdy(value)
ddy(value)
Arguments
- value - The specified value.
rcp (value)
Calculates a fast, approximate, per-component reciprocal.Equivalents
(1.0f / (value))
rcp(value)
Arguments
- value - The specified value.
equal (X, Y)
Performs a component-wise equal-to comparison of two vectors.Equivalents
equal(X,Y)
(X == Y)
Arguments
- X - The first specified value.
- Y - The second specified value.
greaterThan (X, Y)
Performs a component-wise greater-than comparison of two vectors.Equivalents
greaterThan(X,Y)
(X > Y)
Arguments
- X - The first specified value.
- Y - The second specified value.
atan2 (X, Y)
Returns the arctangent of two values (x,y).Equivalents
atan(X,Y)
atan2(X,Y)
Arguments
- X - The first specified value.
- Y - The second specified value.
any (value)
Determines if any components of the specified value are non-zero.Equivalents
(value)
any(value)
Arguments
- value - The specified value.
float max2 (value)
Selects the greater of the first two vector components.Equivalents
max(value.r,value.g)
max(value.r,value.g)
Arguments
- value - The specified vector (can be float2, float3 or float4 vector).
Return value
The maximum value.float max3 (value)
Selects the greater of the first three vector components.Equivalents
max(max(value.r,value.g),value.b)
max(max(value.r,value.g),value.b)
Arguments
- value - The specified vector (can be float3 or float4).
Return value
The maximum value.float max4 (float4 value)
Selects the greater of the four vector components.Equivalents
max(max(max(value.r,value.g),value.b),value.a)
max(max(max(value.r,value.g),value.b),value.a)
Arguments
- float4 value - The specified vector.
Return value
The maximum value.float min2 (value)
Selects the lesser of the first two vector components.Equivalents
min(value.r,value.g)
min(value.r,value.g)
Arguments
- value - The specified vector (can be float2, float3 or float4 vector).
Return value
The minimum value.float min3 (value)
Selects the lesser of the first three vector components.Equivalents
min(min(value.r,value.g),value.b)
min(min(value.r,value.g),value.b)
Arguments
- value - The specified vector (can be float3 or float4 vector).
Return value
The minimum value.float min4 (float4 value)
Selects the lesser of the four vector components.Equivalents
min(min(min(value.r,value.g),value.b),value.a)
min(min(min(value.r,value.g),value.b),value.a)
Arguments
- float4 value - The specified vector.
Return value
The minimum value.pow2 (value)
Returns squared value.Equivalents
value * value
value * value
Arguments
- value - The specified value to be powered (can be float, float2, float3 or float4.
Return value
Squared value (can be float, float2, float3 or float4).float nrand (float2 seed)
Returns the random value within the range of [0;1].Equivalents
frac(sin(dot(seed,float2(12.9898f,78.233f))) * 43758.5453f)
frac(sin(dot(seed,float2(12.9898f,78.233f))) * 43758.5453f)
Arguments
- float2 seed - The random seed.
float2 nrand (float2 seed_0, float2 seed_1)
Returns the float2 vector with random values within the range of [0;1].Arguments
- float2 seed_0 - The first random seed.
- float2 seed_1 - The second random seed.
float2 nrand2 (float2 seed)
Returns the random value within the range of [0;1] (For the second seed, the function shifts the vector: float2(x,y) -> float2(y,x))Arguments
- float2 seed - The random seed.
float nrandTiled (float2 seed_0, flaot tiled)
Returns the random value within the range of [0;1] divided by the tiled seed.Arguments
- float2 seed_0 - The first random seed.
- flaot tiled - The seed of tiling (the number should be the power of two).
float2 nrandTiled (float2 seed_0, float2 seed_1, float tiled)
Returns the float2 vector with random values within the range of [0;1] divided by the tiled seed.Arguments
- float2 seed_0 - The first random seed.
- float2 seed_1 - The second random seed.
- float tiled - The seed of tiling (the number should be the power of two).
float2 nrand2Tiled (float2 seed, float tiled)
Returns the float2 vector with random values within the range of [0;1] divided by the tiled seed (For the second seed, the function shifts the vector: float2(x,y) -> float2(y,x))Arguments
- float2 seed - The random seed.
- float tiled - The seed of tiling (the number should be the power of two).
float nrandTemporal (float2 seed_0, flaot tiled)
Returns the value (that changed each frame) within the range of [0;1] divided by the tiled seed.Arguments
- float2 seed_0 - The first random seed.
- flaot tiled - The seed of tiling (the number should be the power of two).
float2 nrandTemporal (float2 seed_0, float2 seed_1, float tiled)
Returns the float2 vector with random values (that changed each frame) within the range of [0;1] divided by the tiled seed.Arguments
- float2 seed_0 - The first random seed.
- float2 seed_1 - The second random seed.
- float tiled - The seed of tiling (the number should be the power of two).
float2 nrand2Temporal (float2 seed, float tiled)
Returns the float2 vector with random values (that changed each frame) within the range of [0;1] divided by the tiled seed (For the second seed, the function shifts the vector: float2(x,y) -> float2(y,x))Arguments
- float2 seed - The random seed.
- float tiled - The seed of tiling (the number should be the power of two).
float nrandTAA (float2 seed_0, flaot tiled)
Returns the value (that changed each frame) within the range of [0;1] divided by the tiled seed.Arguments
- float2 seed_0 - The first random seed.
- flaot tiled - The seed of tiling (the number should be the power of two).
float2 nrandTAA (float2 seed_0, float2 seed_1, float tiled)
Returns the float2 vector with random values (that changed each frame) within the range of [0;1] divided by the tiled seed.Arguments
- float2 seed_0 - The first random seed.
- float2 seed_1 - The second random seed.
- float tiled - The seed of tiling (the number should be the power of two).
float2 nrand2TAA (float2 seed, float tiled)
Returns the float2 vector with random values (that changed each frame) within the range of [0;1] divided by the tiled seed (For the second seed, the function shifts the vector: float2(x,y) -> float2(y,x))Arguments
- float2 seed - The random seed.
- float tiled - The seed of tiling (the number should be the power of two).
dotFixed (X, Y)
Returns the dot product of two vectors within the range of 0 to 1.Equivalents
saturate(dot(X,Y))
saturate(dot(X,Y)))
Arguments
- X - The first specified vector.
- Y - The second specified vector.
lerpFixed (X, Y, FACTOR)
Performs a linear interpolation of two vectors with the factor in the range of 0 to 1.Equivalents
lerp(X,Y,saturate(FACTOR))
lerp(X,Y,saturate(FACTOR))
Arguments
- X - The first specified vector.
- Y - The second specified vector.
- FACTOR - A value that linearly interpolates between the x parameter and the y parameter.
float4 getPosition (vertex)
Returns the projected position of the vertex.Arguments
- vertex - The first specified vertex (float4 or float3 type).
Return value
The projected position of the vertex.float3 getViewDirection (screen_position)
Returns the view direction.float3((position + s_perspective.zw) / s_perspective.xy,-1.0f);
float3((position + s_perspective.zw) / s_perspective.xy,-1.0f);
Arguments
- screen_position - Position (float2, float3 or float3 type).
Return value
The view direction.void getTangentBasis (float4 basis, float3 tangent, float3 binormal, float3 normal)
Returns the tangent basis.// Get normals
float3 tangent,binormal,normal;
// Getting normal in object-space
getTangentBasis(IN_ATTRIBUTE(2),tangent,binormal,normal);
// Transform object-space TBN into camera-space TBN
normal = normalize(mul3(row_0,row_1,row_2,normal));
tangent = normalize(mul3(row_0,row_1,row_2,tangent));
binormal = normalize(mul3(row_0,row_1,row_2,binormal));
Arguments
- float4 basis - The first specified vertex.
- float3 tangent - The first specified vertex.
- float3 binormal - The first specified vertex.
- float3 normal - The first specified vertex.
float3 mul3 (float4x4 matrix, float3 vector)
Performs the vector * matrix multiplication.Arguments
- float4x4 matrix - The 4x4 matrix.
- float3 vector - The 3-component vector.
Return value
The result of multiplication.float3 mul3 (float3 vector, float4x4 matrix)
Performs the matrix * vector multiplication.Arguments
- float3 vector - The 3-component vector.
- float4x4 matrix - The 4x4 matrix.
Return value
The result of multiplication.float3 mul3 (float4 row_0, float4 row_1, float4 row_2, float3 vector)
Performs the matrix * vector multiplication.Arguments
- float4 row_0 - The first row of the matrix
- float4 row_1 - The second row of the matrix
- float4 row_2 - The third row of the matrix
- float3 vector - The 3-component vector.
Return value
The result of multiplication.float4 mul4 (float4x4 matrix, float3 vector)
Performs the matrix * vector multiplication.(m * float4(v,1.0f)).xyz;
(m * float4(v,1.0f)).xyz;
Arguments
- float4x4 matrix - The 4x4 matrix.
- float3 vector - The 3-component vector.
Return value
The result of multiplication.float4 mul4 (float4x4 matrix, float4 vector)
Performs the matrix * vector multiplication.Arguments
- float4x4 matrix - The 4x4 matrix.
- float4 vector - The 4-component vector.
Return value
The result of multiplication.float4 mul4 (float4 row_0, float4 row_1, float4 row_2, float3 vector)
Performs the matrix * vector multiplication.float4(dot(row_0,v),dot(row_1,v),dot(row_2,v),v.w);
float4(dot(row_0,v),dot(row_1,v),dot(row_2,v),v.w);
Arguments
- float4 row_0 - The first row of the matrix
- float4 row_1 - The second row of the matrix
- float4 row_2 - The third row of the matrix
- float3 vector - The 4-component vector.
Return value
The result of multiplication.Fragment Shader Functions
SET_DEPTH (value)
Sets the depth value.Arguments
- value - Depth value.
SET_VOLUMETRIC (volumetric)
Sets the volumetric value.Arguments
- volumetric - Volumetric value.
SET_DIFFUSE (value)
Sets the volumetric value.Arguments
- value - Diffuse value.
SET_MICROFIBER (value)
Sets the microfiber value.Arguments
- value - Microfiber value.
SET_NORMAL (value)
Sets the normal value.Arguments
- value - Normal value.
SET_GLOSS (value)
Sets the gloss value.Arguments
- value - .
SET_SPECULAR (value)
Sets the specular value.Arguments
- value - .
SET_TRANSLUCENT (value)
Sets the translucent value.Arguments
- value - Translucent value.
SET_OCCLUSION (value)
Sets the occlusion value.Arguments
- value - Occlusion value.
SET_LIGHT_MAP (value)
Sets the lightmap.Arguments
- value - Lightmap value.
SET_DECAL_MASK (value)
Sets the decal mask.Arguments
- value - Decal mask value.
SET_VELOCITY (value)
Sets the velocity value.Arguments
- value - Velocity value.
SET_ALPHA (value)
Sets the velocity value.Arguments
- value - Velocity value.
float GET_DEFERRED_DEPTH (TEX_DEPTH, COORD)
Gets the deferred depth value.Arguments
- TEX_DEPTH - Depth texture slot.
- COORD - UV coordinates.
float FETCH_DEFERRED_DEPTH (TEX_DEPTH, COORD)
Fetches the deferred depth value.Arguments
- TEX_DEPTH - Depth texture slot.
- COORD - UV coordinates.
Scattering Functions
Here is an example of scattering functions usage:
#ifdef USE_HAZE
#ifdef USE_HAZE_SCATTERING
float4 haze = hazeScattering(depth,camera_dir,TEXTURE_OUT_3(TEX_BASE_LUT,TEX_MIE_SUN_LUT,TEX_MIE_MOON_LUT));
#elif USE_HAZE_SOLID
float4 haze = hazeSolid(depth);
#endif
OUT_COLOR.rgb = OUT_COLOR.rgb * haze.a + haze.rgb;
#endif
// forward
#ifdef USE_HAZE && !STAR_AMBIENT
OUT_COLOR = hazeForward(OUT_COLOR,depth,camera_dir,TEXTURE_OUT_3(TEX_BASE_LUT,TEX_MIE_SUN_LUT,TEX_MIE_MOON_LUT));
#endif
float4 hazeScattering (float depth, float3 camera_dir, TEXTURE_IN_3 (base,mie_sun,mie_moon))
Calculates the haze in the scattering mode.Arguments
- float depth - Depth value.
- float3 camera_dir - Camera direction vector.
- TEXTURE_IN_3 (base,mie_sun,mie_moon) - Set of 3 LUT textures: base, mie sun and mie moon.
Return value
Haze vector.float4 hazeForward (float4 color, float depth, float3 camera_dir, TEXTURE_IN_3 (base,mie_sun,mie_moon))
Calculates the haze for objects rendered in the forward mode.Arguments
- float4 color - Color
- float depth - Depth value.
- float3 camera_dir - Camera direction vector.
- TEXTURE_IN_3 (base,mie_sun,mie_moon) - Set of 3 LUT textures: base, mie sun and mie moon.
Return value
Haze vector.float hazeAlpha (float depth)
Calculates transparency alpha value of the haze.Arguments
- float depth - Depth value.
Return value
Haze alpha value.float hazeAlpha (float3 position)
Calculates transparency alpha value of the haze.Arguments
- float3 position - Position.
Return value
Haze alpha value.float hazeAlpha (float4 position)
Calculates transparency alpha value of the haze.Arguments
- float4 position - Position.
Return value
Haze alpha value.float4 hazeSolid (float depth)
Calculates completely solid haze.Arguments
- float depth - Depth value.
Return value
Haze solid vector.float4 hazeSolid (float position)
Calculates completely solid haze.Arguments
- float position - Position.
Return value
Haze solid vector.float4 hazeSolid (float position)
Calculates completely solid haze.Arguments
- float position - Position.
Return value
Haze solid vector.float4 hazeForwardSimple (float4 color, float depth)
Calculates haze for objects rendered in the forward mode, can be used in the vertex shader, turns objects to transparency.Arguments
- float4 color - Color vector.
- float depth - Depth value.
Return value
Haze solid vector.float4 hazeForwardSimple (float4 color, float3 position)
Calculates haze for objects rendered in the forward mode, can be used in the vertex shader, turns objects to transparency.Arguments
- float4 color - Color vector.
- float3 position - Position.
Return value
Haze solid vector.float4 hazeForwardSimple (float4 color, float4 position)
Calculates haze for objects rendered in the forward mode, can be used in the vertex shader, turns objects to transparency.Arguments
- float4 color - Color vector.
- float4 position - Position.