Changeset 8d92284 in opengl-game
- Timestamp:
- Apr 10, 2021, 1:31:20 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- b8efa56
- Parents:
- a00eb06
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
shaders/ship.frag
ra00eb06 r8d92284 4 4 layout(location = 0) in vec3 position_eye; 5 5 layout(location = 1) in vec3 color; 6 layout(location = 2) in vec3 normal_eye; 7 layout(location = 3) in vec3 light_position_eye; 8 layout(location = 4) in vec3 light2_position_eye; 6 layout(location = 2) in vec2 fragTexCoord; 7 layout(location = 3) in vec3 normal_eye; 8 layout(location = 4) in vec3 light_position_eye; 9 layout(location = 5) in vec3 light2_position_eye; 9 10 10 11 layout(location = 0) out vec4 frag_color; … … 55 56 56 57 // specular intensity 57 vec3 Is2 = Ls * Ks * specular_factor2 ;58 vec3 Is2 = Ls * Ks * specular_factor2 + vec3(fragTexCoord, 0.0) - vec3(fragTexCoord, 0.0); 58 59 59 60 frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2) / 2.0, 1.0); -
shaders/ship.vert
ra00eb06 r8d92284 17 17 layout(location = 0) in vec3 vertex_position; 18 18 layout(location = 1) in vec3 vertex_color; 19 layout(location = 2) in vec3 vertex_normal; 20 layout(location = 3) in uint obj_index; 19 layout(location = 2) in vec2 inTexCoord; 20 layout(location = 3) in vec3 vertex_normal; 21 layout(location = 4) in uint obj_index; 21 22 22 23 layout(location = 0) out vec3 position_eye; 23 24 layout(location = 1) out vec3 color; 24 layout(location = 2) out vec3 normal_eye; 25 layout(location = 3) out vec3 light_position_eye; 26 layout(location = 4) out vec3 light2_position_eye; 25 layout(location = 2) out vec2 fragTexCoord; 26 layout(location = 3) out vec3 normal_eye; 27 layout(location = 4) out vec3 light_position_eye; 28 layout(location = 5) out vec3 light2_position_eye; 27 29 28 30 // fixed point light positions … … 40 42 color = vertex_color; 41 43 44 fragTexCoord = inTexCoord; 45 42 46 light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0)); 43 47 light2_position_eye = vec3(ubo.view * vec4(light2_position_world, 1.0)); -
vulkan-game.cpp
ra00eb06 r8d92284 174 174 modelPipeline.createDescriptorSets(swapChainImages); 175 175 176 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ShipVertex::pos)); 177 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ShipVertex::color)); 178 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ShipVertex::normal)); 179 shipPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ShipVertex::objIndex)); 176 // START UNREVIEWED SECTION 177 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::pos)); 178 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::color)); 179 shipPipeline.addAttribute(VK_FORMAT_R32G32_SFLOAT, offset_of(&ModelVertex::texCoord)); 180 shipPipeline.addAttribute(VK_FORMAT_R32G32B32_SFLOAT, offset_of(&ModelVertex::normal)); 181 shipPipeline.addAttribute(VK_FORMAT_R32_UINT, offset_of(&ModelVertex::objIndex)); 180 182 181 183 createBufferSet(sizeof(UBO_VP_mats), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, … … 188 190 // TODO: With the normals, indexing basically becomes pointless since no vertices will have exactly 189 191 // the same data. Add an option to make some pipelines not use indexing 190 SceneObject< ShipVertex, SSBO_ModelObject>& ship = addObject(shipObjects, shipPipeline,191 addObjectIndex< ShipVertex>(shipObjects.size(),192 addVertexNormals< ShipVertex>({192 SceneObject<ModelVertex, SSBO_ModelObject>& ship = addObject(shipObjects, shipPipeline, 193 addObjectIndex<ModelVertex>(shipObjects.size(), 194 addVertexNormals<ModelVertex>({ 193 195 194 196 //back … … 482 484 explosionPipeline.createDescriptorSets(swapChainImages); 483 485 486 // END UNREVIEWED SECTION 487 484 488 currentRenderScreenFn = &VulkanGame::renderMainScreen; 485 489 … … 582 586 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 24, 24, 10); 583 587 584 shipPipeline = GraphicsPipeline_Vulkan< ShipVertex, SSBO_ModelObject>(588 shipPipeline = GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject>( 585 589 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass, 586 590 { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 138, 138, 10); … … 723 727 translate(mat4(1.0f), vec3(0.0f, 0.0f, zOffset)); 724 728 texturedSquare.modified = true; 729 // START UNREVIEWED SECTION 725 730 } else if (e.key.keycode == SDL_SCANCODE_Z && leftLaserIdx == -1) { 726 731 // TODO: When I start actually removing objects from the object vectors, … … 745 750 746 751 rightLaserIdx = laserObjects.size() - 1; 752 // END UNREVIEWED SECTION 747 753 } else { 748 754 cout << "Key event detected" << endl; … … 750 756 break; 751 757 case UI_EVENT_KEYUP: 758 // START UNREVIEWED SECTION 752 759 if (e.key.keycode == SDL_SCANCODE_Z && leftLaserIdx != -1) { 753 760 laserObjects[leftLaserIdx].ssbo.deleted = true; … … 769 776 } 770 777 } 778 // END UNREVIEWED SECTION 771 779 break; 772 780 case UI_EVENT_WINDOW: … … 792 800 // Check which keys are held down 793 801 794 SceneObject< ShipVertex, SSBO_ModelObject>& ship = shipObjects[0];802 SceneObject<ModelVertex, SSBO_ModelObject>& ship = shipObjects[0]; 795 803 796 804 if (gui->keyPressed(SDL_SCANCODE_LEFT)) { … … 836 844 shouldRecreateSwapChain = false; 837 845 } 838 } 846 }// REVIEWED TO THIS POINT 839 847 840 848 updateScene(); -
vulkan-game.hpp
ra00eb06 r8d92284 47 47 vec3 color; 48 48 vec2 texCoord; 49 vec3 normal;50 unsigned int objIndex;51 };52 53 struct ShipVertex {54 vec3 pos;55 vec3 color;56 49 vec3 normal; 57 50 unsigned int objIndex; … … 309 302 // wouldn't work since the whole pipeline couldn't have a common set of descriptors for the textures 310 303 GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline; 311 GraphicsPipeline_Vulkan< ShipVertex, SSBO_ModelObject> shipPipeline;304 GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> shipPipeline; 312 305 GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid> asteroidPipeline; 313 306 GraphicsPipeline_Vulkan<LaserVertex, SSBO_Laser> laserPipeline; … … 330 323 UBO_VP_mats object_VP_mats; 331 324 332 vector<SceneObject< ShipVertex, SSBO_ModelObject>> shipObjects;325 vector<SceneObject<ModelVertex, SSBO_ModelObject>> shipObjects; 333 326 334 327 vector<VkBuffer> uniformBuffers_shipPipeline;
Note:
See TracChangeset
for help on using the changeset viewer.