Added Vulkan examples sources!
This commit is contained in:
parent
367fda186b
commit
c91341813c
868 changed files with 514080 additions and 5584 deletions
2
data/shaders/instancing/generate-spirv.bat
Normal file
2
data/shaders/instancing/generate-spirv.bat
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
glslangvalidator -V instancing.vert -o instancing.vert.spv
|
||||
glslangvalidator -V instancing.frag -o instancing.frag.spv
|
||||
28
data/shaders/instancing/instancing.frag
Normal file
28
data/shaders/instancing/instancing.frag
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#version 450
|
||||
|
||||
#extension GL_ARB_separate_shader_objects : enable
|
||||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
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 = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
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.1), 1.0);
|
||||
vec4 IDiffuse = vec4(1.0) * max(dot(inNormal, inLightVec), 0.0);
|
||||
|
||||
float specular = 0.75;
|
||||
vec4 ISpecular = vec4(0.5, 0.5, 0.5, 1.0) * pow(max(dot(Reflected, Eye), 0.0), 4.0) * specular;
|
||||
|
||||
outFragColor = vec4((IAmbient + IDiffuse) * vec4(inColor, 1.0) + ISpecular);
|
||||
}
|
||||
BIN
data/shaders/instancing/instancing.frag.spv
Normal file
BIN
data/shaders/instancing/instancing.frag.spv
Normal file
Binary file not shown.
37
data/shaders/instancing/instancing.vert
Normal file
37
data/shaders/instancing/instancing.vert
Normal 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 vec4 inPos;
|
||||
layout (location = 1) in vec3 inNormal;
|
||||
layout (location = 3) in vec3 inColor;
|
||||
|
||||
struct Instance
|
||||
{
|
||||
mat4 model;
|
||||
vec4 color;
|
||||
};
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
{
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
Instance instance[343];
|
||||
} 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;
|
||||
|
||||
void main()
|
||||
{
|
||||
outNormal = inNormal;
|
||||
outColor = ubo.instance[gl_InstanceIndex].color.rgb;
|
||||
mat4 modelView = ubo.view * ubo.instance[gl_InstanceIndex].model;
|
||||
gl_Position = ubo.projection * modelView * inPos;
|
||||
outEyePos = vec3(modelView * inPos);
|
||||
vec4 lightPos = vec4(0.0, 0.0, 0.0, 1.0) * modelView;
|
||||
outLightVec = normalize(lightPos.xyz - outEyePos);
|
||||
}
|
||||
BIN
data/shaders/instancing/instancing.vert.spv
Normal file
BIN
data/shaders/instancing/instancing.vert.spv
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue