Merge remote-tracking branch 'refs/remotes/origin/master' into vulkan

Former-commit-id: 12d5722252889558981b1e0b7e4a4538f6884e75 [formerly d4af159fa65c936f375e9e145bacba8ac38fdaa4] [formerly fee7f096c0bd0fb40fc03d663d74f2e847d06156 [formerly 6463645a926ad288de74646a470c3c4b7f8482c8]]
Former-commit-id: ad1e056ead3806ea657842b21d2a19d488ab52e1 [formerly 904fb40602ee4e6d936da58bbbca27acf6f89d82]
Former-commit-id: 7fe9d74b7100cf561c6cdd7445721e686da87f23
This commit is contained in:
Lynix 2016-08-16 13:02:07 +02:00
commit 7dca3f1ab9
50 changed files with 653 additions and 140 deletions

View File

@ -27,6 +27,8 @@ namespace Ndk
BaseSystem(BaseSystem&&) noexcept = default;
virtual ~BaseSystem();
inline void Enable(bool enable = true);
virtual BaseSystem* Clone() const = 0;
bool Filters(const Entity* entity) const;
@ -36,6 +38,8 @@ namespace Ndk
inline float GetUpdateRate() const;
inline World& GetWorld() const;
inline bool IsEnabled() const;
inline bool HasEntity(const Entity* entity) const;
inline void SetUpdateRate(float updatePerSecond);
@ -86,6 +90,7 @@ namespace Ndk
Nz::Bitset<> m_requiredComponents;
SystemIndex m_systemIndex;
World* m_world;
bool m_updateEnabled;
float m_updateCounter;
float m_updateRate;

View File

