Correct sky sphere scale, fixed compiler warnings
This commit is contained in:
parent
e5872c3df4
commit
6b9a8f6051
1 changed files with 15 additions and 21 deletions
|
|
@ -129,7 +129,6 @@ public:
|
||||||
camera.setRotation(glm::vec3(-12.0f, 159.0f, 0.0f));
|
camera.setRotation(glm::vec3(-12.0f, 159.0f, 0.0f));
|
||||||
camera.setTranslation(glm::vec3(0.4f, 1.25f, 0.0f));
|
camera.setTranslation(glm::vec3(0.4f, 1.25f, 0.0f));
|
||||||
camera.movementSpeed = 5.0f;
|
camera.movementSpeed = 5.0f;
|
||||||
srand(time(NULL));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~VulkanExample()
|
~VulkanExample()
|
||||||
|
|
@ -238,7 +237,7 @@ public:
|
||||||
{
|
{
|
||||||
loadMesh(getAssetPath() + "models/plants.dae", &meshes.plants, vertexLayout, 0.0025f);
|
loadMesh(getAssetPath() + "models/plants.dae", &meshes.plants, vertexLayout, 0.0025f);
|
||||||
loadMesh(getAssetPath() + "models/plane_circle.dae", &meshes.ground, vertexLayout, PLANT_RADIUS + 1.0f);
|
loadMesh(getAssetPath() + "models/plane_circle.dae", &meshes.ground, vertexLayout, PLANT_RADIUS + 1.0f);
|
||||||
loadMesh(getAssetPath() + "models/skysphere.dae", &meshes.skysphere, vertexLayout, 512.0f);
|
loadMesh(getAssetPath() + "models/skysphere.dae", &meshes.skysphere, vertexLayout, 512.0f / 10.0f);
|
||||||
|
|
||||||
textureLoader->loadTextureArray(getAssetPath() + "textures/texturearray_plants_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, &textures.plants);
|
textureLoader->loadTextureArray(getAssetPath() + "textures/texturearray_plants_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, &textures.plants);
|
||||||
textureLoader->loadTexture(getAssetPath() + "textures/ground_dry_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, &textures.ground);
|
textureLoader->loadTexture(getAssetPath() + "textures/ground_dry_bc3.ktx", VK_FORMAT_BC3_UNORM_BLOCK, &textures.ground);
|
||||||
|
|
@ -327,9 +326,9 @@ public:
|
||||||
);
|
);
|
||||||
|
|
||||||
vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo();
|
vertices.inputState = vkTools::initializers::pipelineVertexInputStateCreateInfo();
|
||||||
vertices.inputState.vertexBindingDescriptionCount = vertices.bindingDescriptions.size();
|
vertices.inputState.vertexBindingDescriptionCount = static_cast<uint32_t>(vertices.bindingDescriptions.size());
|
||||||
vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data();
|
vertices.inputState.pVertexBindingDescriptions = vertices.bindingDescriptions.data();
|
||||||
vertices.inputState.vertexAttributeDescriptionCount = vertices.attributeDescriptions.size();
|
vertices.inputState.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertices.attributeDescriptions.size());
|
||||||
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
|
vertices.inputState.pVertexAttributeDescriptions = vertices.attributeDescriptions.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -344,7 +343,7 @@ public:
|
||||||
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
VkDescriptorPoolCreateInfo descriptorPoolInfo =
|
||||||
vkTools::initializers::descriptorPoolCreateInfo(
|
vkTools::initializers::descriptorPoolCreateInfo(
|
||||||
poolSizes.size(),
|
static_cast<uint32_t>(poolSizes.size()),
|
||||||
poolSizes.data(),
|
poolSizes.data(),
|
||||||
2);
|
2);
|
||||||
|
|
||||||
|
|
@ -375,7 +374,7 @@ public:
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
VkDescriptorSetLayoutCreateInfo descriptorLayout =
|
||||||
vkTools::initializers::descriptorSetLayoutCreateInfo(
|
vkTools::initializers::descriptorSetLayoutCreateInfo(
|
||||||
setLayoutBindings.data(),
|
setLayoutBindings.data(),
|
||||||
setLayoutBindings.size());
|
static_cast<uint32_t>(setLayoutBindings.size()));
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout));
|
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorLayout, nullptr, &descriptorSetLayout));
|
||||||
|
|
||||||
|
|
@ -419,7 +418,7 @@ public:
|
||||||
&textures.ground.descriptor)
|
&textures.ground.descriptor)
|
||||||
};
|
};
|
||||||
|
|
||||||
vkUpdateDescriptorSets(device, writeDescriptorSets.size(), writeDescriptorSets.data(), 0, NULL);
|
vkUpdateDescriptorSets(device, static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void preparePipelines()
|
void preparePipelines()
|
||||||
|
|
@ -468,7 +467,7 @@ public:
|
||||||
VkPipelineDynamicStateCreateInfo dynamicState =
|
VkPipelineDynamicStateCreateInfo dynamicState =
|
||||||
vkTools::initializers::pipelineDynamicStateCreateInfo(
|
vkTools::initializers::pipelineDynamicStateCreateInfo(
|
||||||
dynamicStateEnables.data(),
|
dynamicStateEnables.data(),
|
||||||
dynamicStateEnables.size(),
|
static_cast<uint32_t>(dynamicStateEnables.size()),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||||
|
|
@ -487,7 +486,7 @@ public:
|
||||||
pipelineCreateInfo.pViewportState = &viewportState;
|
pipelineCreateInfo.pViewportState = &viewportState;
|
||||||
pipelineCreateInfo.pDepthStencilState = &depthStencilState;
|
pipelineCreateInfo.pDepthStencilState = &depthStencilState;
|
||||||
pipelineCreateInfo.pDynamicState = &dynamicState;
|
pipelineCreateInfo.pDynamicState = &dynamicState;
|
||||||
pipelineCreateInfo.stageCount = shaderStages.size();
|
pipelineCreateInfo.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||||
pipelineCreateInfo.pStages = shaderStages.data();
|
pipelineCreateInfo.pStages = shaderStages.data();
|
||||||
|
|
||||||
// Indirect (and instanced) pipeline for the plants
|
// Indirect (and instanced) pipeline for the plants
|
||||||
|
|
@ -498,13 +497,13 @@ public:
|
||||||
// Ground
|
// Ground
|
||||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/indirectdraw/ground.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/indirectdraw/ground.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/indirectdraw/ground.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/indirectdraw/ground.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
//rasterizationState.cullMode = VK_CULL_MODE_BACK_BIT;
|
||||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.ground));
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.ground));
|
||||||
|
|
||||||
// Skysphere
|
// Skysphere
|
||||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/indirectdraw/skysphere.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
shaderStages[0] = loadShader(getAssetPath() + "shaders/indirectdraw/skysphere.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/indirectdraw/skysphere.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/indirectdraw/skysphere.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
|
//rasterizationState.cullMode = VK_CULL_MODE_FRONT_BIT;
|
||||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.skysphere));
|
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.skysphere));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -555,24 +554,19 @@ public:
|
||||||
stagingBuffer.destroy();
|
stagingBuffer.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
float rnd(float range)
|
|
||||||
{
|
|
||||||
return range * (rand() / double(RAND_MAX));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare (and stage) a buffer containing instanced data for the mesh draws
|
// Prepare (and stage) a buffer containing instanced data for the mesh draws
|
||||||
void prepareInstanceData()
|
void prepareInstanceData()
|
||||||
{
|
{
|
||||||
std::vector<InstanceData> instanceData;
|
std::vector<InstanceData> instanceData;
|
||||||
instanceData.resize(objectCount);
|
instanceData.resize(objectCount);
|
||||||
|
|
||||||
std::mt19937 rndGenerator(time(NULL));
|
std::mt19937 rndGenerator((unsigned)time(NULL));
|
||||||
std::uniform_real_distribution<double> uniformDist(0.0, 1.0);
|
std::uniform_real_distribution<float> uniformDist(0.0f, 1.0f);
|
||||||
|
|
||||||
for (auto i = 0; i < objectCount; i++)
|
for (uint32_t i = 0; i < objectCount; i++)
|
||||||
{
|
{
|
||||||
instanceData[i].rot = glm::vec3(0.0f, M_PI * uniformDist(rndGenerator), 0.0f);
|
instanceData[i].rot = glm::vec3(0.0f, float(M_PI) * uniformDist(rndGenerator), 0.0f);
|
||||||
float theta = 2 * M_PI * uniformDist(rndGenerator);
|
float theta = 2 * float(M_PI) * uniformDist(rndGenerator);
|
||||||
float phi = acos(1 - 2 * uniformDist(rndGenerator));
|
float phi = acos(1 - 2 * uniformDist(rndGenerator));
|
||||||
instanceData[i].pos = glm::vec3(sin(phi) * cos(theta), 0.0f, cos(phi)) * PLANT_RADIUS;
|
instanceData[i].pos = glm::vec3(sin(phi) * cos(theta), 0.0f, cos(phi)) * PLANT_RADIUS;
|
||||||
instanceData[i].scale = 1.0f + uniformDist(rndGenerator) * 2.0f;
|
instanceData[i].scale = 1.0f + uniformDist(rndGenerator) * 2.0f;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue