# Xui.GPU.Shaders.Attributes

Assembly: **Xui.Core** · [C# declarations](index.cs) · [Assembly overview](../index.md)

## Types

- [`enum BuiltIn`](#api-fd5d8e9f69007f99)
- [`class BuiltInAttribute`](#api-f7d2fd864abc05c5)
- [`class FragmentShaderAttribute`](#api-db2fe16a1a320220)
- [`class InterpolationAttribute`](#api-faaf4fd5279b9dc8)
- [`enum InterpolationMode`](#api-5759d044dc43f751)
- [`class LocationAttribute`](#api-65a0ad477682b532)
- [`class ShaderProgramAttribute`](#api-37210b9e7dee02bb)
- [`class VertexShaderAttribute`](#api-44f0539cbd03293a)

<a id="api-fd5d8e9f69007f99"></a>

## `enum BuiltIn`

Built-in shader semantics.

```csharp
public enum BuiltIn
{
    Position,
    FragDepth,
    InstanceId,
    VertexId,
}
```

<a id="api-d68e8a512191c97b"></a>

### [`BuiltIn.FragDepth`](#api-d68e8a512191c97b)


```csharp
FragDepth
```

Fragment depth value.

<a id="api-339c5ca746572a7e"></a>

### [`BuiltIn.InstanceId`](#api-339c5ca746572a7e)


```csharp
InstanceId
```

Vertex instance ID.

<a id="api-af1ad97475bd9f86"></a>

### [`BuiltIn.Position`](#api-af1ad97475bd9f86)


```csharp
Position
```

Vertex position in clip space.

<a id="api-ee470024d32b2629"></a>

### [`BuiltIn.VertexId`](#api-ee470024d32b2629)


```csharp
VertexId
```

Vertex ID.


<a id="api-f7d2fd864abc05c5"></a>

## `class BuiltInAttribute`

Specifies that a field represents a built-in shader semantic.

```csharp
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class BuiltInAttribute : Attribute
{
    public BuiltIn Semantic { get; }

    public BuiltInAttribute(BuiltIn semantic);
}
```

<a id="api-788d45f51da16398"></a>

### [`BuiltInAttribute.BuiltInAttribute(BuiltIn semantic)`](#api-788d45f51da16398)


```csharp
public BuiltInAttribute(BuiltIn semantic);
```

Initializes a new instance of the [`Xui.GPU.Shaders.Attributes.BuiltInAttribute`](../xui-gpu-shaders-attributes/index.md#api-f7d2fd864abc05c5) class.

- **`semantic`** — The built-in semantic.

<a id="api-5ec38ed17504ce9e"></a>

### [`BuiltIn BuiltInAttribute.Semantic`](#api-5ec38ed17504ce9e)


```csharp
public BuiltIn Semantic { get; }
```

Gets the built-in semantic.


<a id="api-db2fe16a1a320220"></a>

## `class FragmentShaderAttribute`

Marks a type as a fragment shader stage.

```csharp
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
public sealed class FragmentShaderAttribute : Attribute
{
}
```


<a id="api-faaf4fd5279b9dc8"></a>

## `class InterpolationAttribute`

Attribute to control how a varying (vertex shader output / fragment shader input) is interpolated.

This attribute maps to HLSL interpolation modifiers (linear, noperspective, nointerpolation), Metal&#39;s [[flat]], [[center_perspective]], etc., and Vulkan&#39;s interpolation decorations.

```csharp
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public sealed class InterpolationAttribute : Attribute
{
    public InterpolationMode Mode { get; }

    public InterpolationAttribute(InterpolationMode mode);
}
```

<a id="api-9678f6c056c50b74"></a>

### [`InterpolationAttribute.InterpolationAttribute(InterpolationMode mode)`](#api-9678f6c056c50b74)


```csharp
public InterpolationAttribute(InterpolationMode mode);
```

Initializes a new instance of the [`Xui.GPU.Shaders.Attributes.InterpolationAttribute`](../xui-gpu-shaders-attributes/index.md#api-faaf4fd5279b9dc8) class.

- **`mode`** — The interpolation mode to use for this varying.

<a id="api-5dcba7088ae664f0"></a>

### [`InterpolationMode InterpolationAttribute.Mode`](#api-5dcba7088ae664f0)


```csharp
public InterpolationMode Mode { get; }
```

Gets the interpolation mode.


<a id="api-5759d044dc43f751"></a>

## `enum InterpolationMode`

Specifies the interpolation mode for a shader varying (vertex output / fragment input).

```csharp
public enum InterpolationMode
{
    Perspective,
    Linear,
    Flat
}
```

<a id="api-c47f91274fafbc29"></a>

### [`InterpolationMode.Flat`](#api-c47f91274fafbc29)


```csharp
Flat
```

No interpolation - flat shading. The value from the provoking vertex is used for the entire primitive.

<a id="api-e3782de8920451c3"></a>

### [`InterpolationMode.Linear`](#api-e3782de8920451c3)


```csharp
Linear
```

Linear interpolation without perspective correction. Values are interpolated linearly in screen space.

<a id="api-5f2081644dd42798"></a>

### [`InterpolationMode.Perspective`](#api-5f2081644dd42798)


```csharp
Perspective
```

Default perspective-correct interpolation. Values are interpolated with perspective correction across the triangle.


<a id="api-65a0ad477682b532"></a>

## `class LocationAttribute`

Specifies the location index for a vertex input or fragment output field.

```csharp
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
public sealed class LocationAttribute : Attribute
{
    public int Index { get; }

    public LocationAttribute(int index);
}
```

<a id="api-5415a1e33f4cec97"></a>

### [`LocationAttribute.LocationAttribute(int index)`](#api-5415a1e33f4cec97)


```csharp
public LocationAttribute(int index);
```

Initializes a new instance of the [`Xui.GPU.Shaders.Attributes.LocationAttribute`](../xui-gpu-shaders-attributes/index.md#api-65a0ad477682b532) class.

- **`index`** — The location index.

<a id="api-6c455e7ff27f77eb"></a>

### [`int LocationAttribute.Index`](#api-6c455e7ff27f77eb)


```csharp
public int Index { get; }
```

Gets the location index.


<a id="api-37210b9e7dee02bb"></a>

## `class ShaderProgramAttribute`

Marks a type as a shader program definition. Used by source generators to discover and process shader programs.

```csharp
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
public sealed class ShaderProgramAttribute : Attribute
{
}
```


<a id="api-44f0539cbd03293a"></a>

## `class VertexShaderAttribute`

Marks a type as a vertex shader stage.

```csharp
[AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
public sealed class VertexShaderAttribute : Attribute
{
}
```