@ -2,12 +2,14 @@
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/BaseSystem.hpp>
#include <Nazara/Core/Error.hpp>
#include <type_traits>
namespace Ndk
{
inline BaseSystem::BaseSystem(SystemIndex systemId) :
m_updateEnabled(true),
m_systemIndex(systemId)
{
SetUpdateRate(30);
@ -17,11 +19,17 @@ namespace Ndk
m_excludedComponents(system.m_excludedComponents),
m_requiredComponents(system.m_requiredComponents),
m_systemIndex(system.m_systemIndex),
m_updateEnabled(system.m_updateEnabled),
m_updateCounter(0.f),
m_updateRate(system.m_updateRate)
{
}
inline void BaseSystem::Enable(bool enable)
{
m_updateEnabled = enable;
}
inline const std::vector<EntityHandle>& BaseSystem::GetEntities() const
{
return m_entities;
@ -42,6 +50,11 @@ namespace Ndk
return *m_world;
}
inline bool BaseSystem::IsEnabled() const
{
return m_updateEnabled;
}
inline bool BaseSystem::HasEntity(const Entity* entity) const
{
if (!entity)
@ -58,6 +71,9 @@ namespace Ndk
inline void BaseSystem::Update(float elapsedTime)
{
if (!IsEnabled())
return;
if (m_updateRate > 0.f)
{
m_updateCounter += elapsedTime;

View File

@ -35,7 +35,7 @@ namespace Ndk
inline void Clear();
inline void Detach(const Nz::InstancedRenderableRef& renderable);
inline void Detach(const Nz::InstancedRenderable* renderable);
inline void EnsureBoundingVolumeUpdate() const;
inline void EnsureTransformMatrixUpdate() const;
@ -75,20 +75,31 @@ namespace Ndk
Renderable(Renderable&& renderable) noexcept :
data(std::move(renderable.data)),
renderable(std::move(renderable.renderable)),
dataUpdated(renderable.dataUpdated)
dataUpdated(renderable.dataUpdated),
renderableInvalidationSlot(std::move(renderable.renderableInvalidationSlot)),
renderableReleaseSlot(std::move(renderable.renderableReleaseSlot))
{
}
~Renderable()
{
// Disconnect release slot before releasing instanced renderable reference
renderableReleaseSlot.Disconnect();
}
Renderable& operator=(Renderable&& r) noexcept
{
data = std::move(r.data);
dataUpdated = r.dataUpdated;
renderable = std::move(r.renderable);
renderableInvalidationSlot = std::move(r.renderableInvalidationSlot);
renderableReleaseSlot = std::move(r.renderableReleaseSlot);
return *this;
}
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableRelease, renderableReleaseSlot);
mutable Nz::InstancedRenderable::InstanceData data;
Nz::InstancedRenderableRef renderable;

View File

@ -43,6 +43,7 @@ namespace Ndk
r.data.renderOrder = renderOrder;
r.renderable = std::move(renderable);
r.renderableInvalidationSlot.Connect(r.renderable->OnInstancedRenderableInvalidateData, std::bind(&GraphicsComponent::InvalidateRenderableData, this, std::placeholders::_1, std::placeholders::_2, m_renderables.size() - 1));
r.renderableReleaseSlot.Connect(r.renderable->OnInstancedRenderableRelease, this, &GraphicsComponent::Detach);
InvalidateBoundingVolume();
}
@ -54,7 +55,7 @@ namespace Ndk
InvalidateBoundingVolume();
}
inline void GraphicsComponent::Detach(const Nz::InstancedRenderableRef& renderable)
inline void GraphicsComponent::Detach(const Nz::InstancedRenderable* renderable)
{
for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it)
{

View File

@ -17,7 +17,7 @@ namespace Ndk
using ParticleGroupComponentHandle = Nz::ObjectHandle<ParticleGroupComponent>;
class NDK_API ParticleGroupComponent : public Component<ParticleGroupComponent>, public Nz::ParticleGroup
class NDK_API ParticleGroupComponent : public Component<ParticleGroupComponent>, public Nz::ParticleGroup, public Nz::HandledObject<ParticleGroupComponent>
{
public:
inline ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout);
@ -25,6 +25,12 @@ namespace Ndk
ParticleGroupComponent(const ParticleGroupComponent&) = default;
~ParticleGroupComponent() = default;
void AddEmitter(Entity* emitter);
using ParticleGroup::AddEmitter;
void RemoveEmitter(Entity* emitter);
using ParticleGroup::RemoveEmitter;
static ComponentIndex componentIndex;
};
}

View File

@ -1,8 +1,11 @@
#include "ParticleGroupComponent.hpp"
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Components/ParticleGroupComponent.hpp>
#include <NDK/Components/ParticleEmitterComponent.hpp>
#include <Nazara/Core/Error.hpp>
namespace Ndk
{
inline ParticleGroupComponent::ParticleGroupComponent(unsigned int maxParticleCount, Nz::ParticleLayout layout) :
@ -14,4 +17,22 @@ namespace Ndk
ParticleGroup(maxParticleCount, std::move(declaration))
{
}
inline void ParticleGroupComponent::AddEmitter(Entity* emitter)
{
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a NodeComponent");
auto& emitterComponent = emitter->GetComponent<ParticleEmitterComponent>();
ParticleGroup::AddEmitter(&emitterComponent);
}
inline void ParticleGroupComponent::RemoveEmitter(Entity* emitter)
{
NazaraAssert(emitter && emitter->IsValid(), "Invalid entity");
NazaraAssert(emitter->HasComponent<ParticleEmitterComponent>(), "Entity must have a NodeComponent");
auto& emitterComponent = emitter->GetComponent<ParticleEmitterComponent>();
ParticleGroup::RemoveEmitter(&emitterComponent);
}
}

View File

@ -34,10 +34,14 @@ namespace Ndk
BaseComponent& AddComponent(std::unique_ptr<BaseComponent>&& component);
template<typename ComponentType, typename... Args> ComponentType& AddComponent(Args&&... args);
const EntityHandle& Clone() const;
inline void Enable(bool enable);
inline BaseComponent& GetComponent(ComponentIndex index);
template<typename ComponentType> ComponentType& GetComponent();
inline const BaseComponent& GetComponent(ComponentIndex index) const;
template<typename ComponentType> const ComponentType& GetComponent() const;
inline const Nz::Bitset<>& GetComponentBits() const;
inline EntityId GetId() const;
inline const Nz::Bitset<>& GetSystemBits() const;
@ -52,8 +56,8 @@ namespace Ndk
inline bool IsEnabled() const;
inline bool IsValid() const;
void RemoveAllComponents();
void RemoveComponent(ComponentIndex index);
inline void RemoveAllComponents();
inline void RemoveComponent(ComponentIndex index);
template<typename ComponentType> void RemoveComponent();
inline Nz::String ToString() const;
@ -67,6 +71,10 @@ namespace Ndk
void Create();
void Destroy();
void DestroyComponent(ComponentIndex index);
inline Nz::Bitset<>& GetRemovedComponentBits();
inline void RegisterSystem(SystemIndex index);
inline void SetWorld(World* world) noexcept;
@ -75,6 +83,7 @@ namespace Ndk
std::vector<std::unique_ptr<BaseComponent>> m_components;
Nz::Bitset<> m_componentBits;
Nz::Bitset<> m_removedComponentBits;
Nz::Bitset<> m_systemBits;
EntityId m_id;
World* m_world;

View File

@ -2,6 +2,7 @@
// This file is part of the "Nazara Development Kit"
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <NDK/Entity.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/StringStream.hpp>
#include <algorithm>
@ -50,6 +51,27 @@ namespace Ndk
return static_cast<ComponentType&>(GetComponent(index));
}
inline const BaseComponent& Entity::GetComponent(ComponentIndex index) const
{
///DOC: Le component doit être présent
NazaraAssert(HasComponent(index), "This component is not part of the entity");
BaseComponent* component = m_components[index].get();
NazaraAssert(component, "Invalid component pointer");
return *component;
}
template<typename ComponentType>
const ComponentType& Entity::GetComponent() const
{
///DOC: Le component doit être présent
static_assert(std::is_base_of<BaseComponent, ComponentType>::value, "ComponentType is not a component");
ComponentIndex index = GetComponentIndex<ComponentType>();
return static_cast<ComponentType&>(GetComponent(index));
}
inline const Nz::Bitset<>& Entity::GetComponentBits() const
{
return m_componentBits;
@ -103,12 +125,31 @@ namespace Ndk
RemoveComponent(index);
}
inline void Entity::RemoveAllComponents()
{
m_removedComponentBits = m_componentBits;
Invalidate();
}
inline void Entity::RemoveComponent(ComponentIndex index)
{
m_removedComponentBits.UnboundedSet(index);
Invalidate();
}
inline Nz::String Entity::ToString() const
{
Nz::StringStream ss;
return ss << "Entity(" << GetId() << ')';
}
inline Nz::Bitset<>& Entity::GetRemovedComponentBits()
{
return m_removedComponentBits;
}
inline void Entity::RegisterSystem(SystemIndex index)
{
m_systemBits.UnboundedSet(index);

View File

@ -4,6 +4,7 @@
#pragma once
#ifndef NDK_SERVER
#ifndef NDK_SYSTEMS_PARTICLESYSTEM_HPP
#define NDK_SYSTEMS_PARTICLESYSTEM_HPP
@ -27,3 +28,4 @@ namespace Ndk
#include <NDK/Systems/ParticleSystem.inl>
#endif // NDK_SYSTEMS_PARTICLESYSTEM_HPP
#endif // NDK_SERVER

View File

@ -28,8 +28,8 @@ namespace Ndk
inline RenderSystem(const RenderSystem& renderSystem);
~RenderSystem() = default;
template<typename T> void ChangeRenderTechnique();
inline void ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique);
template<typename T> T& ChangeRenderTechnique();
inline Nz::AbstractRenderTechnique& ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique);
inline const Nz::BackgroundRef& GetDefaultBackground() const;
inline const Nz::Matrix4f& GetCoordinateSystemMatrix() const;

