#version 450

layout(location = 0) in vec3 inPosition;
layout(location = 1) in vec3 inColor;
layout(location = 2) in vec3 inLineStart;
layout(location = 3) in vec3 inLineEnd;

layout(location = 0) out vec3 fragColor;
layout(location = 1) out vec3 fragLineStart;
layout(location = 2) out vec3 fragLineEnd;


layout(binding = 0) uniform UniformBufferObject {
    mat4 proj;
    mat4 model;
    mat4 view;
} ubo;

layout(push_constant) uniform PushConstants {
    float myValue;
} pushConstants;

void main() {
    mat4 worldviewproj = ubo.proj * ubo.view * ubo.model;
    //gl_Position = worldviewproj * vec4(inPosition, 1.0);

    vec2 position = vec2(inPosition.xy*2 -1);
    //gl_Position = vec4(inPosition.xy*2 -1, 0.5, 1.0);
    position = position * pushConstants.myValue;
    gl_Position = vec4(position, 0.5, 1.0);
    
    fragColor = inColor;
    
    fragLineStart = (worldviewproj * vec4(inLineStart, 1.0)).xyz;
    fragLineEnd = (worldviewproj * vec4(inLineEnd, 1.0)).xyz;
}