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
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
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

Unigine::Shader Class

Header: #include <UnigineShader.h>

Interface for shader manipulation. Shader is an interface for loading shaders, setting parameter values, binding graphic context.

To get loaded shader programs, use special methods for corresponding Direct3D11 shaders or use getGLProgramID() to get the OpenGL shaders.

Shader class provides a lot of methods to set parameters (or arrays of parameters) to shader programs.

Shader Class

Members


void * getD3D11ComputeShader ( ) #

Returns Direct3D11 compute shader.

void * getD3D11ControlShader ( ) #

Returns Direct3D11 control shader.

void * getD3D11EvaluateShader ( ) #

Returns Direct3D11 evaluate shader.

void * getD3D11FragmentShader ( ) #

Returns Direct3D11 fragment shader.

void * getD3D11GeometryShader ( ) #

Returns Direct3D11 geometry shader.

void * getD3D11VertexShader ( ) #

Returns Direct3D11 vertex shader.

int getGLProgramID ( ) #

Returns OpenGL program identifier.

void setParameter ( int id, const void * src, int size ) #

Sets shader parameter value by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • const void * src - Parameter pointer.
  • int size - Parameter size in bytes.

void setParameter ( const char * name, const void * src, int size ) #

Sets shader parameter value by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • const void * src - Parameter pointer.
  • int size - Parameter size in bytes.

void setParameterBool ( int id, int value ) #

Sets shader boolean parameter value by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • int value - Parameter value.

void setParameterBool ( const char * name, int value ) #

Sets shader boolean parameter value by using given parameter name.

Arguments

  • const char * name - Parameter identifier.
  • int value - Parameter value.

void setParameterDouble ( int id, double[] value ) #

Sets shader double parameter value by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • double[] value - Parameter value to be set.

void setParameterDouble ( const char * name, double[] value ) #

Sets shader double parameter value by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • double[] value - Parameter value to be set.

void setParameterDoubleArray ( int id, double[] value, int num ) #

Sets shader double array parameter values by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • double[] value - Parameter value to be set.
  • int num - The size of float vector.

void setParameterDoubleArray ( const char * name, double[] value, int num ) #

Sets shader double array parameter values by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • double[] value - Parameter value to be set.
  • int num - The size of float vector.

void setParameterFloat ( int id, float[] value ) #

Sets shader float parameter value by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • float[] value - Parameter value to be set.

void setParameterFloat ( const char * name, float[] value ) #

Sets shader float parameter value by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • float[] value - Parameter value to be set.

void setParameterFloatArray ( int id, float[] value, int num ) #

Sets shader float array parameter values by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • float[] value - Parameter value to be set.
  • int num - The size of float vector.

void setParameterFloatArray ( const char * name, float[] value, int num ) #

Sets shader float array parameter values by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • float[] value - Parameter value to be set.
  • int num - The size of float vector.

void setParameterInt ( int id, int[] value ) #

Sets shader integer parameter value by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • int[] value - Parameter value to be set.

void setParameterInt ( const char * name, int[] value ) #

Sets shader integer parameter value by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • int[] value - Parameter value to be set.

void setParameterUInt ( int id, uint[] value ) #

Sets shader unsigned integer parameter value by using given parameter id.

Arguments

  • int id - Parameter identifier.
  • uint[] value - Parameter value to be set.

void setParameterUInt ( const char * name, uint[] value ) #

Sets shader unsigned integer parameter value by using given parameter name.

Arguments

  • const char * name - Parameter name.
  • uint[] value - Parameter value to be set.

void bind ( ) #

Binds shader.

void clear ( ) #

Clears shader.

int compile ( ) #

Compiles shader.

Return value

1 if the shader compiled successfully; otherwise, 0.

Ptr<Shader> create ( ) #

Default shader constructor.

Return value

Pointer to the created shader.

Ptr<Shader> create ( const char * name, const char * defines = 0 ) #

Shader constructor. Loads all existing shaders with given name.

Arguments

  • const char * name - Shader name.
  • const char * defines - Shader defines.

Return value

Pointer to the created shader.

Ptr<Shader> create ( const char * vertex, const char * fragment, const char * defines ) #

Shader constructor. Loads only vertex and fragment shaders with given names.

Arguments

  • const char * vertex - Vertex shader name or source.
  • const char * fragment - Fragment shader name or source.
  • const char * defines - Shader defines.

Return value

Pointer to the created shader.

void destroy ( ) #

Destroys shader.

int findParameter ( int fast_id ) #

Finds shader parameter.

Arguments

  • int fast_id - Fast identifier.

Return value

Parameter identifier, if found; otherwise, -1.

int findParameter ( const char * name ) #

Finds shader parameter.

Arguments

  • const char * name - Fast identifier.

Return value

Parameter identifier, if found; otherwise, -1.

