A memory slot that fits into a ConstantBuffer. The slot fills entries within the buffer.
More...
|
| enum | DATA_TYPE {
DATA_TYPE::UNKNOWN = 0,
DATA_TYPE::VECTOR,
DATA_TYPE::MATRIX,
DATA_TYPE::CAM_CORNERS_WORLD,
DATA_TYPE::CAM_CORNERS_VIEW,
DATA_TYPE::TARGET_SIZE,
DATA_TYPE::PROJECTION_PARAMS,
DATA_TYPE::TEXTURE_SIZE,
DATA_TYPE::VIEW_MATRIX,
DATA_TYPE::VIEW_MATRIX_INV,
DATA_TYPE::PROJ_MATRIX,
DATA_TYPE::PROJ_MATRIX_INV,
DATA_TYPE::CAM_POSITION,
DATA_TYPE::CAM_DIRECTION_WORLD,
DATA_TYPE::TIME,
DATA_TYPE::CUSTOM
} |
| |
A memory slot that fits into a ConstantBuffer. The slot fills entries within the buffer.
This is done per pass. This means that these slots are made to be called before a full pass rendering is done. It is opposed to the ShaderInstanceMemorySlot, which is called once per renderable during a pass.
◆ DATA_TYPE
Available filling type for the slots.
| Enumerator |
|---|
| UNKNOWN | Unknown place holder.
|
| VECTOR | Writes a vector (nkFloat4).
|
| MATRIX | Writes a matrix (nkFloat4x4).
|
| CAM_CORNERS_WORLD | Writes the cam corners direction in world space (nkFloat4 [4]).
|
| CAM_CORNERS_VIEW | Writes the cam corners direction in view space (nkFloat4 [4]).
|
| TARGET_SIZE | Writes the active render target size (nkInt4).
|
| PROJECTION_PARAMS | Writes the projection parameters (nkFloat4).
|
| TEXTURE_SIZE | Writes a given texture's size (nkInt4).
|
| VIEW_MATRIX | Writes the active view matrix (nkFloat4x4).
|
| VIEW_MATRIX_INV | Writes the active inverse view matrix (nkFloat4x4).
|
| PROJ_MATRIX | Writes the active projection matrix (nkFloat4x4).
|
| PROJ_MATRIX_INV | Writes the active inverse projection matrix (nkFloat4x4).
|
| CAM_POSITION | Writes the active camera position (nkFloat4).
|
| CAM_DIRECTION_WORLD | Writes the active camera direction (nkFloat4).
|
| TIME | Writes information about time (nkFloat4).
|
| CUSTOM | Uses a custom slot made by external code.
|
◆ ShaderPassMemorySlot()
| nkGraphics::ShaderPassMemorySlot::ShaderPassMemorySlot |
( |
System * |
system | ) |
|
|
noexcept |
◆ ~ShaderPassMemorySlot()
| virtual nkGraphics::ShaderPassMemorySlot::~ShaderPassMemorySlot |
( |
| ) |
|
|
virtual |
◆ getData()
| void* nkGraphics::ShaderPassMemorySlot::getData |
( |
| ) |
const |
- Returns
- The data allocated for the tracking.
◆ getDataSize()
| virtual unsigned int nkGraphics::ShaderPassMemorySlot::getDataSize |
( |
| ) |
const |
|
virtual |
- Returns
- The written size, in bytes.
◆ getDataTypeAsString()
◆ getType()
| DATA_TYPE nkGraphics::ShaderPassMemorySlot::getType |
( |
| ) |
const |
◆ getDataAsVector()
| nkMaths::Vector* nkGraphics::ShaderPassMemorySlot::getDataAsVector |
( |
| ) |
const |
- Returns
- The data already casted as a vector. To be used when the slot type is DATA_TYPE::VECTOR.
◆ getDataAsMatrix()
| nkMaths::Matrix* nkGraphics::ShaderPassMemorySlot::getDataAsMatrix |
( |
| ) |
const |
- Returns
- The data already casted as a matrix. To be used when the slot type is DATA_TYPE::MATRIX.
◆ setFromVector()
| void nkGraphics::ShaderPassMemorySlot::setFromVector |
( |
const nkMaths::Vector & |
data | ) |
|
Changes the slot to fill a vector. In shader code, can be received in a nkFloat4 (float4/vec4).
nkConstantBufferDecl(VertexConstants, 0)
{
nkFloat4 vector ;
}
- Parameters
-
◆ setFromMatrix()
| void nkGraphics::ShaderPassMemorySlot::setFromMatrix |
( |
const nkMaths::Matrix & |
data | ) |
|
Changes the slot to fill a matrix. In shader code, can be received in a nkFloat4x4 (float4x4, matrix).
nkConstantBufferDecl(VertexConstants, 0)
{
nkFloat4x4 mat ;
}
- Parameters
-
◆ setAsCamCornersWorld()
| void nkGraphics::ShaderPassMemorySlot::setAsCamCornersWorld |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the camera corners directions, in world space. The directions are non normalized and go from the near to the far. In shader code, can be received in a nkFloat4 [4] (float4/vec4), an array fitting the order in which the post processing square mesh is defined. As such, it can be indexed within the vertex stage using the vertex ID attribute during a post processing pass.
nkConstantBufferDecl(VertexConstants, 0)
{
nkFloat4 CAM_WORLD_CORNERS [4] ;
}
...
Output main (uint vertexId : SV_VertexID)
{
...
output.direction = CAM_WORLD_CORNERS[vertexId] ;
...
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsCamCornersView()
| void nkGraphics::ShaderPassMemorySlot::setAsCamCornersView |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the camera corners directions, in view space. The directions are Z normalized, which means the Z component will be 1.0, and the other components will be expressed relative to that. This allows to directly use the vector with near, far, and linear distance values from the camera and have positions snap to the rendering plane without distortion. In shader code, can be received in a nkFloat4 [4] (float4/vec4), an array fitting the order in which the post processing square mesh is defined. As such, it can be indexed within the vertex stage using the vertex ID attribute during a post processing pass.
nkConstantBufferDecl(VertexConstants, 0)
{
nkFloat4 CAM_VIEW_CORNERS [4] ;
}
...
Output main (uint vertexId : SV_VertexID)
{
...
output.direction = CAM_VIEW_CORNERS[vertexId] ;
...
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsTargetSize()
| void nkGraphics::ShaderPassMemorySlot::setAsTargetSize |
( |
| ) |
|
Changes the slot to fill the active render target size, in pixels. In shader code, can be received in a nkInt4 (int4/ivec4).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkInt4 targetSize ;
}
#define TARGET_WIDTH targetSize.x
#define TARGET_HEIGHT targetSize.y
#define TARGET_DEPTH targetSize.z
#define TARGET_MIPS targetSize.w
◆ setAsProjectionParameters()
| void nkGraphics::ShaderPassMemorySlot::setAsProjectionParameters |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the projection parameters of a camera (see Camera::getProjectionParameters() on how to use them). In shader code, can be received in a nkFloat4 (float4/vec4).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4 projectionParams ;
}
#define PROJ_A projectionParams.x
#define PROJ_B projectionParams.y
#define PROJ_NEAR projectionParams.z
#define PROJ_FAR projectionParams.w
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsViewMatrix()
| void nkGraphics::ShaderPassMemorySlot::setAsViewMatrix |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the view matrix of a camera. In shader code, can be received in a nkFloat4x4 (float4x4/matrix).
The view and projection matrix are provided as row-major, meaning they can be used like :
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4x4 view ;
nkFloat4x4 projection ;
}
...
nkFloat4x4 mvp = mul(projection, mul(view, world)) ;
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsViewMatrixInv()
| void nkGraphics::ShaderPassMemorySlot::setAsViewMatrixInv |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the inverse view matrix of a camera. in shader code, can be received in a nkFloat4x4 (float4x4/matrix).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4x4 viewInverse ;
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsProjectionMatrix()
| void nkGraphics::ShaderPassMemorySlot::setAsProjectionMatrix |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the projection matrix of a camera. In shader code, can be received in a nkFloat4x4 (float4x4/matrix).
The view and projection matrix are provided as row-major, meaning they can be used like :
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4x4 view ;
nkFloat4x4 projection ;
}
...
float4x4 mvp = mul(projection, mul(view, world)) ;
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsProjectionMatrixInv()
| void nkGraphics::ShaderPassMemorySlot::setAsProjectionMatrixInv |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the inverse projection matrix of a camera. In shader code, can be received in a nkFloat4x4 (float4x4/matrix).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4x4 projectionInverse ;
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsViewProjectionMatrix()
| void nkGraphics::ShaderPassMemorySlot::setAsViewProjectionMatrix |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the precomputed (proj * view) matrix. In shader code, can be received in a nkFloat4x4 (float4x4/matrix).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4x4 viewProjectionMatrix ;
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsCameraPosition()
| void nkGraphics::ShaderPassMemorySlot::setAsCameraPosition |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the position of a camera, in world space. In shader code, can be received in a nkFloat4 (float4/vec4).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4 cameraPosition ;
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsCameraDirectionWorld()
| void nkGraphics::ShaderPassMemorySlot::setAsCameraDirectionWorld |
( |
Camera * |
forcedCamera = nullptr | ) |
|
Changes the slot to fill the direction (front) of the camera in world space. In shader code, can be received in a nkFloat4 (float4/vec4).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4 cameraDirection ;
}
- Parameters
-
| forcedCamera | The camera to retrieve information from. If left nullptr, will fetch the active camera. |
◆ setAsTextureSize()
| void nkGraphics::ShaderPassMemorySlot::setAsTextureSize |
( |
Texture * |
tex | ) |
|
Changes the slot to fill a texture size, in pixels. In shader code, can be received in a nkInt4 (int4/ivec4).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkInt4 texSize ;
}
#define TEX_WIDTH texSize.x
#define TEX_HEIGHT texSize.y
#define TEX_DEPTH texSize.z
#define TEX_MIPS texSize.w
◆ setAsTime()
| void nkGraphics::ShaderPassMemorySlot::setAsTime |
( |
unsigned int |
modulo | ) |
|
Changes the slot to fill time information. In shader code, can be received in a nkFloat4 (float4/vec4).
nkConstantBufferDecl(MyConstantBuffer, 0)
{
nkFloat4 timeInfo ;
}
#define TIME_MODULO_VAL timeInfo.x
#define TIME timeInfo.y
#define TIME_DELTA timeInfo.z
#define TIME_UNUSED timeInfo.w
- Parameters
-
| modulo | The modulo looping time of the timer. |
◆ setAsCustom()
Changes the slot to request the data to be filled by a custom slot.
- Parameters
-
| slot | The slot to delegate to. |
◆ exportClassToTree()
| virtual void nkGraphics::ShaderPassMemorySlot::exportClassToTree |
( |
nkExport::Node * |
rootNode | ) |
|
|
overridevirtual |
Exports an item into a tree describing its structure and its data.
- Parameters
-
| rootNode | The node into which the object has to write its related information. |
Reimplemented from nkGraphics::ShaderMemorySlot.
◆ importClassFromTree()
| virtual void nkGraphics::ShaderPassMemorySlot::importClassFromTree |
( |
nkExport::Node * |
rootNode | ) |
|
|
overridevirtual |
Imports information from a tree which is supposed to describe its structure and data.
- Parameters
-
| rootNode | The root node of the tree holding the information. |
Implements nkExport::Exportable.
The documentation for this class was generated from the following file: