100 lines
2.2 KiB
C++
100 lines
2.2 KiB
C++
#ifndef IMaterial_h__
|
|
#define IMaterial_h__
|
|
#include "render/IShader.h"
|
|
#include "Types.h"
|
|
#include "XML.h"
|
|
#include "ResourceManager.h"
|
|
#include "CG.h"
|
|
#include "render/IVideoTexture.h"
|
|
#include "shaders/IShaderGraph.h"
|
|
#include "shaders/IShaderGraphCompiler.h"
|
|
#include <vector>
|
|
#include <map>
|
|
|
|
namespace LifeGraphics
|
|
{
|
|
#define MAX_TEX_SLOT 16
|
|
struct TextureSlot
|
|
{
|
|
texture_ptr Texture;
|
|
uint32 SlotID;
|
|
};
|
|
|
|
enum MaterialTechnique
|
|
{
|
|
MT_RENDER_FORWARD,
|
|
MT_RENDER_DEFERRED
|
|
};
|
|
|
|
enum MaterialPass
|
|
{
|
|
MP_G_FILL,
|
|
MP_DEPTH_SM,
|
|
MP_DEPTH_SOLID,
|
|
};
|
|
|
|
enum MaterialFlags
|
|
{
|
|
MF_NONE = 0,
|
|
MF_GEN_DEFAULT = 1 << 0,
|
|
};
|
|
|
|
class IMaterialPass
|
|
{
|
|
public:
|
|
IMaterialPass(MaterialPass _type);
|
|
~IMaterialPass();
|
|
MaterialPass GetPassType();
|
|
IConstantBuffer* GetConstantBuffer();
|
|
IShader* GetShader(SHADER_TYPE _type);
|
|
void SetShader(SHADER_TYPE _type, IShader* shader);
|
|
void SetTexture(texture_ptr tex, uint32 slot);
|
|
void Apply();
|
|
ShaderInputInfo inputInfo;
|
|
private:
|
|
MaterialPass passType;
|
|
IShader* ps;
|
|
IShader* vs;
|
|
IShader* gs;
|
|
IConstantBuffer* cb;
|
|
|
|
texture_ptr textureSlots[MAX_TEX_SLOT];
|
|
};
|
|
|
|
class IMaterialProxy;
|
|
class IMaterialTechnique;
|
|
class IObjectMesh;
|
|
class IMaterial : public IResource
|
|
{
|
|
friend class IMaterialProxy;
|
|
public:
|
|
IMaterial(IShaderGraph* _graph, IShaderGraphCompiler* _compiler);
|
|
~IMaterial();
|
|
IMaterialPass* AddPass(MaterialPass _type);
|
|
IMaterialPass* GetPass(MaterialPass id);
|
|
void SetTexture(int id, texture_ptr tex);
|
|
texture_ptr GetTexture(int id);
|
|
uint32 GetPassCount();
|
|
bool CastShadows;
|
|
bool ReceiveShadows;
|
|
bool Opaque;
|
|
IMaterialProxy* CreateProxy(IObjectMesh* parent);
|
|
MaterialFlags flags;
|
|
IMaterialTechnique* CreateTechnique(MaterialTechnique tech, IMaterialProxy* target);
|
|
IMaterialPass* CreatePass(IMaterialTechnique* tech, MaterialPass pass);
|
|
private:
|
|
|
|
|
|
typedef std::map<MaterialPass, IMaterialPass*> PassCollection;
|
|
typedef std::map<MaterialPass, IMaterialPass*>::iterator PassCollectionItr;
|
|
|
|
typedef std::map<int, texture_ptr> TexCollection;
|
|
typedef std::map<int, texture_ptr>::iterator TexCollectionItr;
|
|
TexCollection textures;
|
|
PassCollection passes;
|
|
EFFECT_FLAGS ownerFlags;
|
|
IShaderGraph* graph;
|
|
IShaderGraphCompiler* compiler;
|
|
};
|
|
}
|
|
#endif // IMaterial_h__
|