int findParameter ( const char * name, int fast_id ) #

Finds shader parameter.

Arguments

  • const char * name - Parameter name.
  • int fast_id - Fast identifier (hash of name).

Return value

Parameter identifier, if found; otherwise, -1.

void flushParameters ( ) #

Flushes shader parameters.

int loadCompute ( const char * name, const char * defines ) #

Loads compute shader.

Arguments

  • const char * name - Compute shader name or source.
  • const char * defines - Shader defines.

Return value

1 if the compute shader was loaded successfully; otherwise, 0.

int loadControl ( const char * name, const char * defines ) #

Loads control shader.

Arguments

  • const char * name - Control shader name or source.
  • const char * defines - Shader defines.

Return value

1 if the control shader was loaded successfully; otherwise, 0.

int loadEvaluate ( const char * name, const char * defines ) #

Loads evaluate shader.

Arguments

  • const char * name - Evaluate shader name or source.
  • const char * defines - Shader defines.

Return value

1 if the evaluate shader was loaded successfully; otherwise, 0.

int loadFragment ( const char * name, const char * defines ) #

Loads fragment shader.

Arguments

  • const char * name - Fragment shader name or source.
  • const char * defines - Shader defines.

Return value

1 if the fragment shader was loaded successfully; otherwise, 0.

int loadGeometry ( const char * name, const char * defines ) #

Loads geometry shader.

Arguments

  • const char * name - Geometry shader name or source.
  • const char * defines - Shader defines.

Return value

1 if the geometry shader was loaded successfully; otherwise, 0.

int loadVertex ( const char * name, const char * defines ) #

Loads vertex shader.

Arguments

  • const char * name - Vertex shader name or source.
  • const char * defines - Shader defines.

Return value

1 if the vertex shader was loaded successfully; otherwise, 0.

void unbind ( ) #

Unbinds shader.

void setParameterInt1 ( int id, int x ) #

Sets a shader parameter value for the int1 variable.

Arguments

  • int id - Parameter identifier.
  • int x - Parameter value to be set.

void setParameterInt1 ( const char * name, int x ) #

Sets a shader parameter value for the int1 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • int x - Parameter value to be set.

void setParameterInt2 ( int id, int x, int y ) #

Sets a shader parameter value for the int2 variable.

Arguments

  • int id - Parameter identifier.
  • int x - Parameter value to be set.
  • int y - Parameter value to be set.

void setParameterInt2 ( const char * name, int x, int y ) #

Sets a shader parameter value for the int2 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • int x - Parameter value to be set.
  • int y - Parameter value to be set.

void setParameterInt3 ( int id, int x, int y, int z ) #

Sets a shader parameter value for the int3 variable.

Arguments

  • int id - Parameter identifier.
  • int x - Parameter value to be set.
  • int y - Parameter value to be set.
  • int z - Parameter value to be set.

void setParameterInt3 ( const char * name, int x, int y, int z ) #

Sets a shader parameter value for the int3 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • int x - Parameter value to be set.
  • int y - Parameter value to be set.
  • int z - Parameter value to be set.

void setParameterInt4 ( int id, int x, int y, int z, int w ) #

Sets a shader parameter value for the int4 variable.

Arguments

  • int id - Parameter identifier.
  • int x - Parameter value to be set.
  • int y - Parameter value to be set.
  • int z - Parameter value to be set.
  • int w - Parameter value to be set.

void setParameterInt4 ( const char * name, int x, int y, int z, int w ) #

Sets a shader parameter value for the int4 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • int x - Parameter value to be set.
  • int y - Parameter value to be set.
  • int z - Parameter value to be set.
  • int w - Parameter value to be set.

void setParameterUInt1 ( int id, unsigned int x ) #

Sets a shader parameter value for the uint1 variable.

Arguments

  • int id - Parameter identifier.
  • unsigned int x - Parameter value to be set.

void setParameterUInt1 ( const char * name, unsigned int x ) #

Sets a shader parameter value for the uint1 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • unsigned int x - Parameter value to be set.

void setParameterUInt2 ( int id, unsigned int x, unsigned int y ) #

Sets a shader parameter value for the uint2 variable.

Arguments

  • int id - Parameter identifier.
  • unsigned int x - Parameter value to be set.
  • unsigned int y - Parameter value to be set.

void setParameterUInt2 ( const char * name, unsigned int x, unsigned int y ) #

Sets a shader parameter value for the uint2 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • unsigned int x - Parameter value to be set.
  • unsigned int y - Parameter value to be set.

void setParameterUInt3 ( int id, unsigned int x, unsigned int y, unsigned int z ) #

Sets a shader parameter value for the uint3 variable.

Arguments

  • int id - Parameter identifier.
  • unsigned int x - Parameter value to be set.
  • unsigned int y - Parameter value to be set.
  • unsigned int z - Parameter value to be set.

