// Copyright 2023 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include #include #include #include #include #include "Common/CommonTypes.h" #include "VideoCommon/Assets/CustomAsset.h" #include "VideoCommon/Assets/TextureSamplerValue.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/RenderState.h" class ShaderCode; namespace VideoCommon { struct MaterialProperty { static void WriteToMemory(u8*& buffer, const MaterialProperty& property); static std::size_t GetMemorySize(const MaterialProperty& property); using Value = std::variant, std::array, std::array, float, std::array, std::array, std::array, bool>; Value m_value; }; struct MaterialData { static bool FromJson(const CustomAssetLibrary::AssetID& asset_id, const picojson::object& json, MaterialData* data); static void ToJson(picojson::object* obj, const MaterialData& data); CustomAssetLibrary::AssetID shader_asset; CustomAssetLibrary::AssetID next_material_asset; std::vector properties; std::optional cull_mode; std::optional depth_state; std::optional blending_state; std::vector textures; }; // Much like Unity and Unreal materials, a Dolphin material does very little on its own // Its sole purpose is to provide data (through properties) that are used in conjunction // with a shader asset that is provided by name. It is up to user of this asset to // use the two together to create the relevant runtime data class MaterialAsset final : public CustomLoadableAsset { public: using CustomLoadableAsset::CustomLoadableAsset; private: CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) override; }; } // namespace VideoCommon