UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
Программирование
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes

UUSL Data Structure

UUSL has Data structure which offers you a handy access to values.

Data Fields#

Data has the following fields (values in world space has _w postfix):

UUSL
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.

UUSL
/* ... */
// 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: 03.07.2017