2016-04-13 06:07:23 +00:00
|
|
|
#ifndef __URDE_CMODELSHADERS_HPP__
|
|
|
|
#define __URDE_CMODELSHADERS_HPP__
|
2016-04-04 02:32:57 +00:00
|
|
|
|
|
|
|
#include "hecl/Runtime.hpp"
|
|
|
|
#include "optional.hpp"
|
|
|
|
#include "zeus/CVector3f.hpp"
|
|
|
|
#include "zeus/CColor.hpp"
|
2016-08-08 04:48:18 +00:00
|
|
|
#include "Graphics/CGraphics.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 urde
|
|
|
|
{
|
|
|
|
|
2017-03-10 20:52:53 +00:00
|
|
|
enum EExtendedShader : uint8_t
|
|
|
|
{
|
|
|
|
Flat,
|
|
|
|
Lighting,
|
|
|
|
Thermal,
|
|
|
|
ForcedAlpha,
|
|
|
|
ForcedAdditive,
|
|
|
|
SolidColor,
|
2017-09-21 05:10:18 +00:00
|
|
|
SolidColorAdditive,
|
2017-03-14 07:03:58 +00:00
|
|
|
SolidColorFrontfaceCullLEqualAlphaOnly,
|
|
|
|
SolidColorFrontfaceCullAlwaysAlphaOnly, // No Z-write or test
|
|
|
|
SolidColorBackfaceCullLEqualAlphaOnly,
|
|
|
|
SolidColorBackfaceCullGreaterAlphaOnly, // No Z-write
|
2017-10-01 04:26:46 +00:00
|
|
|
MorphBallShadow,
|
2017-12-10 05:30:01 +00:00
|
|
|
WorldShadow,
|
|
|
|
ForcedAlphaNoCull,
|
|
|
|
ForcedAdditiveNoCull
|
2017-03-10 20:52:53 +00:00
|
|
|
};
|
|
|
|
|
2016-04-04 02:32:57 +00:00
|
|
|
class CModelShaders
|
|
|
|
{
|
2016-07-22 02:32:23 +00:00
|
|
|
friend class CModel;
|
2016-04-04 02:32:57 +00:00
|
|
|
hecl::Runtime::ShaderCacheManager m_shaderCache;
|
|
|
|
static hecl::Runtime::ShaderCacheExtensions GetShaderExtensions(boo::IGraphicsDataFactory::Platform plat);
|
|
|
|
static hecl::Runtime::ShaderCacheExtensions GetShaderExtensionsGLSL(boo::IGraphicsDataFactory::Platform plat);
|
|
|
|
static hecl::Runtime::ShaderCacheExtensions GetShaderExtensionsHLSL(boo::IGraphicsDataFactory::Platform plat);
|
|
|
|
static hecl::Runtime::ShaderCacheExtensions GetShaderExtensionsMetal(boo::IGraphicsDataFactory::Platform plat);
|
2016-07-31 20:52:04 +00:00
|
|
|
static const hecl::Backend::TextureInfo ThermalTextures[];
|
2017-03-05 07:57:12 +00:00
|
|
|
static const hecl::Backend::TextureInfo BallFadeTextures[];
|
2017-10-01 04:26:46 +00:00
|
|
|
static const hecl::Backend::TextureInfo WorldShadowTextures[];
|
2016-04-04 02:32:57 +00:00
|
|
|
public:
|
2017-10-22 06:11:22 +00:00
|
|
|
static std::experimental::optional<CModelShaders> g_ModelShaders;
|
|
|
|
|
2016-04-04 02:32:57 +00:00
|
|
|
struct Light
|
|
|
|
{
|
|
|
|
zeus::CVector3f pos;
|
|
|
|
zeus::CVector3f dir;
|
|
|
|
zeus::CColor color = zeus::CColor::skClear;
|
|
|
|
float linAtt[4] = {1.f, 0.f, 0.f};
|
|
|
|
float angAtt[4] = {1.f, 0.f, 0.f};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LightingUniform
|
|
|
|
{
|
|
|
|
Light lights[URDE_MAX_LIGHTS];
|
|
|
|
zeus::CColor ambient;
|
2016-07-21 05:21:45 +00:00
|
|
|
zeus::CColor colorRegs[3];
|
2017-02-10 09:00:57 +00:00
|
|
|
zeus::CColor mulColor;
|
2016-08-08 04:48:18 +00:00
|
|
|
CGraphics::CFogState fog;
|
2017-08-08 06:03:57 +00:00
|
|
|
|
|
|
|
void ActivateLights(const std::vector<CLight>& lts);
|
2016-04-04 02:32:57 +00:00
|
|
|
};
|
|
|
|
|
2016-07-31 02:06:47 +00:00
|
|
|
struct ThermalUniform
|
|
|
|
{
|
|
|
|
zeus::CColor mulColor;
|
|
|
|
zeus::CColor addColor;
|
|
|
|
};
|
|
|
|
|
2017-03-05 07:57:12 +00:00
|
|
|
struct SolidUniform
|
|
|
|
{
|
|
|
|
zeus::CColor solidColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MBShadowUniform
|
|
|
|
{
|
|
|
|
zeus::CVector4f shadowUp;
|
|
|
|
float shadowId;
|
|
|
|
};
|
|
|
|
|
2016-04-04 02:32:57 +00:00
|
|
|
static void Initialize(const hecl::Runtime::FileStoreManager& storeMgr,
|
|
|
|
boo::IGraphicsDataFactory* gfxFactory);
|
2017-03-14 07:03:58 +00:00
|
|
|
static void Shutdown();
|
2016-04-04 02:32:57 +00:00
|
|
|
|
|
|
|
CModelShaders(const hecl::Runtime::FileStoreManager& storeMgr,
|
|
|
|
boo::IGraphicsDataFactory* gfxFactory);
|
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
std::shared_ptr<hecl::Runtime::ShaderPipelines> buildShader(const hecl::Runtime::ShaderTag& tag,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view source,
|
|
|
|
std::string_view diagName,
|
2016-09-12 04:53:28 +00:00
|
|
|
boo::IGraphicsDataFactory& factory)
|
2016-04-04 02:32:57 +00:00
|
|
|
{
|
2016-09-12 04:53:28 +00:00
|
|
|
return m_shaderCache.buildShader(tag, source, diagName, factory);
|
2016-04-04 02:32:57 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
std::shared_ptr<hecl::Runtime::ShaderPipelines> buildShader(const hecl::Runtime::ShaderTag& tag,
|
|
|
|
const hecl::Frontend::IR& ir,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view diagName,
|
2016-09-12 04:53:28 +00:00
|
|
|
boo::IGraphicsDataFactory& factory)
|
2016-04-04 02:32:57 +00:00
|
|
|
{
|
2016-09-12 04:53:28 +00:00
|
|
|
return m_shaderCache.buildShader(tag, ir, diagName, factory);
|
2016-04-04 02:32:57 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
std::shared_ptr<hecl::Runtime::ShaderPipelines> buildExtendedShader(const hecl::Runtime::ShaderTag& tag,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view source,
|
|
|
|
std::string_view diagName,
|
2016-09-12 04:53:28 +00:00
|
|
|
boo::IGraphicsDataFactory& factory)
|
2016-04-04 02:32:57 +00:00
|
|
|
{
|
2016-09-12 04:53:28 +00:00
|
|
|
return m_shaderCache.buildExtendedShader(tag, source, diagName, factory);
|
2016-04-04 02:32:57 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 04:53:28 +00:00
|
|
|
std::shared_ptr<hecl::Runtime::ShaderPipelines> buildExtendedShader(const hecl::Runtime::ShaderTag& tag,
|
|
|
|
const hecl::Frontend::IR& ir,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view diagName,
|
2016-09-12 04:53:28 +00:00
|
|
|
boo::IGraphicsDataFactory& factory)
|
2016-04-04 02:32:57 +00:00
|
|
|
{
|
2016-09-12 04:53:28 +00:00
|
|
|
return m_shaderCache.buildExtendedShader(tag, ir, diagName, factory);
|
2016-04-04 02:32:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-13 06:07:23 +00:00
|
|
|
#endif // __URDE_CMODELSHADERS_HPP__
|