diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2019-08-23 12:53:37 +0200 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2019-08-28 11:32:06 +0200 |
| commit | 28e25d4c9f0ec82f2c7b4eeb63aba7f0c6d4e91f (patch) | |
| tree | 23ce5a09799691f8ace90354f716e0358287e64c /samples/Model/shaders/model.vert | |
| parent | 3ebbf86e007af2ab49f5e50d8b36f63e00c29c81 (diff) | |
save comit before image modif
Diffstat (limited to 'samples/Model/shaders/model.vert')
| -rw-r--r-- | samples/Model/shaders/model.vert | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/samples/Model/shaders/model.vert b/samples/Model/shaders/model.vert new file mode 100644 index 0000000..d63c794 --- /dev/null +++ b/samples/Model/shaders/model.vert @@ -0,0 +1,44 @@ +#version 450 + +#extension GL_ARB_separate_shader_objects : enable +#extension GL_ARB_shading_language_420pack : enable + +layout (location = 0) in vec3 inPos; +layout (location = 1) in vec3 inNormal; +layout (location = 2) in vec2 inUV; + +layout (binding = 0) uniform UBO +{ + mat4 projectionMatrix; + mat4 viewMatrix; + mat4 modelMatrix; +} ubo; + +layout (location = 0) out vec2 outUV; +layout (location = 1) out vec3 outN; +layout (location = 2) out vec3 outV;//ViewDir + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +layout(push_constant) uniform PushConsts { + mat4 model; +} pc; + +void main() +{ + outUV = inUV; + + mat4 mod = ubo.modelMatrix;// * pc.model; + vec4 pos = mod * vec4(inPos.xyz, 1.0); + + //outN = normalize(transpose(inverse(mat3(mod))) * inNormal); + outN = normalize(mat3(mod)* inNormal); + + mat4 viewInv = inverse(ubo.viewMatrix); + outV = -(ubo.viewMatrix * pos).xyz;//normalize(vec3(viewInv * vec4(0.0, 0.0, 0.0, 1.0) - pos)); + + gl_Position = ubo.projectionMatrix * ubo.viewMatrix * pos; +} |