metaforce/Runtime/Graphics/Shaders/CModelShaders.hpp

133 lines
2.7 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-04-04 02:32:57 +00:00
#include <array>
#include <cstdint>
#include <memory>
#include "DataSpec/DNAMP1/CMDLMaterials.hpp"
#include "Runtime/Graphics/CGraphics.hpp"
#include <zeus/CColor.hpp>
#include <zeus/CVector3f.hpp>
#include <zeus/CVector4f.hpp>
2016-04-04 02:32:57 +00:00
2017-08-08 06:03:57 +00:00
#define URDE_MAX_LIGHTS 8
2016-04-04 02:32:57 +00:00
namespace hecl::Backend {
class ShaderTag;
} // namespace hecl::Backend
2018-12-08 05:30:43 +00:00
namespace urde {
class CLight;
struct CModelFlags;
struct CBooSurface;
class CBooModel;
2018-12-08 05:30:43 +00:00
enum class EExtendedShader : uint8_t {
2018-12-08 05:30:43 +00:00
Flat,
Lighting,
Thermal,
ForcedAlpha,
ForcedAdditive,
SolidColor,
SolidColorAdditive,
SolidColorFrontfaceCullLEqualAlphaOnly,
SolidColorFrontfaceCullAlwaysAlphaOnly, // No Z-write or test
SolidColorBackfaceCullLEqualAlphaOnly,
SolidColorBackfaceCullGreaterAlphaOnly, // No Z-write
MorphBallShadow,
WorldShadow,
ForcedAlphaNoCull,
ForcedAdditiveNoCull,
ForcedAlphaNoZWrite,
ForcedAdditiveNoZWrite,
ForcedAlphaNoCullNoZWrite,
ForcedAdditiveNoCullNoZWrite,
DepthGEqualNoZWrite,
Disintegrate,
2019-01-05 08:34:09 +00:00
ForcedAdditiveNoZWriteDepthGreater,
ThermalCold,
2019-02-25 08:14:59 +00:00
LightingAlphaWrite,
LightingAlphaWriteNoZTestNoZWrite,
2019-06-01 03:41:01 +00:00
LightingCubeReflection,
LightingCubeReflectionWorldShadow,
2018-12-08 05:30:43 +00:00
MAX
2017-03-10 20:52:53 +00:00
};
enum class EShaderType : uint8_t {
DiffuseOnly,
Normal,
Dynamic,
DynamicAlpha,
DynamicCharacter
};
enum class EPostType : uint8_t {
Normal,
ThermalHot,
ThermalCold,
Solid,
MBShadow,
Disintegrate
};
2018-12-08 05:30:43 +00:00
class CModelShaders {
friend class CModel;
hsh::binding m_dataBind;
2018-12-08 05:30:43 +00:00
2016-04-04 02:32:57 +00:00
public:
template <uint32_t NCol, uint32_t NUv, uint32_t NWeight>
struct VertData {
hsh::float3 posIn;
hsh::float3 normIn;
std::array<hsh::float4, NCol> colIn;
std::array<hsh::float2, NUv> uvIn;
std::array<hsh::float4, NWeight> weightIn;
2018-12-08 05:30:43 +00:00
};
template <uint32_t NSkinSlots>
struct VertUniform {
std::array<hsh::float4x4, NSkinSlots> objs;
std::array<hsh::float4x4, NSkinSlots> objsInv;
hsh::float4x4 mv;
hsh::float4x4 mvInv;
hsh::float4x4 proj;
2018-12-08 05:30:43 +00:00
};
struct TCGMatrix {
hsh::float4x4 mtx;
hsh::float4x4 postMtx;
2018-12-08 05:30:43 +00:00
};
struct ReflectMtx {
hsh::float4x4 indMtx;
hsh::float4x4 reflectMtx;
float reflectAlpha;
2018-12-08 05:30:43 +00:00
};
struct Light {
alignas(16) hsh::float3 pos;
alignas(16) hsh::float3 dir;
alignas(16) hsh::float4 color;
alignas(16) hsh::float3 linAtt;
alignas(16) hsh::float3 angAtt;
2018-12-08 05:30:43 +00:00
};
struct FragmentUniform {
std::array<Light, URDE_MAX_LIGHTS> lights;
hsh::float4 ambient;
hsh::float4 lightmapMul;
hsh::float4 flagsColor;
2018-12-08 05:30:43 +00:00
CGraphics::CFogState fog;
void ActivateLights(const std::vector<CLight>& lts);
};
2018-12-08 05:30:43 +00:00
hsh::binding& SetCurrent(const CModelFlags& modelFlags, const CBooSurface& surface, const CBooModel& model);
2018-12-08 05:30:43 +00:00
using Material = DataSpec::DNAMP1::HMDLMaterialSet::Material;
2016-04-04 02:32:57 +00:00
};
2018-12-08 05:30:43 +00:00
} // namespace urde