Extending position only support
This commit is contained in:
@@ -20,6 +20,7 @@ struct LightingParameter
|
||||
struct FragmentParameter
|
||||
{
|
||||
float4 position_CS : SV_Position;
|
||||
#ifndef POS_ONLY
|
||||
float3 cameraPos_WS: POSITION0;
|
||||
float3 normal_WS : NORMAL0;
|
||||
float3 tangent_WS : TANGENT0;
|
||||
@@ -47,6 +48,7 @@ struct FragmentParameter
|
||||
result.normal_WS = normal_WS;
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// data passed to visibility render
|
||||
@@ -60,11 +62,13 @@ struct VisibilityParameter
|
||||
struct VertexAttributes
|
||||
{
|
||||
float3 position_MS;
|
||||
#ifndef POS_ONLY
|
||||
float3 normal_MS;
|
||||
float3 tangent_MS;
|
||||
float3 biTangent_MS;
|
||||
float3 vertexColor;
|
||||
float2 texCoords[MAX_TEXCOORDS];
|
||||
#endif
|
||||
FragmentParameter getParameter(float4x4 transformMatrix)
|
||||
{
|
||||
float4 modelPos = float4(position_MS, 1);
|
||||
@@ -73,6 +77,7 @@ struct VertexAttributes
|
||||
float4 clipPos = mul(pViewParams.projectionMatrix, viewPos);
|
||||
FragmentParameter result;
|
||||
result.position_CS = clipPos;
|
||||
#ifndef POS_ONLY
|
||||
float3x3 normalMatrix = float3x3(transformMatrix);
|
||||
float3 T = mul(normalMatrix, tangent_MS);
|
||||
float3 N = mul(normalMatrix, normal_MS);
|
||||
@@ -87,6 +92,7 @@ struct VertexAttributes
|
||||
{
|
||||
result.texCoords[i] = texCoords[i];
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,26 +34,10 @@ struct InstanceData
|
||||
|
||||
struct MeshletCullingInfo
|
||||
{
|
||||
uint32_t visible[MAX_PRIMITIVES / 32];
|
||||
// lookup if a specific triangle is visible
|
||||
bool triangleVisible(uint32_t primIndex)
|
||||
uint32_t visible;
|
||||
bool wasVisible()
|
||||
{
|
||||
uint32_t arrIdx = primIndex / 32;
|
||||
uint32_t cullIdx = primIndex % 32;
|
||||
return (visible[arrIdx] & (1 << cullIdx)) != 0;
|
||||
}
|
||||
bool triangleCulled(uint32_t primIndex)
|
||||
{
|
||||
return !triangleVisible(primIndex);
|
||||
}
|
||||
bool anyVisible()
|
||||
{
|
||||
uint result = 0;
|
||||
for(uint i = 0; i < MAX_PRIMITIVES / 32; ++i)
|
||||
{
|
||||
result |= visible[i];
|
||||
}
|
||||
return result != 0;
|
||||
return bool(visible);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -80,17 +64,14 @@ struct Scene
|
||||
layout(set=2)
|
||||
ParameterBlock<Scene> pScene;
|
||||
|
||||
uint32_t encodePrimitive(uint32_t primitiveId, uint32_t meshletId)
|
||||
uint32_t encodePrimitive(uint32_t meshletId)
|
||||
{
|
||||
return primitiveId + (meshletId * uint(MAX_PRIMITIVES));
|
||||
return meshletId;
|
||||
}
|
||||
|
||||
uint2 decodePrimitive(uint32_t encoded)
|
||||
uint decodePrimitive(uint32_t encoded)
|
||||
{
|
||||
uint prim = uint(encoded % MAX_PRIMITIVES);
|
||||
encoded = encoded / MAX_PRIMITIVES;
|
||||
uint meshletId = uint(encoded);
|
||||
return uint2(prim, meshletId);
|
||||
return encoded;
|
||||
}
|
||||
|
||||
struct MeshPayload
|
||||
|
||||
@@ -8,6 +8,7 @@ struct StaticMeshVertexData : IVertexData
|
||||
{
|
||||
VertexAttributes attributes;
|
||||
attributes.position_MS = positions[index].xyz;
|
||||
#ifndef POS_ONLY
|
||||
attributes.normal_MS = normals[index].xyz;
|
||||
attributes.tangent_MS = tangents[index].xyz;
|
||||
attributes.biTangent_MS = biTangents[index].xyz;
|
||||
@@ -16,14 +17,9 @@ struct StaticMeshVertexData : IVertexData
|
||||
attributes.texCoords[i] = texCoords[i][index];
|
||||
}
|
||||
attributes.vertexColor = color[index].xyz;
|
||||
#endif
|
||||
return attributes;
|
||||
}
|
||||
VertexAttributes getPosition(uint index)
|
||||
{
|
||||
VertexAttributes attributes;
|
||||
attributes.position_MS = positions[index].xyz;
|
||||
return attributes;
|
||||
}
|
||||
StructuredBuffer<float4> positions;
|
||||
StructuredBuffer<float4> normals;
|
||||
StructuredBuffer<float4> tangents;
|
||||
|
||||
@@ -9,7 +9,6 @@ struct VertexInput
|
||||
interface IVertexData
|
||||
{
|
||||
VertexAttributes getAttributes(uint index);
|
||||
VertexAttributes getPosition(uint index);
|
||||
};
|
||||
|
||||
layout(set=1)
|
||||
|
||||
Reference in New Issue
Block a user