Added Vulkan examples sources!

This commit is contained in:
saschawillems 2016-02-16 15:07:25 +01:00
parent 367fda186b
commit c91341813c
868 changed files with 514080 additions and 5584 deletions

View file

@ -0,0 +1,2 @@
glslangvalidator -V mesh.vert -o mesh.vert.spv
glslangvalidator -V mesh.frag -o mesh.frag.spv

View file

@ -0,0 +1,38 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform sampler2D samplerColorMap;
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec3 inColor;
layout (location = 3) in vec3 inEyePos;
layout (location = 4) in vec3 inLightVec;
layout (location = 0) out vec4 outFragColor;
void main()
{
vec4 spec = vec4(0.0);
float shininess = 32.0;
vec3 n = normalize(inNormal);
vec3 l = normalize(inLightVec);
vec3 e = normalize(inEyePos);
vec4 diffuse = vec4(inColor, 1.0);
vec4 specular = vec4(1.0);
vec4 ambient = vec4(vec3(0.05), 0.0);
float intensity = max(dot(n,l), 0.0);
if (intensity > 0.0)
{
vec3 h = normalize(l + e);
float intSpec = max(dot(h,n), 0.0);
spec = specular * pow(intSpec, shininess);
}
outFragColor = max(intensity * diffuse + spec, ambient);
}

View file

@ -0,0 +1,34 @@
#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 vec3 inColor;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
vec4 lightPos;
} ubo;
layout (location = 0) out vec3 outNormal;
layout (location = 1) out vec3 outColor;
layout (location = 2) out vec2 outUV;
layout (location = 3) out vec3 outEyePos;
layout (location = 4) out vec3 outLightVec;
void main()
{
outNormal = normalize(inNormal);
outColor = inColor;
vec4 pos = ubo.model * vec4(inPos.xyz, 1.0);
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
vec4 lPos = ubo.model * ubo.lightPos;
outLightVec = vec3(lPos.xyz - pos.xyz);
outEyePos = vec3(-pos);
}