Changeset 60578ce in opengl-game for shaders/ship.vert


Ignore:
Timestamp:
Dec 18, 2019, 2:48:28 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
a79be34
Parents:
7c929fc
Message:

In VulkanGame, make lighting work correctly in the ship shader with the model, view, and projection matrices all being applied

File:
1 edited

Legend:

Unmodified
Added
Removed
  • shaders/ship.vert

    r7c929fc r60578ce  
    2424layout(location = 2) out vec3 normal_eye;
    2525layout(location = 3) out vec3 light_position_eye;
     26layout(location = 4) out vec3 light2_position_eye;
    2627
    27 // fixed point light position
     28// fixed point light positions
    2829//vec3 light_position_world = vec3(0.0, 0.0, 2.0);
    29 //vec3 light_position_world = vec3(0.4, 1.5, 0.8);
    30 vec3 light_position_world = vec3(0.4, 0.0, 0.2);
     30//vec3 light2_position_world = vec3(0.0, 1.5, -0.1);
     31vec3 light_position_world = vec3(7.0, -7.0, -10.0);
     32vec3 light2_position_world = vec3(4.0, -3.0, -10.0);
    3133
    3234// TODO: This does not account for scaling in the model matrix
    3335// Check Anton's book to see how to fix this
    3436void main() {
    35    //position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));
    36    position_eye = vec3(vec4(vertex_position, 1.0));
     37   position_eye = vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_position, 1.0));
    3738
    3839   // Using 0.0 instead of 1.0 means translations won't effect the normal
    39    //normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
    40    normal_eye = normalize(vec3(vec4(vertex_normal, 0.0)));
     40   normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
     41
    4142   color = vertex_color;
    42    //light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));
    43    light_position_eye = vec3(vec4(light_position_world, 1.0));
    4443
    45    //gl_Position = ubo.proj * vec4(position_eye, 1.0);
    46    gl_Position = vec4(vertex_position, 1.0);
     44   light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));
     45   light2_position_eye = vec3(ubo.view * vec4(light2_position_world, 1.0));
     46
     47   gl_Position = ubo.proj * vec4(position_eye, 1.0);
    4748}
Note: See TracChangeset for help on using the changeset viewer.