Add slang shader for texturing samples
This commit is contained in:
parent
b6b4fccb2c
commit
5484d51bae
8 changed files with 485 additions and 0 deletions
49
shaders/slang/texturearray/instancing.slang
Normal file
49
shaders/slang/texturearray/instancing.slang
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* Copyright (c) 2025, Sascha Willems
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
float3 Pos;
|
||||
float2 UV;
|
||||
};
|
||||
|
||||
struct VSOutput
|
||||
{
|
||||
float4 Pos : SV_POSITION;
|
||||
float3 UV;
|
||||
};
|
||||
|
||||
struct Instance
|
||||
{
|
||||
float4x4 model;
|
||||
float arrayIndex;
|
||||
};
|
||||
|
||||
struct UBO
|
||||
{
|
||||
float4x4 projection;
|
||||
float4x4 view;
|
||||
Instance instance[8];
|
||||
};
|
||||
ConstantBuffer<UBO> ubo;
|
||||
|
||||
Sampler2DArray samplerArray;
|
||||
|
||||
[shader("vertex")]
|
||||
VSOutput vertexMain(VSInput input, uint InstanceIndex: SV_InstanceID)
|
||||
{
|
||||
VSOutput output;
|
||||
output.UV = float3(input.UV, ubo.instance[InstanceIndex].arrayIndex);
|
||||
float4x4 modelView = mul(ubo.view, ubo.instance[InstanceIndex].model);
|
||||
output.Pos = mul(ubo.projection, mul(modelView, float4(input.Pos, 1.0)));
|
||||
return output;
|
||||
}
|
||||
|
||||
[shader("fragment")]
|
||||
float4 fragmentMain(VSOutput input)
|
||||
{
|
||||
return samplerArray.Sample(input.UV);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue