Xui.GPU.Shaders.Intrinsics
Assembly: Xui.Core · C# declarations · Assembly overview
Types
class Shader
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
{
public static F32 Clamp(F32 value, F32 min, F32 max);
public static F32 Saturate(F32 value);
public static F32 Lerp(F32 a, F32 b, F32 t);
public static F32 Min(F32 a, F32 b);
public static F32 Max(F32 a, F32 b);
public static F32 Abs(F32 value);
public static F32 Sin(F32 angle);
public static F32 Cos(F32 angle);
public static F32 Tan(F32 angle);
public static F32 Asin(F32 value);
public static F32 Acos(F32 value);
public static F32 Atan(F32 value);
public static F32 Atan2(F32 y, F32 x);
public static F32 Pow(F32 value, F32 exponent);
public static F32 Exp(F32 value);
public static F32 Log(F32 value);
public static F32 Log2(F32 value);
public static F32 Sqrt(F32 value);
public static F32 Rsqrt(F32 value);
public static F32 Floor(F32 value);
public static F32 Ceil(F32 value);
public static F32 Fract(F32 value);
public static F32 Round(F32 value);
public static F32 Dot(Float2 a, Float2 b);
public static F32 Dot(Float3 a, Float3 b);
public static F32 Dot(Float4 a, Float4 b);
public static F32 Length(Float2 v);
public static F32 Length(Float3 v);
public static F32 Length(Float4 v);
public static F32 Distance(Float2 a, Float2 b);
public static F32 Distance(Float3 a, Float3 b);
public static F32 Distance(Float4 a, Float4 b);
public static Float2 Normalize(Float2 v);
public static Float3 Normalize(Float3 v);
public static Float4 Normalize(Float4 v);
public static Float3 Cross(Float3 a, Float3 b);
public static Float2 Lerp(Float2 a, Float2 b, F32 t);
public static Float3 Lerp(Float3 a, Float3 b, F32 t);
public static Float4 Lerp(Float4 a, Float4 b, F32 t);
public static Float2 Min(Float2 a, Float2 b);
public static Float3 Min(Float3 a, Float3 b);
public static Float4 Min(Float4 a, Float4 b);
public static Float2 Max(Float2 a, Float2 b);
public static Float3 Max(Float3 a, Float3 b);
public static Float4 Max(Float4 a, Float4 b);
public static Float2 Clamp(Float2 value, Float2 min, Float2 max);
public static Float3 Clamp(Float3 value, Float3 min, Float3 max);
public static Float4 Clamp(Float4 value, Float4 min, Float4 max);
public static Float2 Saturate(Float2 value);
public static Float3 Saturate(Float3 value);
public static Float4 Saturate(Float4 value);
public static F32 Ddx(F32 value);
public static F32 Ddy(F32 value);
public static F32 Fwidth(F32 value);
public static Color4 Sample(Texture2D<Color4> texture, Sampler sampler, Float2 uv);
public static Color4 SampleLevel(Texture2D<Color4> texture, Sampler sampler, Float2 uv, F32 level);
public static Color4 Load(Texture2D<Color4> texture, Int2 location);
}
F32 Shader.Abs(F32 value)
public static F32 Abs(F32 value);
Returns the absolute value.
F32 Shader.Acos(F32 value)
public static F32 Acos(F32 value);
Returns the arc cosine (inverse cosine) in radians.
F32 Shader.Asin(F32 value)
public static F32 Asin(F32 value);
Returns the arc sine (inverse sine) in radians.
F32 Shader.Atan(F32 value)
public static F32 Atan(F32 value);
Returns the arc tangent (inverse tangent) in radians.
F32 Shader.Atan2(F32 y, F32 x)
public static F32 Atan2(F32 y, F32 x);
Returns the arc tangent of y/x in radians.
F32 Shader.Ceil(F32 value)
public static F32 Ceil(F32 value);
Returns the smallest integer greater than or equal to the value.
F32 Shader.Clamp(F32 value, F32 min, F32 max)
public static F32 Clamp(F32 value, F32 min, F32 max);
Clamps a value between a minimum and maximum value.
Float2 Shader.Clamp(Float2 value, Float2 min, Float2 max)
public static Float2 Clamp(Float2 value, Float2 min, Float2 max);
Component-wise clamp of a 2D vector.
Float3 Shader.Clamp(Float3 value, Float3 min, Float3 max)
public static Float3 Clamp(Float3 value, Float3 min, Float3 max);
Component-wise clamp of a 3D vector.
Float4 Shader.Clamp(Float4 value, Float4 min, Float4 max)
public static Float4 Clamp(Float4 value, Float4 min, Float4 max);
Component-wise clamp of a 4D vector.
F32 Shader.Cos(F32 angle)
public static F32 Cos(F32 angle);
Returns the cosine of the specified angle in radians.
Float3 Shader.Cross(Float3 a, Float3 b)
public static Float3 Cross(Float3 a, Float3 b);
Returns the cross product of two 3D vectors.
F32 Shader.Ddx(F32 value)
public static F32 Ddx(F32 value);
Returns the partial derivative of the value with respect to screen-space X. Only available in fragment shaders.
This intrinsic requires fragment execution in 2x2 quads to compute derivatives. In the software renderer, this will be implemented by comparing adjacent fragment values.
F32 Shader.Ddy(F32 value)
public static F32 Ddy(F32 value);
Returns the partial derivative of the value with respect to screen-space Y. Only available in fragment shaders.
This intrinsic requires fragment execution in 2x2 quads to compute derivatives. In the software renderer, this will be implemented by comparing adjacent fragment values.
F32 Shader.Distance(Float2 a, Float2 b)
public static F32 Distance(Float2 a, Float2 b);
Returns the distance between two 2D points.
F32 Shader.Distance(Float3 a, Float3 b)
public static F32 Distance(Float3 a, Float3 b);
Returns the distance between two 3D points.
F32 Shader.Distance(Float4 a, Float4 b)
public static F32 Distance(Float4 a, Float4 b);
Returns the distance between two 4D points.
F32 Shader.Dot(Float2 a, Float2 b)
public static F32 Dot(Float2 a, Float2 b);
Returns the dot product of two 2D vectors.
F32 Shader.Dot(Float3 a, Float3 b)
public static F32 Dot(Float3 a, Float3 b);
Returns the dot product of two 3D vectors.
F32 Shader.Dot(Float4 a, Float4 b)
public static F32 Dot(Float4 a, Float4 b);
Returns the dot product of two 4D vectors.
F32 Shader.Exp(F32 value)
public static F32 Exp(F32 value);
Returns the exponential (e^x).
F32 Shader.Floor(F32 value)
public static F32 Floor(F32 value);
Returns the largest integer less than or equal to the value.
F32 Shader.Fract(F32 value)
public static F32 Fract(F32 value);
Returns the fractional part of the value.
F32 Shader.Fwidth(F32 value)
public static F32 Fwidth(F32 value);
Returns the sum of absolute values of ddx and ddy. Only available in fragment shaders.
F32 Shader.Length(Float2 v)
public static F32 Length(Float2 v);
Returns the length (magnitude) of a 2D vector.
F32 Shader.Length(Float3 v)
public static F32 Length(Float3 v);
Returns the length (magnitude) of a 3D vector.
F32 Shader.Length(Float4 v)
public static F32 Length(Float4 v);
Returns the length (magnitude) of a 4D vector.
F32 Shader.Lerp(F32 a, F32 b, F32 t)
public static F32 Lerp(F32 a, F32 b, F32 t);
Linearly interpolates between two values.
a— The start value.b— The end value.t— The interpolation factor (typically 0-1).
Float2 Shader.Lerp(Float2 a, Float2 b, F32 t)
public static Float2 Lerp(Float2 a, Float2 b, F32 t);
Linearly interpolates between two 2D vectors.
Float3 Shader.Lerp(Float3 a, Float3 b, F32 t)
public static Float3 Lerp(Float3 a, Float3 b, F32 t);
Linearly interpolates between two 3D vectors.
Float4 Shader.Lerp(Float4 a, Float4 b, F32 t)
public static Float4 Lerp(Float4 a, Float4 b, F32 t);
Linearly interpolates between two 4D vectors.
Color4 Shader.Load(Texture2D<Color4> texture, Int2 location)
public static Color4 Load(Texture2D<Color4> texture, Int2 location);
Loads a texel from a 2D texture at the specified integer coordinates.
texture— The texture to load from.location— The integer texel coordinates.
Returns: The texel color value.
Unlike Sample(), Load() does not perform filtering and uses integer coordinates. This is a placeholder implementation that will be implemented by the renderer backend.
F32 Shader.Log(F32 value)
public static F32 Log(F32 value);
Returns the natural logarithm.
F32 Shader.Log2(F32 value)
public static F32 Log2(F32 value);
Returns the base-2 logarithm.
F32 Shader.Max(F32 a, F32 b)
public static F32 Max(F32 a, F32 b);
Returns the maximum of two values.
Float2 Shader.Max(Float2 a, Float2 b)
public static Float2 Max(Float2 a, Float2 b);
Component-wise maximum of two 2D vectors.
Float3 Shader.Max(Float3 a, Float3 b)
public static Float3 Max(Float3 a, Float3 b);
Component-wise maximum of two 3D vectors.
Float4 Shader.Max(Float4 a, Float4 b)
public static Float4 Max(Float4 a, Float4 b);
Component-wise maximum of two 4D vectors.
F32 Shader.Min(F32 a, F32 b)
public static F32 Min(F32 a, F32 b);
Returns the minimum of two values.
Float2 Shader.Min(Float2 a, Float2 b)
public static Float2 Min(Float2 a, Float2 b);
Component-wise minimum of two 2D vectors.
Float3 Shader.Min(Float3 a, Float3 b)
public static Float3 Min(Float3 a, Float3 b);
Component-wise minimum of two 3D vectors.
Float4 Shader.Min(Float4 a, Float4 b)
public static Float4 Min(Float4 a, Float4 b);
Component-wise minimum of two 4D vectors.
Float2 Shader.Normalize(Float2 v)
public static Float2 Normalize(Float2 v);
Returns the normalized 2D vector (length = 1).
Float3 Shader.Normalize(Float3 v)
public static Float3 Normalize(Float3 v);
Returns the normalized 3D vector (length = 1).
Float4 Shader.Normalize(Float4 v)
public static Float4 Normalize(Float4 v);
Returns the normalized 4D vector (length = 1).
F32 Shader.Pow(F32 value, F32 exponent)
public static F32 Pow(F32 value, F32 exponent);
Returns the value raised to the specified power.
F32 Shader.Round(F32 value)
public static F32 Round(F32 value);
Returns the value rounded to the nearest integer.
F32 Shader.Rsqrt(F32 value)
public static F32 Rsqrt(F32 value);
Returns the reciprocal square root (1 / sqrt(x)).
Color4 Shader.Sample(Texture2D<Color4> texture, Sampler sampler, Float2 uv)
public static Color4 Sample(Texture2D<Color4> texture, Sampler sampler, Float2 uv);
Samples a 2D texture at the specified UV coordinates using a sampler.
texture— The texture to sample from.sampler— The sampler defining filtering and addressing modes.uv— The UV texture coordinates.
Returns: The sampled color value.
This is a placeholder implementation. Actual texture sampling will be implemented by the software renderer or hardware backend.
Color4 Shader.SampleLevel(Texture2D<Color4> texture, Sampler sampler, Float2 uv, F32 level)
public static Color4 SampleLevel(Texture2D<Color4> texture, Sampler sampler, Float2 uv, F32 level);
Samples a texture at an explicit mip level, interpolating adjacent levels.
F32 Shader.Saturate(F32 value)
public static F32 Saturate(F32 value);
Saturates a value to the range [0, 1].
Float2 Shader.Saturate(Float2 value)
public static Float2 Saturate(Float2 value);
Saturates a 2D vector to the range [0, 1] component-wise.
Float3 Shader.Saturate(Float3 value)
public static Float3 Saturate(Float3 value);
Saturates a 3D vector to the range [0, 1] component-wise.
Float4 Shader.Saturate(Float4 value)
public static Float4 Saturate(Float4 value);
Saturates a 4D vector to the range [0, 1] component-wise.
F32 Shader.Sin(F32 angle)
public static F32 Sin(F32 angle);
Returns the sine of the specified angle in radians.
F32 Shader.Sqrt(F32 value)
public static F32 Sqrt(F32 value);
Returns the square root.
F32 Shader.Tan(F32 angle)
public static F32 Tan(F32 angle);
Returns the tangent of the specified angle in radians.