/  ChuGL Shaders

VertexFormat

ShaderDesc

Shader

ChuGL classes for creating shaders via shader source code and layout descriptions.

VertexFormat

inherits : Object

Vertex format enum. Used to describe vertex data layout in ShaderDesc.

static member variables

int Float

No description available

int Float2

No description available

int Float3

No description available

int Float4

No description available

int Int

No description available

int Int2

No description available

int Int3

No description available

int Int4

No description available

int Undefined

No description available


ShaderDesc

inherits : Object

Shader description object. Used to create a Shader component.If creating a material shader, set either vertexCode or vertexPath, and either fragmentCode or fragmentPath. `vertexLayout` field describes the vertex data layout of buffers going into the vertex shader--use the VertexFormat enum. For compute shaders, set either computeCode or computePath.

constructors

ShaderDesc()

Default constructor for ShaderDesc.

member variables

string computeCode

Compute shader string. Set if passing a raw shader code (not a filepath)

string computePath

Compute shader filepath. Set if passing a filepath to a shader file.

string fragmentCode

Fragment shader string. Set if passing a raw shader code (not a filepath)

string fragmentPath

Fragment shader filepath. Set if passing a filepath to a shader file.

int lit

Set to true if the shader is lit (uses lighting calculations). If set, the renderer will pass in lighting information as part of the per-frame uniforms.you can access these in your shader via the `#include LIGHTING_UNIFORMS` macro.

int usesEnvMap

Set to true if the shader uses an environment map. If set, the renderer will pass in the environment map (set on GG.scene().envMap()) as part of the per-frame uniforms. You can access these in your shader via the `#include ENVIRONMENT_MAP_UNIFORMS` macro.

string vertexCode

Vertex shader string. Set if passing a raw shader code (not a filepath)

int[] vertexLayout

Array of VertexFormat enums describing the vertex data layout.E.g. if your vertex shader takes a vec3 position and a vec2 uv, set `vertexLayout` to [VertexFormat.Float3, VertexFormat.Float2]. By default this field is set to the standard vertex layout, [VertexFormat.Float3, VertexFormat.Float3, VertexFormat.Float2]. This corresponds to position, normal, uv.

string vertexPath

Vertex shader filepath. Set if passing a filepath to a shader file.


Shader

inherits : SG_Component : Object

Shader component. Immutable. Create by passing a ShaderDesc. E.g. new Shader(ShaderDesc)

examples

constructors

Shader()

Default constructor for Shader.

Shader(ShaderDesc shader_desc)

Create a Shader component. Immutable.

member functions

string fragmentCode()

Get the fragment shader string passed in the ShaderDesc at creation.

string fragmentPath()

Get the fragment shader filepath passed in the ShaderDesc at creation.

int lit()

Get whether the shader is lit (uses lighting calculations).

int usesEnvMap()

Get whether the shader uses an environment map.

string vertexCode()

Get the vertex shader string passed in the ShaderDesc at creation.

int[] vertexLayout()

Get the vertex layout passed in the ShaderDesc at creation.

string vertexPath()

Get the vertex shader filepath passed in the ShaderDesc at creation.