Disabling lighting for now
This commit is contained in:
Vendored
+1
-1
Submodule external/vcpkg updated: 0bf1354d67...f9a99aa79c
@@ -25,10 +25,10 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
{
|
||||
result += pLightEnv.directionalLights[i].illuminate(lightingParams, brdf);
|
||||
}
|
||||
for(uint i = 0; i < lightCount; ++i)
|
||||
for(uint i = 0; i < pLightEnv.numPointLights; ++i)
|
||||
{
|
||||
uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||
result += pLightEnv.pointLights[lightIndex].illuminate(lightingParams, brdf);
|
||||
//uint lightIndex = pLightCullingData.lightIndexList[startOffset + i];
|
||||
result += pLightEnv.pointLights[i].illuminate(lightingParams, brdf);
|
||||
}
|
||||
result += brdf.evaluateAmbient(lightingParams.viewDir_WS);
|
||||
return float4(result, brdf.getAlpha());
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
const static float3 vertices[] = {
|
||||
// Right
|
||||
float3( 1, 1, 1),
|
||||
float3( 1, -1, 1),
|
||||
float3( 1, 1, 1),
|
||||
float3( 1, -1, -1),
|
||||
|
||||
float3( 1, -1, -1),
|
||||
float3( 1, 1, 1),
|
||||
float3( 1, 1, -1),
|
||||
|
||||
float3( 1, 1, -1),
|
||||
float3( 1, -1, 1),
|
||||
float3( 1, -1, -1),
|
||||
|
||||
// Left
|
||||
float3(-1, 1, -1),
|
||||
float3(-1, -1, -1),
|
||||
float3(-1, 1, -1),
|
||||
float3(-1, -1, 1),
|
||||
|
||||
float3(-1, -1, 1),
|
||||
float3(-1, 1, -1),
|
||||
float3(-1, 1, 1),
|
||||
|
||||
float3(-1, 1, 1),
|
||||
float3(-1, -1, -1),
|
||||
float3(-1, -1, 1),
|
||||
|
||||
// Bottom
|
||||
float3(-1, 1, 1),
|
||||
float3(-1, 1, -1),
|
||||
float3( 1, 1, 1),
|
||||
float3(-1, -1, 1),
|
||||
float3(-1, -1, -1),
|
||||
float3( 1, -1, 1),
|
||||
|
||||
float3( 1, 1, 1),
|
||||
float3(-1, 1, -1),
|
||||
float3( 1, 1, -1),
|
||||
float3( 1, -1, 1),
|
||||
float3(-1, -1, -1),
|
||||
float3( 1, -1, -1),
|
||||
|
||||
// Top
|
||||
float3(-1, -1, -1),
|
||||
float3(-1, -1, 1),
|
||||
float3( 1, -1, -1),
|
||||
|
||||
float3( 1, -1, -1),
|
||||
float3(-1, -1, 1),
|
||||
float3( 1, -1, 1),
|
||||
|
||||
// Back
|
||||
float3(-1, -1, 1),
|
||||
float3(-1, 1, -1),
|
||||
float3(-1, 1, 1),
|
||||
float3( 1, -1, 1),
|
||||
float3( 1, 1, -1),
|
||||
|
||||
float3( 1, -1, 1),
|
||||
float3( 1, 1, -1),
|
||||
float3(-1, 1, 1),
|
||||
float3( 1, 1, 1),
|
||||
|
||||
// Front
|
||||
float3( 1, -1, -1),
|
||||
float3( 1, 1, -1),
|
||||
float3(-1, -1, -1),
|
||||
// Back
|
||||
float3(-1, 1, 1),
|
||||
float3(-1, -1, 1),
|
||||
float3( 1, 1, 1),
|
||||
|
||||
float3(-1, -1, -1),
|
||||
float3( 1, 1, 1),
|
||||
float3(-1, -1, 1),
|
||||
float3( 1, -1, 1),
|
||||
|
||||
// Front
|
||||
float3( 1, 1, -1),
|
||||
float3( 1, -1, -1),
|
||||
float3(-1, 1, -1),
|
||||
|
||||
float3(-1, 1, -1),
|
||||
float3( 1, -1, -1),
|
||||
float3(-1, -1, -1),
|
||||
};
|
||||
|
||||
struct ViewParams
|
||||
|
||||
@@ -7,9 +7,8 @@ struct QuadOutput
|
||||
[shader("vertex")]
|
||||
QuadOutput quadMain(uint vertexIndex : SV_VertexID)
|
||||
{
|
||||
QuadOutput result;
|
||||
result.uv = float2((vertexIndex << 1) & 2, vertexIndex & 2);
|
||||
QuadOutput result;
|
||||
result.uv = float2(vertexIndex & 2, (vertexIndex << 1) & 2);
|
||||
result.position = float4(result.uv * 2.0f + -1.0f, 0.0f, 1.0f);
|
||||
result.uv.y = 1 - result.uv.y;
|
||||
return result;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ float4 screenToView(float4 screen)
|
||||
float2 texCoord = screen.xy / pViewParams.screenDimensions;
|
||||
|
||||
// Convert to clip space
|
||||
float4 clip = float4( float2( texCoord.x, 1.0f-texCoord.y ) * 2.0f - 1.0f, screen.z, screen.w);
|
||||
float4 clip = float4( texCoord * 2.0f - 1.0f, screen.z, screen.w);
|
||||
|
||||
return clipToView(clip);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ float4 clipToScreen(float4 clip)
|
||||
float oz = 1;
|
||||
float pz = 0 - 1;
|
||||
float zf = pz * ndc.z + oz;
|
||||
return float4(float2(texCoords.x, 1 - texCoords.y) * pViewParams.screenDimensions, zf, 1.0f);
|
||||
return float4(texCoords * pViewParams.screenDimensions, zf, 1.0f);
|
||||
}
|
||||
|
||||
struct Plane
|
||||
|
||||
@@ -337,7 +337,7 @@ struct CookTorrance : IBRDF
|
||||
float nDotL = max(dot(n, lightDir_WS), 0.0);
|
||||
|
||||
float3 result = (k_d * baseColor / PI + specular) * nDotL * lightColor;
|
||||
return result;
|
||||
return baseColor;
|
||||
}
|
||||
[mutating]
|
||||
void transformNormal(float3x3 tangentToWorld)
|
||||
|
||||
@@ -154,8 +154,6 @@ void BasePass::render() {
|
||||
// Base Rendering
|
||||
for (VertexData* vertexData : VertexData::getList()) {
|
||||
transparentData.addAll(vertexData->getTransparentData());
|
||||
vertexData->getInstanceDataSet()->updateBuffer(VertexData::CULLINGDATA_NAME, 0, cullingBuffer);
|
||||
vertexData->getInstanceDataSet()->writeChanges();
|
||||
permutation.setVertexData(vertexData->getTypeName());
|
||||
for (const auto& materialData : vertexData->getMaterialData()) {
|
||||
// material not used for any active meshes, skip
|
||||
|
||||
@@ -125,8 +125,6 @@ void DepthCullingPass::render() {
|
||||
permutation.setDepthCulling(getGlobals().useDepthCulling);
|
||||
for (VertexData* vertexData : VertexData::getList()) {
|
||||
permutation.setVertexData(vertexData->getTypeName());
|
||||
vertexData->getInstanceDataSet()->updateBuffer(VertexData::CULLINGDATA_NAME, 0, cullingBuffer);
|
||||
vertexData->getInstanceDataSet()->writeChanges();
|
||||
// Create Pipeline(VertexData)
|
||||
// Descriptors:
|
||||
// ViewData => global, static
|
||||
|
||||
@@ -104,7 +104,8 @@ void BufferAllocation::updateContents(uint64 regionOffset, uint64 regionSize, vo
|
||||
.flags = VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT,
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
};
|
||||
OBufferAllocation staging = new BufferAllocation(graphics, fmt::format("{0}UpdateStaging", name), stagingInfo, stagingAlloc, Gfx::QueueType::GRAPHICS);
|
||||
OBufferAllocation staging =
|
||||
new BufferAllocation(graphics, fmt::format("{0}UpdateStaging", name), stagingInfo, stagingAlloc, Gfx::QueueType::GRAPHICS);
|
||||
|
||||
uint8* data;
|
||||
VK_CHECK(vmaMapMemory(graphics->getAllocator(), staging->allocation, (void**)&data));
|
||||
@@ -306,7 +307,7 @@ void Buffer::createBuffer(uint64 size, uint32 destIndex) {
|
||||
command->bindResource(PBufferAllocation(buffers[destIndex]));
|
||||
vkCmdFillBuffer(command->getHandle(), buffers[destIndex]->buffer, 0, VK_WHOLE_SIZE, clearValue);
|
||||
buffers[destIndex]->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,8 +486,8 @@ IndexBuffer::IndexBuffer(PGraphics graphics, const IndexBufferCreateInfo& create
|
||||
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR,
|
||||
createInfo.sourceData.owner, false, createInfo.name) {
|
||||
getAlloc()->updateContents(createInfo.sourceData.offset, createInfo.sourceData.size, createInfo.sourceData.data);
|
||||
//getAlloc()->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_INDEX_READ_BIT,
|
||||
// Gfx::SE_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR | Gfx::SE_PIPELINE_STAGE_VERTEX_INPUT_BIT);
|
||||
// getAlloc()->pipelineBarrier(VK_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_INDEX_READ_BIT,
|
||||
// Gfx::SE_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR | Gfx::SE_PIPELINE_STAGE_VERTEX_INPUT_BIT);
|
||||
}
|
||||
|
||||
IndexBuffer::~IndexBuffer() {}
|
||||
|
||||
@@ -269,8 +269,7 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
|
||||
VkDescriptorSet setHandle = descriptorSet->getHandle();
|
||||
Gfx::PPipelineLayout layout = pipeline != nullptr ? pipeline->getPipelineLayout() : rtPipeline->getPipelineLayout();
|
||||
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR,
|
||||
pipeline->getLayout(), layout->findParameter(descriptorSet->getName()), 1, &setHandle, 0,
|
||||
nullptr);
|
||||
pipeline->getLayout(), layout->findParameter(descriptorSet->getName()), 1, &setHandle, 0, nullptr);
|
||||
}
|
||||
|
||||
void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) {
|
||||
@@ -286,9 +285,9 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
||||
|
||||
for (auto& binding : descriptorSet->boundResources) {
|
||||
for (auto& res : binding) {
|
||||
// partially bound descriptors can include nulls
|
||||
// partially bound descriptors can include nulls
|
||||
if (res != nullptr) {
|
||||
res->bind();
|
||||
res->bind();
|
||||
boundResources.add(res);
|
||||
}
|
||||
}
|
||||
@@ -442,8 +441,7 @@ void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptor) {
|
||||
|
||||
VkDescriptorSet setHandle = descriptorSet->getHandle();
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(),
|
||||
pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle,0,
|
||||
nullptr);
|
||||
pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle, 0, nullptr);
|
||||
}
|
||||
|
||||
void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) {
|
||||
@@ -465,8 +463,8 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
|
||||
}
|
||||
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||
}
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets,
|
||||
0, nullptr);
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, 0,
|
||||
nullptr);
|
||||
delete[] sets;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,6 +161,14 @@ Gfx::PDescriptorSet DescriptorPool::allocateDescriptorSet() {
|
||||
if (cachedHandles[setIndex]->getHandle() == VK_NULL_HANDLE) {
|
||||
// If it hasnt been initialized, allocate it
|
||||
VK_CHECK(vkAllocateDescriptorSets(graphics->getDevice(), &allocInfo, &cachedHandles[setIndex]->setHandle));
|
||||
VkDebugUtilsObjectNameInfoEXT nameInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT,
|
||||
.pNext = nullptr,
|
||||
.objectType = VK_OBJECT_TYPE_DESCRIPTOR_SET,
|
||||
.objectHandle = (uint64)cachedHandles[setIndex]->setHandle,
|
||||
.pObjectName = name.c_str(),
|
||||
};
|
||||
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
|
||||
}
|
||||
|
||||
PDescriptorSet vulkanSet = cachedHandles[setIndex];
|
||||
@@ -193,6 +201,7 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
|
||||
boundResources.resize(owner->getLayout()->getBindings().size());
|
||||
for (uint32 i = 0; i < boundResources.size(); ++i) {
|
||||
boundResources[i].resize(owner->getLayout()->getBindings()[i].descriptorCount);
|
||||
std::memset(boundResources[i].data(), 0, sizeof(PCommandBoundResource) * boundResources[i].size());
|
||||
}
|
||||
constantData.resize(owner->getLayout()->constantsSize);
|
||||
}
|
||||
@@ -208,9 +217,10 @@ void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, G
|
||||
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
|
||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||
uint32 binding = map.binding;
|
||||
if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
|
||||
// if the buffer is empty
|
||||
if (vulkanBuffer->getAlloc() == nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = vulkanBuffer->getHandle(),
|
||||
.offset = 0,
|
||||
@@ -234,9 +244,10 @@ void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, G
|
||||
PVertexBuffer vulkanBuffer = indexBuffer.cast<VertexBuffer>();
|
||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||
uint32 binding = map.binding;
|
||||
if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
|
||||
// if the buffer is empty
|
||||
if (vulkanBuffer->getAlloc() == nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = vulkanBuffer->getHandle(),
|
||||
@@ -261,9 +272,9 @@ void DescriptorSet::updateBuffer(const std::string& mappingName, uint32 index, G
|
||||
PIndexBuffer vulkanBuffer = indexBuffer.cast<IndexBuffer>();
|
||||
const auto& map = owner->getLayout()->mappings[mappingName];
|
||||
uint32 binding = map.binding;
|
||||
if (boundResources[binding][index] == vulkanBuffer->getAlloc() || vulkanBuffer->getAlloc() == nullptr) {
|
||||
// if the buffer is empty
|
||||
if (vulkanBuffer->getAlloc() == nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = vulkanBuffer->getHandle(),
|
||||
|
||||
@@ -295,8 +295,7 @@ Viewport::Viewport(PWindow owner, const ViewportCreateInfo& viewportInfo) : Gfx:
|
||||
handle.width = static_cast<float>(sizeX);
|
||||
handle.height = static_cast<float>(sizeY);
|
||||
handle.x = static_cast<float>(offsetX);
|
||||
handle.y = static_cast<float>(offsetY) + handle.height;
|
||||
handle.height = -handle.height;
|
||||
handle.y = static_cast<float>(offsetY);
|
||||
handle.minDepth = 1.f;
|
||||
handle.maxDepth = 0.f;
|
||||
}
|
||||
@@ -307,8 +306,7 @@ void Viewport::resize(uint32 newX, uint32 newY) {
|
||||
sizeX = newX;
|
||||
sizeY = newY;
|
||||
handle.width = static_cast<float>(sizeX);
|
||||
handle.y = static_cast<float>(sizeY + offsetX);
|
||||
handle.height = -static_cast<float>(sizeY);
|
||||
handle.height = static_cast<float>(sizeY);
|
||||
}
|
||||
|
||||
void Viewport::move(uint32 newOffsetX, uint32 newOffsetY) {
|
||||
|
||||
@@ -20,19 +20,13 @@ Viewport::~Viewport() {}
|
||||
|
||||
Matrix4 Viewport::getProjectionMatrix() const {
|
||||
if (fieldOfView > 0.0f) {
|
||||
// float h = 1.0 / tan(fieldOfView * 0.5);
|
||||
// float w = h / (sizeX / static_cast<float>(sizeY));
|
||||
// float zFar = 1000.0f;
|
||||
// float zNear = 0.1f;
|
||||
// float a = -zNear / (zFar - zNear);
|
||||
// float b = (zNear * zFar) / (zFar - zNear);
|
||||
// return Matrix4(
|
||||
// w, 0, 0, 0,
|
||||
// 0, -h, 0, 0,
|
||||
// 0, 0, a, b,
|
||||
// 0, 0, 1, 0
|
||||
//);
|
||||
return glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 1000.0f);
|
||||
Matrix4 projectionMatrix = glm::perspective(fieldOfView, sizeX / static_cast<float>(sizeY), 0.1f, 1000.0f);
|
||||
Matrix4 correctionMatrix = Matrix4(
|
||||
1, 0, 0, 0,
|
||||
0, -1, 0, 0,
|
||||
0, 0, 1 / 2.f, 0,
|
||||
0, 0, 1 / 2.f, 1);
|
||||
return correctionMatrix * projectionMatrix;
|
||||
} else {
|
||||
return glm::ortho(0.0f, (float)sizeX, (float)sizeY, 0.0f);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics)
|
||||
.name = "irradianceMap",
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.name = "irradianceSampler",
|
||||
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
|
||||
});
|
||||
layout->create();
|
||||
|
||||
directionalLights = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
@@ -78,6 +82,7 @@ void LightEnvironment::commit() {
|
||||
set->updateConstants("numDirectionalLights", 0, &numDirectionalLights);
|
||||
set->updateBuffer("directionalLights", 0, directionalLights);
|
||||
set->updateTexture("irradianceMap", 0, environment->getIrradianceMap());
|
||||
set->updateSampler("irradianceSampler", 0, environmentSampler);
|
||||
set->writeChanges();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,6 @@ CameraUpdater::~CameraUpdater() {}
|
||||
|
||||
void CameraUpdater::update(Component::Camera& camera, Component::Transform& transform) {
|
||||
Vector eyePos = transform.getPosition();
|
||||
Vector lookAt = eyePos - transform.getForward();
|
||||
camera.viewMatrix = glm::lookAtLH(eyePos, lookAt, Vector(0, 1, 0));
|
||||
Vector lookAt = eyePos + transform.getForward();
|
||||
camera.viewMatrix = glm::lookAt(eyePos, lookAt, Vector(0, 1, 0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user