Hook up HWWall and use the real main.fp shader for the level mesh

This commit is contained in:
Magnus Norddahl 2023-10-27 20:21:48 +02:00
commit d0d964ae42
8 changed files with 207 additions and 116 deletions

View file

@ -10,12 +10,14 @@
#include <cstring>
#include "textureid.h"
#include "flatvertices.h"
#include "textures.h"
#include <dp_rect_pack.h>
typedef dp::rect_pack::RectPacker<int> RectPacker;
class LevelSubmesh;
class FMaterial;
class LevelMeshLight
{
@ -217,6 +219,24 @@ struct SurfaceUniforms
float padding3;
};
struct FMaterialState
{
FMaterial* mMaterial = nullptr;
int mClampMode;
int mTranslation;
int mOverrideShader;
bool mChanged;
void Reset()
{
mMaterial = nullptr;
mTranslation = 0;
mClampMode = CLAMP_NONE;
mOverrideShader = -1;
mChanged = false;
}
};
class LevelSubmesh
{
public:
@ -233,6 +253,7 @@ public:
TArray<int> MeshSurfaceIndexes;
TArray<int> MeshUniformIndexes;
TArray<SurfaceUniforms> MeshSurfaceUniforms;
TArray<FMaterialState> MeshSurfaceMaterials;
TArray<LevelMeshPortal> Portals;

View file

@ -107,20 +107,20 @@ public:
std::unique_ptr<Mesh> Create();
private:
void Apply();
struct DrawLists
{
TArray<MeshDrawCommand> mDraws;
TArray<MeshDrawCommand> mIndexedDraws;
};
std::map<MeshApplyState, DrawLists> mSortedLists;
DrawLists* mDrawLists = nullptr;
TArray<FFlatVertex> mVertices;
TArray<uint32_t> mIndexes;
int mDepthFunc = 0;
private:
void Apply();
int mDepthFunc = 0;
VSMatrix mTextureMatrix = VSMatrix::identity();
DrawLists* mDrawLists = nullptr;
};

View file

@ -93,24 +93,6 @@ struct FStateVec4
}
};
struct FMaterialState
{
FMaterial *mMaterial = nullptr;
int mClampMode;
int mTranslation;
int mOverrideShader;
bool mChanged;
void Reset()
{
mMaterial = nullptr;
mTranslation = 0;
mClampMode = CLAMP_NONE;
mOverrideShader = -1;
mChanged = false;
}
};
struct FDepthBiasState
{
float mFactor;

View file

@ -314,7 +314,6 @@ void VkRaytrace::UploadMeshes(bool dynamicOnly)
{
info.TextureIndex = 0;
}
submesh->MeshSurfaceUniforms[j].uTextureIndex = info.TextureIndex; // Bit of a hack, but we don't know the texture index before now
*(surfaces++) = info;
}
@ -331,6 +330,22 @@ void VkRaytrace::UploadMeshes(bool dynamicOnly)
const SubmeshBufferLocation& cur = locations[i];
auto submesh = cur.Submesh;
for (int j = 0, count = submesh->MeshSurfaceUniforms.Size(); j < count; j++)
{
auto& surfaceUniforms = submesh->MeshSurfaceUniforms[j];
auto& material = submesh->MeshSurfaceMaterials[j];
if (material.mMaterial)
{
auto source = material.mMaterial->Source();
surfaceUniforms.uSpecularMaterial = { source->GetGlossiness(), source->GetSpecularLevel() };
surfaceUniforms.uTextureIndex = fb->GetBindlessTextureIndex(material.mMaterial, material.mClampMode, material.mTranslation);
}
else
{
surfaceUniforms.uTextureIndex = 0;
}
}
SurfaceUniforms* uniforms = (SurfaceUniforms*)(data + datapos);
size_t copysize = submesh->MeshSurfaceUniforms.Size() * sizeof(SurfaceUniforms);
memcpy(uniforms, submesh->MeshSurfaceUniforms.Data(), copysize);

View file

@ -687,7 +687,7 @@ void VulkanRenderDevice::DrawLevelMesh(const HWViewpointUniforms& viewpoint)
pipelineKey.NumTextureLayers = 0;
pipelineKey.NumTextureLayers = max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it
pipelineKey.ShaderKey.SpecialEffect = EFF_NONE;
pipelineKey.ShaderKey.EffectState = SHADER_NoTexture;
pipelineKey.ShaderKey.EffectState = SHADER_Default;
pipelineKey.ShaderKey.AlphaTest = false;
pipelineKey.ShaderKey.SWLightRadial = true;
pipelineKey.ShaderKey.LightMode = 1; // Software