Add VkLightprober to VulkanRenderDevice and fix the glsl compile errors
This commit is contained in:
parent
6bd629d640
commit
513f90db3e
6 changed files with 35 additions and 16 deletions
|
|
@ -299,8 +299,9 @@ std::vector<uint8_t> VkLightprober::GenerateIrradianceMap()
|
|||
FVector3 side = dir[i] ^ up[i];
|
||||
|
||||
IrradianceMapPushConstants push;
|
||||
push.topLeft = FVector4(dir[i] - up[i] - side, 0.0f);
|
||||
push.bottomRight = FVector4(dir[i] + up[i] + side, 0.0f);
|
||||
push.dir = dir[i];
|
||||
push.side = side;
|
||||
push.up = up[i];
|
||||
|
||||
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_COMPUTE, irradianceMap.pipelineLayout.get(), 0, irradianceMap.descriptorSets[i].get());
|
||||
cmdbuffer->pushConstants(irradianceMap.pipelineLayout.get(), VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, sizeof(PushConstants), &push);
|
||||
|
|
@ -431,8 +432,9 @@ std::vector<uint8_t> VkLightprober::GeneratePrefilterMap()
|
|||
FVector3 side = dir[i] ^ up[i];
|
||||
|
||||
PrefilterMapPushConstants push;
|
||||
push.topLeft = FVector4(dir[i] - up[i] - side, 0.0f);
|
||||
push.bottomRight = FVector4(dir[i] + up[i] + side, 0.0f);
|
||||
push.dir = dir[i];
|
||||
push.side = side;
|
||||
push.up = up[i];
|
||||
|
||||
for (int level = 0; level < prefilterMap.maxlevels; level++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,16 +10,22 @@ class ShaderIncludeResult;
|
|||
|
||||
struct IrradianceMapPushConstants
|
||||
{
|
||||
FVector4 topLeft;
|
||||
FVector4 bottomRight;
|
||||
FVector3 dir;
|
||||
float padding0;
|
||||
FVector3 up;
|
||||
float padding1;
|
||||
FVector3 side;
|
||||
float padding2;
|
||||
};
|
||||
|
||||
struct PrefilterMapPushConstants
|
||||
{
|
||||
FVector4 topLeft;
|
||||
FVector4 bottomRight;
|
||||
FVector3 dir;
|
||||
float roughness;
|
||||
float padding1, padding2, padding3;
|
||||
FVector3 up;
|
||||
float padding0;
|
||||
FVector3 side;
|
||||
float padding1;
|
||||
};
|
||||
|
||||
class VkLightprober
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@
|
|||
#include "vulkan/vk_postprocess.h"
|
||||
#include "vulkan/vk_levelmesh.h"
|
||||
#include "vulkan/vk_lightmapper.h"
|
||||
#include "vulkan/vk_lightprober.h"
|
||||
#include "vulkan/pipelines/vk_renderpass.h"
|
||||
#include "vulkan/descriptorsets/vk_descriptorset.h"
|
||||
#include "vulkan/shaders/vk_shader.h"
|
||||
|
|
@ -247,6 +248,7 @@ void VulkanRenderDevice::InitializeState()
|
|||
mRenderPassManager.reset(new VkRenderPassManager(this));
|
||||
mLevelMesh.reset(new VkLevelMesh(this));
|
||||
mLightmapper.reset(new VkLightmapper(this));
|
||||
mLightprober.reset(new VkLightprober(this));
|
||||
|
||||
mBufferManager->Init();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ class VkRenderPassManager;
|
|||
class VkFramebufferManager;
|
||||
class VkLevelMesh;
|
||||
class VkLightmapper;
|
||||
class VkLightprober;
|
||||
class VkRenderState;
|
||||
class VkStreamBuffer;
|
||||
class VkHardwareDataBuffer;
|
||||
|
|
@ -42,6 +43,7 @@ public:
|
|||
VkRenderPassManager *GetRenderPassManager() { return mRenderPassManager.get(); }
|
||||
VkLevelMesh* GetLevelMesh() { return mLevelMesh.get(); }
|
||||
VkLightmapper* GetLightmapper() { return mLightmapper.get(); }
|
||||
VkLightprober* GetLightproper() { return mLightprober.get(); }
|
||||
VkRenderState *GetRenderState() { return mRenderState.get(); }
|
||||
VkPostprocess *GetPostprocess() { return mPostprocess.get(); }
|
||||
VkRenderBuffers *GetBuffers() { return mActiveRenderBuffers; }
|
||||
|
|
@ -121,6 +123,7 @@ private:
|
|||
std::unique_ptr<VkRenderPassManager> mRenderPassManager;
|
||||
std::unique_ptr<VkLevelMesh> mLevelMesh;
|
||||
std::unique_ptr<VkLightmapper> mLightmapper;
|
||||
std::unique_ptr<VkLightprober> mLightprober;
|
||||
std::unique_ptr<VkRenderState> mRenderState;
|
||||
|
||||
VkRenderBuffers *mActiveRenderBuffers = nullptr;
|
||||
|
|
|
|||
|
|
@ -5,8 +5,12 @@ layout(binding = 1) uniform samplerCube EnvironmentMap;
|
|||
|
||||
layout(push_constant) uniform PushConstants
|
||||
{
|
||||
vec4 topLeft;
|
||||
vec4 bottomRight;
|
||||
vec3 dir;
|
||||
float padding0;
|
||||
vec3 up;
|
||||
float padding1;
|
||||
vec3 side;
|
||||
float padding2;
|
||||
};
|
||||
|
||||
const float PI = 3.14159265359;
|
||||
|
|
@ -18,7 +22,7 @@ void main()
|
|||
return;
|
||||
|
||||
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) / vec2(colorBufferSize);
|
||||
vec3 FragPos = mix(topLeft.xyz, bottomRight.xyz, uv);
|
||||
vec3 FragPos = dir + side * (uv.x * 2.0 - 1.0) + up * (uv.y * 2.0 - 1.0);
|
||||
|
||||
vec3 normal = normalize(FragPos);
|
||||
vec3 right = normalize(cross(vec3(0.0, 1.0, 0.0), normal));
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ layout(binding = 1) uniform samplerCube EnvironmentMap;
|
|||
|
||||
layout(push_constant) uniform PushConstants
|
||||
{
|
||||
vec4 topLeft;
|
||||
vec4 bottomRight;
|
||||
vec3 dir;
|
||||
float roughness;
|
||||
float padding1, padding2, padding3;
|
||||
vec3 up;
|
||||
float padding0;
|
||||
vec3 side;
|
||||
float padding1;
|
||||
};
|
||||
|
||||
const float PI = 3.14159265359;
|
||||
|
|
@ -24,7 +26,7 @@ void main()
|
|||
return;
|
||||
|
||||
vec2 uv = (vec2(gl_GlobalInvocationID.xy) + 0.5) / vec2(colorBufferSize);
|
||||
vec3 FragPos = mix(topLeft.xyz, bottomRight.xyz, uv);
|
||||
vec3 FragPos = dir + side * (uv.x * 2.0 - 1.0) + up * (uv.y * 2.0 - 1.0);
|
||||
|
||||
vec3 normal = normalize(FragPos);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue