Big UberShader update
-Added GRAPHICS_MAX_LIGHTPERPASS macro -Added glGetActiveUniform OpenGL function -Added (Uber)ShaderLibrary -Added (Uber)ShaderName parameter to models -Changed uniform system -Fixed Node copying -Moved Material class to Graphics module -Optimized lights -Remade Shader class -Renamed Node::Invalidate to Node::InvalidateNode -Renamed ShaderProgram to Shader Former-commit-id: 15f0cad52969e91a2442e7d750ba2dc412f3549d
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Audio module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Core module
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/CallOnExit.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/ConditionVariable.hpp>
|
||||
@@ -56,6 +57,7 @@
|
||||
#include <Nazara/Core/MemoryStream.hpp>
|
||||
#include <Nazara/Core/Mutex.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Core/PluginManager.hpp>
|
||||
#include <Nazara/Core/Primitive.hpp>
|
||||
#include <Nazara/Core/PrimitiveList.hpp>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Graphics module
|
||||
@@ -54,6 +54,7 @@
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Graphics/LightManager.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/Model.hpp>
|
||||
#include <Nazara/Graphics/RenderTechniques.hpp>
|
||||
#include <Nazara/Graphics/Scene.hpp>
|
||||
|
||||
@@ -50,7 +50,7 @@ class NAZARA_API NzCamera : public NzAbstractViewer, public NzNode, NzRenderTarg
|
||||
|
||||
private:
|
||||
void ApplyView() const override;
|
||||
void Invalidate() override;
|
||||
void InvalidateNode() override;
|
||||
|
||||
void OnRenderTargetReleased(const NzRenderTarget* renderTarget, void* userdata) override;
|
||||
bool OnRenderTargetSizeChange(const NzRenderTarget* renderTarget, void* userdata) override;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
|
||||
class NAZARA_API NzColorBackground : public NzAbstractBackground
|
||||
{
|
||||
@@ -26,7 +26,10 @@ class NAZARA_API NzColorBackground : public NzAbstractBackground
|
||||
|
||||
private:
|
||||
NzColor m_color;
|
||||
NzShaderProgramConstRef m_program;
|
||||
NzUberShaderConstRef m_uberShader;
|
||||
const NzUberShaderInstance* m_uberShaderInstance;
|
||||
int m_materialDiffuseUniform;
|
||||
int m_vertexDepthUniform;
|
||||
};
|
||||
|
||||
#endif // NAZARA_COLORBACKGROUND_HPP
|
||||
|
||||
@@ -38,4 +38,7 @@
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_GRAPHICS_SAFE 1
|
||||
|
||||
// Le nombre maximum de lumières qu'un shader standard supportera
|
||||
#define NAZARA_GRAPHICS_MAX_LIGHTPERPASS 3U // Unsigned
|
||||
|
||||
#endif // NAZARA_CONFIG_GRAPHICS_HPP
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
|
||||
@@ -38,16 +38,16 @@ class NAZARA_API NzDeferredBloomPass : public NzDeferredRenderPass
|
||||
protected:
|
||||
NzRenderStates m_bloomStates;
|
||||
NzRenderTexture m_bloomRTT;
|
||||
NzShaderProgramRef m_bloomBrightProgram;
|
||||
NzShaderProgramRef m_bloomFinalProgram;
|
||||
NzShaderProgramRef m_gaussianBlurProgram;
|
||||
NzShaderRef m_bloomBrightShader;
|
||||
NzShaderRef m_bloomFinalShader;
|
||||
NzShaderRef m_gaussianBlurShader;
|
||||
NzTextureRef m_bloomTextures[2];
|
||||
NzTextureSampler m_bilinearSampler;
|
||||
mutable bool m_uniformUpdated;
|
||||
float m_brightLuminance;
|
||||
float m_brightMiddleGrey;
|
||||
float m_brightThreshold;
|
||||
int m_gaussianBlurProgramFilterLocation;
|
||||
int m_gaussianBlurShaderFilterLocation;
|
||||
unsigned int m_blurPassCount;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
|
||||
@@ -27,12 +27,12 @@ class NAZARA_API NzDeferredDOFPass : public NzDeferredRenderPass
|
||||
protected:
|
||||
NzRenderTexture m_dofRTT;
|
||||
NzRenderStates m_states;
|
||||
NzShaderProgramRef m_blurProgram;
|
||||
NzShaderProgramRef m_dofProgram;
|
||||
NzShaderConstRef m_dofShader;
|
||||
NzShaderConstRef m_gaussianBlurShader;
|
||||
NzTextureRef m_dofTextures[2];
|
||||
NzTextureSampler m_bilinearSampler;
|
||||
NzTextureSampler m_pointSampler;
|
||||
int m_blurProgramFilterLocation;
|
||||
int m_gaussianBlurShaderFilterLocation;
|
||||
};
|
||||
|
||||
#endif // NAZARA_DEFERREDDOFPASS_HPP
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
|
||||
class NAZARA_API NzDeferredFXAAPass : public NzDeferredRenderPass
|
||||
@@ -23,7 +23,7 @@ class NAZARA_API NzDeferredFXAAPass : public NzDeferredRenderPass
|
||||
|
||||
protected:
|
||||
NzRenderStates m_states;
|
||||
NzShaderProgramRef m_fxaaProgram;
|
||||
NzShaderRef m_fxaaShader;
|
||||
NzTextureSampler m_pointSampler;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
|
||||
class NAZARA_API NzDeferredFinalPass : public NzDeferredRenderPass
|
||||
{
|
||||
@@ -23,8 +23,11 @@ class NAZARA_API NzDeferredFinalPass : public NzDeferredRenderPass
|
||||
|
||||
protected:
|
||||
NzRenderStates m_states;
|
||||
NzShaderProgramRef m_program;
|
||||
NzTextureSampler m_pointSampler;
|
||||
NzUberShaderConstRef m_uberShader;
|
||||
const NzUberShaderInstance* m_uberShaderInstance;
|
||||
int m_materialDiffuseUniform;
|
||||
int m_materialDiffuseMapUniform;
|
||||
};
|
||||
|
||||
#endif // NAZARA_DEFERREDFINALPASS_HPP
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
|
||||
class NAZARA_API NzDeferredFogPass : public NzDeferredRenderPass
|
||||
@@ -23,7 +23,7 @@ class NAZARA_API NzDeferredFogPass : public NzDeferredRenderPass
|
||||
|
||||
protected:
|
||||
NzRenderStates m_states;
|
||||
NzShaderProgramRef m_program;
|
||||
NzShaderRef m_shader;
|
||||
NzTextureSampler m_pointSampler;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
|
||||
class NAZARA_API NzDeferredGeometryPass : public NzDeferredRenderPass
|
||||
{
|
||||
@@ -23,7 +23,7 @@ class NAZARA_API NzDeferredGeometryPass : public NzDeferredRenderPass
|
||||
|
||||
protected:
|
||||
NzRenderStates m_clearStates;
|
||||
NzShaderProgramRef m_clearProgram;
|
||||
NzShaderRef m_clearShader;
|
||||
};
|
||||
|
||||
#endif // NAZARA_DEFERREDGEOMETRYPASS_HPP
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/DeferredRenderPass.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
|
||||
@@ -28,16 +29,17 @@ class NAZARA_API NzDeferredPhongLightingPass : public NzDeferredRenderPass
|
||||
bool Process(const NzScene* scene, unsigned int firstWorkTexture, unsigned secondWorkTexture) const;
|
||||
|
||||
protected:
|
||||
NzLightUniforms m_directionalLightUniforms;
|
||||
NzLightUniforms m_pointSpotLightUniforms;
|
||||
NzMeshRef m_cone;
|
||||
NzMeshRef m_sphere;
|
||||
NzShaderProgramRef m_directionalLightProgram;
|
||||
NzShaderProgramRef m_pointSpotLightProgram;
|
||||
NzShaderRef m_directionalLightShader;
|
||||
NzShaderRef m_pointSpotLightShader;
|
||||
NzTextureSampler m_pointSampler;
|
||||
NzStaticMesh* m_coneMesh;
|
||||
NzStaticMesh* m_sphereMesh;
|
||||
bool m_lightMeshesDrawing;
|
||||
int m_pointSpotLightProgramDiscardLocation;
|
||||
int m_pointSpotLightProgramSpotLightLocation;
|
||||
int m_pointSpotLightShaderDiscardLocation;
|
||||
};
|
||||
|
||||
#endif // NAZARA_DEFERREDPHONGLIGHTINGPASS_HPP
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
@@ -50,7 +49,9 @@ class NAZARA_API NzDeferredRenderTechnique : public NzAbstractRenderTechnique, p
|
||||
|
||||
void SetPass(nzRenderPassType relativeTo, int position, NzDeferredRenderPass* pass);
|
||||
|
||||
static bool Initialize();
|
||||
static bool IsSupported();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
bool Resize(const NzVector2ui& dimensions) const;
|
||||
|
||||
@@ -26,6 +26,23 @@ enum nzLightType
|
||||
nzLightType_Max = nzLightType_Spot
|
||||
};
|
||||
|
||||
enum nzMaterialUniform
|
||||
{
|
||||
nzMaterialUniform_AlphaMap,
|
||||
nzMaterialUniform_AlphaThreshold,
|
||||
nzMaterialUniform_Ambient,
|
||||
nzMaterialUniform_Diffuse,
|
||||
nzMaterialUniform_DiffuseMap,
|
||||
nzMaterialUniform_EmissiveMap,
|
||||
nzMaterialUniform_HeightMap,
|
||||
nzMaterialUniform_NormalMap,
|
||||
nzMaterialUniform_Shininess,
|
||||
nzMaterialUniform_Specular,
|
||||
nzMaterialUniform_SpecularMap,
|
||||
|
||||
nzMaterialUniform_Max = nzMaterialUniform_SpecularMap
|
||||
};
|
||||
|
||||
enum nzRenderPassType
|
||||
{
|
||||
nzRenderPassType_AA,
|
||||
@@ -63,4 +80,15 @@ enum nzSceneNodeType
|
||||
nzSceneNodeType_Max = nzSceneNodeType_User
|
||||
};
|
||||
|
||||
// Ces paramètres sont indépendants du matériau: ils peuvent être demandés à tout moment
|
||||
enum nzShaderFlags
|
||||
{
|
||||
nzShaderFlags_None = 0,
|
||||
|
||||
nzShaderFlags_Deferred = 0x1,
|
||||
nzShaderFlags_Instancing = 0x2,
|
||||
|
||||
nzShaderFlags_Max = nzShaderFlags_Instancing*2-1
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_GRAPHICS_HPP
|
||||
|
||||
@@ -8,13 +8,15 @@
|
||||
#define NAZARA_FORWARDRENDERTECHNIQUE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ResourceListener.hpp>
|
||||
#include <Nazara/Graphics/AbstractRenderTechnique.hpp>
|
||||
#include <Nazara/Graphics/ForwardRenderQueue.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Graphics/LightManager.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||
|
||||
class NAZARA_API NzForwardRenderTechnique : public NzAbstractRenderTechnique
|
||||
class NAZARA_API NzForwardRenderTechnique : public NzAbstractRenderTechnique, NzResourceListener
|
||||
{
|
||||
public:
|
||||
NzForwardRenderTechnique();
|
||||
@@ -30,10 +32,23 @@ class NAZARA_API NzForwardRenderTechnique : public NzAbstractRenderTechnique
|
||||
void SetMaxLightPassPerObject(unsigned int passCount);
|
||||
|
||||
private:
|
||||
struct LightUniforms;
|
||||
|
||||
void DrawOpaqueModels(const NzScene* scene) const;
|
||||
void DrawSprites(const NzScene* scene) const;
|
||||
void DrawTransparentModels(const NzScene* scene) const;
|
||||
const LightUniforms* GetLightUniforms(const NzShader* shader) const;
|
||||
|
||||
struct LightUniforms
|
||||
{
|
||||
NzLightUniforms uniforms;
|
||||
bool exists;
|
||||
int offset; // "Distance" entre Lights[0].type et Lights[1].type
|
||||
/// Moins coûteux en mémoire que de stocker un NzLightUniforms par index de lumière,
|
||||
/// à voir si ça fonctionne chez tout le monde
|
||||
};
|
||||
|
||||
mutable std::unordered_map<const NzShader*, LightUniforms> m_lightUniforms;
|
||||
mutable NzForwardRenderQueue m_renderQueue;
|
||||
NzIndexBufferRef m_indexBuffer;
|
||||
mutable NzLightManager m_directionalLights;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
|
||||
class NzShaderProgram;
|
||||
class NzShader;
|
||||
struct NzLightUniforms;
|
||||
|
||||
class NAZARA_API NzLight : public NzSceneNode
|
||||
{
|
||||
@@ -23,7 +24,7 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||
|
||||
void AddToRenderQueue(NzAbstractRenderQueue* renderQueue) const override;
|
||||
|
||||
void Enable(const NzShaderProgram* program, unsigned int lightUnit) const;
|
||||
void Enable(const NzShader* shader, const NzLightUniforms& uniforms, int offset = 0) const;
|
||||
|
||||
float GetAmbientFactor() const;
|
||||
float GetAttenuation() const;
|
||||
@@ -49,11 +50,11 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||
|
||||
NzLight& operator=(const NzLight& light);
|
||||
|
||||
static void Disable(const NzShaderProgram* program, unsigned int lightUnit);
|
||||
static void Disable(const NzShader* program, const NzLightUniforms& uniforms, int offset = 0);
|
||||
|
||||
private:
|
||||
bool FrustumCull(const NzFrustumf& frustum) override;
|
||||
void Invalidate() override;
|
||||
void InvalidateNode() override;
|
||||
void Register() override;
|
||||
void Unregister() override;
|
||||
void UpdateBoundingVolume() const;
|
||||
@@ -70,4 +71,25 @@ class NAZARA_API NzLight : public NzSceneNode
|
||||
float m_radius;
|
||||
};
|
||||
|
||||
struct NzLightUniforms
|
||||
{
|
||||
struct UniformLocations
|
||||
{
|
||||
int type;
|
||||
int color;
|
||||
int factors;
|
||||
int parameters1;
|
||||
int parameters2;
|
||||
int parameters3;
|
||||
};
|
||||
|
||||
bool ubo;
|
||||
|
||||
union
|
||||
{
|
||||
UniformLocations locations;
|
||||
int blockLocation;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // NAZARA_LIGHT_HPP
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// This file is part of the "Nazara Engine - Graphics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
@@ -13,11 +13,11 @@
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Graphics/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
|
||||
struct NAZARA_API NzMaterialParams
|
||||
{
|
||||
@@ -27,6 +27,7 @@ struct NAZARA_API NzMaterialParams
|
||||
bool loadHeightMap = true;
|
||||
bool loadNormalMap = true;
|
||||
bool loadSpecularMap = true;
|
||||
NzString shaderName = "Basic";
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
@@ -48,11 +49,12 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
NzMaterial(NzMaterial&& material);
|
||||
~NzMaterial();
|
||||
|
||||
void Apply(const NzShaderProgram* program) const;
|
||||
const NzShader* Apply(nzUInt32 shaderFlags = 0, nzUInt8 textureUnit = 0, nzUInt8* lastUsedUnit = nullptr) const;
|
||||
|
||||
void Enable(nzRendererParameter renderParameter, bool enable);
|
||||
void EnableAlphaTest(bool alphaTest);
|
||||
void EnableLighting(bool lighting);
|
||||
void EnableTransform(bool transform);
|
||||
|
||||
NzTexture* GetAlphaMap() const;
|
||||
float GetAlphaThreshold() const;
|
||||
@@ -69,7 +71,8 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
NzTexture* GetHeightMap() const;
|
||||
NzTexture* GetNormalMap() const;
|
||||
const NzRenderStates& GetRenderStates() const;
|
||||
const NzShaderProgram* GetShaderProgram(nzShaderTarget target, nzUInt32 flags) const;
|
||||
const NzUberShader* GetShader() const;
|
||||
const NzUberShaderInstance* GetShaderInstance(nzUInt32 flags = nzShaderFlags_None) const;
|
||||
float GetShininess() const;
|
||||
NzColor GetSpecularColor() const;
|
||||
NzTexture* GetSpecularMap() const;
|
||||
@@ -78,7 +81,6 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
nzBlendFunc GetSrcBlend() const;
|
||||
|
||||
bool HasAlphaMap() const;
|
||||
bool HasCustomShaderProgram(nzShaderTarget target, nzUInt32 flags) const;
|
||||
bool HasDiffuseMap() const;
|
||||
bool HasEmissiveMap() const;
|
||||
bool HasHeightMap() const;
|
||||
@@ -88,6 +90,7 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
bool IsAlphaTestEnabled() const;
|
||||
bool IsEnabled(nzRendererParameter renderParameter) const;
|
||||
bool IsLightingEnabled() const;
|
||||
bool IsTransformEnabled() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzMaterialParams& params = NzMaterialParams());
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzMaterialParams& params = NzMaterialParams());
|
||||
@@ -114,7 +117,8 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
bool SetNormalMap(const NzString& texturePath);
|
||||
void SetNormalMap(NzTexture* map);
|
||||
void SetRenderStates(const NzRenderStates& states);
|
||||
void SetShaderProgram(nzShaderTarget target, nzUInt32 flags, const NzShaderProgram* program);
|
||||
void SetShader(const NzUberShader* uberShader);
|
||||
bool SetShader(const NzString& uberShaderName);
|
||||
void SetShininess(float shininess);
|
||||
void SetSpecularColor(const NzColor& specular);
|
||||
bool SetSpecularMap(const NzString& texturePath);
|
||||
@@ -125,27 +129,26 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
NzMaterial& operator=(const NzMaterial& material);
|
||||
NzMaterial& operator=(NzMaterial&& material);
|
||||
|
||||
static bool Initialize();
|
||||
static NzMaterial* GetDefault();
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
struct ProgramUnit
|
||||
struct ShaderInstance
|
||||
{
|
||||
NzShaderProgramConstRef program;
|
||||
bool custom = false;
|
||||
const NzShader* shader;
|
||||
NzUberShaderInstance* uberInstance;
|
||||
int uniforms[nzMaterialUniform_Max+1];
|
||||
};
|
||||
|
||||
void Copy(const NzMaterial& material);
|
||||
void GenerateProgram(nzShaderTarget target, nzUInt32 flags) const;
|
||||
void InvalidatePrograms(nzShaderTarget target);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
void GenerateShader(nzUInt32 flags) const;
|
||||
void InvalidateShaders();
|
||||
|
||||
NzColor m_ambientColor;
|
||||
NzColor m_diffuseColor;
|
||||
NzColor m_specularColor;
|
||||
NzRenderStates m_states;
|
||||
mutable ProgramUnit m_programs[nzShaderTarget_Max+1][nzShaderFlags_Max+1];
|
||||
NzTextureSampler m_diffuseSampler;
|
||||
NzTextureSampler m_specularSampler;
|
||||
NzTextureRef m_alphaMap;
|
||||
@@ -154,8 +157,11 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
NzTextureRef m_heightMap;
|
||||
NzTextureRef m_normalMap;
|
||||
NzTextureRef m_specularMap;
|
||||
NzUberShaderConstRef m_uberShader;
|
||||
mutable ShaderInstance m_shaders[nzShaderFlags_Max+1];
|
||||
bool m_alphaTestEnabled;
|
||||
bool m_lightingEnabled;
|
||||
bool m_transformEnabled;
|
||||
float m_alphaThreshold;
|
||||
float m_shininess;
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ResourceLoader.hpp>
|
||||
#include <Nazara/Core/Updatable.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
#include <Nazara/Renderer/Material.hpp>
|
||||
#include <Nazara/Utility/Animation.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
|
||||
@@ -22,6 +22,7 @@ struct NAZARA_API NzModelParameters
|
||||
NzAnimationParams animation;
|
||||
NzMaterialParams material;
|
||||
NzMeshParams mesh;
|
||||
NzString shaderName = "PhongLighting";
|
||||
|
||||
bool IsValid() const;
|
||||
};
|
||||
@@ -89,7 +90,7 @@ class NAZARA_API NzModel : public NzSceneNode, public NzUpdatable
|
||||
|
||||
private:
|
||||
bool FrustumCull(const NzFrustumf& frustum) override;
|
||||
void Invalidate() override;
|
||||
void InvalidateNode() override;
|
||||
void Register() override;
|
||||
void Unregister() override;
|
||||
void Update() override;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||
@@ -35,7 +35,7 @@ class NAZARA_API NzSkyboxBackground : public NzAbstractBackground
|
||||
NzTextureRef m_texture;
|
||||
NzTextureSampler m_sampler;
|
||||
NzIndexBufferRef m_indexBuffer;
|
||||
NzShaderProgramRef m_program;
|
||||
NzShaderRef m_shader;
|
||||
NzVertexBufferRef m_vertexBuffer;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#define NAZARA_SPRITE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/SceneNode.hpp>
|
||||
#include <Nazara/Renderer/Material.hpp>
|
||||
|
||||
class NAZARA_API NzSprite : public NzSceneNode
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class NAZARA_API NzSprite : public NzSceneNode
|
||||
|
||||
private:
|
||||
bool FrustumCull(const NzFrustumf& frustum) override;
|
||||
void Invalidate() override;
|
||||
void InvalidateNode() override;
|
||||
void Register() override;
|
||||
void Unregister() override;
|
||||
void UpdateBoundingVolume() const;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Graphics/AbstractBackground.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
|
||||
class NAZARA_API NzTextureBackground : public NzAbstractBackground
|
||||
@@ -26,8 +26,12 @@ class NAZARA_API NzTextureBackground : public NzAbstractBackground
|
||||
void SetTexture(NzTexture* texture);
|
||||
|
||||
private:
|
||||
NzShaderProgramConstRef m_program;
|
||||
NzTextureRef m_texture;
|
||||
NzUberShaderConstRef m_uberShader;
|
||||
const NzUberShaderInstance* m_uberShaderInstance;
|
||||
int m_materialDiffuseUniform;
|
||||
int m_materialDiffuseMapUniform;
|
||||
int m_vertexDepthUniform;
|
||||
};
|
||||
|
||||
#endif // NAZARA_TEXTUREBACKGROUND_HPP
|
||||
|
||||
@@ -48,7 +48,7 @@ class NAZARA_API NzView : public NzAbstractViewer, public NzNode, NzRenderTarget
|
||||
|
||||
private:
|
||||
void ApplyView() const override;
|
||||
void Invalidate() override;
|
||||
void InvalidateNode() override;
|
||||
|
||||
void OnRenderTargetReleased(const NzRenderTarget* renderTarget, void* userdata) override;
|
||||
bool OnRenderTargetSizeChange(const NzRenderTarget* renderTarget, void* userdata) override;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Lua scripting module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Mathematics module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Noise module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Physics module
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Renderer module
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <Nazara/Renderer/DebugDrawer.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/GpuQuery.hpp>
|
||||
#include <Nazara/Renderer/Material.hpp>
|
||||
#include <Nazara/Renderer/OpenGL.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Renderer/Renderer.hpp>
|
||||
@@ -44,10 +43,17 @@
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
#include <Nazara/Renderer/RenderTexture.hpp>
|
||||
#include <Nazara/Renderer/RenderWindow.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgramManager.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgramManagerParams.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/ShaderLibrary.hpp>
|
||||
#include <Nazara/Renderer/ShaderStage.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstance.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstancePreprocessor.hpp>
|
||||
#include <Nazara/Renderer/UberShaderLibrary.hpp>
|
||||
#include <Nazara/Renderer/UberShaderPreprocessor.hpp>
|
||||
#include <Nazara/Renderer/UberShaderPUniform.hpp>
|
||||
#include <Nazara/Renderer/UberShaderPUSubroutine.hpp>
|
||||
|
||||
#endif // NAZARA_GLOBAL_RENDERER_HPP
|
||||
|
||||
@@ -41,7 +41,4 @@
|
||||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_RENDERER_SAFE 1
|
||||
|
||||
// Le nombre maximum de lumières qu'un forward shader supportera
|
||||
#define NAZARA_RENDERER_SHADER_MAX_LIGHTCOUNT 8
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
|
||||
@@ -185,27 +185,6 @@ enum nzSamplerWrap
|
||||
nzSamplerWrap_Max = nzSamplerWrap_Repeat
|
||||
};
|
||||
|
||||
enum nzShaderFlags
|
||||
{
|
||||
nzShaderFlags_None = 0,
|
||||
|
||||
nzShaderFlags_Deferred = 0x1,
|
||||
nzShaderFlags_FlipUVs = 0x2,
|
||||
nzShaderFlags_Instancing = 0x4,
|
||||
|
||||
nzShaderFlags_Max = nzShaderFlags_Instancing*2-1
|
||||
};
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown = -1,
|
||||
|
||||
nzShaderLanguage_Cg,
|
||||
nzShaderLanguage_GLSL,
|
||||
|
||||
nzShaderLanguage_Max = nzShaderLanguage_GLSL
|
||||
};
|
||||
|
||||
enum nzShaderTarget
|
||||
{
|
||||
nzShaderTarget_FullscreenQuad,
|
||||
@@ -226,21 +205,9 @@ enum nzShaderUniform
|
||||
nzShaderUniform_InvWorldMatrix,
|
||||
nzShaderUniform_InvWorldViewMatrix,
|
||||
nzShaderUniform_InvWorldViewProjMatrix,
|
||||
nzShaderUniform_MaterialAlphaMap,
|
||||
nzShaderUniform_MaterialAlphaThreshold,
|
||||
nzShaderUniform_MaterialAmbient,
|
||||
nzShaderUniform_MaterialDiffuse,
|
||||
nzShaderUniform_MaterialDiffuseMap,
|
||||
nzShaderUniform_MaterialEmissiveMap,
|
||||
nzShaderUniform_MaterialHeightMap,
|
||||
nzShaderUniform_MaterialNormalMap,
|
||||
nzShaderUniform_MaterialShininess,
|
||||
nzShaderUniform_MaterialSpecular,
|
||||
nzShaderUniform_MaterialSpecularMap,
|
||||
nzShaderUniform_ProjMatrix,
|
||||
nzShaderUniform_SceneAmbient,
|
||||
nzShaderUniform_TargetSize,
|
||||
nzShaderUniform_VertexDepth,
|
||||
nzShaderUniform_ViewMatrix,
|
||||
nzShaderUniform_ViewProjMatrix,
|
||||
nzShaderUniform_WorldMatrix,
|
||||
@@ -250,13 +217,13 @@ enum nzShaderUniform
|
||||
nzShaderUniform_Max = nzShaderUniform_WorldViewProjMatrix
|
||||
};
|
||||
|
||||
enum nzShaderType
|
||||
enum nzShaderStage
|
||||
{
|
||||
nzShaderType_Fragment,
|
||||
nzShaderType_Geometry,
|
||||
nzShaderType_Vertex,
|
||||
nzShaderStage_Fragment,
|
||||
nzShaderStage_Geometry,
|
||||
nzShaderStage_Vertex,
|
||||
|
||||
nzShaderType_Max = nzShaderType_Vertex
|
||||
nzShaderStage_Max = nzShaderStage_Vertex
|
||||
};
|
||||
|
||||
enum nzStencilOperation
|
||||
|
||||
@@ -140,15 +140,15 @@ class NAZARA_API NzOpenGL
|
||||
static GLenum RendererComparison[nzRendererComparison_Max+1];
|
||||
static GLenum RendererParameter[nzRendererParameter_Max+1];
|
||||
static GLenum SamplerWrapMode[nzSamplerWrap_Max+1];
|
||||
static GLenum ShaderType[nzShaderType_Max+1];
|
||||
static GLenum ShaderStage[nzShaderStage_Max+1];
|
||||
static GLenum StencilOperation[nzStencilOperation_Max+1];
|
||||
static GLenum TextureTarget[nzImageType_Max+1];
|
||||
static GLenum TextureTargetBinding[nzImageType_Max+1];
|
||||
static GLenum TextureTargetProxy[nzImageType_Max+1];
|
||||
|
||||
private:
|
||||
static void OnContextDestruction(const NzContext* context);
|
||||
static void OnContextChange(const NzContext* newContext);
|
||||
static void OnContextDestruction(const NzContext* context);
|
||||
};
|
||||
|
||||
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
@@ -221,6 +221,7 @@ NAZARA_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
|
||||
NAZARA_API extern PFNGLGENSAMPLERSPROC glGenSamplers;
|
||||
NAZARA_API extern PFNGLGENTEXTURESPROC glGenTextures;
|
||||
NAZARA_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
NAZARA_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
|
||||
NAZARA_API extern PFNGLGETBOOLEANVPROC glGetBooleanv;
|
||||
NAZARA_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
|
||||
NAZARA_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
|
||||
|
||||
@@ -21,15 +21,13 @@
|
||||
class NzColor;
|
||||
class NzContext;
|
||||
class NzIndexBuffer;
|
||||
class NzMaterial;
|
||||
class NzRenderTarget;
|
||||
class NzShaderProgram;
|
||||
class NzShader;
|
||||
class NzTexture;
|
||||
class NzVertexBuffer;
|
||||
|
||||
class NAZARA_API NzRenderer
|
||||
{
|
||||
friend NzShaderProgram;
|
||||
friend NzTexture;
|
||||
|
||||
public:
|
||||
@@ -64,7 +62,7 @@ class NAZARA_API NzRenderer
|
||||
static float GetPointSize();
|
||||
static const NzRenderStates& GetRenderStates();
|
||||
static NzRecti GetScissorRect();
|
||||
static const NzShaderProgram* GetShaderProgram();
|
||||
static const NzShader* GetShader();
|
||||
static const NzRenderTarget* GetTarget();
|
||||
static NzRecti GetViewport();
|
||||
|
||||
@@ -89,7 +87,7 @@ class NAZARA_API NzRenderer
|
||||
static void SetPointSize(float size);
|
||||
static void SetRenderStates(const NzRenderStates& states);
|
||||
static void SetScissorRect(const NzRecti& rect);
|
||||
static void SetShaderProgram(const NzShaderProgram* shader);
|
||||
static void SetShader(const NzShader* shader);
|
||||
static void SetStencilCompareFunction(nzRendererComparison compareFunc, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilFailOperation(nzStencilOperation failOperation, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilMask(nzUInt32 mask, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
@@ -107,7 +105,7 @@ class NAZARA_API NzRenderer
|
||||
private:
|
||||
static void EnableInstancing(bool instancing);
|
||||
static bool EnsureStateUpdate();
|
||||
static void OnProgramReleased(const NzShaderProgram* program);
|
||||
static void OnShaderReleased(const NzShader* shader);
|
||||
static void OnTextureReleased(const NzTexture* texture);
|
||||
static void UpdateMatrix(nzMatrixType type);
|
||||
|
||||
|
||||
110
include/Nazara/Renderer/Shader.hpp
Normal file
110
include/Nazara/Renderer/Shader.hpp
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADER_HPP
|
||||
#define NAZARA_SHADER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NzShader;
|
||||
class NzShaderStage;
|
||||
|
||||
using NzShaderConstRef = NzResourceRef<const NzShader>;
|
||||
using NzShaderRef = NzResourceRef<NzShader>;
|
||||
|
||||
class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzShader();
|
||||
NzShader(NzShader&& shader);
|
||||
~NzShader();
|
||||
|
||||
void AttachStage(nzShaderStage stage, const NzShaderStage& shaderStage);
|
||||
bool AttachStageFromFile(nzShaderStage stage, const NzString& filePath);
|
||||
bool AttachStageFromSource(nzShaderStage stage, const char* source, unsigned int length);
|
||||
bool AttachStageFromSource(nzShaderStage stage, const NzString& source);
|
||||
|
||||
void Bind() const;
|
||||
|
||||
bool Create();
|
||||
void Destroy();
|
||||
|
||||
NzByteArray GetBinary() const;
|
||||
NzString GetLog() const;
|
||||
NzString GetSourceCode(nzShaderStage stage) const;
|
||||
int GetUniformLocation(const NzString& name) const;
|
||||
int GetUniformLocation(nzShaderUniform shaderUniform) const;
|
||||
|
||||
bool HasStage(nzShaderStage stage) const;
|
||||
|
||||
bool IsBinaryRetrievable() const;
|
||||
bool IsLinked() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool Link();
|
||||
|
||||
bool LoadFromBinary(const void* buffer, unsigned int size);
|
||||
bool LoadFromBinary(const NzByteArray& byteArray);
|
||||
|
||||
void SendBoolean(int location, bool value) const;
|
||||
void SendColor(int location, const NzColor& color) const;
|
||||
void SendDouble(int location, double value) const;
|
||||
void SendDoubleArray(int location, const double* values, unsigned int count) const;
|
||||
void SendFloat(int location, float value) const;
|
||||
void SendFloatArray(int location, const float* values, unsigned int count) const;
|
||||
void SendInteger(int location, int value) const;
|
||||
void SendIntegerArray(int location, const int* values, unsigned int count) const;
|
||||
void SendMatrix(int location, const NzMatrix4d& matrix) const;
|
||||
void SendMatrix(int location, const NzMatrix4f& matrix) const;
|
||||
void SendVector(int location, const NzVector2d& vector) const;
|
||||
void SendVector(int location, const NzVector2f& vector) const;
|
||||
void SendVector(int location, const NzVector2i& vector) const;
|
||||
void SendVector(int location, const NzVector3d& vector) const;
|
||||
void SendVector(int location, const NzVector3f& vector) const;
|
||||
void SendVector(int location, const NzVector3i& vector) const;
|
||||
void SendVector(int location, const NzVector4d& vector) const;
|
||||
void SendVector(int location, const NzVector4f& vector) const;
|
||||
void SendVector(int location, const NzVector4i& vector) const;
|
||||
void SendVectorArray(int location, const NzVector2d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector2f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector2i* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector3d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector3f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector3i* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector4d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector4f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector4i* vectors, unsigned int count) const;
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
NzShader& operator=(NzShader&& shader);
|
||||
|
||||
static bool IsStageSupported(nzShaderStage stage);
|
||||
|
||||
private:
|
||||
bool PostLinkage();
|
||||
|
||||
std::vector<unsigned int> m_attachedShaders[nzShaderStage_Max+1];
|
||||
bool m_linked;
|
||||
int m_uniformLocations[nzShaderUniform_Max+1];
|
||||
unsigned int m_program;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADER_HPP
|
||||
33
include/Nazara/Renderer/ShaderLibrary.hpp
Normal file
33
include/Nazara/Renderer/ShaderLibrary.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADERLIBRARY_HPP
|
||||
#define NAZARA_SHADERLIBRARY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NAZARA_API NzShaderLibrary
|
||||
{
|
||||
public:
|
||||
NzShaderLibrary() = delete;
|
||||
~NzShaderLibrary() = delete;
|
||||
|
||||
static NzShader* Get(const NzString& name);
|
||||
static bool Has(const NzString& name);
|
||||
|
||||
static bool Initialize();
|
||||
static void Register(const NzString& name, NzShader* shader);
|
||||
static void Uninitialize();
|
||||
static void Unregister(const NzString& name);
|
||||
|
||||
private:
|
||||
static std::unordered_map<NzString, NzShaderRef> s_library;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADERLIBRARY_HPP
|
||||
@@ -1,109 +0,0 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADERPROGRAM_HPP
|
||||
#define NAZARA_SHADERPROGRAM_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Color.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Vector2.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
#include <Nazara/Math/Vector4.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NzShaderProgram;
|
||||
|
||||
using NzShaderProgramConstRef = NzResourceRef<const NzShaderProgram>;
|
||||
using NzShaderProgramRef = NzResourceRef<NzShaderProgram>;
|
||||
|
||||
class NzAbstractShaderProgram;
|
||||
class NzTexture;
|
||||
|
||||
class NAZARA_API NzShaderProgram : public NzResource, NzNonCopyable
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzShaderProgram();
|
||||
NzShaderProgram(nzShaderLanguage language);
|
||||
NzShaderProgram(NzShaderProgram&& shader);
|
||||
~NzShaderProgram();
|
||||
|
||||
bool Create(nzShaderLanguage language);
|
||||
bool Compile();
|
||||
|
||||
void Destroy();
|
||||
|
||||
NzByteArray GetBinary() const;
|
||||
nzUInt32 GetFlags() const;
|
||||
NzString GetLog() const;
|
||||
nzShaderLanguage GetLanguage() const;
|
||||
NzString GetSourceCode(nzShaderType type) const;
|
||||
int GetUniformLocation(const NzString& name) const;
|
||||
int GetUniformLocation(nzShaderUniform uniform) const;
|
||||
|
||||
bool HasUniform(const NzString& name) const;
|
||||
|
||||
bool IsBinaryRetrievable() const;
|
||||
bool IsCompiled() const;
|
||||
bool IsLoaded(nzShaderType type) const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromBinary(const void* buffer, unsigned int size);
|
||||
bool LoadFromBinary(const NzByteArray& byteArray);
|
||||
bool LoadShader(nzShaderType type, const NzString& source);
|
||||
bool LoadShaderFromFile(nzShaderType type, const NzString& filePath);
|
||||
|
||||
bool SendBoolean(int location, bool value) const;
|
||||
bool SendColor(int location, const NzColor& color) const;
|
||||
bool SendDouble(int location, double value) const;
|
||||
bool SendDoubleArray(int location, const double* values, unsigned int count) const;
|
||||
bool SendFloat(int location, float value) const;
|
||||
bool SendFloatArray(int location, const float* values, unsigned int count) const;
|
||||
bool SendInteger(int location, int value) const;
|
||||
bool SendIntegerArray(int location, const int* values, unsigned int count) const;
|
||||
bool SendMatrix(int location, const NzMatrix4d& matrix) const;
|
||||
bool SendMatrix(int location, const NzMatrix4f& matrix) const;
|
||||
bool SendTexture(int location, const NzTexture* texture, nzUInt8* textureUnit = nullptr) const;
|
||||
bool SendVector(int location, const NzVector2d& vector) const;
|
||||
bool SendVector(int location, const NzVector2f& vector) const;
|
||||
bool SendVector(int location, const NzVector2i& vector) const;
|
||||
bool SendVector(int location, const NzVector3d& vector) const;
|
||||
bool SendVector(int location, const NzVector3f& vector) const;
|
||||
bool SendVector(int location, const NzVector3i& vector) const;
|
||||
bool SendVector(int location, const NzVector4d& vector) const;
|
||||
bool SendVector(int location, const NzVector4f& vector) const;
|
||||
bool SendVector(int location, const NzVector4i& vector) const;
|
||||
bool SendVectorArray(int location, const NzVector2d* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector2f* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector2i* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector3d* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector3f* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector3i* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector4d* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector4f* vectors, unsigned int count) const;
|
||||
bool SendVectorArray(int location, const NzVector4i* vectors, unsigned int count) const;
|
||||
|
||||
void SetFlags(nzUInt32 flags);
|
||||
|
||||
NzShaderProgram& operator=(NzShaderProgram&& shader);
|
||||
|
||||
static bool IsLanguageSupported(nzShaderLanguage language);
|
||||
static bool IsShaderTypeSupported(nzShaderType type);
|
||||
|
||||
private:
|
||||
nzUInt32 m_flags;
|
||||
NzAbstractShaderProgram* m_impl;
|
||||
bool m_compiled;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADERPROGRAM_HPP
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADERPROGRAMMANAGER_HPP
|
||||
#define NAZARA_SHADERPROGRAMMANAGER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgram.hpp>
|
||||
#include <Nazara/Renderer/ShaderProgramManagerParams.hpp>
|
||||
|
||||
class NAZARA_API NzShaderProgramManager
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzShaderProgramManager() = delete;
|
||||
~NzShaderProgramManager() = delete;
|
||||
|
||||
static const NzShaderProgram* Get(const NzShaderProgramManagerParams& params);
|
||||
|
||||
private:
|
||||
static NzString BuildFragmentCode(const NzShaderProgramManagerParams& params);
|
||||
static NzString BuildVertexCode(const NzShaderProgramManagerParams& params);
|
||||
static NzShaderProgram* GenerateProgram(const NzShaderProgramManagerParams& params);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADERPROGRAMMANAGER_HPP
|
||||
@@ -1,51 +0,0 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADERPROGRAMMANAGERPARAMS_HPP
|
||||
#define NAZARA_SHADERPROGRAMMANAGERPARAMS_HPP
|
||||
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
struct NzShaderProgramManagerParams
|
||||
{
|
||||
struct FullscreenQuad
|
||||
{
|
||||
bool alphaMapping;
|
||||
bool alphaTest;
|
||||
bool diffuseMapping;
|
||||
};
|
||||
|
||||
struct Model
|
||||
{
|
||||
bool alphaMapping;
|
||||
bool alphaTest;
|
||||
bool diffuseMapping;
|
||||
bool emissiveMapping;
|
||||
bool lighting;
|
||||
bool normalMapping;
|
||||
bool parallaxMapping;
|
||||
bool specularMapping;
|
||||
};
|
||||
|
||||
struct Sprite
|
||||
{
|
||||
bool alphaMapping;
|
||||
bool alphaTest;
|
||||
bool diffuseMapping;
|
||||
};
|
||||
|
||||
nzShaderTarget target;
|
||||
nzUInt32 flags;
|
||||
|
||||
union
|
||||
{
|
||||
FullscreenQuad fullscreenQuad;
|
||||
Model model;
|
||||
Sprite sprite;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADERPROGRAMMANAGERPARAMS_HPP
|
||||
51
include/Nazara/Renderer/ShaderStage.hpp
Normal file
51
include/Nazara/Renderer/ShaderStage.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SHADERSTAGE_HPP
|
||||
#define NAZARA_SHADERSTAGE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NAZARA_API NzShaderStage : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
NzShaderStage();
|
||||
NzShaderStage(nzShaderStage stage);
|
||||
NzShaderStage(NzShaderStage&& stage);
|
||||
~NzShaderStage();
|
||||
|
||||
bool Compile();
|
||||
|
||||
bool Create(nzShaderStage stage);
|
||||
void Destroy();
|
||||
|
||||
NzString GetLog() const;
|
||||
NzString GetSource() const;
|
||||
|
||||
bool IsCompiled() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetSource(const char* source, unsigned int length);
|
||||
void SetSource(const NzString& source);
|
||||
bool SetSourceFromFile(const NzString& filePath);
|
||||
|
||||
NzShaderStage& operator=(NzShaderStage&& shader);
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
static bool IsSupported(nzShaderStage stage);
|
||||
|
||||
private:
|
||||
nzShaderStage m_stage;
|
||||
bool m_compiled;
|
||||
unsigned int m_id;
|
||||
};
|
||||
|
||||
#endif // NAZARA_SHADERSTAGE_HPP
|
||||
31
include/Nazara/Renderer/UberShader.hpp
Normal file
31
include/Nazara/Renderer/UberShader.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UBERSHADER_HPP
|
||||
#define NAZARA_UBERSHADER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/ParameterList.hpp>
|
||||
#include <Nazara/Core/Resource.hpp>
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstance.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzUberShader;
|
||||
|
||||
using NzUberShaderConstRef = NzResourceRef<const NzUberShader>;
|
||||
using NzUberShaderRef = NzResourceRef<NzUberShader>;
|
||||
|
||||
class NAZARA_API NzUberShader : public NzResource
|
||||
{
|
||||
public:
|
||||
NzUberShader() = default;
|
||||
virtual ~NzUberShader();
|
||||
|
||||
virtual NzUberShaderInstance* Get(const NzParameterList& parameters) const = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_UBERSHADER_HPP
|
||||
27
include/Nazara/Renderer/UberShaderInstance.hpp
Normal file
27
include/Nazara/Renderer/UberShaderInstance.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UBERSHADERINSTANCE_HPP
|
||||
#define NAZARA_UBERSHADERINSTANCE_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
|
||||
class NAZARA_API NzUberShaderInstance
|
||||
{
|
||||
public:
|
||||
NzUberShaderInstance(const NzShader* shader);
|
||||
virtual ~NzUberShaderInstance();
|
||||
|
||||
virtual bool Activate() const = 0;
|
||||
|
||||
const NzShader* GetShader() const;
|
||||
|
||||
protected:
|
||||
NzShaderConstRef m_shader;
|
||||
};
|
||||
|
||||
#endif // NAZARA_UBERSHADERINSTANCE_HPP
|
||||
22
include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp
Normal file
22
include/Nazara/Renderer/UberShaderInstancePreprocessor.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP
|
||||
#define NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstance.hpp>
|
||||
|
||||
class NAZARA_API NzUberShaderInstancePreprocessor : public NzUberShaderInstance
|
||||
{
|
||||
public:
|
||||
NzUberShaderInstancePreprocessor(const NzShader* shader);
|
||||
virtual ~NzUberShaderInstancePreprocessor();
|
||||
|
||||
bool Activate() const;
|
||||
};
|
||||
|
||||
#endif // NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP
|
||||
33
include/Nazara/Renderer/UberShaderLibrary.hpp
Normal file
33
include/Nazara/Renderer/UberShaderLibrary.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UBERSHADERLIBRARY_HPP
|
||||
#define NAZARA_UBERSHADERLIBRARY_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NAZARA_API NzUberShaderLibrary
|
||||
{
|
||||
public:
|
||||
NzUberShaderLibrary() = delete;
|
||||
~NzUberShaderLibrary() = delete;
|
||||
|
||||
static NzUberShader* Get(const NzString& name);
|
||||
static bool Has(const NzString& name);
|
||||
|
||||
static bool Initialize();
|
||||
static void Register(const NzString& name, NzUberShader* uberShader);
|
||||
static void Uninitialize();
|
||||
static void Unregister(const NzString& name);
|
||||
|
||||
private:
|
||||
static std::unordered_map<NzString, NzUberShaderRef> s_library;
|
||||
};
|
||||
|
||||
#endif // NAZARA_UBERSHADERLIBRARY_HPP
|
||||
45
include/Nazara/Renderer/UberShaderPreprocessor.hpp
Normal file
45
include/Nazara/Renderer/UberShaderPreprocessor.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright (C) 2014 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Renderer module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UBERSHADERPREPROCESSOR_HPP
|
||||
#define NAZARA_UBERSHADERPREPROCESSOR_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/ShaderStage.hpp>
|
||||
#include <Nazara/Renderer/UberShader.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstancePreprocessor.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NAZARA_API NzUberShaderPreprocessor : public NzUberShader
|
||||
{
|
||||
public:
|
||||
NzUberShaderPreprocessor() = default;
|
||||
~NzUberShaderPreprocessor() = default;
|
||||
|
||||
NzUberShaderInstance* Get(const NzParameterList& parameters) const;
|
||||
|
||||
void SetShader(nzShaderStage stage, const NzString& source, const NzString& flags);
|
||||
bool SetShaderFromFile(nzShaderStage stage, const NzString& filePath, const NzString& flags);
|
||||
|
||||
static bool IsSupported();
|
||||
|
||||
private:
|
||||
struct Shader
|
||||
{
|
||||
mutable std::unordered_map<nzUInt32, NzShaderStage> cache;
|
||||
std::unordered_map<NzString, nzUInt32> flags;
|
||||
NzString source;
|
||||
bool present = false;
|
||||
};
|
||||
|
||||
mutable std::unordered_map<nzUInt32, NzUberShaderInstancePreprocessor> m_cache;
|
||||
std::unordered_map<NzString, nzUInt32> m_flags;
|
||||
Shader m_shaders[nzShaderStage_Max+1];
|
||||
};
|
||||
|
||||
#endif // NAZARA_UBERSHADERPREPROCESSOR_HPP
|
||||
@@ -1,4 +1,4 @@
|
||||
// This file was automatically generated on 12 Jan 2014 at 20:08:11
|
||||
// This file was automatically generated on 21 Feb 2014 at 18:17:18
|
||||
|
||||
/*
|
||||
Nazara Engine - Window module
|
||||
|
||||
@@ -92,7 +92,7 @@ class NAZARA_API NzNode
|
||||
|
||||
protected:
|
||||
void AddChild(NzNode* node) const;
|
||||
virtual void Invalidate();
|
||||
virtual void InvalidateNode();
|
||||
virtual void OnParenting(const NzNode* parent);
|
||||
void RemoveChild(NzNode* node) const;
|
||||
void UpdateDerived() const;
|
||||
|
||||
Reference in New Issue
Block a user