Add lighting in VulkanTest
This commit is contained in:
parent
b2d3605cf4
commit
f1811df6f6
|
|
@ -5,12 +5,16 @@
|
|||
|
||||
layout(binding = 1) uniform sampler2D texSampler;
|
||||
|
||||
layout (location = 0) in vec3 inColor;
|
||||
layout (location = 1) in vec2 outTexCoords;
|
||||
layout (location = 0) in vec3 inNormal;
|
||||
layout (location = 1) in vec2 inUV;
|
||||
|
||||
layout (location = 0) out vec4 outFragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
outFragColor = texture(texSampler, outTexCoords);
|
||||
vec3 lightDir = vec3(0.0, -0.707, 0.707);
|
||||
float lightFactor = dot(inNormal, lightDir);
|
||||
|
||||
float gamma = 2.2;
|
||||
outFragColor = lightFactor * vec4(pow(texture(texSampler, inUV).xyz, vec3(1.0/gamma)), 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -4,7 +4,7 @@
|
|||
#extension GL_ARB_shading_language_420pack : enable
|
||||
|
||||
layout (location = 0) in vec3 inPos;
|
||||
layout (location = 1) in vec3 inColor;
|
||||
layout (location = 1) in vec3 inNormals;
|
||||
layout (location = 2) in vec2 inTexCoord;
|
||||
|
||||
layout (binding = 0) uniform UBO
|
||||
|
|
@ -14,7 +14,7 @@ layout (binding = 0) uniform UBO
|
|||
mat4 viewMatrix;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec3 outColor;
|
||||
layout (location = 0) out vec3 outNormal;
|
||||
layout (location = 1) out vec2 outTexCoords;
|
||||
|
||||
out gl_PerVertex
|
||||
|
|
@ -25,7 +25,7 @@ out gl_PerVertex
|
|||
|
||||
void main()
|
||||
{
|
||||
outColor = inColor;
|
||||
outNormal = inNormals;
|
||||
outTexCoords = inTexCoord;
|
||||
gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Reference in New Issue