Viewport controls

This commit is contained in:
Dynamitos
2022-11-17 16:47:42 +01:00
parent f635ee2100
commit 4ba0bf3b45
73 changed files with 627 additions and 449 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ void computeFrustums(ComputeShaderInput in)
for(int i = 0; i < 4; i++)
{
viewSpace[i] = screenToView(screenSpace[i]).xyz;
viewSpace[i] = screenToClip(screenSpace[i]).xyz;
}
//Compute frustum
+3 -3
View File
@@ -105,9 +105,9 @@ void cullLights(ComputeShaderInput in)
float fMinDepth = asfloat(uMinDepth);
float fMaxDepth = asfloat(uMaxDepth);
float minDepthVS = clipToView(float4(0, 0, fMinDepth, 1)).z;
float maxDepthVS = clipToView(float4(0, 0, fMaxDepth, 1)).z;
float nearClipVS = clipToView(float4(0, 0, 0, 1.0f)).z;
float minDepthVS = fMinDepth;
float maxDepthVS = fMaxDepth;
float nearClipVS = 0.1f;
Plane minPlane = {float3(0, 0, -1), -minDepthVS};
+3 -16
View File
@@ -6,34 +6,21 @@ struct ViewParameter
{
float4x4 viewMatrix;
float4x4 projectionMatrix;
float4x4 inverseProjection;
float4 cameraPos_WS;
float2 screenDimensions;
}
layout(set = INDEX_VIEW_PARAMS, binding = 0, std430)
ConstantBuffer<ViewParameter> gViewParams;
// Convert clip space coordinates to view space
float4 clipToView( float4 clip )
{
// View space position.
float4 view = mul( gViewParams.inverseProjection, clip );
// Perspective projection.
view = view / view.w;
return view;
}
// Convert screen space coordinates to view space.
float4 screenToView( float4 screen )
float4 screenToClip( float4 screen )
{
// Convert to normalized texture coordinates
float2 texCoord = screen.xy / gViewParams.screenDimensions;
// Convert to clip space
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w );
return clipToView( clip );
// Convert to clip space
return float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w );
}
struct Plane