Hook up surface index buffer

This commit is contained in:
Magnus Norddahl 2023-10-20 19:46:49 +02:00
commit d06a9e1305
7 changed files with 30 additions and 3 deletions

View file

@ -93,6 +93,7 @@ void VkDescriptorSetManager::UpdateLevelMeshSet()
.AddBuffer(LevelMesh.Set.get(), 2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetRaytrace()->GetSurfaceUniformsBuffer())
.AddBuffer(LevelMesh.Set.get(), 3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, rsbuffers->Lightbuffer.UBO.get(), 0, sizeof(LightBufferUBO))
.AddBuffer(LevelMesh.Set.get(), 4, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, rsbuffers->Bonebuffer.SSO.get())
.AddBuffer(LevelMesh.Set.get(), 5, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetRaytrace()->GetSurfaceIndexBuffer())
.Execute(fb->GetDevice());
}
@ -272,6 +273,7 @@ void VkDescriptorSetManager::CreateLevelMeshLayout()
.AddBinding(2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT)
.AddBinding(3, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 1, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT)
.AddBinding(4, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT)
.AddBinding(5, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_VERTEX_BIT)
.DebugName("VkDescriptorSetManager.LevelMesh.Layout")
.Create(fb->GetDevice());
}
@ -312,7 +314,7 @@ void VkDescriptorSetManager::CreateLevelMeshPool()
{
LevelMesh.Pool = DescriptorPoolBuilder()
.AddPoolSize(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, 3)
.AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 2)
.AddPoolSize(VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 3)
.MaxSets(1)
.DebugName("VkDescriptorSetManager.LevelMesh.Pool")
.Create(fb->GetDevice());

View file

@ -108,3 +108,10 @@ layout(set = 1, binding = 5, std430) buffer BoneBufferSSO
{
mat4 bones[];
};
#ifdef USE_LEVELMESH
layout(set = 1, binding = 5) buffer SurfaceIndexBuffer
{
int surfaceIndices[];
};
#endif

View file

@ -2,14 +2,16 @@
void main()
{
#ifdef USE_LEVELMESH
if (vLightmap.z >= 0.0)
/*if (vLightmap.z >= 0.0)
{
FragColor = vec4(texture(LightMap, vLightmap).rgb, 1.0);
}
else
{
FragColor = vec4(vec3(pixelpos.w / 1000), 1.0);
}
}*/
FragColor.rgb = vec3(uLightLevel / 255.0);
FragColor.a = 1.0;
#else
#ifdef NO_CLIPDISTANCE_SUPPORT

View file

@ -16,6 +16,10 @@ layout(location = 7) in vec4 ClipDistanceA;
layout(location = 8) in vec4 ClipDistanceB;
#endif
#if defined(USE_LEVELMESH)
layout(location = 10) in flat int uDataIndex;
#endif
layout(location=0) out vec4 FragColor;
#ifdef GBUFFER_PASS
layout(location=1) out vec4 FragFog;

View file

@ -6,7 +6,11 @@
// This must match the PushConstants struct
layout(push_constant) uniform PushConstants
{
#if defined(USE_LEVELMESH)
int unused;
#else
int uDataIndex; // surfaceuniforms index
#endif
int uLightIndex; // dynamic lights
int uBoneIndexBase; // bone animation
int uFogballIndex; // fog balls

View file

@ -26,3 +26,7 @@ layout(location = 6) out vec4 vEyeNormal;
layout(location = 7) out vec4 ClipDistanceA;
layout(location = 8) out vec4 ClipDistanceB;
#endif
#if defined(USE_LEVELMESH)
layout(location = 10) out flat int uDataIndex;
#endif

View file

@ -8,6 +8,10 @@ void main()
vec2 parmTexCoord;
vec4 parmPosition;
#if defined(USE_LEVELMESH)
uDataIndex = surfaceIndices[gl_VertexIndex / 3];
#endif
BonesResult bones = ApplyBones();
parmTexCoord = aTexCoord;