Changeset 14ff67c in opengl-game for color.vert


Ignore:
Timestamp:
May 24, 2018, 2:35:35 AM (6 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
4f3262f
Parents:
e165b85
Message:

Use uniform buffers to store model matrices and add constants to toggle FPS display and vsync.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • color.vert

    re165b85 r14ff67c  
    11#version 410
    22
    3 uniform mat4 model, view, proj;
     3#define MAX_NUM_OBJECTS 1024
    44
    5 layout (std140) uniform shader_data {
    6   mat4 model_mat;
     5uniform mat4 view, proj;
     6
     7layout (std140) uniform models {
     8  mat4 model_mats[MAX_NUM_OBJECTS];
    79};
    810
     
    1012layout(location = 1) in vec3 vertex_color;
    1113layout(location = 2) in vec3 vertex_normal;
     14layout(location = 3) in uint ubo_index;
    1215
    1316out vec3 position_eye, normal_eye, color, light_position_eye;
     
    1720
    1821void main() {
    19   position_eye = vec3(view * model * vec4(vertex_position, 1.0));
    20   normal_eye = vec3(view * model * vec4 (vertex_normal, 0.0));
     22  position_eye = vec3(view * model_mats[ubo_index] * vec4(vertex_position, 1.0));
     23  normal_eye = vec3(view * model_mats[ubo_index] * vec4 (vertex_normal, 0.0));
    2124  color = vertex_color;
    2225  light_position_eye = vec3(view * vec4(light_position_world, 1.0));
Note: See TracChangeset for help on using the changeset viewer.