| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <array> |
| 7 |
#include <optional> |
| 8 |
#include <variant> |
| 9 |
#include <vector> |
| 10 |
|
| 11 |
#include <picojson.h> |
| 12 |
|
| 13 |
#include "Common/CommonTypes.h" |
| 14 |
#include "VideoCommon/Assets/CustomAsset.h" |
| 15 |
#include "VideoCommon/Assets/TextureSamplerValue.h" |
| 16 |
#include "VideoCommon/BPMemory.h" |
| 17 |
#include "VideoCommon/RenderState.h" |
| 18 |
|
| 19 |
class ShaderCode; |
| 20 |
|
| 21 |
namespace VideoCommon |
| 22 |
{ |
| 23 |
struct MaterialProperty |
| 24 |
{ |
| 25 |
static void WriteToMemory(u8*& buffer, const MaterialProperty& property); |
| 26 |
static std::size_t GetMemorySize(const MaterialProperty& property); |
| 27 |
using Value = |
| 28 |
std::variant<s32, std::array<s32, 2>, std::array<s32, 3>, std::array<s32, 4>, float, |
| 29 |
std::array<float, 2>, std::array<float, 3>, std::array<float, 4>, bool>; |
| 30 |
Value m_value; |
| 31 |
}; |
| 32 |
|
| 33 |
struct MaterialData |
| 34 |
{ |
| 35 |
static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json, |
| 36 |
MaterialData* data); |
| 37 |
static void ToJson(picojson::object* obj, const MaterialData& data); |
| 38 |
CustomAssetLibrary::AssetID shader_asset; |
| 39 |
CustomAssetLibrary::AssetID next_material_asset; |
| 40 |
std::vector<MaterialProperty> properties; |
| 41 |
|
| 42 |
std::optional<CullMode> cull_mode; |
| 43 |
std::optional<DepthState> depth_state; |
| 44 |
std::optional<BlendingState> blending_state; |
| 45 |
|
| 46 |
std::vector<TextureSamplerValue> textures; |
| 47 |
}; |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
class MaterialAsset final : public CustomLoadableAsset<MaterialData> |
| 54 |
{ |
| 55 |
public: |
| 56 |
using CustomLoadableAsset::CustomLoadableAsset; |
| 57 |
|
| 58 |
private: |
| 59 |
CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override; |
| 60 |
}; |
| 61 |
|
| 62 |
} |