Table of Contents

Class Shader

Namespace
Xui.GPU.Shaders.Intrinsics
Assembly
Xui.Core.dll

Provides shader intrinsic functions for mathematical operations. These functions mirror GPU shader intrinsics and will be translated to appropriate backend-specific implementations.

public static class Shader
Inheritance
Shader
Inherited Members

Methods

Abs(F32)

Returns the absolute value.

public static F32 Abs(F32 value)

Parameters

value F32

Returns

F32

Acos(F32)

Returns the arc cosine (inverse cosine) in radians.

public static F32 Acos(F32 value)

Parameters

value F32

Returns

F32

Asin(F32)

Returns the arc sine (inverse sine) in radians.

public static F32 Asin(F32 value)

Parameters

value F32

Returns

F32

Atan(F32)

Returns the arc tangent (inverse tangent) in radians.

public static F32 Atan(F32 value)

Parameters

value F32

Returns

F32

Atan2(F32, F32)

Returns the arc tangent of y/x in radians.

public static F32 Atan2(F32 y, F32 x)

Parameters

y F32
x F32

Returns

F32

Ceil(F32)

Returns the smallest integer greater than or equal to the value.

public static F32 Ceil(F32 value)

Parameters

value F32

Returns

F32

Clamp(F32, F32, F32)

Clamps a value between a minimum and maximum value.

public static F32 Clamp(F32 value, F32 min, F32 max)

Parameters

value F32
min F32
max F32

Returns

F32

Clamp(Float2, Float2, Float2)

Component-wise clamp of a 2D vector.

public static Float2 Clamp(Float2 value, Float2 min, Float2 max)

Parameters

value Float2
min Float2
max Float2

Returns

Float2

Clamp(Float3, Float3, Float3)

Component-wise clamp of a 3D vector.

public static Float3 Clamp(Float3 value, Float3 min, Float3 max)

Parameters

value Float3
min Float3
max Float3

Returns

Float3

Clamp(Float4, Float4, Float4)

Component-wise clamp of a 4D vector.

public static Float4 Clamp(Float4 value, Float4 min, Float4 max)

Parameters

value Float4
min Float4
max Float4

Returns

Float4

Cos(F32)

Returns the cosine of the specified angle in radians.

public static F32 Cos(F32 angle)

Parameters

angle F32

Returns

F32

Cross(Float3, Float3)

Returns the cross product of two 3D vectors.

public static Float3 Cross(Float3 a, Float3 b)

Parameters

a Float3
b Float3

Returns

Float3

Ddx(F32)

Returns the partial derivative of the value with respect to screen-space X. Only available in fragment shaders.

public static F32 Ddx(F32 value)

Parameters

value F32

Returns

F32

Remarks

This intrinsic requires fragment execution in 2x2 quads to compute derivatives. In the software renderer, this will be implemented by comparing adjacent fragment values.

Ddy(F32)

Returns the partial derivative of the value with respect to screen-space Y. Only available in fragment shaders.

public static F32 Ddy(F32 value)

Parameters

value F32

Returns

F32

Remarks

This intrinsic requires fragment execution in 2x2 quads to compute derivatives. In the software renderer, this will be implemented by comparing adjacent fragment values.

Distance(Float2, Float2)

Returns the distance between two 2D points.

public static F32 Distance(Float2 a, Float2 b)

Parameters

a Float2
b Float2

Returns

F32

Distance(Float3, Float3)

Returns the distance between two 3D points.

public static F32 Distance(Float3 a, Float3 b)

Parameters

a Float3
b Float3

Returns

F32

Distance(Float4, Float4)

Returns the distance between two 4D points.

public static F32 Distance(Float4 a, Float4 b)

Parameters

a Float4
b Float4

Returns

F32

Dot(Float2, Float2)

Returns the dot product of two 2D vectors.

public static F32 Dot(Float2 a, Float2 b)

Parameters

a Float2
b Float2

Returns

F32

Dot(Float3, Float3)

Returns the dot product of two 3D vectors.

public static F32 Dot(Float3 a, Float3 b)

Parameters

a Float3
b Float3

Returns

F32

Dot(Float4, Float4)

Returns the dot product of two 4D vectors.

public static F32 Dot(Float4 a, Float4 b)

Parameters

a Float4
b Float4

Returns

F32

Exp(F32)

Returns the exponential (e^x).

public static F32 Exp(F32 value)

Parameters

value F32

Returns

F32

Floor(F32)

Returns the largest integer less than or equal to the value.

public static F32 Floor(F32 value)

Parameters

value F32

Returns

F32

Fract(F32)

Returns the fractional part of the value.

public static F32 Fract(F32 value)

Parameters

value F32

Returns

F32

Fwidth(F32)

Returns the sum of absolute values of ddx and ddy. Only available in fragment shaders.

public static F32 Fwidth(F32 value)

Parameters

value F32

Returns

F32

Length(Float2)

Returns the length (magnitude) of a 2D vector.

public static F32 Length(Float2 v)

Parameters

v Float2

Returns

F32

Length(Float3)

Returns the length (magnitude) of a 3D vector.

public static F32 Length(Float3 v)

Parameters

v Float3

Returns

F32

Length(Float4)

Returns the length (magnitude) of a 4D vector.

public static F32 Length(Float4 v)

Parameters

v Float4

Returns

F32

Lerp(F32, F32, F32)

Linearly interpolates between two values.

public static F32 Lerp(F32 a, F32 b, F32 t)

Parameters

a F32

The start value.

b F32

The end value.

t F32