View File

@ -10,14 +10,15 @@ namespace Ndk
}
template<typename T>
inline void RenderSystem::ChangeRenderTechnique()
inline T& RenderSystem::ChangeRenderTechnique()
{
ChangeRenderTechnique(std::make_unique<T>());
return static_cast<T&>(ChangeRenderTechnique(std::make_unique<T>()));
}
inline void RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
inline Nz::AbstractRenderTechnique& RenderSystem::ChangeRenderTechnique(std::unique_ptr<Nz::AbstractRenderTechnique>&& renderTechnique)
{
m_renderTechnique = std::move(renderTechnique);
return *m_renderTechnique.get();
}
inline const Nz::BackgroundRef& RenderSystem::GetDefaultBackground() const

View File

@ -44,6 +44,8 @@ namespace Ndk
void Clear() noexcept;
const EntityHandle& CloneEntity(EntityId id);
const EntityHandle& GetEntity(EntityId id);
inline const EntityList& GetEntities();
inline BaseSystem& GetSystem(SystemIndex index);

View File

@ -44,6 +44,7 @@ namespace Ndk
// Affectation et retour du component
m_components[index] = std::move(componentPtr);
m_componentBits.UnboundedSet(index);
m_removedComponentBits.UnboundedReset(index);
Invalidate();
@ -60,6 +61,14 @@ namespace Ndk
return component;
}
const EntityHandle& Entity::Clone() const
{
///DOC: The clone is enabled by default, even if the original entity is disabled
NazaraAssert(IsValid(), "Invalid entity");
return m_world->CloneEntity(m_id);
}
void Entity::Kill()
{
m_world->KillEntity(this);
@ -71,40 +80,6 @@ namespace Ndk
m_world->Invalidate(m_id);
}
void Entity::RemoveAllComponents()
{
for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i))
RemoveComponent(static_cast<ComponentIndex>(i));
NazaraAssert(m_componentBits.TestNone(), "All components should be gone");
m_components.clear();
Invalidate();
}
void Entity::RemoveComponent(ComponentIndex index)
{
///DOC: N'a aucun effet si le component n'est pas présent
if (HasComponent(index))
{
// On récupère le component et on informe les composants du détachement
BaseComponent& component = *m_components[index].get();
for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i))
{
if (i != index)
m_components[i]->OnComponentDetached(component);
}
component.SetEntity(nullptr);
m_components[index].reset();
m_componentBits.Reset(index);
Invalidate();
}
}
void Entity::Create()
{
m_enabled = true;
@ -128,4 +103,25 @@ namespace Ndk
m_valid = false;
}
void Entity::DestroyComponent(ComponentIndex index)
{
///DOC: N'a aucun effet si le component n'est pas présent
if (HasComponent(index))
{
// On récupère le component et on informe les composants du détachement
BaseComponent& component = *m_components[index].get();
for (std::size_t i = m_componentBits.FindFirst(); i != m_componentBits.npos; i = m_componentBits.FindNext(i))
{
if (i != index)
m_components[i]->OnComponentDetached(component);
}
component.SetEntity(nullptr);
m_components[index].reset();
m_componentBits.Reset(index);
}
}
}

View File

@ -22,7 +22,7 @@ namespace Ndk
NodeComponent& node = entity->GetComponent<NodeComponent>();
const VelocityComponent& velocity = entity->GetComponent<VelocityComponent>();
node.Move(velocity.linearVelocity * elapsedTime);
node.Move(velocity.linearVelocity * elapsedTime, Nz::CoordSys_Global);
}
}

View File

