Descriptors now work in metal hopefully

This commit is contained in:
Dynamitos
2024-09-16 13:00:53 +02:00
parent 49e94d3b74
commit 6417ab940d
45 changed files with 435 additions and 476 deletions
+11 -7
View File
@@ -12,9 +12,13 @@ struct ViewParameter
float4x4 inverseProjection;
float4 cameraPos_WS;
float2 screenDimensions;
}
layout(set=0)
ParameterBlock<ViewParameter> pViewParams;
};
struct ViewParamWrapper
{
ParameterBlock<ViewParameter> c;
};
layout(set = 0)
ParameterBlock<ViewParamWrapper> pViewParams;
float4 worldToModel(float4x4 inverseTransform, float4 world)
{
@@ -27,7 +31,7 @@ float4 worldToModel(float4x4 inverseTransform, float4 world)
float4 viewToWorld(float4 view)
{
float4 world = mul(pViewParams.inverseViewMatrix, view);
float4 world = mul(pViewParams.c.inverseViewMatrix, view);
world = world / world.w;
@@ -43,7 +47,7 @@ float4 viewToModel(float4x4 inverseTransform, float4 view)
float4 clipToView(float4 clip)
{
float4 view = mul(pViewParams.inverseProjection, clip);
float4 view = mul(pViewParams.c.inverseProjection, clip);
view = view / view.w;
@@ -59,7 +63,7 @@ float4 clipToWorld(float4 clip)
float4 screenToView(float4 screen)
{
float2 texCoord = screen.xy / pViewParams.screenDimensions;
float2 texCoord = screen.xy / pViewParams.c.screenDimensions;
// Convert to clip space
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w);
@@ -88,7 +92,7 @@ float4 clipToScreen(float4 clip)
float oz = 1;
float pz = 0 - 1;
float zf = pz * ndc.z + oz;
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.screenDimensions, zf, 1.0f);
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.c.screenDimensions, zf, 1.0f);
}
struct Plane