UUSL Data Structure
Data Fields#
Data has the following fields (values in world space has _w postfix):
struct Data {
float depth;
float3 position;
float3 view;
float3 normal;
float3 reflection;
// world space values
float3 view_w;
float3 normal_w;
float3 reflection_w;
float3 sky_reflect;
float2 screen_coord;
float dotNV;
float dielectric;
float gloss;
};
Data Functions#
Data dataDefault ( ) #
Default constructor for Data structure. It creates an instance with default (not null) values.Return value
Data structure with default (not null) values.void dataSetPosition ( inout Data Data, float3 pos ) #
Calculates position, depth and view values for given Data struct.Arguments
- inout Data Data - Data structure to fill.
- float3 pos - Position vector.
void dataCalculateWorldSpace ( Data Data ) #
Calculates world view, normal, reflection in world space by using corresponding values of given Data struct.Arguments
- Data Data - Data structure to fill.
void dataSetGbuffer ( inout Data Data, GBuffer gbuffer ) #
Sets Data's structure normal, dielectric and gloss values by using corresponding values of given GBuffer instance.Arguments
- inout Data Data - Data structure.
- GBuffer gbuffer - GBuffer instance with necessary values to be set.
void dataCalculateAll ( inout Data data, GBuffer gbuffer, float3 pos, float2 screen_coord ) #
Calculates all values for Data struct.Arguments
- inout Data data - Data structure to be filled with calculated values.
- GBuffer gbuffer - GBuffer struct.
- float3 pos - Position vector.
- float2 screen_coord - Screen coordinates.
Usage Example#
To use Data structure in your shader's code, you should define and initialize the Data structure and fill it.
The following example shows the way of creating Data structure and calculating its values.
/* ... */
// input structure for fragment shader
STRUCT(FRAGMENT_IN)
INIT_POSITION
INIT_IN(float4,0)
INIT_IN(float3,1)
INIT_IN(float3x3,2)
#ifdef USE_ALPHA_FADE && ALPHA_FADE
INIT_IN(float,9)
#endif
END
/* ... */
// in the main function of fragment shader
// GBuffer
GBuffer gbuffer;
/* fill the GBuffer struct */
Data data;
dataCalculateAll(data,gbuffer,IN_DATA(1),IN_POSITION.xy);
/* ... */
Last update:
2021-12-13
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)