void setParameterUInt3 ( const char * name, unsigned int x, unsigned int y, unsigned int z ) #

Sets a shader parameter value for the uint3 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • unsigned int x - Parameter value to be set.
  • unsigned int y - Parameter value to be set.
  • unsigned int z - Parameter value to be set.

void setParameterUInt4 ( int id, unsigned int x, unsigned int y, unsigned int z, unsigned int w ) #

Sets a shader parameter value for the uint4 variable.

Arguments

  • int id - Parameter identifier.
  • unsigned int x - Parameter value to be set.
  • unsigned int y - Parameter value to be set.
  • unsigned int z - Parameter value to be set.
  • unsigned int w - Parameter value to be set.

void setParameterUInt4 ( const char * name, unsigned int x, unsigned int y, unsigned int z, unsigned int w ) #

Sets a shader parameter value for the uint4 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • unsigned int x - Parameter value to be set.
  • unsigned int y - Parameter value to be set.
  • unsigned int z - Parameter value to be set.
  • unsigned int w - Parameter value to be set.

void setParameterFloat1 ( int id, float x ) #

Sets a shader parameter value for the float1 variable.

Arguments

  • int id - Parameter identifier.
  • float x - Parameter value to be set.

void setParameterFloat1 ( const char * name, float x ) #

Sets a shader parameter value for the float1 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • float x - Parameter value to be set.

void setParameterFloat2 ( int id, float x, float y ) #

Sets a shader parameter value for the float2 variable.

Arguments

  • int id - Parameter identifier.
  • float x - Parameter value to be set.
  • float y - Parameter value to be set.

void setParameterFloat2 ( const char * name, float x, float y ) #

Sets a shader parameter value for the float2 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • float x - Parameter value to be set.
  • float y - Parameter value to be set.

void setParameterFloat3 ( int id, float x, float y, float z ) #

Sets a shader parameter value for the float3 variable.

Arguments

  • int id - Parameter identifier.
  • float x - Parameter value to be set.
  • float y - Parameter value to be set.
  • float z - Parameter value to be set.

void setParameterFloat3 ( const char * name, float x, float y, float z ) #

Sets a shader parameter value for the float3 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • float x - Parameter value to be set.
  • float y - Parameter value to be set.
  • float z - Parameter value to be set.

void setParameterFloat4 ( int id, float x, float y, float z, float w ) #

Sets a shader parameter value for the float4 variable.

Arguments

  • int id - Parameter identifier.
  • float x - Parameter value to be set.
  • float y - Parameter value to be set.
  • float z - Parameter value to be set.
  • float w - Parameter value to be set.

void setParameterFloat4 ( const char * name, float x, float y, float z, float w ) #

Sets a shader parameter value for the float4 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • float x - Parameter value to be set.
  • float y - Parameter value to be set.
  • float z - Parameter value to be set.
  • float w - Parameter value to be set.

void setParameterDouble1 ( int id, double x ) #

Sets a shader parameter value for the double1 variable.

Arguments

  • int id - Parameter identifier.
  • double x - Parameter value to be set.

void setParameterDouble1 ( const char * name, double x ) #

Sets a shader parameter value for the double1 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • double x - Parameter value to be set.

void setParameterDouble2 ( int id, double x, double y ) #

Sets a shader parameter value for the double2 variable.

Arguments

  • int id - Parameter identifier.
  • double x - Parameter value to be set.
  • double y - Parameter value to be set.

void setParameterDouble2 ( const char * name, double x, double y ) #

Sets a shader parameter value for the double2 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • double x - Parameter value to be set.
  • double y - Parameter value to be set.

void setParameterDouble3 ( int id, double x, double y, double z ) #

Sets a shader parameter value for the double3 variable.

Arguments

  • int id - Parameter identifier.
  • double x - Parameter value to be set.
  • double y - Parameter value to be set.
  • double z - Parameter value to be set.

void setParameterDouble3 ( const char * name, double x, double y, double z ) #

Sets a shader parameter value for the double3 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • double x - Parameter value to be set.
  • double y - Parameter value to be set.
  • double z - Parameter value to be set.

void setParameterDouble4 ( int id, double x, double y, double z, double w ) #

Sets a shader parameter value for the double4 variable.

Arguments

  • int id - Parameter identifier.
  • double x - Parameter value to be set.
  • double y - Parameter value to be set.
  • double z - Parameter value to be set.
  • double w - Parameter value to be set.

void setParameterDouble4 ( const char * name, double x, double y, double z, double w ) #

Sets a shader parameter value for the double4 variable using the parameter name.

Arguments

  • const char * name - Parameter name.
  • double x - Parameter value to be set.
  • double y - Parameter value to be set.
  • double z - Parameter value to be set.
  • double w - Parameter value to be set.
Last update: 2019-08-16