Fragment Shader

The Renderable Component accepts custom fragment shaders.

These fragment shaders are written in GLSL and have some special variables.

Inputs

Name

Type

Description

NtshEngn_position

vec3

The fragment’s position, in world-space.

NtshEngn_normal

vec3

The fragment’s normal.

NtshEngn_tangent

vec3

The fragment’s tangent.

NtshEngn_bitangent

vec3

The fragment’s bitangent.

NtshEngn_uv

vec2

The fragment’s texture coordinates.

NtshEngn_tbn

mat3

The fragment’s Tangent-Bitangent-Normal matrix.

NtshEngn_diffuseTextureSampler

sampler2D

The object’s material’s diffuse texture.

NtshEngn_normalTextureSampler

sampler2D

The object’s material’s normal texture.

NtshEngn_metalnessTextureSampler

sampler2D

The object’s material’s metalness texture.

NtshEngn_roughnessTextureSampler

sampler2D

The object’s material’s roughness texture.

NtshEngn_occlusionTextureSampler

sampler2D

The object’s material’s occlusion texture.

NtshEngn_emissiveTextureSampler

sampler2D

The object’s material’s emissive texture.

NtshEngn_emissiveFactor

float

The object’s material’s metalness factor.

NtshEngn_alphaCutoff

float

The object’s material’s alpha cutoff.

NtshEngn_scaleUV

vec2

The object’s material’s UV scale.

NtshEngn_offsetUV

vec2

The object’s material’s UV offset.

NtshEngn_useTriplanarMapping

bool

true if the object’s material uses triplanar mapping, else, false.

NtshEngn_directionalLightCount

uint

The number of directional lights in the scene.

NtshEngn_directionalLight(i)

Light

The *i*th directional light.

NtshEngn_pointLightCount

uint

The number of point lights in the scene.

NtshEngn_pointLight(i)

Light

The *i*th point light.

NtshEngn_spotLightCount

uint

The number of spot lights in the scene.

NtshEngn_spotLight(i)

Light

The *i*th spot light.

NtshEngn_ambientLightCount

uint

The number of ambient lights in the scene.

NtshEngn_ambientLight(i)

Light

The *i*th ambient light.

NtshEngn_time

float

The time since the application’s launch, in seconds.

NtshEngn_cameraPosition

vec3

The camera’s position, in world-space.

NtshEngn_useReversedDepth

bool

true if the graphics module uses reversed depth (1 is close, 0 is far), else, false (0 is close, 1 is far).

Outputs

Name

Type

Description

NtshEngn_outColor

vec4

The output color.

NtshEngn_outDepth

float

The output depth.