From ca052f275912752e4fc80c2d95fd0a0d9672d892 Mon Sep 17 00:00:00 2001 From: havetc Date: Sun, 5 Nov 2023 16:09:20 +0100 Subject: [PATCH] [DEV] Cleaning, polishing removing the clutter (all the model not required are no longer loaded and shown) Changing the initial camera position for a better view Modifying the frag shader, so that big body can now become a bit purple and are no longer exactly all the same color. -> this could be further properly refactored in the future --- src/Main.cpp | 39 +++++++++------------------------------ src/shaders/particle.vert | 5 +++-- 2 files changed, 12 insertions(+), 32 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index dba0571..7e43503 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -49,19 +49,12 @@ int main() return EXIT_FAILURE; } - Model gridModel, ruinsModel, carModelLeft, carModelRight, beetleModel, bikeModel, handModelLeft, handModelRight, + Model gridModel, handModelLeft, handModelRight, logoModel, particleModel; - std::vector models = { &particleModel, &gridModel, &ruinsModel, &carModelLeft, &carModelRight, - &beetleModel, &bikeModel, &handModelLeft, &handModelRight, &logoModel }; + std::vector models = { &particleModel, &gridModel, &handModelLeft, &handModelRight, &logoModel }; gridModel.type = PipeType::Grid; particleModel.type = PipeType::Part; - gridModel.worldMatrix = ruinsModel.worldMatrix = particleModel.worldMatrix = glm::mat4(1.0f); - carModelLeft.worldMatrix = - glm::rotate(glm::translate(glm::mat4(1.0f), { -3.5f, 0.0f, -7.0f }), glm::radians(75.0f), { 0.0f, 1.0f, 0.0f }); - carModelRight.worldMatrix = - glm::rotate(glm::translate(glm::mat4(1.0f), { 8.0f, 0.0f, -15.0f }), glm::radians(-15.0f), { 0.0f, 1.0f, 0.0f }); - beetleModel.worldMatrix = - glm::rotate(glm::translate(glm::mat4(1.0f), { -3.5f, 0.0f, -0.5f }), glm::radians(-125.0f), { 0.0f, 1.0f, 0.0f }); + gridModel.worldMatrix = particleModel.worldMatrix = glm::mat4(1.0f); logoModel.worldMatrix = glm::translate(glm::mat4(1.0f), { 0.0f, 3.0f, -10.0f }); MeshData* meshData = new MeshData; @@ -70,35 +63,19 @@ int main() return EXIT_FAILURE; } - if (!meshData->loadModel("models/Ruins.obj", MeshData::Color::White, models, 1u, 1u)) + if (!meshData->loadModel("models/Hand.obj", MeshData::Color::White, models, 1u, 2u)) { return EXIT_FAILURE; } - if (!meshData->loadModel("models/Car.obj", MeshData::Color::White, models, 2u, 2u)) + if (!meshData->loadModel("models/Logo.obj", MeshData::Color::White, models, 3u, 1u)) { return EXIT_FAILURE; } - if (!meshData->loadModel("models/Beetle.obj", MeshData::Color::White, models, 4u, 1u)) - { - return EXIT_FAILURE; - } - - if (!meshData->loadModel("models/Bike.obj", MeshData::Color::White, models, 5u, 1u)) - { - return EXIT_FAILURE; - } + //Set initial position + cameraMatrix = glm::translate(cameraMatrix, glm::vec3(0,-1,-2.5)); - if (!meshData->loadModel("models/Hand.obj", MeshData::Color::White, models, 6u, 2u)) - { - return EXIT_FAILURE; - } - - if (!meshData->loadModel("models/Logo.obj", MeshData::Color::White, models, 8u, 1u)) - { - return EXIT_FAILURE; - } Particles p; @@ -160,8 +137,10 @@ int main() handModelRight.worldMatrix = inverseCameraMatrix * controllers.getPose(1u); handModelRight.worldMatrix = glm::scale(handModelRight.worldMatrix, { -1.0f, 1.0f, 1.0f }); + /* Example of moving a model by editing its world matrix. bikeModel.worldMatrix = glm::rotate(glm::translate(glm::mat4(1.0f), { 0.5f, 0.0f, -4.5f }), time * 0.2f, { 0.0f, 1.0f, 0.0f }); + */ // Render renderer.render(cameraMatrix, swapchainImageIndex, time); diff --git a/src/shaders/particle.vert b/src/shaders/particle.vert index 0143caf..033fd64 100644 --- a/src/shaders/particle.vert +++ b/src/shaders/particle.vert @@ -29,8 +29,9 @@ void main () outColor.g *= inMass / 50.0; outColor.b *= inMass / 20.0; outColor = clamp(outColor,vec4(0),vec4(1)); - outColor.g -= clamp(0.2*(inMass-70)/30,0,1); - outColor.r -= clamp(0.4*(inMass-70)/30,0,1); + float oversize = clamp(2-log(inMass)/6,0,1); + outColor.g -= clamp(0.2*(inMass-70)/30,0,oversize); + outColor.r -= clamp(0.4*(inMass-70)/30,0,oversize); gl_Position = viewProjection.matrices[gl_ViewIndex] * world.matrix * vec4(inPos, 1.0); //point size depending on the distance!! gl_PointSize = 4 * pow(inMass,1.0/3.0) / ((gl_Position.z)); // try mass / 10 mass is between 10 and 100 At the moment