Added sprite overlay rendering
Former-commit-id: 1e25a7d85f06f4a4bc3ed0ead76df01db440671d
This commit is contained in:
@@ -18,6 +18,7 @@ class NzDrawable;
|
||||
class NzLight;
|
||||
class NzMaterial;
|
||||
class NzSprite;
|
||||
class NzTexture;
|
||||
struct NzMeshData;
|
||||
|
||||
class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||
@@ -29,7 +30,7 @@ class NAZARA_API NzAbstractRenderQueue : NzNonCopyable
|
||||
virtual void AddDrawable(const NzDrawable* drawable) = 0;
|
||||
virtual void AddLight(const NzLight* light) = 0;
|
||||
virtual void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) = 0;
|
||||
virtual void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount) = 0;
|
||||
virtual void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) = 0;
|
||||
|
||||
virtual void Clear(bool fully) = 0;
|
||||
};
|
||||
|
||||
@@ -31,7 +31,7 @@ class NAZARA_API NzDeferredRenderQueue : public NzAbstractRenderQueue, NzResourc
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount) override;
|
||||
void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) override;
|
||||
|
||||
void Clear(bool fully);
|
||||
|
||||
|
||||
@@ -85,9 +85,10 @@ enum nzShaderFlags
|
||||
{
|
||||
nzShaderFlags_None = 0,
|
||||
|
||||
nzShaderFlags_Deferred = 0x1,
|
||||
nzShaderFlags_Instancing = 0x2,
|
||||
nzShaderFlags_VertexColor = 0x4,
|
||||
nzShaderFlags_Deferred = 0x1,
|
||||
nzShaderFlags_Instancing = 0x2,
|
||||
nzShaderFlags_TextureOverlay = 0x4,
|
||||
nzShaderFlags_VertexColor = 0x8,
|
||||
|
||||
nzShaderFlags_Max = nzShaderFlags_VertexColor*2-1
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzResource
|
||||
void AddDrawable(const NzDrawable* drawable) override;
|
||||
void AddLight(const NzLight* light) override;
|
||||
void AddMesh(const NzMaterial* material, const NzMeshData& meshData, const NzBoxf& meshAABB, const NzMatrix4f& transformMatrix) override;
|
||||
void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount) override;
|
||||
void AddSprites(const NzMaterial* material, const NzVertexStruct_XYZ_Color_UV* vertices, unsigned int spriteCount, const NzTexture* overlay = nullptr) override;
|
||||
|
||||
void Clear(bool fully);
|
||||
|
||||
@@ -74,7 +74,8 @@ class NAZARA_API NzForwardRenderQueue : public NzAbstractRenderQueue, NzResource
|
||||
|
||||
typedef std::map<NzMeshData, std::pair<NzSpheref, std::vector<NzMatrix4f>>, MeshDataComparator> MeshInstanceContainer;
|
||||
typedef std::map<const NzMaterial*, std::tuple<bool, bool, MeshInstanceContainer>, BatchedModelMaterialComparator> ModelBatches;
|
||||
typedef std::map<const NzMaterial*, std::vector<SpriteChain_XYZ_Color_UV>> BasicSpriteBatches;
|
||||
typedef std::map<const NzTexture*, std::vector<SpriteChain_XYZ_Color_UV>> BasicSpriteOverlayContainer;
|
||||
typedef std::map<const NzMaterial*, BasicSpriteOverlayContainer> BasicSpriteBatches;
|
||||
typedef std::vector<const NzLight*> LightContainer;
|
||||
typedef std::vector<unsigned int> TransparentModelContainer;
|
||||
|
||||
|
||||
@@ -32,23 +32,27 @@ class NAZARA_API NzForwardRenderTechnique : public NzAbstractRenderTechnique, Nz
|
||||
void SetMaxLightPassPerObject(unsigned int passCount);
|
||||
|
||||
private:
|
||||
struct LightUniforms;
|
||||
struct ShaderUniforms;
|
||||
|
||||
void DrawBasicSprites(const NzScene* scene) const;
|
||||
void DrawOpaqueModels(const NzScene* scene) const;
|
||||
void DrawTransparentModels(const NzScene* scene) const;
|
||||
const LightUniforms* GetLightUniforms(const NzShader* shader) const;
|
||||
const ShaderUniforms* GetShaderUniforms(const NzShader* shader) const;
|
||||
|
||||
struct LightUniforms
|
||||
struct ShaderUniforms
|
||||
{
|
||||
NzLightUniforms uniforms;
|
||||
bool exists;
|
||||
int offset; // "Distance" entre Lights[0].type et Lights[1].type
|
||||
NzLightUniforms lightUniforms;
|
||||
bool hasLightUniforms;
|
||||
|
||||
/// Moins coûteux en mémoire que de stocker un NzLightUniforms par index de lumière,
|
||||
/// à voir si ça fonctionne chez tout le monde
|
||||
int lightOffset; // "Distance" entre Lights[0].type et Lights[1].type
|
||||
|
||||
// Autre uniformes
|
||||
int textureOverlay;
|
||||
};
|
||||
|
||||
mutable std::unordered_map<const NzShader*, LightUniforms> m_lightUniforms;
|
||||
mutable std::unordered_map<const NzShader*, ShaderUniforms> m_shaderUniforms;
|
||||
mutable NzForwardRenderQueue m_renderQueue;
|
||||
NzIndexBufferRef m_indexBuffer;
|
||||
mutable NzLightManager m_directionalLights;
|
||||
|
||||
Reference in New Issue
Block a user