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,16 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform samplerCube shadowCubeMap;
layout (location = 0) in vec3 inUVW;
layout (location = 0) out vec4 outFragColor;
void main()
{
float dist = length(texture(shadowCubeMap, inUVW).rgb) * 0.005;
outFragColor = vec4(vec3(dist), 1.0);
}

Binary file not shown.

View file

@ -0,0 +1,22 @@
#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 view;
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.

View file

@ -0,0 +1,7 @@
glslangvalidator -V offscreen.vert -o offscreen.vert.spv
glslangvalidator -V offscreen.frag -o offscreen.frag.spv
glslangvalidator -V scene.vert -o scene.vert.spv
glslangvalidator -V scene.frag -o scene.frag.spv
glslangvalidator -V cubemapdisplay.vert -o cubemapdisplay.vert.spv
glslangvalidator -V cubemapdisplay.frag -o cubemapdisplay.frag.spv

View file

@ -0,0 +1,16 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (location = 0) out float outFragColor;
layout (location = 0) in vec4 inPos;
layout (location = 1) in vec3 inLightPos;
void main()
{
// Store distance to light as 32 bit float value
vec3 lightVec = inPos.xyz - inLightPos;
outFragColor = length(lightVec);
}

Binary file not shown.

View file

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

Binary file not shown.

View file

@ -0,0 +1,43 @@
#version 450
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
layout (binding = 1) uniform samplerCube shadowCubeMap;
layout (location = 0) in vec3 inNormal;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec3 inEyePos;
layout (location = 3) in vec3 inLightVec;
layout (location = 4) in vec3 inWorldPos;
layout (location = 5) in vec3 inLightPos;
layout (location = 0) out vec4 outFragColor;
#define EPSILON 0.15
#define SHADOW_OPACITY 0.5
void main()
{
// Lighting
vec3 N = normalize(inNormal);
vec3 L = normalize(vec3(1.0));
vec3 Eye = normalize(-inEyePos);
vec3 Reflected = normalize(reflect(-inLightVec, inNormal));
vec4 IAmbient = vec4(vec3(0.05), 1.0);
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
outFragColor = vec4(IAmbient + IDiffuse * vec4(inColor, 1.0));
// Shadow
vec3 lightVec = inWorldPos - inLightPos;
float sampledDist = texture(shadowCubeMap, lightVec).r;
float dist = length(lightVec);
// Check if fragment is in shadow
float shadow = (dist <= sampledDist + EPSILON) ? 1.0 : SHADOW_OPACITY;
outFragColor.rgb *= shadow;
}

Binary file not shown.

View file

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

Binary file not shown.