Everything is broken
This commit is contained in:
@@ -67,7 +67,7 @@ struct AABB
|
||||
{
|
||||
float4 clipCorner = mul(mvp, corners[i]);
|
||||
float4 screenCorner = clipToScreen(clipCorner);
|
||||
int2 screenCoords = int2(clamp(int(screenCorner.x), 0, int(pViewParams.c.screenDimensions.x)), clamp(int(screenCorner.y), 0, int(pViewParams.c.screenDimensions.y)));
|
||||
int2 screenCoords = int2(clamp(int(screenCorner.x), 0, int(pViewParams.screenDimensions.x)), clamp(int(screenCorner.y), 0, int(pViewParams.screenDimensions.y)));
|
||||
screenCornerMin = int2(min(screenCornerMin.x, screenCoords.x), min(screenCornerMin.y, screenCoords.y));
|
||||
screenCornerMax = int2(max(screenCornerMax.x, screenCoords.x), max(screenCornerMax.y, screenCoords.y));
|
||||
maxDepth = max(maxDepth, screenCorner.z);
|
||||
|
||||
@@ -13,12 +13,8 @@ struct ViewParameter
|
||||
float4 cameraPos_WS;
|
||||
float2 screenDimensions;
|
||||
};
|
||||
struct ViewParamWrapper
|
||||
{
|
||||
ParameterBlock<ViewParameter> c;
|
||||
};
|
||||
layout(set = 0)
|
||||
ParameterBlock<ViewParamWrapper> pViewParams;
|
||||
ParameterBlock<ViewParameter> pViewParams;
|
||||
|
||||
float4 worldToModel(float4x4 inverseTransform, float4 world)
|
||||
{
|
||||
@@ -31,7 +27,7 @@ float4 worldToModel(float4x4 inverseTransform, float4 world)
|
||||
|
||||
float4 viewToWorld(float4 view)
|
||||
{
|
||||
float4 world = mul(pViewParams.c.inverseViewMatrix, view);
|
||||
float4 world = mul(pViewParams.inverseViewMatrix, view);
|
||||
|
||||
world = world / world.w;
|
||||
|
||||
@@ -47,7 +43,7 @@ float4 viewToModel(float4x4 inverseTransform, float4 view)
|
||||
|
||||
float4 clipToView(float4 clip)
|
||||
{
|
||||
float4 view = mul(pViewParams.c.inverseProjection, clip);
|
||||
float4 view = mul(pViewParams.inverseProjection, clip);
|
||||
|
||||
view = view / view.w;
|
||||
|
||||
@@ -63,7 +59,7 @@ float4 clipToWorld(float4 clip)
|
||||
|
||||
float4 screenToView(float4 screen)
|
||||
{
|
||||
float2 texCoord = screen.xy / pViewParams.c.screenDimensions;
|
||||
float2 texCoord = screen.xy / pViewParams.screenDimensions;
|
||||
|
||||
// Convert to clip space
|
||||
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w);
|
||||
@@ -92,7 +88,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.c.screenDimensions, zf, 1.0f);
|
||||
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.screenDimensions, zf, 1.0f);
|
||||
}
|
||||
|
||||
struct Plane
|
||||
|
||||
@@ -6,11 +6,7 @@ struct DispatchParams
|
||||
uint pad0;
|
||||
uint3 numThreads;
|
||||
uint pad1;
|
||||
RWStructuredBuffer<Frustum> frustums;
|
||||
};
|
||||
|
||||
struct DispatchParamWrapper
|
||||
{
|
||||
DispatchParams p;
|
||||
RWStructuredBuffer<Frustum> frustums;
|
||||
}
|
||||
ParameterBlock<DispatchParamWrapper> pDispatchParams;
|
||||
ParameterBlock<DispatchParams> pDispatchParams;
|
||||
@@ -51,7 +51,7 @@ struct FragmentParameter
|
||||
float3x3 tbn = float3x3(normalize(tangent_WS), normalize(biTangent_WS), normalize(normal_WS));
|
||||
result.tbn = tbn;
|
||||
result.position_TS = mul(tbn, position_WS);
|
||||
result.viewDir_TS = mul(tbn, normalize(pViewParams.c.cameraPos_WS.xyz - position_WS));
|
||||
result.viewDir_TS = mul(tbn, normalize(pViewParams.cameraPos_WS.xyz - position_WS));
|
||||
result.normal_TS = mul(tbn, normal_WS);
|
||||
return result;
|
||||
}
|
||||
@@ -102,8 +102,8 @@ struct VertexAttributes
|
||||
{
|
||||
float4 modelPos = float4(position_MS, 1);
|
||||
float4 worldPos = mul(transformMatrix, modelPos);
|
||||
float4 viewPos = mul(pViewParams.c.viewMatrix, worldPos);
|
||||
float4 clipPos = mul(pViewParams.c.projectionMatrix, viewPos);
|
||||
float4 viewPos = mul(pViewParams.viewMatrix, worldPos);
|
||||
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
|
||||
FragmentParameter result;
|
||||
result.position_CS = clipPos;
|
||||
#ifndef POS_ONLY
|
||||
|
||||
@@ -20,8 +20,8 @@ struct MeshData
|
||||
uint32_t numIndices;
|
||||
};
|
||||
|
||||
static const uint32_t MAX_VERTICES = 64;
|
||||
static const uint32_t MAX_PRIMITIVES = 126;
|
||||
static const uint32_t MAX_VERTICES = 256;
|
||||
static const uint32_t MAX_PRIMITIVES = 256;
|
||||
static const uint32_t MAX_MESHLETS_PER_INSTANCE = 2048;
|
||||
|
||||
struct InstanceData
|
||||
|
||||
@@ -51,7 +51,7 @@ struct StaticMeshVertexData
|
||||
{
|
||||
attributes.texCoords[i] = float2(uint16ToFloat(texCoords[i][index * 2 + 0]), uint16ToFloat(texCoords[i][index * 2 + 1]));
|
||||
}
|
||||
attributes.vertexColor = float3(color[index * 3 + 0], color[index * 3 + 1] , color[index * 3 + 2]);
|
||||
attributes.vertexColor = float3(uint16ToFloat(color[index * 3 + 0]), uint16ToFloat(color[index * 3 + 1]) , uint16ToFloat(color[index * 3 + 2]));
|
||||
#endif
|
||||
return attributes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user