Table of Contents

Class RaylibUniform

Namespace
ShadowDusk.Compiler.Raylib
Assembly
ShadowDusk.Compiler.dll

One non-sampler uniform of a RaylibShader.

public sealed record RaylibUniform : IEquatable<RaylibUniform>
Inheritance
RaylibUniform
Implements
Inherited Members

Constructors

RaylibUniform(string, string, int)

One non-sampler uniform of a RaylibShader.

public RaylibUniform(string Name, string GlslType, int ArrayLength)

Parameters

Name string

The GLSL uniform name (the HLSL global's name).

GlslType string

The GLSL type, e.g. vec4; pick the matching ShaderUniformDataType.

ArrayLength int

Element count for an array uniform, or 0 for a non-array.

Properties

ArrayLength

Element count for an array uniform, or 0 for a non-array.

public int ArrayLength { get; init; }

Property Value

int

DefaultValue

The default the HLSL declaration gives this uniform (float Thickness = 1.0;), or null when it is unknown: the same values, in the same layout, as DefaultValue on the MGFX route for the same source (issue #435). The fragment shader declares the uniform WITHOUT a value, so raylib reads it as zero until the caller sets it; set it to this value to get the effect the .fx author declared.

public IReadOnlyList<float>? DefaultValue { get; init; }

Property Value

IReadOnlyList<float>

Remarks

Layout. max(1, ArrayLength) elements one after another, each the uniform's components in order, no padding: exactly the values SetShaderValueV(shader, loc, values, type, max(1, ArrayLength)) takes. Matrices do not occur, because the converter refuses matrix uniforms (SD0636).

Values. int values converted to floats, uint values by their unsigned value (one beyond 2^24 is not exact), bool as 0 or 1; the MGFX route's value for an OpenGL build (the converter's macro set). A bool global is a uint uniform (SPIR-V has no bool in a uniform block). An int/ivecN uniform takes the values as int (ShaderUniformDataType.Int...); a uint/uvecN one, a bool's included, as uint (ShaderUniformDataType.UInt...: Int on a uint uniform is a GL error).

When it is null. The global has no initializer, or the initializer could not be evaluated or does not match the uniform's shape (the conversion then carries the MGFX route's SD0017 warning; so does a global with a default that no listed uniform pairs with). Samplers are not uniforms here (see Samplers).

GlslType

The GLSL type, e.g. vec4; pick the matching ShaderUniformDataType.

public string GlslType { get; init; }

Property Value

string

Name

The GLSL uniform name (the HLSL global's name).

public string Name { get; init; }

Property Value

string

Methods

Equals(RaylibUniform?)

Value equality, comparing DefaultValue element by element.

public bool Equals(RaylibUniform? other)

Parameters

other RaylibUniform

The uniform to compare with.

Returns

bool

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.