Use mip mapping sampler by default, rotate tunnel when not paused
This commit is contained in:
parent
2758c47b86
commit
dad0a4d661
3 changed files with 19 additions and 15 deletions
|
|
@ -10,8 +10,8 @@ layout (location = 2) in vec3 inNormal;
|
||||||
layout (binding = 0) uniform UBO
|
layout (binding = 0) uniform UBO
|
||||||
{
|
{
|
||||||
mat4 projection;
|
mat4 projection;
|
||||||
|
mat4 view;
|
||||||
mat4 model;
|
mat4 model;
|
||||||
vec4 viewPos;
|
|
||||||
float lodBias;
|
float lodBias;
|
||||||
float samplerIndex;
|
float samplerIndex;
|
||||||
} ubo;
|
} ubo;
|
||||||
|
|
@ -31,5 +31,5 @@ void main()
|
||||||
outUV.s *= 10.0;
|
outUV.s *= 10.0;
|
||||||
outLodBias = ubo.lodBias;
|
outLodBias = ubo.lodBias;
|
||||||
outSamplerIndex = ubo.samplerIndex;
|
outSamplerIndex = ubo.samplerIndex;
|
||||||
gl_Position = ubo.projection * ubo.model * vec4(inPos, 1.0);
|
gl_Position = ubo.projection * ubo.view * ubo.model * vec4(inPos, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -28,13 +28,6 @@
|
||||||
#define VERTEX_BUFFER_BIND_ID 0
|
#define VERTEX_BUFFER_BIND_ID 0
|
||||||
#define ENABLE_VALIDATION false
|
#define ENABLE_VALIDATION false
|
||||||
|
|
||||||
// Vertex layout for this example
|
|
||||||
struct Vertex {
|
|
||||||
float pos[3];
|
|
||||||
float uv[2];
|
|
||||||
float normal[3];
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<vkMeshLoader::VertexLayout> vertexLayout =
|
std::vector<vkMeshLoader::VertexLayout> vertexLayout =
|
||||||
{
|
{
|
||||||
vkMeshLoader::VERTEX_LAYOUT_POSITION,
|
vkMeshLoader::VERTEX_LAYOUT_POSITION,
|
||||||
|
|
@ -72,9 +65,9 @@ public:
|
||||||
struct uboVS {
|
struct uboVS {
|
||||||
glm::mat4 projection;
|
glm::mat4 projection;
|
||||||
glm::mat4 view;
|
glm::mat4 view;
|
||||||
glm::vec4 viewPos;
|
glm::mat4 model;
|
||||||
float lodBias = 0.0f;
|
float lodBias = 0.0f;
|
||||||
float samplerIndex = 0.0f;
|
float samplerIndex = 1.0f;
|
||||||
} uboVS;
|
} uboVS;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -95,6 +88,8 @@ public:
|
||||||
camera.setTranslation(glm::vec3(10.0f, 0.0f, 0.0f));
|
camera.setTranslation(glm::vec3(10.0f, 0.0f, 0.0f));
|
||||||
camera.movementSpeed = 2.5f;
|
camera.movementSpeed = 2.5f;
|
||||||
camera.rotationSpeed = 0.5f;
|
camera.rotationSpeed = 0.5f;
|
||||||
|
timerSpeed *= 0.15f;
|
||||||
|
paused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
@ -439,7 +434,7 @@ public:
|
||||||
vertices.bindingDescriptions[0] =
|
vertices.bindingDescriptions[0] =
|
||||||
vkTools::initializers::vertexInputBindingDescription(
|
vkTools::initializers::vertexInputBindingDescription(
|
||||||
VERTEX_BUFFER_BIND_ID,
|
VERTEX_BUFFER_BIND_ID,
|
||||||
sizeof(Vertex),
|
vkMeshLoader::vertexSize(vertexLayout),
|
||||||
VK_VERTEX_INPUT_RATE_VERTEX);
|
VK_VERTEX_INPUT_RATE_VERTEX);
|
||||||
|
|
||||||
// Attribute descriptions
|
// Attribute descriptions
|
||||||
|
|
@ -451,21 +446,21 @@ public:
|
||||||
VERTEX_BUFFER_BIND_ID,
|
VERTEX_BUFFER_BIND_ID,
|
||||||
0,
|
0,
|
||||||
VK_FORMAT_R32G32B32_SFLOAT,
|
VK_FORMAT_R32G32B32_SFLOAT,
|
||||||
offsetof(Vertex, pos));
|
0);
|
||||||
// Location 1 : Texture coordinates
|
// Location 1 : Texture coordinates
|
||||||
vertices.attributeDescriptions[1] =
|
vertices.attributeDescriptions[1] =
|
||||||
vkTools::initializers::vertexInputAttributeDescription(
|
vkTools::initializers::vertexInputAttributeDescription(
|
||||||
VERTEX_BUFFER_BIND_ID,
|
VERTEX_BUFFER_BIND_ID,
|
||||||
1,
|
1,
|
||||||
VK_FORMAT_R32G32_SFLOAT,
|
VK_FORMAT_R32G32_SFLOAT,
|
||||||
offsetof(Vertex, uv));
|
3 * sizeof(float));
|
||||||
// Location 1 : Vertex normal
|
// Location 1 : Vertex normal
|
||||||
vertices.attributeDescriptions[2] =
|
vertices.attributeDescriptions[2] =
|
||||||
vkTools::initializers::vertexInputAttributeDescription(
|
vkTools::initializers::vertexInputAttributeDescription(
|
||||||
VERTEX_BUFFER_BIND_ID,
|
VERTEX_BUFFER_BIND_ID,
|
||||||
2,
|
2,
|
||||||
VK_FORMAT_R32G32B32_SFLOAT,
|
VK_FORMAT_R32G32B32_SFLOAT,
|
||||||
offsetof(Vertex, normal));
|
5 * sizeof(float));
|
||||||
|
|
||||||
vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo();
|
vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo();
|
||||||
vertices.inputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertices.bindingDescriptions.size());
|
vertices.inputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertices.bindingDescriptions.size());
|
||||||
|
|
@ -670,6 +665,11 @@ public:
|
||||||
uboVS.projection = camera.matrices.perspective;
|
uboVS.projection = camera.matrices.perspective;
|
||||||
uboVS.view = camera.matrices.view;
|
uboVS.view = camera.matrices.view;
|
||||||
|
|
||||||
|
if (!paused)
|
||||||
|
{
|
||||||
|
uboVS.model = glm::rotate(glm::mat4(), glm::radians(timer * 360.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
VK_CHECK_RESULT(uniformBufferVS.map());
|
VK_CHECK_RESULT(uniformBufferVS.map());
|
||||||
memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS));
|
memcpy(uniformBufferVS.mapped, &uboVS, sizeof(uboVS));
|
||||||
uniformBufferVS.unmap();
|
uniformBufferVS.unmap();
|
||||||
|
|
@ -694,6 +694,10 @@ public:
|
||||||
if (!prepared)
|
if (!prepared)
|
||||||
return;
|
return;
|
||||||
draw();
|
draw();
|
||||||
|
if (!paused)
|
||||||
|
{
|
||||||
|
updateUniformBuffers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void viewChanged()
|
virtual void viewChanged()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue