Correct specular highlights, light colors
This commit is contained in:
parent
f3a86c292c
commit
94d8f7b94a
5 changed files with 21 additions and 26 deletions
|
|
@ -73,7 +73,6 @@ float filterPCF(vec4 sc, float layer)
|
|||
return shadowFactor / count;
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
// Get G-Buffer values
|
||||
|
|
@ -112,18 +111,19 @@ void main()
|
|||
float spotEffect = smoothstep(lightCosOuterAngle, lightCosInnerAngle, cosDir);
|
||||
float heightAttenuation = smoothstep(lightRange, 0.0f, dist);
|
||||
|
||||
// Diffuse lighting.
|
||||
// Diffuse lighting
|
||||
float NdotL = max(0.0, dot(N, L));
|
||||
vec3 diff = vec3(NdotL);
|
||||
|
||||
// Specular lighting.
|
||||
// Specular lighting
|
||||
vec3 R = reflect(-L, N);
|
||||
float NdotR = max(0.0, dot(R, V));
|
||||
vec3 spec = vec3(pow(NdotR, 16.0));
|
||||
vec3 spec = vec3(pow(NdotR, 16.0) * albedo.a * 2.5);
|
||||
|
||||
fragcolor += vec3((diff + spec) * spotEffect * heightAttenuation) * ubo.lights[i].color.rgb * albedo.rgb ;
|
||||
fragcolor += vec3((diff + spec) * spotEffect * heightAttenuation) * ubo.lights[i].color.rgb * albedo.rgb;
|
||||
}
|
||||
|
||||
// Shadow calculations in a separate pass
|
||||
for(int i = 0; i < LIGHT_COUNT; ++i)
|
||||
{
|
||||
vec4 shadowClip = ubo.lights[i].viewMatrix * vec4(fragPos, 1.0);
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -14,23 +14,14 @@ layout (binding = 0) uniform UBO
|
|||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
//layout (location = 1) out vec4 outShadowCoord;
|
||||
|
||||
out gl_PerVertex
|
||||
{
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
/*
|
||||
const mat4 biasMat = mat4(
|
||||
0.5, 0.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 0.0,
|
||||
0.0, 0.0, 1.0, 0.0,
|
||||
0.5, 0.5, 0.0, 1.0 );
|
||||
*/
|
||||
void main()
|
||||
{
|
||||
outUV = inUV;
|
||||
gl_Position = ubo.projection * ubo.modelview * vec4(inPos.xyz, 1.0);
|
||||
//outShadowCoord = (biasMat * ubo.lightMVP * ubo.modelview) * vec4(inPos, 1.0);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -540,7 +540,7 @@ public:
|
|||
|
||||
vkMeshLoader::MeshCreateInfo meshCreateInfo;
|
||||
meshCreateInfo.scale = glm::vec3(15.0f);
|
||||
meshCreateInfo.uvscale = glm::vec2(2.0f);
|
||||
meshCreateInfo.uvscale = glm::vec2(1.0f, 1.5f);
|
||||
meshCreateInfo.center = glm::vec3(0.0f, 2.3f, 0.0f);
|
||||
loadMesh(getAssetPath() + "models/openbox.dae", &meshes.background, vertexLayout, &meshCreateInfo);
|
||||
}
|
||||
|
|
@ -1079,7 +1079,8 @@ public:
|
|||
};
|
||||
std::vector<glm::vec4> lightColors =
|
||||
{
|
||||
glm::vec4(1.0f, 0.0f, 0.0f, 0.0f),
|
||||
// glm::vec4(1.0f),
|
||||
glm::vec4(1.0f, 0.5f, 0.5f, 0.0f),
|
||||
glm::vec4(0.0f, 0.0f, 1.0f, 0.0f),
|
||||
glm::vec4(1.0f, 1.0f, 1.0f, 0.0f),
|
||||
};
|
||||
|
|
@ -1091,7 +1092,8 @@ public:
|
|||
};
|
||||
|
||||
// Animate
|
||||
// todo: wip
|
||||
if (!paused)
|
||||
{
|
||||
lightPositions[0].x = -14.0f + abs(sin(glm::radians(timer * 360.0f)) * 20.0f);
|
||||
lightPositions[0].z = 15.0f + cos(glm::radians(timer *360.0f)) * 1.0f;
|
||||
|
||||
|
|
@ -1100,6 +1102,7 @@ public:
|
|||
|
||||
lightPositions[2].x = 0.0f + sin(glm::radians(timer *360.0f)) * 4.0f;
|
||||
lightPositions[2].z = 4.0f + cos(glm::radians(timer *360.0f)) * 2.0f;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < static_cast<uint32_t>(lightPositions.size()); i++)
|
||||
{
|
||||
|
|
@ -1127,6 +1130,7 @@ public:
|
|||
vkUnmapMemory(device, uniformData.uboShadowGS.memory);
|
||||
|
||||
uboFragmentLights.viewPos = glm::vec4(uboOffscreenVS.view[3]);
|
||||
uboFragmentLights.viewPos = glm::vec4(camera.position, 0.0f) * glm::vec4(-1.0f, 1.0f, -1.0f, 1.0f);;
|
||||
|
||||
VK_CHECK_RESULT(vkMapMemory(device, uniformData.fsLights.memory, 0, sizeof(uboFragmentLights), 0, (void **)&pData));
|
||||
memcpy(pData, &uboFragmentLights, sizeof(uboFragmentLights));
|
||||
|
|
@ -1189,7 +1193,7 @@ public:
|
|||
if (!prepared)
|
||||
return;
|
||||
draw();
|
||||
if (!paused)
|
||||
//if (!paused)
|
||||
updateUniformBufferDeferredLights();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue