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,17 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform sampler2D colorMap;
layout (location = 0) in vec3 inColor;
layout (location = 1) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
void main()
{
outFragColor.rgb = inColor;
// outFragColor = texture(colorMap, inUV);// * vec4(inColor, 1.0);
}

Binary file not shown.

View file

@ -0,0 +1,33 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (location = 0) in vec4 inPos;
layout (location = 1) in vec2 inUV;
layout (location = 2) in vec3 inColor;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
vec4 glowColor;
} ubo;
layout (location = 0) out vec3 outColor;
layout (location = 1) out vec2 outUV;
void main()
{
outUV = inUV;
/*
if (inColor.r >= 0.9)
{
outColor = ubo.glowColor.rgb;
}
else*/
{
outColor = inColor;
}
gl_Position = ubo.projection * ubo.model * inPos;
}

Binary file not shown.

View file

@ -0,0 +1,47 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform sampler2D samplerColor;
layout (binding = 2) uniform UBO
{
int texWidth;
int texHeight;
float blurScale;
float blurStrength;
int horizontal;
} ubo;
layout (location = 0) in vec2 inUV;
layout (location = 0) out vec4 outFragColor;
void main()
{
float weight[5];
weight[0] = 0.227027;
weight[1] = 0.1945946;
weight[2] = 0.1216216;
weight[3] = 0.054054;
weight[4] = 0.016216;
vec2 tex_offset = 1.0 / textureSize(samplerColor, 0) * ubo.blurScale; // gets size of single texel
vec3 result = texture(samplerColor, inUV).rgb * weight[0]; // current fragment's contribution
for(int i = 1; i < 5; ++i)
{
if (ubo.horizontal == 1)
{
result += texture(samplerColor, inUV + vec2(tex_offset.x * i, 0.0)).rgb * weight[i] * ubo.blurStrength;
result += texture(samplerColor, inUV - vec2(tex_offset.x * i, 0.0)).rgb * weight[i] * ubo.blurStrength;
}
else
{
result += texture(samplerColor, inUV + vec2(0.0, tex_offset.y * i)).rgb * weight[i] * ubo.blurStrength;
result += texture(samplerColor, inUV - vec2(0.0, tex_offset.y * i)).rgb * weight[i] * ubo.blurStrength;
}
}
outFragColor = vec4(result, 1.0);
}

Binary file not shown.

View file

@ -0,0 +1,21 @@
#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 vec2 inUV;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
} ubo;
layout (location = 0) out vec2 outUV;
void main()
{
outUV = inUV;
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
}

Binary file not shown.

View file

@ -0,0 +1,12 @@
glslangvalidator -V colorpass.vert -o colorpass.vert.spv
glslangvalidator -V colorpass.frag -o colorpass.frag.spv
glslangvalidator -V phongpass.vert -o phongpass.vert.spv
glslangvalidator -V phongpass.frag -o phongpass.frag.spv
glslangvalidator -V gaussblur.vert -o gaussblur.vert.spv
glslangvalidator -V gaussblur.frag -o gaussblur.frag.spv
glslangvalidator -V skybox.vert -o skybox.vert.spv
glslangvalidator -V skybox.frag -o skybox.frag.spv

View file

@ -0,0 +1,35 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform sampler2D colorMap;
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec2 inUV;
layout (location = 2) in vec3 inColor;
layout (location = 3) in vec3 inEyePos;
layout (location = 4) in vec3 inLightVec;
layout (location = 0) out vec4 outFragColor;
void main()
{
// No light calculations for glow color
// Use max. color channel value
// to detect bright glow emitters
if ((inColor.r >= 0.9) || (inColor.g >= 0.9) || (inColor.b >= 0.9))
{
outFragColor.rgb = inColor;
}
else
{
vec3 Eye = normalize(-inEyePos);
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
vec4 IDiffuse = vec4(inColor, 1.0) * max(dot(inNormal, inLightVec), 0.0);
float specular = 0.25;
vec4 ISpecular = vec4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 16.0) * specular;
outFragColor = IDiffuse + ISpecular;
}
}

Binary file not shown.

View file

@ -0,0 +1,32 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (location = 0) in vec4 inPos;
layout (location = 1) in vec2 inUV;
layout (location = 2) in vec3 inColor;
layout (location = 3) in vec3 inNormal;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
} ubo;
layout (location = 0) out vec3 outNormal;
layout (location = 1) out vec2 outUV;
layout (location = 2) out vec3 outColor;
layout (location = 3) out vec3 outEyePos;
layout (location = 4) out vec3 outLightVec;
void main()
{
outNormal = inNormal;
outColor = inColor;
outUV = inUV;
gl_Position = ubo.projection * ubo.model * inPos;
outEyePos = vec3(ubo.model * inPos);
vec4 lightPos = vec4(-5.0, -5.0, 0.0, 1.0);
outLightVec = normalize(lightPos.xyz - inPos.xyz);
}

Binary file not shown.

View file

@ -0,0 +1,15 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform samplerCube samplerCubeMap;
layout (location = 0) in vec3 inUVW;
layout (location = 0) out vec4 outFragColor;
void main()
{
outFragColor = texture(samplerCubeMap, inUVW);
}

Binary file not shown.

View file

@ -0,0 +1,20 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (location = 0) in vec3 inPos;
layout (binding = 0) uniform UBO
{
mat4 projection;
mat4 model;
} ubo;
layout (location = 0) out vec3 outUVW;
void main()
{
outUVW = inPos;
gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
}

Binary file not shown.