Changeset 914bb99 in opengl-game


Ignore:
Timestamp:
Apr 9, 2021, 3:26:38 PM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
a00eb06
Parents:
5049354
Message:

In VulkanGame, specify each vertex explicitly for the model pipeline instead of using the same index multiple times, in order to support the current approach to normal calculation.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.hpp

    r5049354 r914bb99  
    4444
    4545class VulkanGame {
     46
    4647   public:
     48
    4749      VulkanGame();
    4850      ~VulkanGame();
     
    5153
    5254   private:
     55
    5356      static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
    5457         VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
  • vulkan-game.cpp

    r5049354 r914bb99  
    135135         {{ 0.5f, -0.5f,  0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
    136136         {{ 0.5f,  0.5f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
    137          {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
    138          }), {
    139             0, 1, 2, 2, 3, 0
     137         {{ 0.5f,  0.5f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
     138         {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
     139         {{-0.5f, -0.5f,  0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}
     140      }), {
     141         0, 1, 2, 3, 4, 5
    140142      }, {
    141143         mat4(1.0f)
     
    151153         {{ 0.5f, -0.5f,  0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
    152154         {{ 0.5f,  0.5f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
    153          {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
    154          }), {
    155             0, 1, 2, 2, 3, 0
     155         {{ 0.5f,  0.5f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
     156         {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
     157         {{-0.5f, -0.5f,  0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}
     158      }), {
     159         0, 1, 2, 3, 4, 5
    156160      }, {
    157161         mat4(1.0f)
     
    573577   modelPipeline = GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject>(
    574578      VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, physicalDevice, device, renderPass,
    575       { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 16, 24, 10);
     579      { 0, 0, (int)swapChainExtent.width, (int)swapChainExtent.height }, swapChainImages, 24, 24, 10);
    576580
    577581   shipPipeline = GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject>(
     
    664668             io.WantCaptureMouse) {
    665669            if (sdlEvent.type == SDL_MOUSEWHEEL || sdlEvent.type == SDL_MOUSEBUTTONDOWN ||
    666                sdlEvent.type == SDL_MOUSEBUTTONUP) {
     670                sdlEvent.type == SDL_MOUSEBUTTONUP) {
    667671               continue;
    668672            }
     
    703707                           {{ 0.5f, -0.5f,  0.0f}, {0.0f, 1.0f, 0.0f}, {1.0f, 1.0f}},
    704708                           {{ 0.5f,  0.5f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
    705                            {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}}
     709                           {{ 0.5f,  0.5f,  0.0f}, {0.0f, 0.0f, 1.0f}, {1.0f, 0.0f}},
     710                           {{-0.5f,  0.5f,  0.0f}, {1.0f, 1.0f, 1.0f}, {0.0f, 0.0f}},
     711                           {{-0.5f, -0.5f,  0.0f}, {1.0f, 0.0f, 0.0f}, {0.0f, 1.0f}}
    706712                        }), {
    707                            0, 1, 2, 2, 3, 0
     713                           0, 1, 2, 3, 4, 5
    708714                        }, {
    709715                           mat4(1.0f)
  • vulkan-game.hpp

    r5049354 r914bb99  
    212212
    213213class VulkanGame {
     214
    214215   public:
    215216
     
    558559}
    559560
     561// This function sets all the normals for a face to be parallel
     562// This is good for models that should have distinct faces, but bad for models that should appear smooth
     563// Maybe add an option to set all copies of a point to have the same normal and have the direction of
     564// that normal be the weighted average of all the faces it is a part of, where the weight from each face
     565// is its surface area.
     566
     567// TODO: Since the current approach to normal calculation basicaly makes indexed drawing useless, see if it's
     568// feasible to automatically enable/disable indexed drawing based on which approach is used
    560569template<class VertexType>
    561570vector<VertexType> VulkanGame::addVertexNormals(vector<VertexType> vertices) {
Note: See TracChangeset for help on using the changeset viewer.