@ -4,6 +4,7 @@
#include <NDK/World.hpp>
#include <Nazara/Core/Error.hpp>
#include <NDK/BaseComponent.hpp>
#include <NDK/Systems/PhysicsSystem.hpp>
#include <NDK/Systems/VelocitySystem.hpp>
@ -74,6 +75,27 @@ namespace Ndk
m_killedEntities.Clear();
}
const EntityHandle& World::CloneEntity(EntityId id)
{
EntityHandle original = GetEntity(id);
if (!original)
{
NazaraError("Invalid entity ID");
return EntityHandle::InvalidHandle;
}
EntityHandle clone = CreateEntity();
const Nz::Bitset<>& componentBits = original->GetComponentBits();
for (std::size_t i = componentBits.FindFirst(); i != componentBits.npos; i = componentBits.FindNext(i))
{
std::unique_ptr<BaseComponent> component(original->GetComponent(ComponentIndex(i)).Clone());
clone->AddComponent(std::move(component));
}
return GetEntity(clone->GetId());
}
void World::KillEntity(Entity* entity)
{
///DOC: Ignoré si l'entité est invalide
@ -139,6 +161,11 @@ namespace Ndk
if (!entity->IsValid())
continue;
Nz::Bitset<>& removedComponents = entity->GetRemovedComponentBits();
for (std::size_t j = removedComponents.FindFirst(); j != m_dirtyEntities.npos; j = removedComponents.FindNext(j))
entity->DestroyComponent(j);
removedComponents.Reset();
for (auto& system : m_systems)
{
// Ignore non-existent systems

View File

@ -30,6 +30,8 @@ TOOL.FilesExcluded = {
"../SDK/**/LightComponent.*",
"../SDK/**/ListenerComponent.*",
"../SDK/**/ListenerSystem.*",
"../SDK/**/Particle*Component.*",
"../SDK/**/ParticleSystem.*",
"../SDK/**/RenderSystem.*",
"../SDK/**/LuaBinding_Audio.*",
"../SDK/**/LuaBinding_Graphics.*",

View File

@ -124,7 +124,7 @@ namespace Nz
template<typename T, std::size_t N>
constexpr std::size_t CountOf(T(&name)[N]) noexcept
{
NazaraUnused(name);
// NazaraUnused(name); //< Because "body of function is not a return-statement" >.>
return N;
}

View File

@ -2,6 +2,7 @@
// This file is part of the "Nazara Engine - Core module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/Error.hpp>
#include <utility>
#include <Nazara/Core/Debug.hpp>

View File

@ -47,9 +47,9 @@ namespace Nz
Vector2ui m_dimensions;
DeferredRenderTechnique* m_deferredTechnique;
DeferredRenderQueue* m_renderQueue;
RenderBuffer* m_depthStencilBuffer;
RenderTexture* m_GBufferRTT;
RenderTexture* m_workRTT;
Texture* m_depthStencilTexture;
Texture* m_GBuffer[4];
Texture* m_workTextures[2];

View File

@ -37,7 +37,7 @@ namespace Nz
void EnablePass(RenderPassType renderPass, int position, bool enable);
RenderBuffer* GetDepthStencilBuffer() const;
Texture* GetDepthStencilTexture() const;
Texture* GetGBuffer(unsigned int i) const;
RenderTexture* GetGBufferRTT() const;
const ForwardRenderTechnique* GetForwardTechnique() const;
@ -69,7 +69,7 @@ namespace Nz
std::map<RenderPassType, std::map<int, std::unique_ptr<DeferredRenderPass>>, RenderPassComparator> m_passes;
ForwardRenderTechnique m_forwardTechnique; // Must be initialized before the RenderQueue
DeferredRenderQueue m_renderQueue;
mutable RenderBufferRef m_depthStencilBuffer;
mutable TextureRef m_depthStencilTexture;
mutable RenderTexture m_GBufferRTT;
mutable RenderTexture m_workRTT;
mutable TextureRef m_GBuffer[4];

View File

@ -61,7 +61,7 @@ namespace Nz
if (!operator==(static_cast<const RenderStates&>(lhs), static_cast<const RenderStates&>(rhs)))
return false;
#define NazaraPipelineMember(field) if (lhs.##field != rhs.##field) return false
#define NazaraPipelineMember(field) if (lhs.field != rhs.field) return false
#define NazaraPipelineBoolMember NazaraPipelineMember
NazaraPipelineBoolMember(alphaTest);
@ -115,8 +115,8 @@ namespace std
Nz::UInt16 parameterHash = 0;
Nz::UInt16 parameterIndex = 0;
#define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.##member)
#define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
#define NazaraPipelineMember(member) Nz::HashCombine(seed, pipelineInfo.member)
#define NazaraPipelineBoolMember(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++)
NazaraPipelineBoolMember(alphaTest);
NazaraPipelineBoolMember(depthSorting);

View File

@ -11,6 +11,8 @@ namespace Nz
ParticleDeclarationRef ParticleDeclaration::New(Args&&... args)
{
std::unique_ptr<ParticleDeclaration> object(new ParticleDeclaration(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}

View File

@ -0,0 +1,45 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP
#define NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/ParticleController.hpp>
#include <functional>
namespace Nz
{
class ParticleFunctionController;
using ParticleFunctionControllerConstRef = ObjectRef<const ParticleFunctionController>;
using ParticleFunctionControllerRef = ObjectRef<ParticleFunctionController>;
class NAZARA_GRAPHICS_API ParticleFunctionController : public ParticleController
{
public:
using Controller = std::function<void(ParticleGroup& /*group*/, ParticleMapper& /*mapper*/, unsigned int /*startId*/, unsigned int /*endId*/, float /*elapsedTime*/)>;
inline ParticleFunctionController(Controller controller);
ParticleFunctionController(const ParticleFunctionController&) = default;
~ParticleFunctionController() = default;
void Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override final;
inline const Controller& GetController() const;
inline void SetController(Controller controller);
template<typename... Args> static ParticleFunctionControllerRef New(Args&&... args);
private:
Controller m_controller;
};
}
#include <Nazara/Graphics/ParticleFunctionController.inl>
#endif // NAZARA_PARTICLEFUNCTIONCONTROLLER_HPP

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionController.hpp>
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline ParticleFunctionController::ParticleFunctionController(Controller controller) :
m_controller(std::move(controller))
{
}
/*!
* \brief Gets the controller function
*
* \return Controller function responsible for particle update
*/
inline const ParticleFunctionController::Controller& ParticleFunctionController::GetController() const
{
return m_controller;
}
/*!
* \brief Sets the controller function
*
* \remark The controller function must be valid
*/
inline void ParticleFunctionController::SetController(Controller controller)
{
m_controller = std::move(controller);
}
template<typename... Args>
ParticleFunctionControllerRef ParticleFunctionController::New(Args&&... args)
{
std::unique_ptr<ParticleFunctionController> object(new ParticleFunctionController(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@ -0,0 +1,45 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PARTICLEFUNCTIONGENERATOR_HPP
#define NAZARA_PARTICLEFUNCTIONGENERATOR_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/ParticleGenerator.hpp>
#include <functional>
namespace Nz
{
class ParticleFunctionGenerator;
using ParticleFunctionGeneratorConstRef = ObjectRef<const ParticleFunctionGenerator>;
using ParticleFunctionGeneratorRef = ObjectRef<ParticleFunctionGenerator>;
class NAZARA_GRAPHICS_API ParticleFunctionGenerator : public ParticleGenerator
{
public:
using Generator = std::function<void(ParticleGroup& /*group*/, ParticleMapper& /*mapper*/, unsigned int /*startId*/, unsigned int /*endId*/)>;
inline ParticleFunctionGenerator(Generator controller);
ParticleFunctionGenerator(const ParticleFunctionGenerator&) = default;
~ParticleFunctionGenerator() = default;
void Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId) override final;
inline const Generator& GetGenerator() const;
inline void SetGenerator(Generator generator);
template<typename... Args> static ParticleFunctionGeneratorRef New(Args&&... args);
private:
Generator m_generator;
};
}
#include <Nazara/Graphics/ParticleFunctionGenerator.inl>
#endif // NAZARA_PARTICLEFUNCTIONGENERATOR_HPP

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionGenerator.hpp>
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline ParticleFunctionGenerator::ParticleFunctionGenerator(Generator generator) :
m_generator(std::move(generator))
{
}
/*!
* \brief Gets the generator function
*
* \return Generator function responsible for particle creation
*/
inline const ParticleFunctionGenerator::Generator& ParticleFunctionGenerator::GetGenerator() const
{
return m_generator;
}
/*!
* \brief Sets the generator function
*
* \remark The generator function must be valid
*/
inline void ParticleFunctionGenerator::SetGenerator(Generator generator)
{
m_generator = std::move(generator);
}
template<typename... Args>
ParticleFunctionGeneratorRef ParticleFunctionGenerator::New(Args&&... args)
{
std::unique_ptr<ParticleFunctionGenerator> object(new ParticleFunctionGenerator(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@ -0,0 +1,45 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_PARTICLEFUNCTIONRENDERER_HPP
#define NAZARA_PARTICLEFUNCTIONRENDERER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Graphics/ParticleRenderer.hpp>
#include <functional>
namespace Nz
{
class ParticleFunctionRenderer;
using ParticleFunctionRendererConstRef = ObjectRef<const ParticleFunctionRenderer>;
using ParticleFunctionRendererRef = ObjectRef<ParticleFunctionRenderer>;
class NAZARA_GRAPHICS_API ParticleFunctionRenderer : public ParticleRenderer
{
public:
using Renderer = std::function<void(const ParticleGroup& /*group*/, const ParticleMapper& /*mapper*/, unsigned int /*startId*/, unsigned int /*endId*/, AbstractRenderQueue* /*renderQueue*/)>;
inline ParticleFunctionRenderer(Renderer renderer);
ParticleFunctionRenderer(const ParticleFunctionRenderer&) = default;
~ParticleFunctionRenderer() = default;
void Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) override final;
inline const Renderer& GetRenderer() const;
inline void SetRenderer(Renderer renderer);
template<typename... Args> static ParticleFunctionRendererRef New(Args&&... args);
private:
Renderer m_renderer;
};
}
#include <Nazara/Graphics/ParticleFunctionRenderer.inl>
#endif // NAZARA_PARTICLEFUNCTIONRENDERER_HPP

View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionRenderer.hpp>
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
inline ParticleFunctionRenderer::ParticleFunctionRenderer(Renderer renderer) :
m_renderer(std::move(renderer))
{
}
/*!
* \brief Gets the renderer function
*
* \return Renderer function responsible for particle rendering
*/
inline const ParticleFunctionRenderer::Renderer& ParticleFunctionRenderer::GetRenderer() const
{
return m_renderer;
}
/*!
* \brief Sets the renderer function
*
* \remark The renderer function must be valid
*/
inline void ParticleFunctionRenderer::SetRenderer(Renderer renderer)
{
m_renderer = std::move(renderer);
}
template<typename... Args>
ParticleFunctionRendererRef ParticleFunctionRenderer::New(Args&&... args)
{
std::unique_ptr<ParticleFunctionRenderer> object(new ParticleFunctionRenderer(std::forward<Args>(args)...));
object->SetPersistent(false);
return object.release();
}
}
#include <Nazara/Graphics/DebugOff.hpp>

View File

@ -8,7 +8,7 @@
#define NAZARA_PARTICLEGROUP_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/signal.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Graphics/ParticleController.hpp>
#include <Nazara/Graphics/ParticleDeclaration.hpp>
#include <Nazara/Graphics/ParticleEmitter.hpp>

View File

@ -12,9 +12,9 @@ namespace Nz
{
bool operator==(const RenderStates& lhs, const RenderStates& rhs)
{
#define NazaraRenderStateMember(field) if (lhs.##field != rhs.##field) return false
#define NazaraRenderStateMember(field) if (lhs.field != rhs.field) return false
#define NazaraRenderStateBoolMember NazaraRenderStateMember
#define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.##field, rhs.##field, maxDiff)) return false
#define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.field, rhs.field, maxDiff)) return false
NazaraRenderStateBoolMember(blending);
NazaraRenderStateBoolMember(colorWrite);
@ -81,59 +81,59 @@ namespace std
Nz::UInt8 parameterHash = 0;
Nz::UInt8 parameterIndex = 0;
#define NazaraRenderStateMember(member) Nz::HashCombine(seed, pipelineInfo.##member)
#define NazaraRenderStateBoolMember(member) parameterHash |= ((pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateBoolMemberDep(dependency, member) parameterHash |= ((pipelineInfo.##dependency && pipelineInfo.##member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateFloatMember(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.##member / maxDiff) * maxDiff)
#define NazaraRenderStateBool(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateBoolDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateEnum(member) Nz::HashCombine(seed, static_cast<Nz::UInt8>(pipelineInfo.member))
#define NazaraRenderStateFloat(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff)
NazaraRenderStateBoolMember(blending);
NazaraRenderStateBoolMember(colorWrite);
NazaraRenderStateBoolMember(depthBuffer);
NazaraRenderStateBoolMember(faceCulling);
NazaraRenderStateBoolMember(scissorTest);
NazaraRenderStateBoolMember(stencilTest);
NazaraRenderStateBool(blending);
NazaraRenderStateBool(colorWrite);
NazaraRenderStateBool(depthBuffer);
NazaraRenderStateBool(faceCulling);
NazaraRenderStateBool(scissorTest);
NazaraRenderStateBool(stencilTest);
NazaraRenderStateBoolMemberDep(depthBuffer, depthWrite);
NazaraRenderStateBoolDep(depthBuffer, depthWrite);
NazaraRenderStateMember(faceFilling);
NazaraRenderStateEnum(faceFilling);
if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending
{
NazaraRenderStateMember(dstBlend);
NazaraRenderStateMember(srcBlend);
NazaraRenderStateEnum(dstBlend);
NazaraRenderStateEnum(srcBlend);
}
if (pipelineInfo.depthBuffer)
NazaraRenderStateMember(depthFunc);
NazaraRenderStateEnum(depthFunc);
if (pipelineInfo.faceCulling)
NazaraRenderStateMember(cullingSide);
NazaraRenderStateEnum(cullingSide);
if (pipelineInfo.stencilTest)
{
NazaraRenderStateMember(stencilCompare.back);
NazaraRenderStateMember(stencilCompare.front);
NazaraRenderStateMember(stencilCompareMask.back);
NazaraRenderStateMember(stencilCompareMask.front);
NazaraRenderStateMember(stencilDepthFail.back);
NazaraRenderStateMember(stencilDepthFail.front);
NazaraRenderStateMember(stencilFail.back);
NazaraRenderStateMember(stencilFail.front);
NazaraRenderStateMember(stencilPass.back);
NazaraRenderStateMember(stencilPass.front);
NazaraRenderStateMember(stencilReference.back);
NazaraRenderStateMember(stencilReference.front);
NazaraRenderStateMember(stencilWriteMask.back);
NazaraRenderStateMember(stencilWriteMask.front);
NazaraRenderStateEnum(stencilCompare.back);
NazaraRenderStateEnum(stencilCompare.front);
NazaraRenderStateEnum(stencilCompareMask.back);
NazaraRenderStateEnum(stencilCompareMask.front);
NazaraRenderStateEnum(stencilDepthFail.back);
NazaraRenderStateEnum(stencilDepthFail.front);
NazaraRenderStateEnum(stencilFail.back);
NazaraRenderStateEnum(stencilFail.front);
NazaraRenderStateEnum(stencilPass.back);
NazaraRenderStateEnum(stencilPass.front);
NazaraRenderStateEnum(stencilReference.back);
NazaraRenderStateEnum(stencilReference.front);
NazaraRenderStateEnum(stencilWriteMask.back);
NazaraRenderStateEnum(stencilWriteMask.front);
}
NazaraRenderStateFloatMember(lineWidth, 0.001f);
NazaraRenderStateFloatMember(pointSize, 0.001f);
NazaraRenderStateFloat(lineWidth, 0.001f);
NazaraRenderStateFloat(pointSize, 0.001f);
#undef NazaraRenderStateMember
#undef NazaraRenderStateBoolMember
#undef NazaraRenderStateBoolMemberDep
#undef NazaraRenderStateFloatMember
#undef NazaraRenderStateBool
#undef NazaraRenderStateBoolDep
#undef NazaraRenderStateEnum
#undef NazaraRenderStateFloat
Nz::HashCombine(seed, parameterHash);

View File

@ -179,7 +179,7 @@ namespace Nz
m_errorCount++;
if (m_lineCount > 20 && (m_errorCount * 100 / m_lineCount) > 50)
if (m_errorCount > 10 && (m_errorCount * 100 / m_lineCount) > 50)
{
NazaraError("Aborting parsing because of error percentage");
return false; //< Abort parsing if error percentage is too high

View File

@ -47,5 +47,7 @@ namespace Nz
if (line != 0 && file && function)
stream << " (" << file << ':' << line << ": " << function << ')';
Write(stream);
}
}

View File

@ -23,7 +23,7 @@ namespace Nz
m_uniformUpdated(false),
m_brightLuminance(0.8f),
m_brightMiddleGrey(0.5f),
m_brightThreshold(0.8f),
m_brightThreshold(0.4f),
m_blurPassCount(5)
{
m_bilinearSampler.SetAnisotropyLevel(1);

View File

@ -232,7 +232,7 @@ namespace Nz
unsigned int width = dimensions.x;
unsigned int height = dimensions.y;
m_depthStencilBuffer->Create(PixelFormatType_Depth24Stencil8, width, height);
m_depthStencilTexture->Create(ImageType_2D, PixelFormatType_Depth24Stencil8, width, height);
m_GBuffer[0]->Create(ImageType_2D, PixelFormatType_RGBA8, width, height); // Texture 0 : Diffuse Color + Specular
m_GBuffer[1]->Create(ImageType_2D, PixelFormatType_RG16F, width, height); // Texture 1 : Encoded normal
@ -246,7 +246,7 @@ namespace Nz
// Texture 3 : Emission map ?
m_GBufferRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer);
m_GBufferRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture);
m_GBufferRTT->Unlock();
@ -258,7 +258,7 @@ namespace Nz
m_workRTT->AttachTexture(AttachmentPoint_Color, i, m_workTextures[i]);
}
m_workRTT->AttachBuffer(AttachmentPoint_DepthStencil, 0, m_depthStencilBuffer);
m_workRTT->AttachTexture(AttachmentPoint_DepthStencil, 0, m_depthStencilTexture);
m_workRTT->Unlock();

View File

@ -114,6 +114,9 @@ namespace Nz
Renderer::SetTexture(2, m_GBuffer[2]);
Renderer::SetTextureSampler(2, m_pointSampler);
Renderer::SetTexture(3, m_depthStencilTexture);
Renderer::SetTextureSampler(3, m_pointSampler);
Renderer::SetClearColor(Color::Black);
Renderer::Clear(RendererBuffer_Color);

View File

@ -48,7 +48,7 @@ namespace Nz
m_deferredTechnique = technique;
m_renderQueue = static_cast<DeferredRenderQueue*>(technique->GetRenderQueue());
m_depthStencilBuffer = technique->GetDepthStencilBuffer();
m_depthStencilTexture = technique->GetDepthStencilTexture();
m_GBufferRTT = technique->GetGBufferRTT();
for (unsigned int i = 0; i < 3; ++i)

View File

@ -239,6 +239,8 @@ namespace Nz
std::vector<Matrix4f>& instances = it2->second.instances;
instances.push_back(transformMatrix);
materialEntry.maxInstanceCount = std::max(materialEntry.maxInstanceCount, instances.size());
}
}

View File

@ -136,7 +136,7 @@ namespace Nz
m_renderQueue(static_cast<ForwardRenderQueue*>(m_forwardTechnique.GetRenderQueue())),
m_GBufferSize(0U)
{
m_depthStencilBuffer = RenderBuffer::New();
m_depthStencilTexture = Texture::New();
for (unsigned int i = 0; i < 2; ++i)
m_workTextures[i] = Texture::New();
@ -305,9 +305,9 @@ namespace Nz
* \return Pointer to the rendering buffer
*/
RenderBuffer* DeferredRenderTechnique::GetDepthStencilBuffer() const
Texture* DeferredRenderTechnique::GetDepthStencilTexture() const
{
return m_depthStencilBuffer;
return m_depthStencilTexture;
}
/*!
@ -652,6 +652,7 @@ namespace Nz
shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0);
shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1);
shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2);
shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3);
shader = RegisterDeferredShader("DeferredPointSpotLight", r_fragmentSource_PointSpotLight, sizeof(r_fragmentSource_PointSpotLight), basicVertexStage, &error);
@ -664,6 +665,7 @@ namespace Nz
shader->SendInteger(shader->GetUniformLocation("GBuffer0"), 0);
shader->SendInteger(shader->GetUniformLocation("GBuffer1"), 1);
shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 2);
shader->SendInteger(shader->GetUniformLocation("DepthBuffer"), 3);
// Shaders optionnels (S'ils ne sont pas présents, le rendu minimal sera quand même assuré)

View File

@ -49,8 +49,8 @@ namespace Nz
*/
MaterialPipelineRef MaterialPipeline::GetPipeline(const MaterialPipelineInfo& pipelineInfo)
{
auto it = s_pipelineCache.lower_bound(pipelineInfo);
if (it == s_pipelineCache.end() || it->first != pipelineInfo)
auto it = s_pipelineCache.find(pipelineInfo);
if (it == s_pipelineCache.end())
it = s_pipelineCache.insert(it, PipelineCache::value_type(pipelineInfo, New(pipelineInfo)));
return it->second;
@ -58,6 +58,8 @@ namespace Nz
void MaterialPipeline::GenerateRenderPipeline(UInt32 flags) const
{
NazaraAssert(m_pipelineInfo.uberShader, "Material pipeline has no uber shader");
ParameterList list;
list.SetParameter("ALPHA_MAPPING", m_pipelineInfo.hasAlphaMap);
list.SetParameter("ALPHA_TEST", m_pipelineInfo.alphaTest);
@ -136,6 +138,7 @@ namespace Nz
// Once the base shaders are registered, we can now set some default materials
MaterialPipelineInfo pipelineInfo;
pipelineInfo.uberShader = UberShaderLibrary::Get("Basic");
// Basic 2D - No depth write/face culling
pipelineInfo.depthWrite = false;
@ -144,7 +147,7 @@ namespace Nz
MaterialPipelineLibrary::Register("Basic2D", GetPipeline(pipelineInfo));
// Translucent 2D - Alpha blending with no depth write/face culling
pipelineInfo.blending = false;
pipelineInfo.blending = true;
pipelineInfo.depthWrite = false;
pipelineInfo.faceCulling = false;
pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha;
@ -152,6 +155,16 @@ namespace Nz
MaterialPipelineLibrary::Register("Translucent2D", GetPipeline(pipelineInfo));
// Translucent 3D - Alpha blending with depth buffer and no depth write/face culling
pipelineInfo.blending = true;
pipelineInfo.depthBuffer = true;
pipelineInfo.depthWrite = false;
pipelineInfo.faceCulling = false;
pipelineInfo.dstBlend = BlendFunc_InvSrcAlpha;
pipelineInfo.srcBlend = BlendFunc_SrcAlpha;
MaterialPipelineLibrary::Register("Translucent3D", GetPipeline(pipelineInfo));
return true;
}

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionController.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::ParticleFunctionController
* \brief Helper class used to provide a function as a particle controller without going in the process of making a new class
*/
/*!
* \brief Calls the controller function
*
* \param group Particle group responsible of the particles
* \param mapper Particle mapper, allowing access to the particle data
* \param startId The first ID of the particle to update (inclusive)
* \param endId The last ID of the particle to update (inclusive)
* \param elapsedTime Elapsed time in seconds since the last update
*/
void ParticleFunctionController::Apply(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime)
{
m_controller(group, mapper, startId, endId, elapsedTime);
}
}

View File

@ -0,0 +1,28 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionGenerator.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::ParticleFunctionGenerator
* \brief Helper class used to provide a function as a particle generator without going in the process of making a new class
*/
/*!
* \brief Calls the generator function
*
* \param group Particle group responsible of the particles
* \param mapper Particle mapper, allowing access to the particle data
* \param startId The first ID of the particle to update (inclusive)
* \param endId The last ID of the particle to update (inclusive)
*/
void ParticleFunctionGenerator::Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId)
{
m_generator(group, mapper, startId, endId);
}
}

View File

@ -0,0 +1,29 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/ParticleFunctionRenderer.hpp>
#include <Nazara/Graphics/Debug.hpp>
namespace Nz
{
/*!
* \ingroup graphics
* \class Nz::ParticleFunctionRenderer
* \brief Helper class used to provide a function as a particle renderer without going in the process of making a new class
*/
/*!
* \brief Calls the renderer function
*
* \param group Particle group responsible of the particles
* \param mapper Particle mapper, allowing constant access to the particle data
* \param startId The first ID of the particle to update (inclusive)
* \param endId The last ID of the particle to update (inclusive)
* \param renderQueue The concerned render queue that will receive drawable informations
*/
void ParticleFunctionRenderer::Render(const ParticleGroup& group, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue)
{
m_renderer(group, mapper, startId, endId, renderQueue);
}
}

View File

@ -11,17 +11,12 @@ uniform vec4 LightDirection;
uniform sampler2D GBuffer0;
uniform sampler2D GBuffer1;
uniform sampler2D GBuffer2;
uniform sampler2D DepthBuffer;
uniform mat4 InvViewProjMatrix;
uniform vec2 InvTargetSize;
uniform vec4 SceneAmbient;
float ColorToFloat(vec3 color)
{
const vec3 byte_to_float = vec3(1.0, 1.0/256, 1.0/(256*256));
return dot(color, byte_to_float);
}
#define kPI 3.1415926536
vec3 DecodeNormal(in vec4 encodedNormal)
@ -44,7 +39,7 @@ void main()
vec3 diffuseColor = gVec0.xyz;
vec3 normal = DecodeNormal(gVec1);
float specularMultiplier = gVec0.w;
float depth = ColorToFloat(gVec2.xyz);
float depth = textureLod(DepthBuffer, texCoord, 0.0).r;
float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5);
vec3 lightDir = -LightDirection.xyz;

File diff suppressed because one or more lines are too long

View File

@ -19,6 +19,7 @@ uniform vec2 LightParameters3;
uniform sampler2D GBuffer0;
uniform sampler2D GBuffer1;
uniform sampler2D GBuffer2;
uniform sampler2D DepthBuffer;
uniform mat4 InvViewProjMatrix;
uniform vec2 InvTargetSize;
@ -57,7 +58,7 @@ void main()
vec3 diffuseColor = gVec0.xyz;
vec3 normal = DecodeNormal(gVec1);
float specularMultiplier = gVec0.w;
float depth = ColorToFloat(gVec2.xyz);
float depth = textureLod(DepthBuffer, texCoord, 0.0).r;
float shininess = (gVec2.w == 0.0) ? 0.0 : exp2(gVec2.w*10.5);
vec3 viewSpace = vec3(texCoord*2.0 - 1.0, depth*2.0 - 1.0);

File diff suppressed because one or more lines are too long

View File

@ -2,6 +2,13 @@
layout(early_fragment_tests) in;
#endif
// HACK UNTIL PROPER FIX
#if GLSL_VERSION < 400
#undef SHADOW_MAPPING
#define SHADOW_MAPPING 0
#endif
// HACK
#define LIGHT_DIRECTIONAL 0
#define LIGHT_POINT 1
#define LIGHT_SPOT 2
@ -61,21 +68,6 @@ uniform vec4 SceneAmbient;
uniform sampler2D TextureOverlay;
/********************Fonctions********************/
vec3 FloatToColor(float f)
{
vec3 color;
f *= 256.0;
color.x = floor(f);
f = (f - color.x) * 256.0;
color.y = floor(f);
color.z = f - color.y;
color.xy *= 0.00390625; // *= 1.0/256
return color;
}
#define kPI 3.1415926536
@ -177,7 +169,7 @@ void main()
*/
RenderTarget0 = vec4(diffuseColor.rgb, dot(specularColor, vec3(0.3, 0.59, 0.11)));
RenderTarget1 = vec4(EncodeNormal(normal));
RenderTarget2 = vec4(FloatToColor(gl_FragCoord.z), (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
RenderTarget2 = vec4(0.0, 0.0, 0.0, (MaterialShininess == 0.0) ? 0.0 : max(log2(MaterialShininess), 0.1)/10.5); // http://www.guerrilla-games.com/publications/dr_kz2_rsx_dev07.pdf
#else // FLAG_DEFERRED
#if ALPHA_MAPPING
diffuseColor.a *= texture(MaterialAlphaMap, texCoord).r;

File diff suppressed because one or more lines are too long

View File

@ -588,7 +588,7 @@ namespace Nz
std::memcpy(&m_impl->colorTargets[0], targets, targetCount*sizeof(UInt8));
m_impl->userDefinedTargets = true;
InvalidateDrawBuffers();
InvalidateTargets();
}
void RenderTexture::SetColorTargets(const std::initializer_list<UInt8>& targets) const
@ -614,7 +614,7 @@ namespace Nz
*ptr++ = index;
m_impl->userDefinedTargets = true;
InvalidateDrawBuffers();
InvalidateTargets();
}
void RenderTexture::Unlock() const

View File

@ -31,6 +31,7 @@ namespace Nz
String matName, meshName;
matName = meshName = "default";
m_errorCount = 0;
m_keepLastLine = false;
m_lineCount = 0;
m_meshes.clear();
@ -299,7 +300,7 @@ namespace Nz
m_positions.push_back(vertex);
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
}
else if (word == "vn")
@ -310,7 +311,7 @@ namespace Nz
m_normals.push_back(normal);
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
}
else if (word == "vt")
@ -321,12 +322,12 @@ namespace Nz
m_texCoords.push_back(uvw);
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
}
#if NAZARA_UTILITY_STRICT_RESOURCE_PARSING
else if (!UnrecognizedLine())
false;
return false;
#endif
break;