The interpolation factor (typically 0-1).

Returns

F32

Lerp(Float2, Float2, F32)

Linearly interpolates between two 2D vectors.

public static Float2 Lerp(Float2 a, Float2 b, F32 t)

Parameters

a Float2
b Float2
t F32

Returns

Float2

Lerp(Float3, Float3, F32)

Linearly interpolates between two 3D vectors.

public static Float3 Lerp(Float3 a, Float3 b, F32 t)

Parameters

a Float3
b Float3
t F32

Returns

Float3

Lerp(Float4, Float4, F32)

Linearly interpolates between two 4D vectors.

public static Float4 Lerp(Float4 a, Float4 b, F32 t)

Parameters

a Float4
b Float4
t F32

Returns

Float4

Load(Texture2D<Color4>, Int2)

Loads a texel from a 2D texture at the specified integer coordinates.

public static Color4 Load(Texture2D<Color4> texture, Int2 location)

Parameters

texture Texture2D<Color4>

The texture to load from.

location Int2

The integer texel coordinates.

Returns

Color4

The texel color value.

Remarks

Unlike Sample(), Load() does not perform filtering and uses integer coordinates. This is a placeholder implementation that will be implemented by the renderer backend.

Log(F32)

Returns the natural logarithm.

public static F32 Log(F32 value)

Parameters

value F32

Returns

F32

Log2(F32)

Returns the base-2 logarithm.

public static F32 Log2(F32 value)

Parameters

value F32

Returns

F32

Max(F32, F32)

Returns the maximum of two values.

public static F32 Max(F32 a, F32 b)

Parameters

a F32
b F32

Returns

F32

Max(Float2, Float2)

Component-wise maximum of two 2D vectors.

public static Float2 Max(Float2 a, Float2 b)

Parameters

a Float2
b Float2

Returns

Float2

Max(Float3, Float3)

Component-wise maximum of two 3D vectors.

public static Float3 Max(Float3 a, Float3 b)

Parameters

a Float3
b Float3

Returns

Float3

Max(Float4, Float4)

Component-wise maximum of two 4D vectors.

public static Float4 Max(Float4 a, Float4 b)

Parameters

a Float4
b Float4

Returns

Float4

Min(F32, F32)

Returns the minimum of two values.

public static F32 Min(F32 a, F32 b)

Parameters

a F32
b F32

Returns

F32

Min(Float2, Float2)

Component-wise minimum of two 2D vectors.

public static Float2 Min(Float2 a, Float2 b)

Parameters

a Float2
b Float2

Returns

Float2

Min(Float3, Float3)

Component-wise minimum of two 3D vectors.

public static Float3 Min(Float3 a, Float3 b)

Parameters

a Float3
b Float3

Returns

Float3

Min(Float4, Float4)

Component-wise minimum of two 4D vectors.

public static Float4 Min(Float4 a, Float4 b)

Parameters

a Float4
b Float4

Returns

Float4

Normalize(Float2)

Returns the normalized 2D vector (length = 1).

public static Float2 Normalize(Float2 v)

Parameters

v Float2

Returns

Float2

Normalize(Float3)

Returns the normalized 3D vector (length = 1).

public static Float3 Normalize(Float3 v)

Parameters

v Float3

Returns

Float3

Normalize(Float4)

Returns the normalized 4D vector (length = 1).

public static Float4 Normalize(Float4 v)

Parameters

v Float4

Returns

Float4

Pow(F32, F32)

Returns the value raised to the specified power.

public static F32 Pow(F32 value, F32 exponent)

Parameters

value F32
exponent F32

Returns

F32

Round(F32)

Returns the value rounded to the nearest integer.

public static F32 Round(F32 value)

Parameters

value F32

Returns

F32

Rsqrt(F32)

Returns the reciprocal square root (1 / sqrt(x)).

public static F32 Rsqrt(F32 value)

Parameters

value F32

Returns

F32

Sample(Texture2D<Color4>, Sampler, Float2)

Samples a 2D texture at the specified UV coordinates using a sampler.

public static Color4 Sample(Texture2D<Color4> texture, Sampler sampler, Float2 uv)

Parameters

texture Texture2D<Color4>

The texture to sample from.

sampler Sampler

The sampler defining filtering and addressing modes.

uv Float2

The UV texture coordinates.

Returns

Color4

The sampled color value.

Remarks

This is a placeholder implementation. Actual texture sampling will be implemented by the software renderer or hardware backend.

Saturate(F32)

Saturates a value to the range [0, 1].

public static F32 Saturate(F32 value)

Parameters

value F32

Returns

F32

Saturate(Float2)

Saturates a 2D vector to the range [0, 1] component-wise.

public static Float2 Saturate(Float2 value)

Parameters

value Float2

Returns

Float2

Saturate(Float3)

Saturates a 3D vector to the range [0, 1] component-wise.

public static Float3 Saturate(Float3 value)

Parameters

value Float3

Returns

Float3

Saturate(Float4)

Saturates a 4D vector to the range [0, 1] component-wise.

public static Float4 Saturate(Float4 value)

Parameters

value Float4

Returns

Float4

Sin(F32)

Returns the sine of the specified angle in radians.

public static F32 Sin(F32 angle)

Parameters

angle F32

Returns

F32

Sqrt(F32)

Returns the square root.

public static F32 Sqrt(F32 value)

Parameters

value F32

Returns

F32

Tan(F32)

Returns the tangent of the specified angle in radians.

public static F32 Tan(F32 angle)

Parameters

angle F32

Returns

F32