Slang shaders for descriptor indexing sample
This commit is contained in:
parent
9b25dbce53
commit
c120051814
1 changed files with 43 additions and 0 deletions
43
shaders/slang/descriptorindexing/descriptorindexing.slang
Normal file
43
shaders/slang/descriptorindexing/descriptorindexing.slang
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
float3 Pos : POSITION0;
|
||||
float2 UV;
|
||||
int TextureIndex;
|
||||
};
|
||||
|
||||
struct Matrices {
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
float4x4 model;
|
||||
};
|
||||
ConstantBuffer<Matrices> matrices;
|
||||
Sampler2D textures[];
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
int TextureIndex;
|
||||
float2 UV;
|
||||
};
|
||||
|
||||
[shader("vertex")]
|
||||
VSOutput vertexMain(VSInput input)
|
||||
{
|
||||
VSOutput output;
|
||||
output.UV = input.UV;
|
||||
output.TextureIndex = input.TextureIndex;
|
||||
output.Pos = mul(matrices.projection, mul(matrices.view, mul(matrices.model, float4(input.Pos.xyz, 1.0))));
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragmentMain(VSOutput input) : SV_TARGET
|
||||
{
|
||||
return textures[NonUniformResourceIndex(input.TextureIndex)].Sample(input.UV);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue