Grab the light list from the surfaces in the shader

This commit is contained in:
Magnus Norddahl 2024-02-26 16:15:14 +01:00
commit ccc5c259ad
6 changed files with 24 additions and 16 deletions

View file

@ -595,6 +595,8 @@ void VkLevelMeshUploader::UploadSurfaces()
{
info.TextureIndex = 0;
}
info.LightStart = surface->LightList.Pos;
info.LightEnd = surface->LightList.Pos + surface->LightList.Count;
*(surfaces++) = info;
}

View file

@ -34,7 +34,11 @@ struct SurfaceInfo
uint32_t PortalIndex;
int32_t TextureIndex;
float Alpha;
float Padding;
float Padding0;
uint32_t LightStart;
uint32_t LightEnd;
uint32_t Padding1;
uint32_t Padding2;
};
struct PortalInfo

View file

@ -195,8 +195,6 @@ void VkLightmapper::Render()
{
LevelMeshSurface* surface = mesh->GetSurface(surfaceIndex);
pc.SurfaceIndex = surfaceIndex;
pc.LightStart = surface->LightList.Pos;
pc.LightEnd = surface->LightList.Pos + surface->LightList.Count;
VkDrawIndexedIndirectCommand cmd;
cmd.indexCount = surface->MeshLocation.NumElements;

View file

@ -20,16 +20,16 @@ struct Uniforms
struct LightmapRaytracePC
{
uint32_t LightStart;
uint32_t LightEnd;
int32_t SurfaceIndex;
int32_t PushPadding1;
int32_t Padding0;
int32_t Padding1;
int32_t Padding2;
FVector3 WorldToLocal;
float TextureSize;
FVector3 ProjLocalToU;
float PushPadding2;
float Padding3;
FVector3 ProjLocalToV;
float PushPadding3;
float Padding4;
float TileX;
float TileY;
float TileWidth;

View file

@ -14,7 +14,11 @@ struct SurfaceInfo
uint PortalIndex;
int TextureIndex;
float Alpha;
float Padding;
float Padding0;
uint LightStart;
uint LightEnd;
uint Padding1;
uint Padding2;
};
struct PortalInfo
@ -46,16 +50,16 @@ layout(set = 0, binding = 5) buffer PortalBuffer { PortalInfo portals[]; };
struct LightmapRaytracePC
{
uint LightStart;
uint LightEnd;
int SurfaceIndex;
int PushPadding1;
int Padding0;
int Padding1;
int Padding2;
vec3 WorldToLocal;
float TextureSize;
vec3 ProjLocalToU;
float PushPadding2;
float Padding3;
vec3 ProjLocalToV;
float PushPadding3;
float Padding4;
float TileX;
float TileY;
float TileWidth;

View file

@ -15,9 +15,9 @@ layout(location = 0) out vec4 fragcolor;
void main()
{
uint LightStart = constants[InstanceIndex].LightStart;
uint LightEnd = constants[InstanceIndex].LightEnd;
int SurfaceIndex = constants[InstanceIndex].SurfaceIndex;
uint LightStart = surfaces[SurfaceIndex].LightStart;
uint LightEnd = surfaces[SurfaceIndex].LightEnd;
vec3 normal = surfaces[SurfaceIndex].Normal;
vec3 origin = worldpos + normal * 0.01;