source: opengl-game/shaders/model.vert@ b01b50c

feature/imgui-sdl
Last change on this file since b01b50c was a00eb06, checked in by Dmitry Portnoy <dportnoy@…>, 3 years ago

In VulkanGame, add a normal varying attribute to ModelVertex

  • Property mode set to 100644
File size: 1019 bytes
RevLine 
[4befb76]1#version 450
[de32fda]2#extension GL_ARB_separate_shader_objects : enable
3
[055750a]4struct Object {
[de32fda]5 mat4 model;
[055750a]6};
7
8layout (binding = 0) uniform UniformBufferObject {
[de32fda]9 mat4 view;
10 mat4 proj;
11} ubo;
[4befb76]12
[055750a]13layout(binding = 1) readonly buffer StorageBufferObject {
[6385d0f]14 Object objects[];
[055750a]15} sbo;
16
[a00eb06]17layout (binding = 2) uniform UboInstance {
18 mat4 model;
19} uboInstance;
20
[adcd252]21layout(location = 0) in vec3 inPosition;
[80edd70]22layout(location = 1) in vec3 inColor;
[fba08f2]23layout(location = 2) in vec2 inTexCoord;
[a00eb06]24layout(location = 3) in vec3 vertex_normal;
25layout(location = 4) in uint obj_index;
[4befb76]26
[80edd70]27layout(location = 0) out vec3 fragColor;
[fba08f2]28layout(location = 1) out vec2 fragTexCoord;
[a00eb06]29layout(location = 2) out vec3 normal_eye;
[4befb76]30
31void main() {
[a00eb06]32 // Using 0.0 instead of 1.0 means translations won't effect the normal
33 normal_eye = normalize(vec3(ubo.view * sbo.objects[obj_index].model * vec4(vertex_normal, 0.0)));
34
[f00ee54]35 fragColor = inColor;
[fba08f2]36 fragTexCoord = inTexCoord;
[f00ee54]37
[5a1ace0]38 gl_Position = ubo.proj * ubo.view * sbo.objects[obj_index].model * vec4(inPosition, 1.0);
[f00ee54]39}
Note: See TracBrowser for help on using the repository browser.