UUSL数据结构
资料栏位#
Data具有以下字段(世界空间中的值具有_w后缀):
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功能#
Data dataDefault ( ) #
Data结构的默认构造函数。它使用默认值(非null)创建一个实例。返回值
Data结构,具有默认值(非null)。void dataSetPosition ( inout Data Data, float3 pos ) #
为给定的Data结构计算位置,深度和视图值。参数
- inout Data Data - 要填充的Data结构。
- float3 pos - 位置向量。
void dataCalculateWorldSpace ( Data Data ) #
通过使用给定的Data结构的相应值来计算世界空间中的世界观,法线和反射。参数
- Data Data - 要填充的Data结构。
void dataSetGbuffer ( inout Data Data, GBuffer gbuffer ) #
通过使用给定GBuffer实例的相应值来设置数据的结构正常,介电和光泽度值。参数
- inout Data Data - Data结构。
- GBuffer gbuffer - GBuffer实例,需要设置必要的值。
void dataCalculateAll ( inout Data data, GBuffer gbuffer, float3 pos, float2 screen_coord ) #
计算数据结构的所有值。参数
- inout Data data - Data结构要填充计算所得的值。
- GBuffer gbuffer - GBuffer结构。
- float3 pos - 位置向量。
- float2 screen_coord - 屏幕坐标。
使用范例#
要在着色器代码中使用Data结构,应定义并初始化Data结构并填充它。
以下示例显示了创建数据结构和计算其值的方法。
/* ... */
// 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);
/* ... */
最新更新:
2023-12-19
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)