Add slang shaders for additional samples

This commit is contained in:
Sascha Willems 2025-05-10 13:58:14 +02:00
parent d0a20a693f
commit 7e5a387eb8
5 changed files with 320 additions and 0 deletions

View file

@ -0,0 +1,46 @@
/* Copyright (c) 2025, Sascha Willems
*
* SPDX-License-Identifier: MIT
*
*/
struct VSInput
{
float3 Pos;
};
struct VSOutput
{
float4 Pos : SV_POSITION;
float3 UVW;
};
struct UBO
{
float4x4 projection;
float4x4 model;
float4x4 normal;
float4x4 view;
};
ConstantBuffer<UBO> ubo;
SamplerCube samplerCubeMap;
[shader("vertex")]
VSOutput vertexMain(VSInput input)
{
VSOutput output;
// Remove translation from view matrix
float4x4 viewMat = ubo.view;
viewMat[0][3] = 0.0;
viewMat[1][3] = 0.0;
viewMat[2][3] = 0.0;
output.UVW = input.Pos;
output.Pos = mul(ubo.projection, mul(viewMat, mul(ubo.model, float4(input.Pos.xyz, 1.0))));
return output;
}
[shader("fragment")]
float4 fragmentMain(VSOutput input)
{
return samplerCubeMap.Sample(input.UVW);
}