diff --git a/computecullandlod/computecullandlod.cpp b/computecullandlod/computecullandlod.cpp index 39c39542..eba0348e 100644 --- a/computecullandlod/computecullandlod.cpp +++ b/computecullandlod/computecullandlod.cpp @@ -33,7 +33,7 @@ #if defined(__ANDROID__) #define OBJECT_COUNT 32 #else -#define OBJECT_COUNT 96 +#define OBJECT_COUNT 64 #endif #define MAX_LOD_LEVEL 5 @@ -43,7 +43,6 @@ std::vector vertexLayout = { vkMeshLoader::VERTEX_LAYOUT_POSITION, vkMeshLoader::VERTEX_LAYOUT_NORMAL, - vkMeshLoader::VERTEX_LAYOUT_UV, vkMeshLoader::VERTEX_LAYOUT_COLOR }; @@ -65,8 +64,6 @@ public: // Per-instance data block struct InstanceData { glm::vec3 pos; - float texIndex; - glm::vec3 rot; float scale; }; @@ -258,21 +255,13 @@ public: VK_FORMAT_R32G32B32_SFLOAT, sizeof(float) * 3) ); - // Location 2 : Texture coordinates + // Location 2 : Color vertices.attributeDescriptions.push_back( vkTools::initializers::vertexInputAttributeDescription( VERTEX_BUFFER_BIND_ID, 2, - VK_FORMAT_R32G32_SFLOAT, - sizeof(float) * 6) - ); - // Location 3 : Color - vertices.attributeDescriptions.push_back( - vkTools::initializers::vertexInputAttributeDescription( - VERTEX_BUFFER_BIND_ID, - 3, VK_FORMAT_R32G32B32_SFLOAT, - sizeof(float) * 8) + sizeof(float) * 6) ); // Instanced attributes @@ -281,20 +270,10 @@ public: vkTools::initializers::vertexInputAttributeDescription( INSTANCE_BUFFER_BIND_ID, 4, VK_FORMAT_R32G32B32_SFLOAT, offsetof(InstanceData, pos)) ); - // Location 5: Rotation + // Location 5: Scale vertices.attributeDescriptions.push_back( vkTools::initializers::vertexInputAttributeDescription( - INSTANCE_BUFFER_BIND_ID, 5, VK_FORMAT_R32G32B32_SFLOAT, offsetof(InstanceData, rot)) - ); - // Location 6: Scale - vertices.attributeDescriptions.push_back( - vkTools::initializers::vertexInputAttributeDescription( - INSTANCE_BUFFER_BIND_ID, 6, VK_FORMAT_R32_SFLOAT, offsetof(InstanceData, scale)) - ); - // Location 7: Texture array layer index - vertices.attributeDescriptions.push_back( - vkTools::initializers::vertexInputAttributeDescription( - INSTANCE_BUFFER_BIND_ID, 7, VK_FORMAT_R32_SFLOAT, offsetof(InstanceData, texIndex)) + INSTANCE_BUFFER_BIND_ID, 5, VK_FORMAT_R32_SFLOAT, offsetof(InstanceData, scale)) ); vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo(); @@ -561,7 +540,6 @@ public: uint32_t index = x + y * OBJECT_COUNT + z * OBJECT_COUNT * OBJECT_COUNT; instanceData[index].pos = glm::vec3((float)x, (float)y, (float)z) - glm::vec3((float)OBJECT_COUNT / 2.0f); instanceData[index].scale = 2.0f; - instanceData[index].rot = glm::vec3(0.0f); } } } diff --git a/data/shaders/computecullandlod/cull.comp b/data/shaders/computecullandlod/cull.comp index a9ae7974..d752d6f3 100644 --- a/data/shaders/computecullandlod/cull.comp +++ b/data/shaders/computecullandlod/cull.comp @@ -7,8 +7,8 @@ layout (constant_id = 0) const int MAX_LOD_LEVEL = 5; struct InstanceData { - vec4 pos; - vec4 rot; + vec3 pos; + float scale; }; // Binding 0: Instance input data for culling diff --git a/data/shaders/computecullandlod/cull.comp.spv b/data/shaders/computecullandlod/cull.comp.spv index 31e21853..47208954 100644 Binary files a/data/shaders/computecullandlod/cull.comp.spv and b/data/shaders/computecullandlod/cull.comp.spv differ diff --git a/data/shaders/computecullandlod/indirectdraw.frag b/data/shaders/computecullandlod/indirectdraw.frag index 87c64b6b..36a29da4 100644 --- a/data/shaders/computecullandlod/indirectdraw.frag +++ b/data/shaders/computecullandlod/indirectdraw.frag @@ -5,9 +5,8 @@ layout (location = 0) in vec3 inNormal; layout (location = 1) in vec3 inColor; -layout (location = 2) in vec3 inUV; -layout (location = 3) in vec3 inViewVec; -layout (location = 4) in vec3 inLightVec; +layout (location = 2) in vec3 inViewVec; +layout (location = 3) in vec3 inLightVec; layout (location = 0) out vec4 outFragColor; diff --git a/data/shaders/computecullandlod/indirectdraw.frag.spv b/data/shaders/computecullandlod/indirectdraw.frag.spv index 61e0a1ba..3d585528 100644 Binary files a/data/shaders/computecullandlod/indirectdraw.frag.spv and b/data/shaders/computecullandlod/indirectdraw.frag.spv differ diff --git a/data/shaders/computecullandlod/indirectdraw.vert b/data/shaders/computecullandlod/indirectdraw.vert index 5a6ee1c4..9ad23897 100644 --- a/data/shaders/computecullandlod/indirectdraw.vert +++ b/data/shaders/computecullandlod/indirectdraw.vert @@ -6,14 +6,11 @@ // Vertex attributes layout (location = 0) in vec4 inPos; layout (location = 1) in vec3 inNormal; -layout (location = 2) in vec2 inUV; -layout (location = 3) in vec3 inColor; +layout (location = 2) in vec3 inColor; // Instanced attributes layout (location = 4) in vec3 instancePos; -layout (location = 5) in vec3 instanceRot; -layout (location = 6) in float instanceScale; -layout (location = 7) in float instanceTexIndex; +layout (location = 5) in float instanceScale; layout (binding = 0) uniform UBO { @@ -23,9 +20,8 @@ layout (binding = 0) uniform UBO layout (location = 0) out vec3 outNormal; layout (location = 1) out vec3 outColor; -layout (location = 2) out vec3 outUV; -layout (location = 3) out vec3 outViewVec; -layout (location = 4) out vec3 outLightVec; +layout (location = 2) out vec3 outViewVec; +layout (location = 3) out vec3 outLightVec; out gl_PerVertex { @@ -35,12 +31,10 @@ out gl_PerVertex void main() { outColor = inColor; - outUV = vec3(inUV, instanceTexIndex); - outUV.t = 1.0 - outUV.t; - outNormal = inNormal;// * mat3(rotMat); + outNormal = inNormal; - vec4 pos = vec4((inPos.xyz * instanceScale) + instancePos, 1.0)/* rotMat*/; + vec4 pos = vec4((inPos.xyz * instanceScale) + instancePos, 1.0); gl_Position = ubo.projection * ubo.modelview * pos; diff --git a/data/shaders/computecullandlod/indirectdraw.vert.spv b/data/shaders/computecullandlod/indirectdraw.vert.spv index e7a3f524..0b18663b 100644 Binary files a/data/shaders/computecullandlod/indirectdraw.vert.spv and b/data/shaders/computecullandlod/indirectdraw.vert.spv differ